-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from Web3-API/prealpha-dev
Prep 0.0.1-prealpha.13
- Loading branch information
Showing
28 changed files
with
320 additions
and
516 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 |
---|---|---|
@@ -1 +1 @@ | ||
0.0.1-prealpha.12 | ||
0.0.1-prealpha.13 |
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
export * from "./Web3ApiClient"; | ||
export * from "./createWeb3ApiClient"; | ||
export * from "@web3api/core-js"; | ||
|
||
// TODO: client.sanitizeRedirects() -> iterate through all redirects, make sure we can resolve all of them (will call getImplementations...) | ||
// TODO: client.getImplementations(uri) -> iterate through all known Web3API's and find all implementations |
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 @@ | ||
!.gitignore |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,38 +1,78 @@ | ||
.App { | ||
text-align: center; | ||
.main { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
height: 100vh; | ||
align-items: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
.main__logo { | ||
max-width: 15rem; | ||
margin-bottom: 5rem; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
.main__heading { | ||
font-size: 45px; | ||
margin-top: 2rem; | ||
font-weight: 700; | ||
margin-bottom: 20px; | ||
color: white; | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
.main__text { | ||
text-align: center; | ||
max-width: 40rem; | ||
color: #529dad; | ||
font-style: italic; | ||
line-height: 1.5; | ||
font-weight: 400; | ||
font-size: 22px; | ||
} | ||
|
||
.main__link { | ||
text-decoration: none; | ||
font-size: 22px; | ||
font-weight: 600; | ||
margin-top: 2rem; | ||
color: white; | ||
} | ||
|
||
.main__input { | ||
font: inherit; | ||
color: white; | ||
width: 40rem; | ||
border: 1px solid white; | ||
height: 1.1876em; | ||
margin: 2.5rem 0; | ||
display: block; | ||
padding: 1rem; | ||
min-width: 0; | ||
background: none; | ||
box-sizing: content-box; | ||
letter-spacing: inherit; | ||
animation-duration: 10ms; | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
.main__btn { | ||
font-size: 0.875rem; | ||
color: #60c093; | ||
border: 1px solid #529dad; | ||
padding: 5px 15px; | ||
font-weight: 500; | ||
line-height: 1.75; | ||
min-width: 64px; | ||
cursor: pointer; | ||
border-radius: 4px; | ||
text-transform: uppercase; | ||
background-color: transparent; | ||
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, | ||
box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, | ||
border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
.main__btn:hover { | ||
color: #ffffff; | ||
border: solid 1px #529dad; | ||
background-color: #60c093; | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,88 +1,30 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import React from "react"; | ||
import Lottie from "react-lottie"; | ||
import { Web3ApiProvider } from "@web3api/react"; | ||
|
||
import { Uri, UriRedirect, Web3ApiClient } from "@web3api/client-js"; | ||
import { ensPlugin } from "@web3api/ens-plugin-js"; | ||
import { ethereumPlugin } from "@web3api/ethereum-plugin-js"; | ||
import { ipfsPlugin } from "@web3api/ipfs-plugin-js"; | ||
import { HelloWorld } from "./HelloWorld"; | ||
import Web3ApiAnimation from "./lottie/Web3API_Icon_Cycle.json"; | ||
import "./App.css"; | ||
|
||
function App() { | ||
const [contract, setContract] = React.useState<string | undefined>(undefined); | ||
const [client, setClient] = React.useState<Web3ApiClient | undefined>(undefined); | ||
export const App: React.FC = () => { | ||
|
||
async function setupClient() { | ||
const ethereum = (window as any).ethereum; | ||
if (ethereum && ethereum.enable) { | ||
await ethereum.enable(); | ||
} | ||
|
||
const redirects: UriRedirect[] = [ | ||
{ | ||
from: "w3://ens/ethereum.web3api.eth", | ||
to: ethereumPlugin({ provider: ethereum }) | ||
}, | ||
{ | ||
from: "w3://ens/ipfs.web3api.eth", | ||
to: ipfsPlugin({ provider: "https://ipfs.io/api/v0/" }), | ||
}, | ||
{ | ||
from: "w3://ens/ens.web3api.eth", | ||
to: ensPlugin({}), | ||
} | ||
]; | ||
setClient(new Web3ApiClient({ redirects })); | ||
} | ||
|
||
const deployContract = async () => { | ||
if (!client) { | ||
await setupClient(); | ||
|
||
if (!client) { | ||
return; | ||
} | ||
} | ||
|
||
console.log("querying") | ||
|
||
const { data, errors } = await client.query({ | ||
uri: new Uri("ens/api.simplestorage.eth"), | ||
query: `mutation { deployContract }` | ||
}); | ||
|
||
console.log(data) | ||
console.log(errors) | ||
|
||
if (errors) { | ||
console.error(errors); | ||
} | ||
|
||
if (data) { | ||
setContract( | ||
data.deployContract as string | ||
); | ||
} | ||
} | ||
const logoLottieOptions = { | ||
loop: true, | ||
autoplay: true, | ||
animationData: Web3ApiAnimation, | ||
}; | ||
|
||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Web3API: SimpleStorage Demo | ||
</p> | ||
{!contract ? | ||
(<button onClick={deployContract}> | ||
Deploy Contract | ||
</button>) : | ||
<p>SimpleStorage Contract: {contract}</p> | ||
} | ||
<button> | ||
Set Storage | ||
</button> | ||
</header> | ||
<div className="main"> | ||
<Web3ApiProvider> | ||
<Lottie | ||
options={logoLottieOptions} | ||
isClickToPauseDisabled={true} | ||
height={"300px"} | ||
width={"300px"} | ||
/> | ||
<HelloWorld /> | ||
</Web3ApiProvider> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from "react"; | ||
import { useWeb3ApiQuery } from "@web3api/react"; | ||
|
||
export const HelloWorld: React.FC = () => { | ||
const [message, setMessage] = React.useState(""); | ||
|
||
const { execute } = useWeb3ApiQuery({ | ||
provider: "helloWorld", | ||
uri: "ens/helloworld.eth", | ||
query: `query { | ||
logMessage( | ||
message: "${message}" | ||
) | ||
}`, | ||
}); | ||
|
||
// data: deployData, | ||
// loading: loadingDeploy, | ||
// errors: deployContractErrors, | ||
const logMsgHandler = async (): Promise<any> => { | ||
const result = await execute(); | ||
console.log(result); | ||
}; | ||
|
||
const onChangeHandler = (event: any): void => { | ||
setMessage(event?.target.value); | ||
}; | ||
|
||
return ( | ||
<> | ||
<text className="main__heading">Hello world from Web3API!</text> | ||
<text className="main__text"> | ||
Try out our Hello World demo by typing anything into | ||
the input below, click the submit and check out your | ||
developer console logs. | ||
</text> | ||
<input | ||
className="main__input" | ||
onChange={(event) => onChangeHandler(event)} | ||
/> | ||
<button className="main__btn" onClick={logMsgHandler}> | ||
Submit | ||
</button> | ||
<a | ||
className="main__link" | ||
href="https://documentation-master.on.fleek.co/" | ||
> | ||
Want to build your own Web3API? Visit our documentation{" "} | ||
<span style={{ color: "blue" }}>here</span>. | ||
</a> | ||
</> | ||
); | ||
} |
Oops, something went wrong.