Skip to content

Commit f4f7cd6

Browse files
committed
chore: fix cli to use new GNS interface
1 parent 3c25e10 commit f4f7cd6

File tree

2 files changed

+55
-110
lines changed

2 files changed

+55
-110
lines changed

cli/commands/contracts/gns.ts

Lines changed: 53 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const setDefaultName = async (cli: CLIEnvironment, cliArgs: CLIArgs): Pro
2020

2121
export const publishNewSubgraph = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
2222
const ipfs = cliArgs.ipfs
23-
const graphAccount = cliArgs.graphAccount
2423
const subgraphDeploymentID = cliArgs.subgraphDeploymentID
2524
const versionPath = cliArgs.versionPath
2625
const subgraphPath = cliArgs.subgraphPath
@@ -30,89 +29,77 @@ export const publishNewSubgraph = async (cli: CLIEnvironment, cliArgs: CLIArgs):
3029
const subgraphHashBytes = await pinMetadataToIPFS(ipfs, 'subgraph', subgraphPath)
3130
const gns = cli.contracts.GNS
3231

33-
logger.info(`Publishing new subgraph for ${graphAccount}`)
32+
logger.info(`Publishing new subgraph for ${cli.walletAddress}...`)
3433
await sendTransaction(cli.wallet, gns, 'publishNewSubgraph', [
35-
graphAccount,
3634
subgraphDeploymentIDBytes,
3735
versionHashBytes,
3836
subgraphHashBytes,
3937
])
4038
}
4139

4240
export const publishNewVersion = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
41+
const subgraphID = cliArgs.subgraphID
4342
const ipfs = cliArgs.ipfs
44-
const graphAccount = cliArgs.graphAccount
4543
const subgraphDeploymentID = cliArgs.subgraphDeploymentID
4644
const versionPath = cliArgs.versionPath
47-
const subgraphNumber = cliArgs.subgraphNumber
4845

4946
const subgraphDeploymentIDBytes = IPFS.ipfsHashToBytes32(subgraphDeploymentID)
5047
const versionHashBytes = await pinMetadataToIPFS(ipfs, 'version', versionPath)
5148
const gns = cli.contracts.GNS
5249

53-
logger.info(`Publishing new subgraph version for ${graphAccount}`)
50+
logger.info(`Publishing new subgraph version for ${subgraphID}...`)
5451
await sendTransaction(cli.wallet, gns, 'publishNewVersion', [
55-
graphAccount,
56-
subgraphNumber,
52+
subgraphID,
5753
subgraphDeploymentIDBytes,
5854
versionHashBytes,
5955
])
6056
}
6157

6258
export const deprecate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
63-
const graphAccount = cliArgs.graphAccount
64-
const subgraphNumber = cliArgs.subgraphNumber
59+
const subgraphID = cliArgs.subgraphID
6560
const gns = cli.contracts.GNS
66-
logger.info(`Deprecating subgraph ${graphAccount}-${subgraphNumber}...`)
67-
await sendTransaction(cli.wallet, gns, 'deprecate', [graphAccount, subgraphNumber])
61+
logger.info(`Deprecating subgraph ${subgraphID}...`)
62+
await sendTransaction(cli.wallet, gns, 'deprecateSubgraph', [subgraphID])
6863
}
6964

7065
export const updateSubgraphMetadata = async (
7166
cli: CLIEnvironment,
7267
cliArgs: CLIArgs,
7368
): Promise<void> => {
7469
const ipfs = cliArgs.ipfs
75-
const graphAccount = cliArgs.graphAccount
76-
const subgraphNumber = cliArgs.subgraphNumber
70+
const subgraphID = cliArgs.subgraphID
7771
const subgraphPath = cliArgs.subgraphPath
7872
const subgraphHashBytes = await pinMetadataToIPFS(ipfs, 'subgraph', subgraphPath)
7973
const gns = cli.contracts.GNS
8074

81-
logger.info(`Updating subgraph metadata for ${graphAccount}-${subgraphNumber}...`)
82-
await sendTransaction(cli.wallet, gns, 'updateSubgraphMetadata', [
83-
graphAccount,
84-
subgraphNumber,
85-
subgraphHashBytes,
86-
])
75+
logger.info(`Updating subgraph metadata for ${subgraphID}...`)
76+
await sendTransaction(cli.wallet, gns, 'updateSubgraphMetadata', [subgraphID, subgraphHashBytes])
8777
}
8878

