Skip to content

Commit 8d8227b

Browse files
committed
Add network string to execute transaction
1 parent cadb79f commit 8d8227b

File tree

11 files changed

+88
-46
lines changed

11 files changed

+88
-46
lines changed

scripts/contracts/curation.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ const main = async () => {
5454
console.log(
5555
' First calling approve() to ensure curation contract can call transferFrom()...',
5656
)
57-
await executeTransaction(connectedGT.approveWithDecimals(curation.contract.address, amount))
57+
await executeTransaction(
58+
connectedGT.approveWithDecimals(curation.contract.address, amount),
59+
network,
60+
)
5861
console.log(' Now calling signal() on curation...')
59-
await executeTransaction(curation.signalWithDecimals(id, amount))
62+
await executeTransaction(curation.signalWithDecimals(id, amount), network)
6063
} else if (func == 'redeem') {
6164
console.log(`Redeeming ${amount} shares on ${id}...`)
62-
await executeTransaction(curation.redeemWithDecimals(id, amount))
65+
await executeTransaction(curation.redeemWithDecimals(id, amount), network)
6366
} else {
6467
console.log(`Wrong func name provided`)
6568
process.exit(1)

scripts/contracts/ens.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const main = async () => {
4646
try {
4747
if (func == 'registerName') {
4848
console.log(`Setting owner for ${name} and the text record...`)
49-
await executeTransaction(ens.setTestRecord(name))
50-
await executeTransaction(ens.setText(name))
49+
await executeTransaction(ens.setTestRecord(name), network)
50+
await executeTransaction(ens.setText(name), network)
5151
} else if (func == 'checkOwner') {
5252
console.log(`Checking owner of ${name} ...`)
5353
await ens.checkOwner(name)

scripts/contracts/ethereumDIDRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const main = async () => {
5353
try {
5454
if (func == 'setAttribute') {
5555
console.log(`Setting attribute on ethereum DID registry ...`)
56-
await executeTransaction(ethereumDIDRegistry.pinIPFSAndSetAttribute(ipfs, metadataPath))
56+
await executeTransaction(ethereumDIDRegistry.pinIPFSAndSetAttribute(ipfs, metadataPath), network)
5757
} else {
5858
console.log(`Wrong func name provided`)
5959
process.exit(1)

scripts/contracts/gns.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const main = async () => {
104104
name,
105105
metadataPath,
106106
),
107+
network,
107108
)
108109
} else if (func == 'publishNewVersion') {
109110
checkFuncInputs(
@@ -129,11 +130,12 @@ const main = async () => {
129130
metadataPath,
130131
subgraphNumber,
131132
),
133+
network,
132134
)
133135
} else if (func == 'deprecate') {
134136
checkFuncInputs([subgraphNumber], ['subgraphNumber'], 'deprecate')
135137
console.log(`Deprecating subgraph ${graphAccount}-${subgraphNumber}`)
136-
await executeTransaction(gns.gns.deprecate(graphAccount, subgraphNumber))
138+
await executeTransaction(gns.gns.deprecate(graphAccount, subgraphNumber), network)
137139
} else {
138140
console.log(`Wrong func name provided`)
139141
process.exit(1)

scripts/contracts/graph-token.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ const main = async () => {
5252
try {
5353
if (func == 'mint') {
5454
console.log(`Minting ${amount} tokens to user ${account}...`)
55-
await executeTransaction(graphToken.mintWithDecimals(account, amount))
55+
await executeTransaction(graphToken.mintWithDecimals(account, amount), network)
5656
} else if (func == 'transfer') {
5757
console.log(`Transferring ${amount} tokens to user ${account}...`)
58-
await executeTransaction(graphToken.transferWithDecimals(account, amount))
58+
await executeTransaction(graphToken.transferWithDecimals(account, amount), network)
5959
} else if (func == 'approve') {
6060
console.log(`Approving ${amount} tokens to spend by ${account}...`)
61-
await executeTransaction(graphToken.approveWithDecimals(account, amount))
61+
await executeTransaction(graphToken.approveWithDecimals(account, amount), network)
6262
} else {
6363
console.log(`Wrong func name provided`)
6464
process.exit(1)

scripts/contracts/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ export const basicOverrides = (): Overrides => {
112112

113113
export const executeTransaction = async (
114114
transaction: Promise<ContractTransaction>,
115+
network: string,
115116
): Promise<ContractReceipt> => {
116117
try {
117118
const tx = await transaction
118-
console.log(` Transaction pending: 'https://kovan.etherscan.io/tx/${tx.hash}'`)
119+
console.log(` Transaction pending: 'https://${network}.etherscan.io/tx/${tx.hash}'`)
119120
const receipt = await tx.wait(1)
120121
console.log(` Transaction successfully included in block #${receipt.blockNumber}`)
121122
return receipt

scripts/contracts/populateData.ts

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ const sendEth = async (
4545
to: signers[i].address,
4646
value: amountEther,
4747
}
48-
await executeTransaction(governor.sendTransaction(data))
48+
await executeTransaction(governor.sendTransaction(data), network)
4949
}
5050
for (let i = 0; i < proxies.length; i++) {
5151
const data = {
5252
to: proxies[i].address,
5353
value: amountEther,
5454
}
55-
await executeTransaction(governor.sendTransaction(data))
55+
await executeTransaction(governor.sendTransaction(data), network)
5656
}
5757
}
5858

@@ -67,8 +67,8 @@ const populateGraphToken = async (
6767
const graphToken = new ConnectedGraphToken(network, signers[0]) // defaults to governor
6868
console.log('Sending GRT to indexers, curators, and proxies...')
6969
for (let i = 0; i < signers.length; i++) {
70-
await executeTransaction(graphToken.transferWithDecimals(signers[i].address, amount))
71-
await executeTransaction(graphToken.transferWithDecimals(proxies[i].address, amount))
70+
await executeTransaction(graphToken.transferWithDecimals(signers[i].address, amount), network)
71+
await executeTransaction(graphToken.transferWithDecimals(proxies[i].address, amount), network)
7272
}
7373
}
7474

@@ -85,6 +85,7 @@ const populateEthereumDIDRegistry = async (network: string, signers: Array<Walle
8585
const ipfs = 'https://api.thegraph.com/ipfs/'
8686
await executeTransaction(
8787
edr.pinIPFSAndSetAttribute(ipfs, accountMetadatas[account] as AccountMetadata),
88+
network,
8889
)
8990
i++
9091
}
@@ -100,8 +101,8 @@ const populateENS = async (network: string, signers: Array<Wallet>) => {
100101
// edge case - graph is only ens name that doesn't match display name in mock data
101102
if (name == 'The Graph') name = 'graphprotocol'
102103
console.log(`Setting ${name} for ${ens.configuredWallet.address} on ens ...`)
103-
await executeTransaction(ens.setTestRecord(name))
104-
await executeTransaction(ens.setText(name))
104+
await executeTransaction(ens.setTestRecord(name), network)
105+
await executeTransaction(ens.setText(name), network)
105106
i++
106107
}
107108
}
@@ -129,6 +130,7 @@ const populateGNS = async (network: string, signers: Array<Wallet>) => {
129130
name,
130131
subgraphMetadatas[subgraph] as SubgraphMetadata,
131132
),
133+
network,
132134
)
133135
console.log(`Updating version of ${name} for ${gns.configuredWallet.address} on GNS ...`)
134136
await executeTransaction(
@@ -141,13 +143,14 @@ const populateGNS = async (network: string, signers: Array<Wallet>) => {
141143
subgraphMetadatas[subgraph] as SubgraphMetadata,
142144
'0', // TODO, only works on the first run right now, make more robust
143145
),
146+
network,
144147
)
145148
i++
146149
}
147150

148151
// Deprecation one subgraph for account 5
149152
const gns = new ConnectedGNS(network, signers[5])
150-
await executeTransaction(gns.gns.deprecate(gns.configuredWallet.address, '0'))
153+
await executeTransaction(gns.gns.deprecate(gns.configuredWallet.address, '0'), network)
151154
}
152155

153156
// Each GraphAccount curates on their own
@@ -164,20 +167,34 @@ const populateCuration = async (network: string, signers: Array<Wallet>) => {
164167
console.log('First calling approve() to ensure curation contract can call transferFrom()...')
165168
await executeTransaction(
166169
connectedGT.approveWithDecimals(curation.contract.address, totalAmount),
170+
network,
167171
)
168172
console.log('Now calling multiple signal() txs on curation...')
169-
await executeTransaction(curation.signalWithDecimals(mockDeploymentIDsBytes32[i], signalAmount))
170-
await executeTransaction(curation.signalWithDecimals(mockDeploymentIDsBytes32[0], signalAmount))
171-
await executeTransaction(curation.signalWithDecimals(mockDeploymentIDsBytes32[1], signalAmount))
173+
await executeTransaction(
174+
curation.signalWithDecimals(mockDeploymentIDsBytes32[i], signalAmount),
175+
network,
176+
)
177+
await executeTransaction(
178+
curation.signalWithDecimals(mockDeploymentIDsBytes32[0], signalAmount),
179+
network,
180+
)
181+
await executeTransaction(
182+
curation.signalWithDecimals(mockDeploymentIDsBytes32[1], signalAmount),
183+
network,
184+
)
172185
await executeTransaction(
173186
curation.signalWithDecimals(mockDeploymentIDsBytes32[2], signalAmountBig),
187+
network,
174188
)
175189
}
176190
const redeemAmount = '1' // Redeeming SHARES/Signal, NOT tokens. 1 share can be a lot of tokens
177191
console.log('Running redeem transactions...')
178192
for (let i = 0; i < signers.length / 2; i++) {
179193
const curation = new ConnectedCuration(network, signers[i])
180-
await executeTransaction(curation.redeemWithDecimals(mockDeploymentIDsBytes32[1], redeemAmount))
194+
await executeTransaction(
195+
curation.redeemWithDecimals(mockDeploymentIDsBytes32[1], redeemAmount),
196+
network,
197+
)
181198
}
182199
}
183200

@@ -217,13 +234,13 @@ const populateServiceRegistry = async (network: string, signers: Array<Wallet>)
217234
for (let i = 0; i < signers.length; i++) {
218235
const serviceRegistry = new ConnectedServiceRegistry(network, signers[i])
219236
console.log(`Registering an indexer in the service registry...`)
220-
await executeTransaction(serviceRegistry.contract.register(urls[i], geoHashes[i]))
237+
await executeTransaction(serviceRegistry.contract.register(urls[i], geoHashes[i]), network)
221238
if (i < 2) {
222239
// Just need to test a few
223240
console.log(`Unregistering a few to test...`)
224-
await executeTransaction(serviceRegistry.contract.unregister())
241+
await executeTransaction(serviceRegistry.contract.unregister(), network)
225242
console.log(`Re-registering them...`)
226-
await executeTransaction(serviceRegistry.contract.register(urls[i], geoHashes[i]))
243+
await executeTransaction(serviceRegistry.contract.register(urls[i], geoHashes[i]), network)
227244
}
228245
}
229246
}
@@ -248,23 +265,29 @@ const populateStaking = async (network: string, signers: Array<Wallet>, proxies:
248265
console.log(
249266
'First calling approve() to ensure staking contract can call transferFrom() from the stakers...',
250267
)
251-
await executeTransaction(connectedGT.approveWithDecimals(staking.contract.address, stakeAmount))
268+
await executeTransaction(
269+
connectedGT.approveWithDecimals(staking.contract.address, stakeAmount),
270+
network,
271+
)
252272
console.log('Now calling stake()...')
253-
await executeTransaction(staking.stakeWithDecimals(stakeAmount))
273+
await executeTransaction(staking.stakeWithDecimals(stakeAmount), network)
254274
}
255275

256276
console.log('Calling governor function to set epoch length to 1...')
257-
await executeTransaction(epochManager.setEpochLength(1))
277+
await executeTransaction(epochManager.setEpochLength(1), network)
258278
console.log('Calling governor function to set thawing period to 0...')
259-
await executeTransaction(networkContracts.staking.setThawingPeriod(0))
279+
await executeTransaction(networkContracts.staking.setThawingPeriod(0), network)
260280
console.log('Approve, stake extra, initialize unstake and withdraw for 3 signers...')
261281
for (let i = 0; i < 3; i++) {
262282
const staking = new ConnectedStaking(network, signers[i])
263283
const connectedGT = new ConnectedGraphToken(network, signers[i])
264-
await executeTransaction(connectedGT.approveWithDecimals(staking.contract.address, stakeAmount))
265-
await executeTransaction(staking.stakeWithDecimals(stakeAmount))
266-
await executeTransaction(staking.unstakeWithDecimals(stakeAmount))
267-
await executeTransaction(staking.contract.withdraw())
284+
await executeTransaction(
285+
connectedGT.approveWithDecimals(staking.contract.address, stakeAmount),
286+
network,
287+
)
288+
await executeTransaction(staking.stakeWithDecimals(stakeAmount), network)
289+
await executeTransaction(staking.unstakeWithDecimals(stakeAmount), network)
290+
await executeTransaction(staking.contract.withdraw(), network)
268291
}
269292

270293
console.log('Create 10 allocations...')
@@ -278,11 +301,12 @@ const populateStaking = async (network: string, signers: Array<Wallet>, proxies:
278301
mockDeploymentIDsBytes32[i],
279302
mockChannelPubKeys[i],
280303
),
304+
network,
281305
)
282306
}
283307

284308
console.log('Run Epoch....')
285-
await executeTransaction(epochManager.runEpoch())
309+
await executeTransaction(epochManager.runEpoch(), network)
286310
console.log('Settle 5 allocations...')
287311
for (let i = 0; i < 5; i++) {
288312
// Note that the array of proxy wallets is used, not the signers
@@ -291,16 +315,19 @@ const populateStaking = async (network: string, signers: Array<Wallet>, proxies:
291315
console.log(
292316
'First calling approve() to ensure staking contract can call transferFrom() from the proxies...',
293317
)
294-
await executeTransaction(connectedGT.approveWithDecimals(staking.contract.address, stakeAmount))
318+
await executeTransaction(
319+
connectedGT.approveWithDecimals(staking.contract.address, stakeAmount),
320+
network,
321+
)
295322
console.log('Settling a channel...')
296-
await executeTransaction(staking.settleWithDecimals(stakeAmount))
323+
await executeTransaction(staking.settleWithDecimals(stakeAmount), network)
297324
}
298325
const defaultThawingPeriod = 20
299326
const defaultEpochLength = 5760
300327
console.log('Setting epoch length back to default')
301-
await executeTransaction(epochManager.setEpochLength(defaultEpochLength))
328+
await executeTransaction(epochManager.setEpochLength(defaultEpochLength), network)
302329
console.log('Setting back the thawing period to default')
303-
await executeTransaction(networkContracts.staking.setThawingPeriod(defaultThawingPeriod))
330+
await executeTransaction(networkContracts.staking.setThawingPeriod(defaultThawingPeriod), network)
304331
}
305332

306333
const populateAll = async (mnemonic: string, provider: string, network: string): Promise<void> => {

scripts/contracts/sendTeamTokens.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ const main = async () => {
4646
if (func == 'mint') {
4747
for (const member in teamAddresses) {
4848
console.log(`Minting ${amount} tokens to user ${member}...`)
49-
await executeTransaction(graphToken.mintWithDecimals(teamAddresses[member], amount))
49+
await executeTransaction(
50+
graphToken.mintWithDecimals(teamAddresses[member], amount),
51+
network,
52+
)
5053
}
5154
} else {
5255
console.log(`Wrong func name provided`)

scripts/contracts/service-registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const main = async () => {
5252
console.log(
5353
`Registering ${await serviceRegistry.contract.signer.getAddress()} with url ${url} and geoHash ${geoHash}...`,
5454
)
55-
await executeTransaction(serviceRegistry.contract.register(url, geoHash))
55+
await executeTransaction(serviceRegistry.contract.register(url, geoHash), network)
5656
} else if (func == 'unregister') {
5757
console.log(`Unregistering ${await serviceRegistry.contract.signer.getAddress()}...`)
58-
await executeTransaction(serviceRegistry.contract.unregister())
58+
await executeTransaction(serviceRegistry.contract.unregister(), network)
5959
} else {
6060
console.log(`Wrong func name provided`)
6161
process.exit(1)

scripts/contracts/staking.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,19 @@ const main = async () => {
8181
if (func == 'stake') {
8282
checkFuncInputs([amount], ['amount'], 'stake')
8383
console.log(' First calling approve() to ensure staking contract can call transferFrom()...')
84-
await executeTransaction(connectedGT.approveWithDecimals(staking.contract.address, amount))
84+
await executeTransaction(
85+
connectedGT.approveWithDecimals(staking.contract.address, amount),
86+
network,
87+
)
8588
console.log(`Staking ${amount} tokens in the staking contract...`)
86-
await executeTransaction(staking.stakeWithDecimals(amount))
89+
await executeTransaction(staking.stakeWithDecimals(amount), network)
8790
} else if (func == 'unstake') {
8891
checkFuncInputs([amount], ['amount'], 'unstake')
8992
console.log(`Unstaking ${amount} tokens. Tokens will be locked...`)
90-
await executeTransaction(staking.unstakeWithDecimals(amount))
93+
await executeTransaction(staking.unstakeWithDecimals(amount), network)
9194
} else if (func == 'withdraw') {
9295
console.log(`Unlock tokens and withdraw them from the staking contract...`)
93-
await executeTransaction(staking.contract.withdraw())
96+
await executeTransaction(staking.contract.withdraw(), network)
9497
} else if (func == 'allocate') {
9598
checkFuncInputs([amount, price], ['amount', 'price'], 'allocate')
9699
console.log(`Allocating ${amount} tokens on state channel ${subgraphDeploymentID} ...`)
@@ -102,12 +105,13 @@ const main = async () => {
102105
channelPubKey,
103106
channelProxy,
104107
),
108+
network,
105109
)
106110
} else if (func == 'settle') {
107111
// Note - this function must be called by the channel proxy eth address
108112
checkFuncInputs([amount], ['amount'], 'settle')
109113
console.log(`Settling ${amount} tokens on state channel with proxy address TODO`)
110-
await executeTransaction(staking.settleWithDecimals(amount))
114+
await executeTransaction(staking.settleWithDecimals(amount), network)
111115
} else {
112116
console.log(`Wrong func name provided`)
113117
process.exit(1)

0 commit comments

Comments
 (0)