@ar.io/sdk 2.6.0 → 2.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/web.bundle.min.js +65 -65
- package/lib/cjs/cli/cli.js +712 -0
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +211 -0
- package/lib/cjs/cli/commands/readCommands.js +219 -0
- package/lib/cjs/cli/commands/transfer.js +26 -0
- package/lib/cjs/cli/options.js +336 -0
- package/lib/cjs/cli/types.js +2 -0
- package/lib/cjs/cli/utils.js +406 -0
- package/lib/cjs/common/io.js +2 -7
- package/lib/cjs/types/io.js +13 -1
- package/lib/cjs/utils/ao.js +32 -13
- package/lib/cjs/utils/base64.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +710 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +194 -0
- package/lib/esm/cli/commands/readCommands.js +197 -0
- package/lib/esm/cli/commands/transfer.js +22 -0
- package/lib/esm/cli/options.js +333 -0
- package/lib/esm/cli/types.js +1 -0
- package/lib/esm/cli/utils.js +366 -0
- package/lib/esm/common/io.js +2 -7
- package/lib/esm/types/io.js +11 -0
- package/lib/esm/utils/ao.js +30 -12
- package/lib/esm/utils/base64.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/cli.d.ts +2 -0
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +38 -0
- package/lib/types/cli/commands/readCommands.d.ts +57 -0
- package/lib/types/cli/commands/transfer.d.ts +23 -0
- package/lib/types/cli/options.d.ts +326 -0
- package/lib/types/cli/types.d.ts +106 -0
- package/lib/types/cli/utils.d.ts +66 -0
- package/lib/types/common/io.d.ts +4 -7
- package/lib/types/types/io.d.ts +81 -60
- package/lib/types/utils/ao.d.ts +20 -10
- package/lib/types/version.d.ts +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line header/header -- This is a CLI file
|
|
18
|
+
import { program } from 'commander';
|
|
19
|
+
import { spawnANT } from '../node/index.js';
|
|
20
|
+
import { mIOToken } from '../types/token.js';
|
|
21
|
+
import { version } from '../version.js';
|
|
22
|
+
import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
|
|
23
|
+
import { getAllowedDelegates, getArNSAuction, getArNSAuctionPrices, getArNSRecord, getArNSReservedName, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listArNSAuctions, listArNSRecords, listArNSReservedNames, listGateways, } from './commands/readCommands.js';
|
|
24
|
+
import { transfer } from './commands/transfer.js';
|
|
25
|
+
import { addressAndVaultIdOptions, addressOptions, antStateOptions, arNSAuctionPricesOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, initiatorOptions, joinNetworkOptions, nameOptions, nameWriteOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, writeActionOptions, } from './options.js';
|
|
26
|
+
import { assertConfirmationPrompt, epochInputFromOptions, formatIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, ioProcessIdFromOptions, makeCommand, paginationParamsFromOptions, positiveIntegerFromOptions, readANTFromOptions, readIOFromOptions, recordTypeFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredPositiveIntegerFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, writeIOFromOptions, } from './utils.js';
|
|
27
|
+
makeCommand({
|
|
28
|
+
name: 'ar.io', // TODO: can it be ar.io?
|
|
29
|
+
description: 'AR.IO Network CLI',
|
|
30
|
+
})
|
|
31
|
+
.version(version)
|
|
32
|
+
.helpCommand(true);
|
|
33
|
+
makeCommand({
|
|
34
|
+
name: 'info',
|
|
35
|
+
description: 'Get network info',
|
|
36
|
+
action: (options) => readIOFromOptions(options).getInfo(),
|
|
37
|
+
});
|
|
38
|
+
makeCommand({
|
|
39
|
+
name: 'token-supply',
|
|
40
|
+
description: 'Get the total token supply',
|
|
41
|
+
action: (options) => readIOFromOptions(options).getTokenSupply(),
|
|
42
|
+
});
|
|
43
|
+
makeCommand({
|
|
44
|
+
name: 'get-registration-fees',
|
|
45
|
+
description: 'Get registration fees',
|
|
46
|
+
action: (options) => readIOFromOptions(options).getRegistrationFees(),
|
|
47
|
+
});
|
|
48
|
+
makeCommand({
|
|
49
|
+
name: 'get-demand-factor',
|
|
50
|
+
description: 'Get demand factor',
|
|
51
|
+
action: (options) => readIOFromOptions(options).getDemandFactor(),
|
|
52
|
+
});
|
|
53
|
+
makeCommand({
|
|
54
|
+
name: 'get-gateway',
|
|
55
|
+
description: 'Get the gateway of an address',
|
|
56
|
+
options: addressOptions,
|
|
57
|
+
action: getGateway,
|
|
58
|
+
});
|
|
59
|
+
makeCommand({
|
|
60
|
+
name: 'list-gateways',
|
|
61
|
+
description: 'List the gateways of the network',
|
|
62
|
+
options: paginationOptions,
|
|
63
|
+
action: listGateways,
|
|
64
|
+
});
|
|
65
|
+
makeCommand({
|
|
66
|
+
name: 'get-gateway-delegates',
|
|
67
|
+
description: 'Get the delegates of a gateway',
|
|
68
|
+
options: paginationAddressOptions,
|
|
69
|
+
action: getGatewayDelegates,
|
|
70
|
+
});
|
|
71
|
+
makeCommand({
|
|
72
|
+
name: 'get-delegations',
|
|
73
|
+
description: 'Get all stake delegated to gateways from this address',
|
|
74
|
+
options: addressOptions,
|
|
75
|
+
action: getDelegations,
|
|
76
|
+
});
|
|
77
|
+
makeCommand({
|
|
78
|
+
name: 'get-allowed-delegates',
|
|
79
|
+
description: 'Get the allow list of a gateway delegate',
|
|
80
|
+
options: paginationAddressOptions,
|
|
81
|
+
action: getAllowedDelegates,
|
|
82
|
+
});
|
|
83
|
+
makeCommand({
|
|
84
|
+
name: 'get-arns-record',
|
|
85
|
+
description: 'Get an ArNS record by name',
|
|
86
|
+
options: nameOptions,
|
|
87
|
+
action: getArNSRecord,
|
|
88
|
+
});
|
|
89
|
+
makeCommand({
|
|
90
|
+
name: 'list-arns-records',
|
|
91
|
+
description: 'List all ArNS records',
|
|
92
|
+
options: paginationOptions,
|
|
93
|
+
action: listArNSRecords,
|
|
94
|
+
});
|
|
95
|
+
makeCommand({
|
|
96
|
+
name: 'get-arns-reserved-name',
|
|
97
|
+
description: 'Get a reserved ArNS name',
|
|
98
|
+
options: nameOptions,
|
|
99
|
+
action: getArNSReservedName,
|
|
100
|
+
});
|
|
101
|
+
makeCommand({
|
|
102
|
+
name: 'list-arns-reserved-names',
|
|
103
|
+
description: 'Get all reserved ArNS names',
|
|
104
|
+
options: paginationOptions,
|
|
105
|
+
action: listArNSReservedNames,
|
|
106
|
+
});
|
|
107
|
+
makeCommand({
|
|
108
|
+
name: 'get-arns-auction',
|
|
109
|
+
description: 'Get an ArNS auction by name',
|
|
110
|
+
options: nameOptions,
|
|
111
|
+
action: getArNSAuction,
|
|
112
|
+
});
|
|
113
|
+
makeCommand({
|
|
114
|
+
name: 'list-arns-auctions',
|
|
115
|
+
description: 'Get all ArNS auctions',
|
|
116
|
+
options: paginationOptions,
|
|
117
|
+
action: listArNSAuctions,
|
|
118
|
+
});
|
|
119
|
+
makeCommand({
|
|
120
|
+
name: 'get-arns-auction-prices',
|
|
121
|
+
description: 'Get ArNS auction prices',
|
|
122
|
+
options: arNSAuctionPricesOptions,
|
|
123
|
+
action: getArNSAuctionPrices,
|
|
124
|
+
});
|
|
125
|
+
makeCommand({
|
|
126
|
+
name: 'get-epoch',
|
|
127
|
+
description: 'Get epoch data',
|
|
128
|
+
options: epochOptions,
|
|
129
|
+
action: getEpoch,
|
|
130
|
+
});
|
|
131
|
+
makeCommand({
|
|
132
|
+
name: 'get-current-epoch',
|
|
133
|
+
description: 'Get current epoch data',
|
|
134
|
+
action: (options) => readIOFromOptions(options).getCurrentEpoch(),
|
|
135
|
+
});
|
|
136
|
+
makeCommand({
|
|
137
|
+
name: 'get-prescribed-observers',
|
|
138
|
+
description: 'Get prescribed observers for an epoch',
|
|
139
|
+
options: epochOptions,
|
|
140
|
+
action: getPrescribedObservers,
|
|
141
|
+
});
|
|
142
|
+
makeCommand({
|
|
143
|
+
name: 'get-prescribed-names',
|
|
144
|
+
description: 'Get prescribed names for an epoch',
|
|
145
|
+
options: epochOptions,
|
|
146
|
+
action: getPrescribedNames,
|
|
147
|
+
});
|
|
148
|
+
makeCommand({
|
|
149
|
+
name: 'get-observations',
|
|
150
|
+
description: 'Get observations for an epoch',
|
|
151
|
+
options: epochOptions,
|
|
152
|
+
action: (o) => readIOFromOptions(o).getObservations(epochInputFromOptions(o)),
|
|
153
|
+
});
|
|
154
|
+
makeCommand({
|
|
155
|
+
name: 'get-distributions',
|
|
156
|
+
description: 'Get distributions for an epoch',
|
|
157
|
+
options: epochOptions,
|
|
158
|
+
action: (o) => readIOFromOptions(o).getDistributions(epochInputFromOptions(o)),
|
|
159
|
+
});
|
|
160
|
+
makeCommand({
|
|
161
|
+
name: 'get-token-cost',
|
|
162
|
+
description: 'Get token cost',
|
|
163
|
+
options: tokenCostOptions,
|
|
164
|
+
action: getTokenCost,
|
|
165
|
+
});
|
|
166
|
+
makeCommand({
|
|
167
|
+
name: 'list-vaults',
|
|
168
|
+
description: 'Get all wallet vaults',
|
|
169
|
+
options: paginationOptions,
|
|
170
|
+
action: (o) => readIOFromOptions(o)
|
|
171
|
+
.getVaults(paginationParamsFromOptions(o))
|
|
172
|
+
.then((result) => result.items.length ? result : { message: 'No vaults found' }),
|
|
173
|
+
});
|
|
174
|
+
// TODO: Could assert valid arweave (or ETH) addresses at CLI level when coming from options (no need from wallet)
|
|
175
|
+
makeCommand({
|
|
176
|
+
name: 'get-primary-name-request',
|
|
177
|
+
description: 'Get primary name request',
|
|
178
|
+
options: initiatorOptions,
|
|
179
|
+
action: (o) => readIOFromOptions(o)
|
|
180
|
+
.getPrimaryNameRequest({
|
|
181
|
+
initiator: requiredStringFromOptions(o, 'initiator'),
|
|
182
|
+
})
|
|
183
|
+
.then((result) => result ?? {
|
|
184
|
+
message: `No primary name request found`,
|
|
185
|
+
}),
|
|
186
|
+
});
|
|
187
|
+
makeCommand({
|
|
188
|
+
name: 'list-primary-name-requests',
|
|
189
|
+
description: 'Get primary name requests',
|
|
190
|
+
options: paginationOptions,
|
|
191
|
+
action: (o) => readIOFromOptions(o)
|
|
192
|
+
.getPrimaryNameRequests(paginationParamsFromOptions(o))
|
|
193
|
+
.then((result) => result.items.length ? result : { message: 'No requests found' }),
|
|
194
|
+
});
|
|
195
|
+
makeCommand({
|
|
196
|
+
name: 'get-primary-name',
|
|
197
|
+
description: 'Get primary name',
|
|
198
|
+
options: [...addressOptions, optionMap.name],
|
|
199
|
+
action: getPrimaryName,
|
|
200
|
+
});
|
|
201
|
+
makeCommand({
|
|
202
|
+
name: 'list-primary-names',
|
|
203
|
+
description: 'Get primary names',
|
|
204
|
+
options: paginationOptions,
|
|
205
|
+
action: (o) => readIOFromOptions(o)
|
|
206
|
+
.getPrimaryNames(paginationParamsFromOptions(o))
|
|
207
|
+
.then((result) => result.items.length ? result : { message: 'No names found' }),
|
|
208
|
+
});
|
|
209
|
+
makeCommand({
|
|
210
|
+
name: 'balance',
|
|
211
|
+
description: 'Get the balance of an address',
|
|
212
|
+
options: addressOptions,
|
|
213
|
+
action: (options) => readIOFromOptions(options)
|
|
214
|
+
.getBalance({ address: requiredAddressFromOptions(options) })
|
|
215
|
+
.then((result) => ({
|
|
216
|
+
address: requiredAddressFromOptions(options),
|
|
217
|
+
mIOBalance: result,
|
|
218
|
+
message: `Provided address current has a balance of ${formatIOWithCommas(new mIOToken(result).toIO())} IO`,
|
|
219
|
+
})),
|
|
220
|
+
});
|
|
221
|
+
makeCommand({
|
|
222
|
+
name: 'list-balances',
|
|
223
|
+
description: 'List all balances',
|
|
224
|
+
options: paginationOptions,
|
|
225
|
+
action: (o) => readIOFromOptions(o)
|
|
226
|
+
.getBalances(paginationParamsFromOptions(o))
|
|
227
|
+
.then((result) => result.items.length ? result : { message: 'No balances found' }),
|
|
228
|
+
});
|
|
229
|
+
makeCommand({
|
|
230
|
+
name: 'get-redelegation-fee',
|
|
231
|
+
description: 'Get redelegation fee',
|
|
232
|
+
options: addressOptions,
|
|
233
|
+
action: (options) => readIOFromOptions(options).getRedelegationFee({
|
|
234
|
+
address: requiredAddressFromOptions(options),
|
|
235
|
+
}),
|
|
236
|
+
});
|
|
237
|
+
makeCommand({
|
|
238
|
+
name: 'get-vault',
|
|
239
|
+
description: 'Get the vault of provided address and vault ID',
|
|
240
|
+
options: getVaultOptions,
|
|
241
|
+
action: getVault,
|
|
242
|
+
});
|
|
243
|
+
makeCommand({
|
|
244
|
+
name: 'get-gateway-vaults',
|
|
245
|
+
description: 'Get the vaults of a gateway',
|
|
246
|
+
options: paginationAddressOptions,
|
|
247
|
+
action: getGatewayVaults,
|
|
248
|
+
});
|
|
249
|
+
makeCommand({
|
|
250
|
+
name: 'transfer',
|
|
251
|
+
description: 'Transfer IO to another address',
|
|
252
|
+
options: transferOptions,
|
|
253
|
+
action: transfer,
|
|
254
|
+
});
|
|
255
|
+
makeCommand({
|
|
256
|
+
name: 'join-network',
|
|
257
|
+
description: 'Join a gateway to the AR.IO network',
|
|
258
|
+
options: joinNetworkOptions,
|
|
259
|
+
action: joinNetwork,
|
|
260
|
+
});
|
|
261
|
+
makeCommand({
|
|
262
|
+
name: 'leave-network',
|
|
263
|
+
description: 'Leave a gateway from the AR.IO network',
|
|
264
|
+
action: leaveNetwork,
|
|
265
|
+
});
|
|
266
|
+
makeCommand({
|
|
267
|
+
name: 'update-gateway-settings',
|
|
268
|
+
description: 'Update AR.IO gateway settings',
|
|
269
|
+
options: updateGatewaySettingsOptions,
|
|
270
|
+
action: updateGatewaySettings,
|
|
271
|
+
});
|
|
272
|
+
makeCommand({
|
|
273
|
+
name: 'save-observations',
|
|
274
|
+
description: 'Save observations',
|
|
275
|
+
options: [
|
|
276
|
+
optionMap.failedGateways,
|
|
277
|
+
optionMap.transactionId,
|
|
278
|
+
...writeActionOptions,
|
|
279
|
+
],
|
|
280
|
+
action: saveObservations,
|
|
281
|
+
});
|
|
282
|
+
makeCommand({
|
|
283
|
+
name: 'increase-operator-stake',
|
|
284
|
+
description: 'Increase operator stake',
|
|
285
|
+
options: operatorStakeOptions,
|
|
286
|
+
action: increaseOperatorStake,
|
|
287
|
+
});
|
|
288
|
+
makeCommand({
|
|
289
|
+
name: 'decrease-operator-stake',
|
|
290
|
+
description: 'Decrease operator stake',
|
|
291
|
+
options: operatorStakeOptions,
|
|
292
|
+
action: decreaseOperatorStake,
|
|
293
|
+
});
|
|
294
|
+
makeCommand({
|
|
295
|
+
name: 'instant-withdrawal',
|
|
296
|
+
description: 'Instantly withdraw stake from an existing gateway withdrawal vault',
|
|
297
|
+
options: addressAndVaultIdOptions,
|
|
298
|
+
action: instantWithdrawal,
|
|
299
|
+
});
|
|
300
|
+
makeCommand({
|
|
301
|
+
name: 'cancel-withdrawal',
|
|
302
|
+
description: 'Cancel a pending gateway withdrawal vault',
|
|
303
|
+
options: addressAndVaultIdOptions,
|
|
304
|
+
action: cancelWithdrawal,
|
|
305
|
+
});
|
|
306
|
+
makeCommand({
|
|
307
|
+
name: 'delegate-stake',
|
|
308
|
+
description: 'Delegate stake to a gateway',
|
|
309
|
+
options: delegateStakeOptions,
|
|
310
|
+
action: delegateStake,
|
|
311
|
+
});
|
|
312
|
+
makeCommand({
|
|
313
|
+
name: 'decrease-delegate-stake',
|
|
314
|
+
description: 'Decrease delegated stake',
|
|
315
|
+
options: decreaseDelegateStakeOptions,
|
|
316
|
+
action: decreaseDelegateStake,
|
|
317
|
+
});
|
|
318
|
+
makeCommand({
|
|
319
|
+
name: 'redelegate-stake',
|
|
320
|
+
description: 'Redelegate stake to another gateway',
|
|
321
|
+
options: redelegateStakeOptions,
|
|
322
|
+
action: redelegateStake,
|
|
323
|
+
});
|
|
324
|
+
makeCommand({
|
|
325
|
+
name: 'buy-record',
|
|
326
|
+
description: 'Buy a record',
|
|
327
|
+
options: buyRecordOptions,
|
|
328
|
+
action: async (options) => {
|
|
329
|
+
const io = writeIOFromOptions(options).io;
|
|
330
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
331
|
+
const type = recordTypeFromOptions(options);
|
|
332
|
+
const years = positiveIntegerFromOptions(options, 'years');
|
|
333
|
+
// TODO: Assert balance is sufficient for action
|
|
334
|
+
// TODO: Assert record is not already owned
|
|
335
|
+
const processId = options.processId;
|
|
336
|
+
if (processId === undefined) {
|
|
337
|
+
// TODO: Spawn ANT process, register it to ANT registry, get process ID
|
|
338
|
+
throw new Error('Process ID must be provided for buy-record');
|
|
339
|
+
}
|
|
340
|
+
await assertConfirmationPrompt(`Are you sure you want to ${type} the record ${name}?`, options);
|
|
341
|
+
return io.buyRecord({
|
|
342
|
+
name: requiredStringFromOptions(options, 'name'),
|
|
343
|
+
processId,
|
|
344
|
+
type,
|
|
345
|
+
years,
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
makeCommand({
|
|
350
|
+
name: 'upgrade-record',
|
|
351
|
+
description: 'Upgrade the lease of a record to a permabuy',
|
|
352
|
+
options: [...nameOptions, ...writeActionOptions],
|
|
353
|
+
// TODO: could assert record is leased by sender, assert balance is sufficient
|
|
354
|
+
action: async (options) => {
|
|
355
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
356
|
+
await assertConfirmationPrompt(`Are you sure you want to upgrade the lease of ${name} to a permabuy?`, options);
|
|
357
|
+
return writeIOFromOptions(options).io.upgradeRecord({
|
|
358
|
+
name,
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
makeCommand({
|
|
363
|
+
name: 'extend-lease',
|
|
364
|
+
description: 'Extend the lease of a record',
|
|
365
|
+
options: [...writeActionOptions, optionMap.name, optionMap.years],
|
|
366
|
+
action: async (options) => {
|
|
367
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
368
|
+
const years = requiredPositiveIntegerFromOptions(options, 'years');
|
|
369
|
+
await assertConfirmationPrompt(`Are you sure you want to extend the lease of ${name} by ${years}?`, options);
|
|
370
|
+
return writeIOFromOptions(options).io.extendLease({
|
|
371
|
+
name,
|
|
372
|
+
years,
|
|
373
|
+
}, writeActionTagsFromOptions(options));
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
makeCommand({
|
|
377
|
+
name: 'increase-undername-limit',
|
|
378
|
+
description: 'Increase the limit of a name',
|
|
379
|
+
options: [...writeActionOptions, optionMap.name, optionMap.increaseCount],
|
|
380
|
+
action: async (options) => {
|
|
381
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
382
|
+
const increaseCount = requiredPositiveIntegerFromOptions(options, 'increaseCount');
|
|
383
|
+
await assertConfirmationPrompt(`Are you sure you want to increase the undername limit of ${name} by ${increaseCount}?`, options);
|
|
384
|
+
return writeIOFromOptions(options).io.increaseUndernameLimit({
|
|
385
|
+
name,
|
|
386
|
+
increaseCount,
|
|
387
|
+
}, writeActionTagsFromOptions(options));
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
makeCommand({
|
|
391
|
+
name: 'request-primary-name',
|
|
392
|
+
description: 'Request a primary name',
|
|
393
|
+
options: nameWriteOptions,
|
|
394
|
+
action: async (options) => {
|
|
395
|
+
// TODO: Assert balance is sufficient for action?
|
|
396
|
+
// TODO: Assert name requested is not already owned
|
|
397
|
+
// TODO: More assertions?
|
|
398
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
399
|
+
await assertConfirmationPrompt(`Are you sure you want to request the primary name ${name}?`, options);
|
|
400
|
+
return writeIOFromOptions(options).io.requestPrimaryName({
|
|
401
|
+
name,
|
|
402
|
+
});
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
makeCommand({
|
|
406
|
+
name: 'spawn-ant',
|
|
407
|
+
description: 'Spawn an ANT process',
|
|
408
|
+
options: antStateOptions,
|
|
409
|
+
action: async (options) => {
|
|
410
|
+
const state = getANTStateFromOptions(options);
|
|
411
|
+
const antProcessId = await spawnANT({
|
|
412
|
+
state,
|
|
413
|
+
signer: requiredAoSignerFromOptions(options),
|
|
414
|
+
logger: getLoggerFromOptions(options),
|
|
415
|
+
});
|
|
416
|
+
return {
|
|
417
|
+
processId: antProcessId,
|
|
418
|
+
state,
|
|
419
|
+
message: `Spawned ANT process with process ID ${antProcessId}`,
|
|
420
|
+
};
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
makeCommand({
|
|
424
|
+
name: 'get-ant-state',
|
|
425
|
+
description: 'Get the state of an ANT process',
|
|
426
|
+
options: [optionMap.processId],
|
|
427
|
+
action: async (options) => {
|
|
428
|
+
return readANTFromOptions(options).getState();
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
makeCommand({
|
|
432
|
+
name: 'get-ant-info',
|
|
433
|
+
description: 'Get the info of an ANT process',
|
|
434
|
+
options: [optionMap.processId],
|
|
435
|
+
action: async (options) => {
|
|
436
|
+
return readANTFromOptions(options).getInfo();
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
makeCommand({
|
|
440
|
+
name: 'get-ant-record',
|
|
441
|
+
description: 'Get a record of an ANT process',
|
|
442
|
+
options: [optionMap.processId, optionMap.undername],
|
|
443
|
+
action: async (options) => {
|
|
444
|
+
return ((await readANTFromOptions(options).getRecord({
|
|
445
|
+
undername: requiredStringFromOptions(options, 'undername'),
|
|
446
|
+
})) ?? { message: 'No record found' });
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
makeCommand({
|
|
450
|
+
name: 'list-ant-records',
|
|
451
|
+
description: 'Get the records of an ANT process',
|
|
452
|
+
options: [optionMap.processId],
|
|
453
|
+
action: async (options) => {
|
|
454
|
+
return readANTFromOptions(options).getRecords();
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
makeCommand({
|
|
458
|
+
name: 'get-ant-owner',
|
|
459
|
+
description: 'Get the owner of an ANT process',
|
|
460
|
+
options: [optionMap.processId],
|
|
461
|
+
action: async (options) => {
|
|
462
|
+
return readANTFromOptions(options).getOwner();
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
makeCommand({
|
|
466
|
+
name: 'list-ant-controllers',
|
|
467
|
+
description: 'List the controllers of an ANT process',
|
|
468
|
+
options: [optionMap.processId],
|
|
469
|
+
action: async (options) => {
|
|
470
|
+
return readANTFromOptions(options).getControllers();
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
makeCommand({
|
|
474
|
+
name: 'get-ant-name',
|
|
475
|
+
description: 'Get the name of an ANT process',
|
|
476
|
+
options: [optionMap.processId],
|
|
477
|
+
action: async (options) => {
|
|
478
|
+
return readANTFromOptions(options).getName();
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
makeCommand({
|
|
482
|
+
name: 'get-ant-ticker',
|
|
483
|
+
description: 'Get the ticker of an ANT process',
|
|
484
|
+
options: [optionMap.processId],
|
|
485
|
+
action: async (options) => {
|
|
486
|
+
return readANTFromOptions(options).getTicker();
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
makeCommand({
|
|
490
|
+
name: 'get-ant-balance',
|
|
491
|
+
description: 'Get the balance of an ANT process',
|
|
492
|
+
options: [optionMap.processId, optionMap.address],
|
|
493
|
+
action: async (options) => {
|
|
494
|
+
return readANTFromOptions(options).getBalance({
|
|
495
|
+
address: requiredAddressFromOptions(options),
|
|
496
|
+
});
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
makeCommand({
|
|
500
|
+
name: 'list-ant-balances',
|
|
501
|
+
description: 'Get the balances of an ANT process',
|
|
502
|
+
options: [optionMap.processId],
|
|
503
|
+
action: async (options) => {
|
|
504
|
+
return readANTFromOptions(options).getBalances();
|
|
505
|
+
},
|
|
506
|
+
});
|
|
507
|
+
makeCommand({
|
|
508
|
+
name: 'transfer-ant-ownership',
|
|
509
|
+
description: 'Transfer ownership of an ANT process',
|
|
510
|
+
options: [optionMap.processId, optionMap.target, ...writeActionOptions],
|
|
511
|
+
action: async (options) => {
|
|
512
|
+
const target = requiredStringFromOptions(options, 'target');
|
|
513
|
+
await assertConfirmationPrompt(`Are you sure you want to transfer ANT ownership to ${target}?`, options);
|
|
514
|
+
return writeANTFromOptions(options).transfer({
|
|
515
|
+
target,
|
|
516
|
+
}, writeActionTagsFromOptions(options));
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
makeCommand({
|
|
520
|
+
name: 'add-ant-controller',
|
|
521
|
+
description: 'Add a controller to an ANT process',
|
|
522
|
+
options: [optionMap.processId, optionMap.controller, ...writeActionOptions],
|
|
523
|
+
action: async (options) => {
|
|
524
|
+
const controller = requiredStringFromOptions(options, 'controller');
|
|
525
|
+
await assertConfirmationPrompt(`Are you sure you want to add ${controller} as a controller?`, options);
|
|
526
|
+
return writeANTFromOptions(options).addController({
|
|
527
|
+
controller: requiredStringFromOptions(options, 'controller'),
|
|
528
|
+
}, writeActionTagsFromOptions(options));
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
makeCommand({
|
|
532
|
+
name: 'remove-ant-controller',
|
|
533
|
+
description: 'Remove a controller from an ANT process',
|
|
534
|
+
options: [optionMap.processId, optionMap.controller, ...writeActionOptions],
|
|
535
|
+
action: async (options) => {
|
|
536
|
+
return writeANTFromOptions(options).removeController({
|
|
537
|
+
controller: requiredStringFromOptions(options, 'controller'),
|
|
538
|
+
}, writeActionTagsFromOptions(options));
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
makeCommand({
|
|
542
|
+
name: 'set-ant-record',
|
|
543
|
+
description: 'Set a record of an ANT process',
|
|
544
|
+
options: [
|
|
545
|
+
optionMap.processId,
|
|
546
|
+
optionMap.undername,
|
|
547
|
+
optionMap.transactionId,
|
|
548
|
+
optionMap.ttlSeconds,
|
|
549
|
+
...writeActionOptions,
|
|
550
|
+
],
|
|
551
|
+
action: async (options) => {
|
|
552
|
+
const ttlSeconds = options.ttlSeconds ?? 3600;
|
|
553
|
+
const undername = requiredStringFromOptions(options, 'undername');
|
|
554
|
+
const transactionId = requiredStringFromOptions(options, 'transactionId');
|
|
555
|
+
await assertConfirmationPrompt(`Are you sure you want to set this record?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, options);
|
|
556
|
+
return writeANTFromOptions(options).setRecord({
|
|
557
|
+
undername,
|
|
558
|
+
transactionId,
|
|
559
|
+
ttlSeconds,
|
|
560
|
+
}, writeActionTagsFromOptions(options));
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
makeCommand({
|
|
564
|
+
name: 'remove-ant-record',
|
|
565
|
+
description: 'Remove a record from an ANT process',
|
|
566
|
+
options: [optionMap.processId, optionMap.undername, ...writeActionOptions],
|
|
567
|
+
action: async (options) => {
|
|
568
|
+
const undername = requiredStringFromOptions(options, 'undername');
|
|
569
|
+
await assertConfirmationPrompt(`Are you sure you want to remove the record with undername ${undername}?`, options);
|
|
570
|
+
return writeANTFromOptions(options).removeRecord({
|
|
571
|
+
undername,
|
|
572
|
+
}, writeActionTagsFromOptions(options));
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
makeCommand({
|
|
576
|
+
name: 'set-ant-ticker',
|
|
577
|
+
description: 'Set the ticker of an ANT process',
|
|
578
|
+
options: [optionMap.processId, optionMap.ticker, ...writeActionOptions],
|
|
579
|
+
action: async (options) => {
|
|
580
|
+
const ticker = requiredStringFromOptions(options, 'ticker');
|
|
581
|
+
await assertConfirmationPrompt(`Are you sure you want to set the ticker to ${ticker}?`, options);
|
|
582
|
+
return writeANTFromOptions(options).setTicker({
|
|
583
|
+
ticker,
|
|
584
|
+
}, writeActionTagsFromOptions(options));
|
|
585
|
+
},
|
|
586
|
+
});
|
|
587
|
+
makeCommand({
|
|
588
|
+
name: 'set-ant-name',
|
|
589
|
+
description: 'Set the name of an ANT process',
|
|
590
|
+
options: [optionMap.processId, optionMap.name, ...writeActionOptions],
|
|
591
|
+
action: async (options) => {
|
|
592
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
593
|
+
await assertConfirmationPrompt(`Are you sure you want to set the name to ${requiredStringFromOptions(options, 'name')}?`, options);
|
|
594
|
+
return writeANTFromOptions(options).setName({
|
|
595
|
+
name,
|
|
596
|
+
}, writeActionTagsFromOptions(options));
|
|
597
|
+
},
|
|
598
|
+
});
|
|
599
|
+
makeCommand({
|
|
600
|
+
name: 'set-ant-description',
|
|
601
|
+
description: 'Set the description of an ANT process',
|
|
602
|
+
options: [optionMap.processId, optionMap.description, ...writeActionOptions],
|
|
603
|
+
action: async (options) => {
|
|
604
|
+
const description = requiredStringFromOptions(options, 'description');
|
|
605
|
+
await assertConfirmationPrompt(`Are you sure you want to set the ANT description to ${description}?`, options);
|
|
606
|
+
return writeANTFromOptions(options).setDescription({
|
|
607
|
+
description,
|
|
608
|
+
}, writeActionTagsFromOptions(options));
|
|
609
|
+
},
|
|
610
|
+
});
|
|
611
|
+
makeCommand({
|
|
612
|
+
name: 'set-ant-keywords',
|
|
613
|
+
description: 'Set the keywords of an ANT process',
|
|
614
|
+
options: [optionMap.processId, optionMap.keywords, ...writeActionOptions],
|
|
615
|
+
action: async (options) => {
|
|
616
|
+
const keywords = requiredStringArrayFromOptions(options, 'keywords');
|
|
617
|
+
await assertConfirmationPrompt(`Are you sure you want to set the ANT keywords to ${keywords}?`, options);
|
|
618
|
+
return writeANTFromOptions(options).setKeywords({
|
|
619
|
+
keywords,
|
|
620
|
+
}, writeActionTagsFromOptions(options));
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
makeCommand({
|
|
624
|
+
name: 'set-ant-logo',
|
|
625
|
+
description: 'Set the logo of an ANT process',
|
|
626
|
+
options: [
|
|
627
|
+
optionMap.processId,
|
|
628
|
+
optionMap.transactionId,
|
|
629
|
+
...writeActionOptions,
|
|
630
|
+
],
|
|
631
|
+
action: async (options) => {
|
|
632
|
+
const txId = requiredStringFromOptions(options, 'transactionId');
|
|
633
|
+
await assertConfirmationPrompt(`Are you sure you want to set the ANT logo to target Arweave TxID ${txId}?`, options);
|
|
634
|
+
return writeANTFromOptions(options).setLogo({
|
|
635
|
+
// TODO: Could take a logo file, upload it to Arweave, get transaction ID
|
|
636
|
+
txId,
|
|
637
|
+
}, writeActionTagsFromOptions(options));
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
makeCommand({
|
|
641
|
+
name: 'release-name',
|
|
642
|
+
description: 'Release the name of an ANT process',
|
|
643
|
+
options: [optionMap.processId, optionMap.name, ...writeActionOptions],
|
|
644
|
+
action: async (options) => {
|
|
645
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
646
|
+
await assertConfirmationPrompt(`Are you sure you want to release the name ${name} back to the protocol?`, options);
|
|
647
|
+
return writeANTFromOptions(options).releaseName({
|
|
648
|
+
name,
|
|
649
|
+
ioProcessId: ioProcessIdFromOptions(options),
|
|
650
|
+
}, writeActionTagsFromOptions(options));
|
|
651
|
+
},
|
|
652
|
+
});
|
|
653
|
+
makeCommand({
|
|
654
|
+
name: 'reassign-name',
|
|
655
|
+
description: 'Reassign the name of an ANT process to another ANT process',
|
|
656
|
+
options: [
|
|
657
|
+
optionMap.processId,
|
|
658
|
+
optionMap.name,
|
|
659
|
+
optionMap.target,
|
|
660
|
+
...writeActionOptions,
|
|
661
|
+
],
|
|
662
|
+
action: async (options) => {
|
|
663
|
+
const targetProcess = requiredStringFromOptions(options, 'target');
|
|
664
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
665
|
+
await assertConfirmationPrompt(`Are you sure you want to reassign the name ${name} to ANT process ${targetProcess}?`, options);
|
|
666
|
+
return writeANTFromOptions(options).reassignName({
|
|
667
|
+
name,
|
|
668
|
+
ioProcessId: ioProcessIdFromOptions(options),
|
|
669
|
+
antProcessId: targetProcess,
|
|
670
|
+
}, writeActionTagsFromOptions(options));
|
|
671
|
+
},
|
|
672
|
+
});
|
|
673
|
+
makeCommand({
|
|
674
|
+
name: 'approve-primary-name-request',
|
|
675
|
+
description: 'Approve a primary name request',
|
|
676
|
+
options: [
|
|
677
|
+
optionMap.processId,
|
|
678
|
+
optionMap.name,
|
|
679
|
+
optionMap.address,
|
|
680
|
+
...writeActionOptions,
|
|
681
|
+
],
|
|
682
|
+
action: async (options) => {
|
|
683
|
+
const address = requiredAddressFromOptions(options);
|
|
684
|
+
const name = requiredStringFromOptions(options, 'name');
|
|
685
|
+
await assertConfirmationPrompt(`Are you sure you want to approve the primary name request ${name} to ${address}?`, options);
|
|
686
|
+
return writeANTFromOptions(options).approvePrimaryNameRequest({
|
|
687
|
+
name,
|
|
688
|
+
address,
|
|
689
|
+
ioProcessId: ioProcessIdFromOptions(options),
|
|
690
|
+
}, writeActionTagsFromOptions(options));
|
|
691
|
+
},
|
|
692
|
+
});
|
|
693
|
+
makeCommand({
|
|
694
|
+
name: 'remove-primary-names',
|
|
695
|
+
description: 'Remove primary names',
|
|
696
|
+
options: [optionMap.processId, optionMap.names, ...writeActionOptions],
|
|
697
|
+
action: async (options) => {
|
|
698
|
+
const names = requiredStringArrayFromOptions(options, 'names');
|
|
699
|
+
await assertConfirmationPrompt(`Are you sure you want to remove the primary names ${names}?`, options);
|
|
700
|
+
return writeANTFromOptions(options).removePrimaryNames({
|
|
701
|
+
names,
|
|
702
|
+
ioProcessId: ioProcessIdFromOptions(options),
|
|
703
|
+
}, writeActionTagsFromOptions(options));
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
if (process.argv[1].includes('bin/ar.io') || // Running from global .bin
|
|
707
|
+
process.argv[1].includes('cli/cli') // Running from source
|
|
708
|
+
) {
|
|
709
|
+
program.parse(process.argv);
|
|
710
|
+
}
|