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
import React, { useEffect, useState } from "react"; | |
import { useDrizzleContext } from "./drizzle/drizzleContext"; | |
import { connect } from "react-redux"; | |
function App({ dataCall, account }) { | |
const drizzle = useDrizzleContext(); | |
const [data, setData] = useState(""); | |
const [cacheKey, setCacheKey] = useState(null); |
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
import React from "react"; | |
import { connect } from "react-redux"; | |
const LoadingContainer = ({ web3, accounts, initialized, children }) => { | |
if (initialized) { | |
if (web3.status === "failed") { | |
return ( | |
<main className="container loading-screen"> | |
<div className="pure-g"> | |
<div className="pure-u-1-1"> |
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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import App from "./App"; | |
import { DrizzleProvider } from "./drizzle/drizzleContext"; | |
import { Provider as ReduxProvider } from "react-redux"; | |
import options from "./drizzle/drizzleOptions"; | |
import { Drizzle, generateStore } from "@drizzle/store"; | |
import logger from "redux-logger"; | |
const store = generateStore({ |
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
import React, { createContext, useContext } from "react"; | |
const Context = createContext(); | |
export function DrizzleProvider({ drizzle, children }) { | |
return <Context.Provider value={drizzle}>{children}</Context.Provider>; | |
} | |
export function useDrizzleContext() { | |
const context = useContext(Context); |
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
const Web3 = require("web3"); | |
const EventExample = require("../build/contracts/EventExample.json"); | |
const init = async () => { | |
const web3 = new Web3("ws://localhost:7545"); | |
const id = await web3.eth.net.getId(); | |
const deployedNetwork = EventExample.networks[id]; | |
const eventExample = new web3.eth.Contract( | |
EventExample.abi, |
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
const displayGreeting = async (greeting, contract) => { | |
greeting = await contract.methods.sayHello().call(); | |
$("h2").html(greeting); | |
}; | |
const updateGreeting = (greeting, contract, accounts) => { | |
let input; | |
$("#input").on("change", (e) => { | |
input = e.target.value; | |
}); |
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
const getContract = async (web3) => { | |
const data = await $.getJSON("./contracts/Greeting.json"); | |
const netId = await web3.eth.net.getId(); | |
const deployedNetwork = data.networks[netId]; | |
const greeting = new web3.eth.Contract( | |
data.abi, | |
deployedNetwork && deployedNetwork.address | |
); | |
return greeting; |
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
const getWeb3 = () => { | |
return new Promise((resolve, reject) => { | |
window.addEventListener("load", async () => { | |
if (window.ethereum) { | |
const web3 = new Web3(window.ethereum); | |
try { | |
// ask user permission to access his accounts | |
await window.ethereum.request({ method: "eth_requestAccounts" }); | |
resolve(web3); | |
} catch (error) { |
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
// SPDX-License-Identifier: MIT | |
pragma solidity >=0.4.22 <0.8.0; | |
contract Greeting { | |
string public greeting = "hello"; | |
function sayHello() external view returns (string memory) { | |
return greeting; | |
} |
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
contract("Factory", function (/* accounts */) { | |
it("should assert true", async function () { | |
await Factory.deployed(); | |
return assert.isTrue(true); | |
}); | |
describe("#createChild()",async () => { | |
let factory; | |
beforeEach(async ()=>{ | |
factory = await Factory.deployed(); |
NewerOlder