89-
export const mintNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
90-
const graphAccount = cliArgs.graphAccount
91-
const subgraphNumber = cliArgs.subgraphNumber
79+
export const mintSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
80+
const subgraphID = cliArgs.subgraphID
9281
const tokens = parseGRT(cliArgs.tokens)
9382
const gns = cli.contracts.GNS
9483

95-
logger.info(`Minting nSignal for ${graphAccount}-${subgraphNumber}...`)
96-
await sendTransaction(cli.wallet, gns, 'mintNSignal', [graphAccount, subgraphNumber, tokens, 0])
84+
logger.info(`Minting signal for ${subgraphID}...`)
85+
await sendTransaction(cli.wallet, gns, 'mintSignal', [subgraphID, tokens, 0])
9786
}
9887

99-
export const burnNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
100-
const graphAccount = cliArgs.graphAccount
101-
const subgraphNumber = cliArgs.subgraphNumber
102-
const nSignal = cliArgs.nSignal
88+
export const burnSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
89+
const subgraphID = cliArgs.subgraphID
90+
const signal = cliArgs.signal
10391
const gns = cli.contracts.GNS
10492

105-
logger.info(`Burning nSignal from ${graphAccount}-${subgraphNumber}...`)
106-
await sendTransaction(cli.wallet, gns, 'burnNSignal', [graphAccount, subgraphNumber, nSignal])
93+
logger.info(`Burning signal from ${subgraphID}...`)
94+
await sendTransaction(cli.wallet, gns, 'burnSignal', [subgraphID, signal, 0])
10795
}
10896

109-
export const withdrawGRT = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
110-
const graphAccount = cliArgs.graphAccount
111-
const subgraphNumber = cliArgs.subgraphNumber
97+
export const withdraw = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
98+
const subgraphID = cliArgs.subgraphID
11299
const gns = cli.contracts.GNS
113100

114-
logger.info(`Withdrawing locked GRT from subgraph ${graphAccount}-${subgraphNumber}...`)
115-
await sendTransaction(cli.wallet, gns, 'withdrawGRT', [graphAccount, subgraphNumber])
101+
logger.info(`Withdrawing locked GRT from subgraph ${subgraphID}...`)
102+
await sendTransaction(cli.wallet, gns, 'withdraw', [subgraphID])
116103
}
117104

