Skip to content

Commit ed147ff

Browse files
davekay100abarmat
andauthored
Add scripts to call contracts (#215)
* Update typechain to v2 * Finish gns scripts, and update helpers * Add mock metadata * Update addresses * Remove old scripts. Add blank files for new scripts * Update README * Script done for graph token * Finish service registry scripts. Refactor tx try/catch * Finish curation scripts * WIP * build: update Typescript config * build: add dom lib to tsconfig * Stake and unstake scripts work for staking * Deploy new Kovan contracts * Clean up readme Co-authored-by: Ariel Barmat <[email protected]>
1 parent 09bfde6 commit ed147ff

19 files changed

+764
-534
lines changed

addresses.json

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
{
2-
"updated-on": "September 17th 2019",
3-
"ropsten": {
4-
"GNS": "0x2b0FB3a066D3676B392B318Bda633aD373F99506",
5-
"GraphToken": "0xF94B27eBA87C7982E7e92322B6f7717F2f5e64f4",
6-
"MultisigWallet": "Not a contract, currently daves metamask",
7-
"ServiceRegistry": "0x6e4De1886Ffd8908cfe4CD12560465CcaB0F5409",
8-
"Staking": "0x2B7F343cD8933c94A1666AdB9d309798F5F74812"
9-
},
10-
"ganache": {
11-
"GNS": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
12-
"GraphToken": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
13-
"MultisigWallet": "Not a contract, currently ganache account[1]",
14-
"ServiceRegistry": "0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb",
15-
"Staking": "0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B"
16-
},
2+
"updated-on": "June 2nd, 2020",
173
"kovan": {
18-
"GNS": "0x9B20eD2d1e9F52C787f8C41e3419771822a2FEe1",
19-
"GraphToken": "0x85bcdBf4d77f33625C4a88CB4BB80C726865dD25",
20-
"MultisigWallet": "Not a contract, currently daves metamask",
21-
"ServiceRegistry": "0xD8530C664521919B65D6378146EfAaD2eB4E6852",
22-
"Staking": "0x33AF9a8CAcae99b439F20E8c9Fe8Ed488FBEbBa2"
4+
"commit-hash": "https://github.com/graphprotocol/contracts/tree/d59900ddeb0ef433326de940e14341a6befa8cf7",
5+
"blockNumber": "18838602",
6+
"governor": "0x93606b27cB5e4c780883eC4F6b7Bed5f6572d1dd",
7+
"graphToken": "0x5E32393c1C3DEC28228458d60A66B35ED40f96C6",
8+
"epochManager": "0x2eE455eBb75D90a80b38BbF7De5C931403f15736",
9+
"disputeManager": "0x8a714a02feEFd3CD763BF9d626650dCb0692be9A",
10+
"staking": "0xB3c62a4a46e00E85dC63E3BBF851a33aFa928386",
11+
"curation": "0x9ce3085eC642414bDFE8CfF7DE603e1DA6f1F702",
12+
"rewardsManager": "0xd1a9930A53D7Ef7126EF2E8A7C51eC40419E37B8",
13+
"serviceRegistry": "0x2aF5CcB503292937171228E72858793160fb6560",
14+
"gns": "0xdc845c78D4eB360CE77794FDbE74E707799D0eBE"
2315
},
2416
"mainnet": {}
2517
}

package-lock.json

Lines changed: 60 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"@nomiclabs/buidler-ethers": "^1.3.3",
3131
"@nomiclabs/buidler-waffle": "^1.3.4",
3232
"@typechain/ethers-v4": "^1.0.0",
33+
"@types/bs58": "^4.0.1",
34+
"@types/minimist": "^1.2.0",
3335
"@types/mocha": "^7.0.2",
3436
"@types/node": "^14.0.5",
3537
"chai": "^4.2.0",
@@ -39,6 +41,7 @@
3941
"husky": "^4.2.5",
4042
"ipfs-http-client": "34.0.0",
4143
"lint-staged": "^10.2.2",
44+
"minimist": "^1.2.5",
4245
"prettier": "^1.19.1",
4346
"prettier-plugin-solidity": "^1.0.0-alpha.51",
4447
"solidity-coverage": "^0.7.5",

scripts/README.md

Lines changed: 79 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ These are convenience scripts for interacting with the contracts.
44

55
The scripts expect the following:
66

7-
- `ts-node` to be installed globally on your system. This can be achieved with:
8-
9-
```sh
10-
npm install -g typescript ts-node
11-
```
12-
137
- A `.privkey.txt` file at the root of this repository with the mnemonics for
148
your Ethereum account.
159

@@ -19,76 +13,110 @@ The scripts expect the following:
1913
following at the root of the repository:
2014

2115
```sh
22-
yarn contracts && yarn typechain
16+
yarn build && yarn typechain
2317
```
2418

25-
## Set the Graph subgraph ID and bootstrap indexers
19+
All scripts that are working are below. Run the script without arguments for more usage info,
20+
as the CLI will print the information
2621

22+
23+
## GNS
24+
**Publishing a subgraph**
2725
```sh
28-
./set-graph-subgraph-id.ts \
29-
--subgraph-id <ipfs-hash> \
30-
--indexers <addr1>[,<addr2>,...]
26+
ts-node ./gns.ts
27+
--func publish
28+
--ipfs https://api.thegraph.com/ipfs/
29+
--subgraphName davesSubgraph
30+
--subgraphID QmdiX6GsbFaz7HDzNxmWCh1oi3bmy19C4te8YSkHbvLbQQ
31+
--metadataPath ./data/metadata.json
3132
```
32-
33-
Run the script without arguments for more usage info.
34-
35-
## Set bootstrap index node URLs
36-
33+
**Unpublishing a subgraph**
3734
```sh
38-
./set-bootstrap-indexer-url.ts \
39-
--indexer <ethereum-address> \
40-
--url <index-node>
35+
ts-node ./gns.ts
36+
--func unpublish
37+
--subgraphName davesSubgraph
4138
```
4239

43-
Run the script without arguments for more usage info.
44-
45-
## Register a top-level domain
46-
40+
**Transferring ownership of a subgraph**
4741
```sh
48-
./register-domain.ts --domain <name>
42+
ts-node ./gns.ts
43+
--func transfer
44+
--subgraphName davesSubgraph
45+
--newOwner 0x7F11E5B7Fe8C04c1E4Ce0dD98aC5c922ECcfA4ed
4946
```
5047

51-
Run the script without arguments for more usage info.
52-
53-
## Create a subgraph (with meta data)
54-
48+
## Graph Token
49+
**Mint**
5550
```sh
56-
./create-subgraph.ts \
57-
--ipfs <ipfs-node> \
58-
--subgraph <subgraph-name> \
59-
--display-name "..." \
60-
...
51+
ts-node ./graph-token.ts
52+
--func mint
53+
--account 0x7F11E5B7Fe8C04c1E4Ce0dD98aC5c922ECcfA4ed
54+
--amount 100
6155
```
6256

63-
Run the script without arguments for more usage info.
64-
65-
## Update a subgraph to a new ID
66-
57+
**Transfer**
6758
```sh
68-
./update-subgraph-id.ts \
69-
--subgraph <subgraph-name> \
70-
--id <ipfs-hash>
59+
ts-node ./graph-token.ts
60+
--func transfer
61+
--account 0x7F11E5B7Fe8C04c1E4Ce0dD98aC5c922ECcfA4ed
62+
--amount 100
7163
```
7264

73-
Run the script without arguments for more usage info.
65+
**Approve**
66+
```sh
67+
ts-node ./graph-token.ts
68+
--func approve
69+
--account 0x7F11E5B7Fe8C04c1E4Ce0dD98aC5c922ECcfA4ed
70+
--amount 100
71+
```
7472

75-
## Stake for indexing on a subgraph ID
73+
## Service Registry
74+
**Register**
75+
```sh
76+
ts-node ./service-registry.ts
77+
--func register
78+
--url https://172.0.0.1
79+
--geohash gbsuve
80+
```
7681

82+
**Unregister**
7783
```sh
78-
./stake-for-indexing.ts \
79-
--subgraph-id <ipfs-hash> \
80-
--amount <number> # minimum: 100
84+
ts-node ./service-registry.ts
85+
--func unregister
8186
```
8287

83-
Run the script without arguments for more usage info.
88+
## Curation
89+
**stake**
90+
```sh
91+
ts-node ./curation.ts
92+
--func stake
93+
--amount 520
94+
```
8495

85-
## Update an indexer's node URL
96+
**redeem**
97+
```sh
98+
ts-node ./curation.ts
99+
--func redeem
100+
--amount 520
101+
```
86102

87-
This sets the current Ethereum account's index node URL in the service registry.
103+
## Staking
104+
**stake**
105+
```sh
106+
ts-node ./staking.ts
107+
--func stake
108+
--amount 520
109+
```
88110

111+
**unstake**
89112
```sh
90-
./set-url.ts \
91-
--url <index-node-url>
113+
ts-node ./staking.ts
114+
--func unstake
115+
--amount 520
92116
```
93117

94-
Run the script without arguments for more usage info.
118+
**withdraw**
119+
```sh
120+
ts-node ./staking.ts
121+
--func withdraw
122+
```

0 commit comments

Comments
 (0)