Skip to content

Commit

Permalink
Merge pull request #111 from metagov/deploy-graph-on-optimism-goerli
Browse files Browse the repository at this point in the history
Deploy TheGraph Indexer on optimism-goerli
  • Loading branch information
crazyyuan authored Aug 19, 2023
2 parents 57a9a30 + d10e20d commit b5bf330
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 129 deletions.
6 changes: 6 additions & 0 deletions Implementations/Subgraph/daostar/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@
"address": "0x8180cbfBFFe59F54BF3Ea5d7DdbaE1232e2bB298",
"startBlock": 27702194
}
},
"optimism-goerli": {
"EIP4824Index": {
"address": "0x9Aff4e5e7A7Ae449B89162EF4798b2Bb60DC92c0",
"startBlock": 13115254
}
}
}
8 changes: 5 additions & 3 deletions Implementations/Subgraph/daostar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"build:mainnet": "graph codegen && graph build --network mainnet",
"build:goerli": "graph codegen && graph build --network goerli",
"build:gnosis": "graph codegen && graph build --network gnosis",
"build:optimism-goerli": "graph codegen && graph build --network optimism-goerli",
"codegen": "graph codegen",
"build": "graph build",
"deploy:mainnet": "graph deploy --node https://api.thegraph.com/deploy/ Rashmi-278/daostar",
"deploy:goerli": "graph deploy --node https://api.thegraph.com/deploy/ Rashmi-278/daostar-goerli",
"deploy:mainnet": "graph deploy --node https://api.thegraph.com/deploy/ ipatka/daostar",
"deploy:goerli": "graph deploy --node https://api.thegraph.com/deploy/ ipatka/daostar-goerli",
"deploy:optimism-goerli": "graph deploy --node https://api.thegraph.com/deploy/ rashmi-278/daostar-optimism-goerli",
"deploy:gnosis": "graph deploy --node https://api.thegraph.com/deploy/ mrutsavg/daostar-gnosis",
"deploy:all": "yarn build:goerli && yarn deploy:goerli && yarn build:mainnet && yarn deploy:mainnet && yarn build:gnosis && yarn deploy:gnosis",
"deploy:all": "yarn build:optimism-goerli && yarn deploy:optimism-goerli && yarn build:goerli && yarn deploy:goerli && yarn build:mainnet && yarn deploy:mainnet && yarn build:gnosis && yarn deploy:gnosis",
"create-local": "graph create --node http://localhost:8020/ ipatka/daostar",
"remove-local": "graph remove --node http://localhost:8020/ ipatka/daostar",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 ipatka/daostar"
Expand Down
24 changes: 20 additions & 4 deletions daostar-website/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ function App() {
context: { apiName: "goerli" },
variables: { id: "goerli" },
});
const optimismGoerliRes = useQuery(queries.REGISTRATIONS, {
context: { apiName: "optimismGoerli" },
variables: { id: "optimism-goerli" },
});
const {
loading: optimismGoerliLoading,
error: optimismGoerliError,
data: optimismGoerliData,
} = optimismGoerliRes;
const {
loading: goerliLoading,
error: goerliError,
Expand All @@ -50,19 +59,26 @@ function App() {
error: gnosisError,
data: gnosisData,
} = gnosisRes;
console.log({ mainnetData, goerliData, gnosisData });
console.log({ mainnetData, goerliData, gnosisData, optimismGoerliData });

// if (error || goerliError || gnosisError) return "error";
if (loading || goerliLoading || gnosisLoading) return "loading...";
if (error || goerliError || optimismGoerliError ) {
console.error("Mainnet Error "+ error);
console.error("Goerli Error "+ goerliError);
console.error("Optimism Goerli Error "+ optimismGoerliError);
};
if (loading || goerliLoading || gnosisLoading || optimismGoerliLoading) return "loading...";
const mainnetRegistrations =
mainnetData?.registrationNetwork?.registrations || [];
const goerliRegistrations =
goerliData?.registrationNetwork?.registrations || [];
const optimismGoerliRegistrations =
optimismGoerliData?.registrationNetwork?.registrations || [];
const gnosisRegistrations =
gnosisData?.registrationNetwork?.registrations || [];
const registrationInstances = mainnetRegistrations.concat(
goerliRegistrations,
gnosisRegistrations
gnosisRegistrations,
optimismGoerliRegistrations
);

console.log({ registrationInstances });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import FRAMEWORK_URIs from './FRAMEWORK_URIs'

const networkIds = {
mainnet: 1,
goerli: 5,
optimismGoerli: 420

}

const RegistrationForm = ({ toggleRegScreen, setRegistrationData }) => {
Expand Down Expand Up @@ -179,6 +182,14 @@ const RegistrationForm = ({ toggleRegScreen, setRegistrationData }) => {
daoURI: response.data.url,
daoContractAddress: daoContractAddress,
daoContractNetwork: daoContractNetwork,
daoName: daoName,
daoDescription: daoDescription,
governanceURI: daoGovURI,
membersURI: daoMembersURI,
proposalsURI: daoProposalsURI,
activityLogURI: daoActivityURI,
contractsRegistryURI: daoContractsRegistryURI,
issuersURI: daoIssuersURI
})
toggleRegScreen('REG_RECEIVED')
})
Expand All @@ -194,6 +205,7 @@ const RegistrationForm = ({ toggleRegScreen, setRegistrationData }) => {
options={[
{ label: 'Mainnet', value: 'mainnet' },
{ label: 'Goerli', value: 'goerli' },
{ label: 'Optimism-Goerli', value: 'optimismGoerli'}
]}
/>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,128 +1,112 @@
import React, { Fragment } from 'react';
import { Button, Divider, FormGroup, TextArea } from '@blueprintjs/core';
import { useWeb3Modal } from '@web3modal/react';
import { ethers } from 'ethers';
import RegistrationContract from '../../../abi/RegistrationContract';
import CopyField from '../../ui/CopyField/CopyField';
import React, { Fragment } from "react";
import { Button, Divider, FormGroup, TextArea } from "@blueprintjs/core";
import { useWeb3Modal } from "@web3modal/react";
import { ethers } from "ethers";
import RegistrationContract from "../../../abi/RegistrationContract";
import CopyField from "../../ui/CopyField/CopyField";

const RegistrationReceived = ({
daoURI,
daoContractAddress,
daoContractNetwork,
isUpdate = false
daoURI,
daoContractAddress,
daoContractNetwork,
isUpdate = false,
}) => {
const { isOpen, open } = useWeb3Modal();
const factoryContracts = {
mainnet: `0x2dac5dbbf1d024c1e0d9c92d3aeda7618e15add7`,
goerli: `0x3271b3479f7485dadb2bd5fff43eeb4367b1a91a`,
gnosis: `0x4f2c9028fe7107d9f1a8a9cff34aa2d3f28600fa`,
polygon: `0x37dF3fC47C1c3A2acaFd2Dad9c1C00090a8655Bc`,
optimism: `0x37dF3fC47C1c3A2acaFd2Dad9c1C00090a8655Bc`,
optimismGoerli: `0x45E81552DEC1F57c18E3cbd69549252624b96D98`
};

const { isOpen, open } = useWeb3Modal();
const factoryContracts = {
mainnet: `0x2dac5dbbf1d024c1e0d9c92d3aeda7618e15add7`,
goerli: `0x3271b3479f7485dadb2bd5fff43eeb4367b1a91a`,
gnosis: `0x4f2c9028fe7107d9f1a8a9cff34aa2d3f28600fa`,
polygon: `0x37dF3fC47C1c3A2acaFd2Dad9c1C00090a8655Bc`,
optimism: `0x37dF3fC47C1c3A2acaFd2Dad9c1C00090a8655Bc`
}
const regContract = new ethers.Contract(
`0x5ef59b7cDe41b744f36b6e07fEF230884F800529`,
RegistrationContract
);
const saltNumber = Math.floor(100000000000 + Math.random() * 900000000000);
const salt = `0x${saltNumber}0000000000000000000000000000000000000000000000000000`; // TODO: generate salt
console.log("salt", salt);
const managerExample = `0x5ef59b7cDe41b744f36b6e07fEF230884F800529`;
const contracts = [];
const bytes = [];
const daoIPFS_URI = `ipfs://${daoURI.substring(
daoURI.indexOf(`immutable/`) + 10
)}`;
console.log("ipfs", daoIPFS_URI);
const regData = [salt, daoIPFS_URI, managerExample, contracts, bytes];
const rawRegData = regContract.interface.encodeFunctionData(
"summonRegistration",
[...regData]
);

const regContract = new ethers.Contract(`0x5ef59b7cDe41b744f36b6e07fEF230884F800529`, RegistrationContract);
const saltNumber = Math.floor(100000000000 + Math.random() * 900000000000)
const salt = `0x${saltNumber}0000000000000000000000000000000000000000000000000000`; // TODO: generate salt
console.log('salt', salt);
const managerExample = `0x5ef59b7cDe41b744f36b6e07fEF230884F800529`;
const contracts = [];
const bytes = [];
const daoIPFS_URI = `ipfs://${daoURI.substring(daoURI.indexOf(`immutable/`) + 10)}`;
console.log('ipfs', daoIPFS_URI);
const regData = [
salt,
daoIPFS_URI,
managerExample,
contracts,
bytes
]
const rawRegData = regContract.interface.encodeFunctionData("summonRegistration", [...regData]);
return (
<Fragment>
<h3>
{isUpdate ? "Updated registration received" : "Registration received!"}
</h3>
<Divider vertical={true} />
<div className="wizard-row wizard-center">
<p className="wizard-margin-bottom-8">Your DAO URI has been created.</p>
<div className="wizard-margin-bottom-8">
<CopyField text={daoURI} />
</div>
<p className="wizard-margin-bottom-8">
To complete registration, propose this transaction to your DAO:
</p>
<Button
disabled
className="wizard-margin-bottom-8"
intent="primary"
text="Connect as DAO (coming soon)"
onClick={open}
loading={isOpen}
/>
</div>
<Divider vertical={true} />
<div className="wizard-row">
<p className="wizard-center">
Or, manually copy transaction to your DAO:
</p>
</div>
<div className="wizard-row">
<FormGroup label="Address" labelFor="address">
<CopyField
id="address"
fill={true}
text={factoryContracts[daoContractNetwork]}
/>
</FormGroup>
</div>
<div className="wizard-row">
<FormGroup label="Value" labelFor="value">
<CopyField fill id="value" text={"0"} />
</FormGroup>
</div>
<div className="wizard-row">
<FormGroup label="Function" labelFor="function">
<CopyField
fill
id="function"
text={`summonRegistration(bytes32 salt,string daoURI_,address manager,address[] contracts,bytes[] data)`}
/>
</FormGroup>
</div>
<div className="wizard-row">
<FormGroup label="Call Data" labelFor="call-data">
<TextArea
fill
// disabled
id="advanced-settings"
value={rawRegData}
growVertically
style={{ minHeight: 200 }}
/>
</FormGroup>
</div>
</Fragment>
);
};

return (
<Fragment>
<h3>{isUpdate ? 'Updated registration received' : 'Registration received!'}</h3>
<Divider vertical={true} />
<div className='wizard-row wizard-center'>
<p className='wizard-margin-bottom-8'>
Your DAO URI has been created.
</p>
<div className='wizard-margin-bottom-8'>
<CopyField
text={daoURI}
/>
</div>
<p className='wizard-margin-bottom-8'>
To complete registration, propose this transaction to your DAO:
</p>
<Button
disabled
className='wizard-margin-bottom-8'
intent='primary'
text='Connect as DAO (coming soon)'
onClick={open}
loading={isOpen}
/>
</div>
<Divider vertical={true} />
<div className='wizard-row'>
<p className='wizard-center'>
Or, manually copy transaction to your DAO:
</p>
</div>
<div className='wizard-row'>
<FormGroup
label='Address'
labelFor='address'
>
<CopyField
id='address'
fill={true}
text={factoryContracts[daoContractNetwork]}
/>
</FormGroup>
</div>
<div className='wizard-row'>
<FormGroup
label='Value'
labelFor='value'
>
<CopyField
fill
id='value'
text={'0'}
/>
</FormGroup>
</div>
<div className='wizard-row'>
<FormGroup
label='Function'
labelFor='function'
>
<CopyField
fill
id='function'
text={`summonRegistration(bytes32 salt,string daoURI_,address manager,address[] contracts,bytes[] data)`}
/>
</FormGroup>
</div>
<div className='wizard-row'>
<FormGroup
label='Call Data'
labelFor='call-data'
>
<TextArea
fill
// disabled
id='advanced-settings'
value={rawRegData}
growVertically
style={{ minHeight: 200 }}
/>
</FormGroup>
</div>
</Fragment>
)
}

export default RegistrationReceived;
export default RegistrationReceived;
1 change: 1 addition & 0 deletions daostar-website/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const client = new ApolloClient({
new MultiAPILink({
endpoints: {
goerli: `https://api.thegraph.com/subgraphs/name/ipatka/daostar-goerli`,
optimismGoerli: `https://api.thegraph.com/subgraphs/name/rashmi-278/daostar-optimism-goerli`,
mainnet: `https://api.thegraph.com/subgraphs/name/ipatka/daostar`,
gnosis: `https://api.thegraph.com/subgraphs/name/mrutsavg/daostar-gnosis`,
},
Expand Down

0 comments on commit b5bf330

Please sign in to comment.