118105
export const gnsCommand = {
@@ -153,12 +140,6 @@ export const gnsCommand = {
153140
requiresArg: true,
154141
demandOption: true,
155142
})
156-
.option('graphAccount', {
157-
description: 'graph account address',
158-
type: 'string',
159-
requiresArg: true,
160-
demandOption: true,
161-
})
162143
.option('subgraphDeploymentID', {
163144
description: 'subgraph deployment ID in base58',
164145
type: 'string',
@@ -194,14 +175,14 @@ export const gnsCommand = {
194175
describe: 'Withdraw unlocked GRT',
195176
builder: (yargs: Argv) => {
196177
return yargs
197-
.option('ipfs', {
198-
description: 'ipfs endpoint. ex. https://api.thegraph.com/ipfs/',
178+
.option('subgraphID', {
179+
description: 'Subgraph identifier',
199180
type: 'string',
200181
requiresArg: true,
201182
demandOption: true,
202183
})
203-
.option('graphAccount', {
204-
description: 'graph account address',
184+
.option('ipfs', {
185+
description: 'ipfs endpoint. ex. https://api.thegraph.com/ipfs/',
205186
type: 'string',
206187
requiresArg: true,
207188
demandOption: true,
@@ -220,12 +201,6 @@ export const gnsCommand = {
220201
requiresArg: true,
221202
demandOption: true,
222203
})
223-
.option('subgraphNumber', {
224-
description: 'subgraph number the account is updating',
225-
type: 'number',
226-
requiresArg: true,
227-
demandOption: true,
228-
})
229204
},
230205
handler: async (argv: CLIArgs): Promise<void> => {
231206
return publishNewVersion(await loadEnv(argv), argv)
@@ -235,19 +210,12 @@ export const gnsCommand = {
235210
command: 'deprecate',
236211
describe: 'Deprecate a subgraph',
237212
builder: (yargs: Argv) => {
238-
return yargs
239-
.option('graphAccount', {
240-
description: 'graph account address',
241-
type: 'string',
242-
requiresArg: true,
243-
demandOption: true,
244-
})
245-
.option('subgraphNumber', {
246-
description: 'subgraph number the account is deprecating',
247-
type: 'string',
248-
requiresArg: true,
249-
demandOption: true,
250-
})
213+
return yargs.option('subgraphID', {
214+
description: 'Subgraph identifier',
215+
type: 'string',
216+
requiresArg: true,
217+
demandOption: true,
218+
})
251219
},
252220
handler: async (argv: CLIArgs): Promise<void> => {
253221
return deprecate(await loadEnv(argv), argv)
@@ -258,14 +226,8 @@ export const gnsCommand = {
258226
describe: 'Update a subgraphs metadata',
259227
builder: (yargs: Argv) => {
260228
return yargs
261-
.option('graphAccount', {
262-
description: 'graph account address',
263-
type: 'string',
264-
requiresArg: true,
265-
demandOption: true,
266-
})
267-
.option('subgraphNumber', {
268-
description: 'subgraph number to update',
229+
.option('subgraphID', {
230+
description: 'Subgraph identifier',
269231
type: 'string',
270232
requiresArg: true,
271233
demandOption: true,
@@ -287,18 +249,12 @@ export const gnsCommand = {
287249
},
288250
})
289251
.command({
290-
command: 'mintNSignal',
252+
command: 'mintSignal',
291253
describe: 'Mint Name Signal by depositing tokens',
292254
builder: (yargs: Argv) => {
293255
return yargs
294-
.option('graphAccount', {
295-
description: 'graph account address',
296-
type: 'string',
297-
requiresArg: true,
298-
demandOption: true,
299-
})
300-
.option('subgraphNumber', {
301-
description: 'subgraph number of the name signal',
256+
.option('subgraphID', {
257+
description: 'Subgraph identifier',
302258
type: 'string',
303259
requiresArg: true,
304260
demandOption: true,
@@ -311,57 +267,44 @@ export const gnsCommand = {
311267
})
312268
},
313269
handler: async (argv: CLIArgs): Promise<void> => {
314-
return mintNSignal(await loadEnv(argv), argv)
270+
return mintSignal(await loadEnv(argv), argv)
315271
},
316272
})
317273
.command({
318-
command: 'burnNSignal',
274+
command: 'burnSignal',
319275
describe: 'Burn Name Signal and receive tokens',
320276
builder: (yargs: Argv) => {
321277
return yargs
322-
.option('graphAccount', {
323-
description: 'graph account address',
278+
.option('subgraphID', {
279+
description: 'Subgraph identifier',
324280
type: 'string',
325281
requiresArg: true,
326282
demandOption: true,
327283
})
328-
.option('subgraphNumber', {
329-
description: 'subgraph number of the name signal',
330-
type: 'string',
331-
requiresArg: true,
332-
demandOption: true,
333-
})
334-
.option('nSignal', {
335-
description: 'Amount of nSignal to burn',
284+
.option('signal', {
285+
description: 'Amount of signal to burn',
336286
type: 'string',
337287
requiresArg: true,
338288
demandOption: true,
339289
})
340290
},
341291
handler: async (argv: CLIArgs): Promise<void> => {
342-
return burnNSignal(await loadEnv(argv), argv)
292+
return burnSignal(await loadEnv(argv), argv)
343293
},
344294
})
345295
.command({
346-
command: 'withdrawGRT',
296+
command: 'withdraw',
347297
describe: 'Withdraw GRT from a deprecated subgraph',
348298
builder: (yargs: Argv) => {
349-
return yargs
350-
.option('graphAccount', {
351-
description: 'graph account address',
352-
type: 'string',
353-
requiresArg: true,
354-
demandOption: true,
355-
})
356-
.option('subgraphNumber', {
357-
description: 'subgraph number to withdraw from',
358-
type: 'string',
359-
requiresArg: true,
360-
demandOption: true,
361-
})
299+
return yargs.option('subgraphID', {
300+
description: 'Subgraph identifier',
301+
type: 'string',
302+
requiresArg: true,
303+
demandOption: true,
304+
})
362305
},
363306
handler: async (argv: CLIArgs): Promise<void> => {
364-
return withdrawGRT(await loadEnv(argv), argv)
307+
return withdraw(await loadEnv(argv), argv)
365308
},
366309
})
367310
},

graph.config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ contracts:
7474
calls:
7575
- fn: "setTokenDescriptor"
7676
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
77+
- fn: "setMinter"
78+
minter: "${{GNS.address}}"
7779
Staking:
7880
proxy: true
7981
init:

0 commit comments

Comments
 (0)