From 0c4e42f92703e3c5900056c4499af3ca7b8274c2 Mon Sep 17 00:00:00 2001 From: Bliss Da Sailor Date: Mon, 20 Dec 2021 12:29:39 -0600 Subject: [PATCH 1/3] block explorer url for current network --- packages/react-app/src/components/Address.jsx | 2 +- packages/react-app/src/components/PGCard.jsx | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/react-app/src/components/Address.jsx b/packages/react-app/src/components/Address.jsx index 112b0c3..731fb5a 100644 --- a/packages/react-app/src/components/Address.jsx +++ b/packages/react-app/src/components/Address.jsx @@ -31,7 +31,7 @@ import { useLookupAddress } from "eth-hooks/dapps/ens"; const { Text } = Typography; -const blockExplorerLink = (address, blockExplorer) => blockExplorer || `https://etherscan.io/address/${address}`; +const blockExplorerLink = (address, blockExplorer) => `${blockExplorer || "https://etherscan.io/"}address/${address}`; export default function Address(props) { const { currentTheme } = useThemeSwitcher(); diff --git a/packages/react-app/src/components/PGCard.jsx b/packages/react-app/src/components/PGCard.jsx index 6cd6b2c..98b5667 100644 --- a/packages/react-app/src/components/PGCard.jsx +++ b/packages/react-app/src/components/PGCard.jsx @@ -6,7 +6,7 @@ import { Address } from "."; const abi = ["function name() view returns (string memory)", "function symbol() view returns (string)"]; -export default function PGCard({ creator, token, supply, pgType, mainnetProvider, localProvider, ...props }) { +export default function PGCard({ creator, token, supply, pgType, mainnetProvider, localProvider, blockExplorer }) { const [tokenDetails, setTokenDetails] = useState({}); const fetchTokenData = async () => { @@ -24,7 +24,7 @@ export default function PGCard({ creator, token, supply, pgType, mainnetProvider }, [token]); return ( - +
Supply: {supply} @@ -32,13 +32,25 @@ export default function PGCard({ creator, token, supply, pgType, mainnetProvider
Token Address: -
+
Created By: -
+
From 988dfc4c0f2bd345d45ca5488fef2c9e375fca8a Mon Sep 17 00:00:00 2001 From: Bliss Da Sailor Date: Mon, 20 Dec 2021 12:29:55 -0600 Subject: [PATCH 2/3] timestamp for events --- packages/hardhat/contracts/PGDeployer.sol | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/hardhat/contracts/PGDeployer.sol b/packages/hardhat/contracts/PGDeployer.sol index 56867a8..eaab93d 100644 --- a/packages/hardhat/contracts/PGDeployer.sol +++ b/packages/hardhat/contracts/PGDeployer.sol @@ -19,7 +19,8 @@ contract PGDeployer is Ownable { address indexed token, address indexed creator, pgType indexed pgtype, - uint256 supply + uint256 supply, + uint256 timestamp ); event pgerc20Deployed(address indexed token); event pgerc721Deployed(address indexed token, uint256 totalSupply); @@ -38,7 +39,13 @@ contract PGDeployer is Ownable { token.transferOwnership(tokenOwner); // emit event - emit pgDeployed(address(token), msg.sender, pgType.erc20, supply); + emit pgDeployed( + address(token), + msg.sender, + pgType.erc20, + supply, + block.timestamp + ); } function deployERC721( @@ -62,6 +69,12 @@ contract PGDeployer is Ownable { token.transferOwnership(tokenOwner); // emit event - emit pgDeployed(address(token), msg.sender, pgType.erc721, supply); + emit pgDeployed( + address(token), + msg.sender, + pgType.erc721, + supply, + block.timestamp + ); } } From f110495dbb8f5ca32707ed0e7c533fff807c9eb0 Mon Sep 17 00:00:00 2001 From: Bliss Da Sailor Date: Mon, 20 Dec 2021 12:30:58 -0600 Subject: [PATCH 3/3] reset post deploy --- packages/react-app/src/App.jsx | 3 ++- packages/react-app/src/pgcomponents/Deployer.jsx | 8 ++++++-- packages/react-app/src/views/DeployModal.jsx | 1 + packages/react-app/src/views/Home.jsx | 15 ++++++++------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/react-app/src/App.jsx b/packages/react-app/src/App.jsx index d63c6ea..c4af8db 100644 --- a/packages/react-app/src/App.jsx +++ b/packages/react-app/src/App.jsx @@ -60,7 +60,7 @@ const providers = [ function App(props) { // specify all the chains your app is available on. Eg: ['localhost', 'mainnet', ...otherNetworks ] // reference './constants.js' for other networks - const networkOptions = ["localhost", "mainnet", "rinkeby"]; + const networkOptions = ["rinkeby", "localhost"]; const [injectedProvider, setInjectedProvider] = useState(); const [address, setAddress] = useState(); @@ -200,6 +200,7 @@ function App(props) { address={address} localProvider={localProvider} readContracts={readContracts} + blockExplorer={blockExplorer} writeContracts={writeContracts} mainnetProvider={mainnetProvider} yourLocalBalance={yourLocalBalance} diff --git a/packages/react-app/src/pgcomponents/Deployer.jsx b/packages/react-app/src/pgcomponents/Deployer.jsx index 483664b..ed726ba 100644 --- a/packages/react-app/src/pgcomponents/Deployer.jsx +++ b/packages/react-app/src/pgcomponents/Deployer.jsx @@ -24,7 +24,6 @@ function Details({ tx, reset, pgType, pgData, address, isDeploying, writeContrac const result = tx(writeContracts.PGDeployer[method](...calldata), update => { console.log("📡 Transaction Update:", update); if (update && (update.status === "confirmed" || update.status === 1)) { - reset(); console.log(" 🍾 Transaction " + update.hash + " finished!"); console.log( " ⛽️ " + @@ -38,7 +37,12 @@ function Details({ tx, reset, pgType, pgData, address, isDeploying, writeContrac } }); console.log("awaiting metamask/web3 confirm result...", result); - console.log(await result); + const txResult = await result; + + // wait for given number of confirmations + txResult.wait(1); + + reset(); } catch (error) { console.log(error); setIsDeploying(false); diff --git a/packages/react-app/src/views/DeployModal.jsx b/packages/react-app/src/views/DeployModal.jsx index f7088ca..d401193 100644 --- a/packages/react-app/src/views/DeployModal.jsx +++ b/packages/react-app/src/views/DeployModal.jsx @@ -24,6 +24,7 @@ function DeployModal({ tx, writeContracts, address, show, onCancel }) { setActiveStep(0); setPgType(0); setPgData({}); + setIsDeploying(false); }; const onNextStep = () => { diff --git a/packages/react-app/src/views/Home.jsx b/packages/react-app/src/views/Home.jsx index 09e9375..26be947 100644 --- a/packages/react-app/src/views/Home.jsx +++ b/packages/react-app/src/views/Home.jsx @@ -4,12 +4,12 @@ import DeployModal from "./DeployModal"; import { useEventListener } from "eth-hooks/events/useEventListener"; import { PGCard } from "../components"; -function Home({ tx, writeContracts, address, readContracts, localProvider }) { +function Home({ tx, writeContracts, address, readContracts, blockExplorer, localProvider }) { const [show, setShow] = useState(false); - const pgs = (useEventListener(readContracts, "PGDeployer", "pgDeployed", localProvider, 1) || []).reverse(); - - console.log(pgs); + const pgs = (useEventListener(readContracts, "PGDeployer", "pgDeployed", localProvider, 1) || []).sort((a, b) => + a.args.timestamp > b.args.timestamp ? 1 : -1, + ); return (
@@ -22,18 +22,19 @@ function Home({ tx, writeContracts, address, readContracts, localProvider }) { />
- +
( - +