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