-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,009 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.logo.react { | ||
animation: logo-spin infinite 60s linear; | ||
} | ||
} | ||
|
||
.logo.motoko:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
.logo-stack { | ||
display: inline-grid; | ||
} | ||
|
||
.logo-stack > * { | ||
grid-column: 1; | ||
grid-row: 1; | ||
} | ||
|
||
@keyframes logo-swim { | ||
from { | ||
transform: rotate(4deg) translateY(0); | ||
} | ||
50% { | ||
transform: rotate(-5deg) translateY(0); | ||
} | ||
to { | ||
transform: rotate(4deg) translateY(0); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.logo.motoko { | ||
animation: logo-swim 5s ease-in-out infinite; | ||
} | ||
} | ||
|
||
@keyframes logo-pulse { | ||
from { | ||
transform: scale(1); | ||
} | ||
50% { | ||
transform: scale(1.1); | ||
} | ||
to { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.logo.ethereum { | ||
animation: logo-pulse 5s ease-in-out infinite; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { useEffect, useState } from 'react'; | ||
import './App.css'; | ||
import motokoLogo from './assets/motoko_moving.png'; | ||
import motokoShadowLogo from './assets/motoko_shadow.png'; | ||
import reactLogo from './assets/react.svg'; | ||
import ethLogo from './assets/eth.svg'; | ||
import { backend } from './declarations/backend'; | ||
import { Block } from './declarations/backend/backend.did'; | ||
|
||
function App() { | ||
const [loading, setLoading] = useState(false); | ||
const [block, setBlock] = useState<Block | undefined>(); | ||
const [error, setError] = useState<string | undefined>(); | ||
|
||
const fetchBlock = async () => { | ||
try { | ||
setLoading(true); | ||
setError(undefined); | ||
const block = await backend.getLatestEthereumBlock(); | ||
setBlock(block); | ||
} catch (err) { | ||
console.error(err); | ||
setError(String(err)); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
// useEffect(() => { | ||
// fetchBlock(); | ||
// }, []); | ||
|
||
return ( | ||
<div className="App"> | ||
<div> | ||
<a href="https://reactjs.org" target="_blank"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
<a | ||
href="https://internetcomputer.org/docs/current/developer-docs/build/cdks/motoko-dfinity/motoko/" | ||
target="_blank" | ||
> | ||
<span className="logo-stack"> | ||
<img | ||
src={motokoShadowLogo} | ||
className="logo motoko-shadow" | ||
alt="Motoko logo" | ||
/> | ||
<img src={motokoLogo} className="logo motoko" alt="Motoko logo" /> | ||
</span> | ||
</a> | ||
<a href="https://github.com/internet-computer-protocol/evm-rpc-canister#readme" target="_blank"> | ||
<img src={ethLogo} className="logo ethereum" alt="Ethereum logo" /> | ||
</a> | ||
</div> | ||
<h1>React + Motoko + EVM RPC</h1> | ||
<div className="card"> | ||
<button onClick={fetchBlock} style={{ opacity: loading ? 0.5 : 1 }}> | ||
Get latest Ethereum block | ||
</button> | ||
{!!block && ( | ||
<pre | ||
style={{ | ||
textAlign: 'left', | ||
color: 'darkgreen', | ||
maxWidth: 800, | ||
opacity: loading ? 0.5 : 1, | ||
}} | ||
> | ||
{JSON.stringify( | ||
block, | ||
(_, v) => (typeof v === 'bigint' ? v.toString() : v), | ||
2, | ||
)} | ||
</pre> | ||
)} | ||
{!!error && ( | ||
<pre style={{ textAlign: 'left', color: 'darkred' }}>{error}</pre> | ||
)} | ||
</div> | ||
<p className="read-the-docs"> | ||
Click on the React, Motoko, and Ethereum logos to learn more | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.