@ar.io/sdk 3.10.2 → 3.11.0-alpha.10

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 (114) hide show
  1. package/README.md +52 -0
  2. package/bundles/web.bundle.min.js +140 -132
  3. package/lib/cjs/cli/cli.js +137 -122
  4. package/lib/cjs/cli/commands/readCommands.js +6 -0
  5. package/lib/cjs/cli/options.js +12 -0
  6. package/lib/cjs/cli/utils.js +40 -11
  7. package/lib/cjs/common/ant-versions.js +5 -5
  8. package/lib/cjs/common/ant.js +5 -5
  9. package/lib/cjs/common/index.js +2 -0
  10. package/lib/cjs/common/io.js +106 -1
  11. package/lib/cjs/common/turbo.js +208 -0
  12. package/lib/cjs/common/wayfinder/gateways/trusted-gateways.js +106 -0
  13. package/lib/cjs/common/wayfinder/gateways.js +86 -0
  14. package/lib/cjs/common/wayfinder/index.js +44 -0
  15. package/lib/cjs/common/wayfinder/routers/priority.js +29 -0
  16. package/lib/cjs/common/wayfinder/routers/priority.test.js +155 -0
  17. package/lib/cjs/common/wayfinder/routers/random.js +23 -0
  18. package/lib/cjs/common/wayfinder/routers/random.test.js +25 -0
  19. package/lib/cjs/common/wayfinder/routers/simple-cache.js +25 -0
  20. package/lib/cjs/common/wayfinder/routers/simple-cache.test.js +41 -0
  21. package/lib/cjs/common/wayfinder/routers/static.js +14 -0
  22. package/lib/cjs/common/wayfinder/routers/static.test.js +14 -0
  23. package/lib/cjs/common/wayfinder/verification/data-root-verifier.js +139 -0
  24. package/lib/cjs/common/wayfinder/verification/hash-verifier.js +50 -0
  25. package/lib/cjs/common/wayfinder/wayfinder.js +596 -0
  26. package/lib/cjs/common/wayfinder/wayfinder.test.js +500 -0
  27. package/lib/cjs/types/ant.js +12 -1
  28. package/lib/cjs/types/index.js +1 -0
  29. package/lib/cjs/types/io.js +1 -1
  30. package/lib/cjs/types/wayfinder.js +3 -0
  31. package/lib/cjs/utils/ao.js +42 -0
  32. package/lib/cjs/utils/hash.js +56 -0
  33. package/lib/cjs/utils/random.js +30 -0
  34. package/lib/cjs/utils/url.js +28 -0
  35. package/lib/cjs/utils/url.test.js +24 -0
  36. package/lib/cjs/utils/utils.test.js +8 -8
  37. package/lib/cjs/version.js +1 -1
  38. package/lib/cjs/web/index.js +3 -1
  39. package/lib/esm/cli/cli.js +138 -123
  40. package/lib/esm/cli/commands/readCommands.js +5 -0
  41. package/lib/esm/cli/options.js +12 -0
  42. package/lib/esm/cli/utils.js +39 -11
  43. package/lib/esm/common/ant-versions.js +5 -5
  44. package/lib/esm/common/ant.js +5 -5
  45. package/lib/esm/common/index.js +2 -0
  46. package/lib/esm/common/io.js +106 -1
  47. package/lib/esm/common/turbo.js +200 -0
  48. package/lib/esm/common/wayfinder/gateways/trusted-gateways.js +102 -0
  49. package/lib/esm/common/wayfinder/gateways.js +80 -0
  50. package/lib/esm/common/wayfinder/index.js +28 -0
  51. package/lib/esm/common/wayfinder/routers/priority.js +25 -0
  52. package/lib/esm/common/wayfinder/routers/priority.test.js +153 -0
  53. package/lib/esm/common/wayfinder/routers/random.js +19 -0
  54. package/lib/esm/common/wayfinder/routers/random.test.js +23 -0
  55. package/lib/esm/common/wayfinder/routers/simple-cache.js +21 -0
  56. package/lib/esm/common/wayfinder/routers/simple-cache.test.js +39 -0
  57. package/lib/esm/common/wayfinder/routers/static.js +10 -0
  58. package/lib/esm/common/wayfinder/routers/static.test.js +12 -0
  59. package/lib/esm/common/wayfinder/verification/data-root-verifier.js +130 -0
  60. package/lib/esm/common/wayfinder/verification/hash-verifier.js +46 -0
  61. package/lib/esm/common/wayfinder/wayfinder.js +584 -0
  62. package/lib/esm/common/wayfinder/wayfinder.test.js +495 -0
  63. package/lib/esm/types/ant.js +11 -0
  64. package/lib/esm/types/index.js +1 -0
  65. package/lib/esm/types/io.js +1 -1
  66. package/lib/esm/types/wayfinder.js +2 -0
  67. package/lib/esm/utils/ao.js +42 -0
  68. package/lib/esm/utils/hash.js +50 -0
  69. package/lib/esm/utils/random.js +26 -0
  70. package/lib/esm/utils/url.js +24 -0
  71. package/lib/esm/utils/url.test.js +19 -0
  72. package/lib/esm/utils/utils.test.js +1 -1
  73. package/lib/esm/version.js +1 -1
  74. package/lib/esm/web/index.js +1 -1
  75. package/lib/types/cli/commands/antCommands.d.ts +3 -3
  76. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
  77. package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
  78. package/lib/types/cli/commands/readCommands.d.ts +2 -0
  79. package/lib/types/cli/commands/transfer.d.ts +3 -3
  80. package/lib/types/cli/options.d.ts +9 -0
  81. package/lib/types/cli/types.d.ts +3 -0
  82. package/lib/types/cli/utils.d.ts +4 -0
  83. package/lib/types/common/ant-versions.d.ts +3 -6
  84. package/lib/types/common/index.d.ts +1 -0
  85. package/lib/types/common/io.d.ts +13 -8
  86. package/lib/types/common/turbo.d.ts +62 -0
  87. package/lib/types/common/wayfinder/gateways/trusted-gateways.d.ts +51 -0
  88. package/lib/types/common/wayfinder/gateways.d.ts +53 -0
  89. package/lib/types/common/wayfinder/index.d.ts +23 -0
  90. package/lib/types/common/wayfinder/routers/priority.d.ts +29 -0
  91. package/lib/types/common/wayfinder/routers/priority.test.d.ts +1 -0
  92. package/lib/types/common/wayfinder/routers/random.d.ts +27 -0
  93. package/lib/types/common/wayfinder/routers/random.test.d.ts +1 -0
  94. package/lib/types/common/wayfinder/routers/simple-cache.d.ts +28 -0
  95. package/lib/types/common/wayfinder/routers/simple-cache.test.d.ts +1 -0
  96. package/lib/types/common/wayfinder/routers/static.d.ts +24 -0
  97. package/lib/types/common/wayfinder/routers/static.test.d.ts +1 -0
  98. package/lib/types/common/wayfinder/verification/data-root-verifier.d.ts +31 -0
  99. package/lib/types/common/wayfinder/verification/hash-verifier.d.ts +27 -0
  100. package/lib/types/common/wayfinder/wayfinder.d.ts +265 -0
  101. package/lib/types/common/wayfinder/wayfinder.test.d.ts +1 -0
  102. package/lib/types/types/ant.d.ts +53 -1
  103. package/lib/types/types/common.d.ts +7 -2
  104. package/lib/types/types/index.d.ts +1 -0
  105. package/lib/types/types/io.d.ts +23 -6
  106. package/lib/types/types/wayfinder.d.ts +62 -0
  107. package/lib/types/utils/ao.d.ts +1 -12
  108. package/lib/types/utils/hash.d.ts +4 -0
  109. package/lib/types/utils/random.d.ts +7 -0
  110. package/lib/types/utils/url.d.ts +19 -0
  111. package/lib/types/utils/url.test.d.ts +1 -0
  112. package/lib/types/version.d.ts +1 -1
  113. package/lib/types/web/index.d.ts +1 -1
  114. package/package.json +5 -3
@@ -33,6 +33,7 @@ const utils_js_1 = require("./utils.js");
33
33
  .version(version_js_1.version)
34
34
  .description('AR.IO Network CLI')
35
35
  .helpCommand(true), options_js_1.globalOptions);
36
+ // # Getters
36
37
  (0, utils_js_1.makeCommand)({
37
38
  name: 'info',
38
39
  description: 'Get network info',
@@ -43,6 +44,18 @@ const utils_js_1 = require("./utils.js");
43
44
  description: 'Get the total token supply',
44
45
  action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getTokenSupply(),
45
46
  });
47
+ (0, utils_js_1.makeCommand)({
48
+ name: 'balance',
49
+ description: 'Get the balance of an address',
50
+ options: [options_js_1.optionMap.address],
51
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options)
52
+ .getBalance({ address: (0, utils_js_1.requiredAddressFromOptions)(options) })
53
+ .then((result) => ({
54
+ address: (0, utils_js_1.requiredAddressFromOptions)(options),
55
+ mARIOBalance: result,
56
+ message: `Provided address current has a balance of ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(result).toARIO())} ARIO`,
57
+ })),
58
+ });
46
59
  (0, utils_js_1.makeCommand)({
47
60
  name: 'get-registration-fees',
48
61
  description: 'Get registration fees',
@@ -69,24 +82,18 @@ const utils_js_1 = require("./utils.js");
69
82
  options: [options_js_1.optionMap.address],
70
83
  action: readCommands_js_1.getGateway,
71
84
  });
72
- (0, utils_js_1.makeCommand)({
73
- name: 'list-gateways',
74
- description: 'List the gateways of the network',
75
- options: options_js_1.paginationOptions,
76
- action: readCommands_js_1.listGateways,
77
- });
78
- (0, utils_js_1.makeCommand)({
79
- name: 'list-all-delegates',
80
- description: 'List all paginated delegates from all gateways',
81
- options: options_js_1.paginationOptions,
82
- action: readCommands_js_1.listAllDelegatesCLICommand,
83
- });
84
85
  (0, utils_js_1.makeCommand)({
85
86
  name: 'get-gateway-delegates',
86
87
  description: 'Get the delegates of a gateway',
87
88
  options: options_js_1.paginationAddressOptions,
88
89
  action: readCommands_js_1.getGatewayDelegates,
89
90
  });
91
+ (0, utils_js_1.makeCommand)({
92
+ name: 'get-gateway-vaults',
93
+ description: 'Get the vaults of a gateway',
94
+ options: options_js_1.paginationAddressOptions,
95
+ action: readCommands_js_1.getGatewayVaults,
96
+ });
90
97
  (0, utils_js_1.makeCommand)({
91
98
  name: 'get-delegations',
92
99
  description: 'Get all stake delegated to gateways from this address',
@@ -105,36 +112,18 @@ const utils_js_1 = require("./utils.js");
105
112
  options: [options_js_1.optionMap.name],
106
113
  action: readCommands_js_1.getArNSRecord,
107
114
  });
108
- (0, utils_js_1.makeCommand)({
109
- name: 'list-arns-records',
110
- description: 'List all ArNS records',
111
- options: options_js_1.paginationOptions,
112
- action: readCommands_js_1.listArNSRecords,
113
- });
114
115
  (0, utils_js_1.makeCommand)({
115
116
  name: 'get-arns-reserved-name',
116
117
  description: 'Get a reserved ArNS name',
117
118
  options: [options_js_1.optionMap.name],
118
119
  action: readCommands_js_1.getArNSReservedName,
119
120
  });
120
- (0, utils_js_1.makeCommand)({
121
- name: 'list-arns-reserved-names',
122
- description: 'Get all reserved ArNS names',
123
- options: options_js_1.paginationOptions,
124
- action: readCommands_js_1.listArNSReservedNames,
125
- });
126
121
  (0, utils_js_1.makeCommand)({
127
122
  name: 'get-arns-returned-name',
128
123
  description: 'Get an ArNS returned name by name',
129
124
  options: [options_js_1.optionMap.name],
130
125
  action: readCommands_js_1.getArNSReturnedName,
131
126
  });
132
- (0, utils_js_1.makeCommand)({
133
- name: 'list-arns-returned-names',
134
- description: 'Get all ArNS recently returned names',
135
- options: options_js_1.paginationOptions,
136
- action: readCommands_js_1.listArNSReturnedNames,
137
- });
138
127
  (0, utils_js_1.makeCommand)({
139
128
  name: 'get-epoch',
140
129
  description: 'Get epoch data',
@@ -195,14 +184,11 @@ const utils_js_1 = require("./utils.js");
195
184
  action: readCommands_js_1.getCostDetails,
196
185
  });
197
186
  (0, utils_js_1.makeCommand)({
198
- name: 'list-vaults',
199
- description: 'Get all wallet vaults',
200
- options: options_js_1.paginationOptions,
201
- action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
202
- .getVaults((0, utils_js_1.paginationParamsFromOptions)(o))
203
- .then((result) => result.items.length ? result : { message: 'No vaults found' }),
187
+ name: 'get-primary-name',
188
+ description: 'Get primary name',
189
+ options: [options_js_1.optionMap.address, options_js_1.optionMap.name],
190
+ action: readCommands_js_1.getPrimaryName,
204
191
  });
205
- // TODO: Could assert valid arweave (or ETH) addresses at CLI level when coming from options (no need from wallet)
206
192
  (0, utils_js_1.makeCommand)({
207
193
  name: 'get-primary-name-request',
208
194
  description: 'Get primary name request',
@@ -215,6 +201,66 @@ const utils_js_1 = require("./utils.js");
215
201
  message: `No primary name request found`,
216
202
  }),
217
203
  });
204
+ (0, utils_js_1.makeCommand)({
205
+ name: 'get-redelegation-fee',
206
+ description: 'Get redelegation fee',
207
+ options: [options_js_1.optionMap.address],
208
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRedelegationFee({
209
+ address: (0, utils_js_1.requiredAddressFromOptions)(options),
210
+ }),
211
+ });
212
+ (0, utils_js_1.makeCommand)({
213
+ name: 'get-vault',
214
+ description: 'Get the vault of provided address and vault ID',
215
+ options: options_js_1.getVaultOptions,
216
+ action: readCommands_js_1.getVault,
217
+ });
218
+ // # ArNS Resolution
219
+ (0, utils_js_1.makeCommand)({
220
+ name: 'resolve-arns-name',
221
+ description: 'Resolve an ArNS name',
222
+ options: [options_js_1.optionMap.name],
223
+ action: readCommands_js_1.resolveArNSName,
224
+ });
225
+ // # Paginated handlers
226
+ (0, utils_js_1.makeCommand)({
227
+ name: 'list-gateways',
228
+ description: 'List the gateways of the network',
229
+ options: options_js_1.paginationOptions,
230
+ action: readCommands_js_1.listGateways,
231
+ });
232
+ (0, utils_js_1.makeCommand)({
233
+ name: 'list-all-delegates',
234
+ description: 'List all paginated delegates from all gateways',
235
+ options: options_js_1.paginationOptions,
236
+ action: readCommands_js_1.listAllDelegatesCLICommand,
237
+ });
238
+ (0, utils_js_1.makeCommand)({
239
+ name: 'list-arns-records',
240
+ description: 'List all ArNS records',
241
+ options: options_js_1.paginationOptions,
242
+ action: readCommands_js_1.listArNSRecords,
243
+ });
244
+ (0, utils_js_1.makeCommand)({
245
+ name: 'list-arns-reserved-names',
246
+ description: 'Get all reserved ArNS names',
247
+ options: options_js_1.paginationOptions,
248
+ action: readCommands_js_1.listArNSReservedNames,
249
+ });
250
+ (0, utils_js_1.makeCommand)({
251
+ name: 'list-arns-returned-names',
252
+ description: 'Get all ArNS recently returned names',
253
+ options: options_js_1.paginationOptions,
254
+ action: readCommands_js_1.listArNSReturnedNames,
255
+ });
256
+ (0, utils_js_1.makeCommand)({
257
+ name: 'list-vaults',
258
+ description: 'Get all wallet vaults',
259
+ options: options_js_1.paginationOptions,
260
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
261
+ .getVaults((0, utils_js_1.paginationParamsFromOptions)(o))
262
+ .then((result) => result.items.length ? result : { message: 'No vaults found' }),
263
+ });
218
264
  (0, utils_js_1.makeCommand)({
219
265
  name: 'list-primary-name-requests',
220
266
  description: 'Get primary name requests',
@@ -223,12 +269,6 @@ const utils_js_1 = require("./utils.js");
223
269
  .getPrimaryNameRequests((0, utils_js_1.paginationParamsFromOptions)(o))
224
270
  .then((result) => result.items.length ? result : { message: 'No requests found' }),
225
271
  });
226
- (0, utils_js_1.makeCommand)({
227
- name: 'get-primary-name',
228
- description: 'Get primary name',
229
- options: [options_js_1.optionMap.address, options_js_1.optionMap.name],
230
- action: readCommands_js_1.getPrimaryName,
231
- });
232
272
  (0, utils_js_1.makeCommand)({
233
273
  name: 'list-primary-names',
234
274
  description: 'Get primary names',
@@ -237,18 +277,6 @@ const utils_js_1 = require("./utils.js");
237
277
  .getPrimaryNames((0, utils_js_1.paginationParamsFromOptions)(o))
238
278
  .then((result) => result.items.length ? result : { message: 'No names found' }),
239
279
  });
240
- (0, utils_js_1.makeCommand)({
241
- name: 'balance',
242
- description: 'Get the balance of an address',
243
- options: [options_js_1.optionMap.address],
244
- action: (options) => (0, utils_js_1.readARIOFromOptions)(options)
245
- .getBalance({ address: (0, utils_js_1.requiredAddressFromOptions)(options) })
246
- .then((result) => ({
247
- address: (0, utils_js_1.requiredAddressFromOptions)(options),
248
- mARIOBalance: result,
249
- message: `Provided address current has a balance of ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(result).toARIO())} ARIO`,
250
- })),
251
- });
252
280
  (0, utils_js_1.makeCommand)({
253
281
  name: 'list-balances',
254
282
  description: 'List all balances',
@@ -257,32 +285,13 @@ const utils_js_1 = require("./utils.js");
257
285
  .getBalances((0, utils_js_1.paginationParamsFromOptions)(o))
258
286
  .then((result) => result.items.length ? result : { message: 'No balances found' }),
259
287
  });
260
- (0, utils_js_1.makeCommand)({
261
- name: 'get-redelegation-fee',
262
- description: 'Get redelegation fee',
263
- options: [options_js_1.optionMap.address],
264
- action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRedelegationFee({
265
- address: (0, utils_js_1.requiredAddressFromOptions)(options),
266
- }),
267
- });
268
- (0, utils_js_1.makeCommand)({
269
- name: 'get-vault',
270
- description: 'Get the vault of provided address and vault ID',
271
- options: options_js_1.getVaultOptions,
272
- action: readCommands_js_1.getVault,
273
- });
274
- (0, utils_js_1.makeCommand)({
275
- name: 'get-gateway-vaults',
276
- description: 'Get the vaults of a gateway',
277
- options: options_js_1.paginationAddressOptions,
278
- action: readCommands_js_1.getGatewayVaults,
279
- });
280
288
  (0, utils_js_1.makeCommand)({
281
289
  name: 'list-all-gateway-vaults',
282
290
  description: 'List vaults from all gateways',
283
291
  options: options_js_1.paginationAddressOptions,
284
292
  action: readCommands_js_1.getAllGatewayVaults,
285
293
  });
294
+ // # Actions
286
295
  (0, utils_js_1.makeCommand)({
287
296
  name: 'transfer',
288
297
  description: 'Transfer ARIO to another address',
@@ -418,24 +427,8 @@ const utils_js_1 = require("./utils.js");
418
427
  options: options_js_1.arnsPurchaseOptions,
419
428
  action: arnsPurchaseCommands_js_1.requestPrimaryNameCLICommand,
420
429
  });
421
- (0, utils_js_1.makeCommand)({
422
- name: 'spawn-ant',
423
- description: 'Spawn an ANT process',
424
- options: options_js_1.antStateOptions,
425
- action: async (options) => {
426
- const state = (0, utils_js_1.getANTStateFromOptions)(options);
427
- const antProcessId = await (0, index_js_1.spawnANT)({
428
- state,
429
- signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
430
- logger: (0, utils_js_1.getLoggerFromOptions)(options),
431
- });
432
- return {
433
- processId: antProcessId,
434
- state,
435
- message: `Spawned ANT process with process ID ${antProcessId}`,
436
- };
437
- },
438
- });
430
+ // # ANTS
431
+ // # Getters
439
432
  (0, utils_js_1.makeCommand)({
440
433
  name: 'get-ant-state',
441
434
  description: 'Get the state of an ANT process',
@@ -462,14 +455,6 @@ const utils_js_1 = require("./utils.js");
462
455
  })) ?? { message: 'No record found' });
463
456
  },
464
457
  });
465
- (0, utils_js_1.makeCommand)({
466
- name: 'list-ant-records',
467
- description: 'Get the records of an ANT process',
468
- options: [options_js_1.optionMap.processId],
469
- action: async (options) => {
470
- return (0, utils_js_1.readANTFromOptions)(options).getRecords();
471
- },
472
- });
473
458
  (0, utils_js_1.makeCommand)({
474
459
  name: 'get-ant-owner',
475
460
  description: 'Get the owner of an ANT process',
@@ -478,14 +463,6 @@ const utils_js_1 = require("./utils.js");
478
463
  return (0, utils_js_1.readANTFromOptions)(options).getOwner();
479
464
  },
480
465
  });
481
- (0, utils_js_1.makeCommand)({
482
- name: 'list-ant-controllers',
483
- description: 'List the controllers of an ANT process',
484
- options: [options_js_1.optionMap.processId],
485
- action: async (options) => {
486
- return (0, utils_js_1.readANTFromOptions)(options).getControllers();
487
- },
488
- });
489
466
  (0, utils_js_1.makeCommand)({
490
467
  name: 'get-ant-name',
491
468
  description: 'Get the name of an ANT process',
@@ -512,6 +489,42 @@ const utils_js_1 = require("./utils.js");
512
489
  });
513
490
  },
514
491
  });
492
+ // # Spawn
493
+ (0, utils_js_1.makeCommand)({
494
+ name: 'spawn-ant',
495
+ description: 'Spawn an ANT process',
496
+ options: options_js_1.antStateOptions,
497
+ action: async (options) => {
498
+ const state = (0, utils_js_1.getANTStateFromOptions)(options);
499
+ const antProcessId = await (0, index_js_1.spawnANT)({
500
+ state,
501
+ signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
502
+ logger: (0, utils_js_1.getLoggerFromOptions)(options),
503
+ });
504
+ return {
505
+ processId: antProcessId,
506
+ state,
507
+ message: `Spawned ANT process with process ID ${antProcessId}`,
508
+ };
509
+ },
510
+ });
511
+ // # ANT Paginated Handlers
512
+ (0, utils_js_1.makeCommand)({
513
+ name: 'list-ant-records',
514
+ description: 'Get the records of an ANT process',
515
+ options: [options_js_1.optionMap.processId],
516
+ action: async (options) => {
517
+ return (0, utils_js_1.readANTFromOptions)(options).getRecords();
518
+ },
519
+ });
520
+ (0, utils_js_1.makeCommand)({
521
+ name: 'list-ant-controllers',
522
+ description: 'List the controllers of an ANT process',
523
+ options: [options_js_1.optionMap.processId],
524
+ action: async (options) => {
525
+ return (0, utils_js_1.readANTFromOptions)(options).getControllers();
526
+ },
527
+ });
515
528
  (0, utils_js_1.makeCommand)({
516
529
  name: 'list-ant-balances',
517
530
  description: 'Get the balances of an ANT process',
@@ -520,6 +533,7 @@ const utils_js_1 = require("./utils.js");
520
533
  return (0, utils_js_1.readANTFromOptions)(options).getBalances();
521
534
  },
522
535
  });
536
+ // # Actions
523
537
  (0, utils_js_1.makeCommand)({
524
538
  name: 'transfer-ant-ownership',
525
539
  description: 'Transfer ownership of an ANT process',
@@ -554,6 +568,18 @@ const utils_js_1 = require("./utils.js");
554
568
  }, (0, utils_js_1.customTagsFromOptions)(options));
555
569
  },
556
570
  });
571
+ (0, utils_js_1.makeCommand)({
572
+ name: 'remove-ant-record',
573
+ description: 'Remove a record from an ANT process',
574
+ options: [options_js_1.optionMap.processId, options_js_1.optionMap.undername, ...options_js_1.writeActionOptions],
575
+ action: async (options) => {
576
+ const undername = (0, utils_js_1.requiredStringFromOptions)(options, 'undername');
577
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the record with undername ${undername}?`, options);
578
+ return (0, utils_js_1.writeANTFromOptions)(options).removeRecord({
579
+ undername,
580
+ }, (0, utils_js_1.customTagsFromOptions)(options));
581
+ },
582
+ });
557
583
  (0, utils_js_1.makeCommand)({
558
584
  name: 'set-ant-record',
559
585
  description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
@@ -572,18 +598,6 @@ const utils_js_1 = require("./utils.js");
572
598
  options: options_js_1.setAntUndernameOptions,
573
599
  action: antCommands_js_1.setAntRecordCLICommand,
574
600
  });
575
- (0, utils_js_1.makeCommand)({
576
- name: 'remove-ant-record',
577
- description: 'Remove a record from an ANT process',
578
- options: [options_js_1.optionMap.processId, options_js_1.optionMap.undername, ...options_js_1.writeActionOptions],
579
- action: async (options) => {
580
- const undername = (0, utils_js_1.requiredStringFromOptions)(options, 'undername');
581
- await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the record with undername ${undername}?`, options);
582
- return (0, utils_js_1.writeANTFromOptions)(options).removeRecord({
583
- undername,
584
- }, (0, utils_js_1.customTagsFromOptions)(options));
585
- },
586
- });
587
601
  (0, utils_js_1.makeCommand)({
588
602
  name: 'set-ant-ticker',
589
603
  description: 'Set the ticker of an ANT process',
@@ -644,11 +658,11 @@ const utils_js_1 = require("./utils.js");
644
658
  const txId = (0, utils_js_1.requiredStringFromOptions)(options, 'transactionId');
645
659
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT logo to target Arweave TxID ${txId}?`, options);
646
660
  return (0, utils_js_1.writeANTFromOptions)(options).setLogo({
647
- // TODO: Could take a logo file, upload it to Arweave, get transaction ID
648
661
  txId,
649
662
  }, (0, utils_js_1.customTagsFromOptions)(options));
650
663
  },
651
664
  });
665
+ // # ARIO Actions
652
666
  (0, utils_js_1.makeCommand)({
653
667
  name: 'release-name',
654
668
  description: 'Release the name of an ANT process',
@@ -715,6 +729,7 @@ const utils_js_1 = require("./utils.js");
715
729
  }, (0, utils_js_1.customTagsFromOptions)(options));
716
730
  },
717
731
  });
732
+ // # Utilities
718
733
  (0, utils_js_1.makeCommand)({
719
734
  name: 'write-action',
720
735
  description: 'Send a write action to an AO Process',
@@ -21,6 +21,7 @@ exports.getPrimaryName = getPrimaryName;
21
21
  exports.getGatewayVaults = getGatewayVaults;
22
22
  exports.getAllGatewayVaults = getAllGatewayVaults;
23
23
  exports.getVault = getVault;
24
+ exports.resolveArNSName = resolveArNSName;
24
25
  const token_js_1 = require("../../types/token.js");
25
26
  const utils_js_1 = require("../utils.js");
26
27
  async function getGateway(o) {
@@ -188,3 +189,8 @@ async function getVault(o) {
188
189
  message: `No vault found for provided address and vault ID`,
189
190
  });
190
191
  }
192
+ async function resolveArNSName(o) {
193
+ const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
194
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).resolveArNSName({ name });
195
+ return result ?? { message: `No record found for name ${name}` };
196
+ }
@@ -52,6 +52,10 @@ exports.optionMap = {
52
52
  alias: '--cu-url <cuUrl>',
53
53
  description: 'The URL for a custom compute unit',
54
54
  },
55
+ paymentUrl: {
56
+ alias: '--payment-url <paymentUrl>',
57
+ description: 'The URL for a custom turbo payment service',
58
+ },
55
59
  processId: {
56
60
  alias: '--process-id <processId>',
57
61
  description: 'The process ID to interact with',
@@ -272,9 +276,15 @@ exports.optionMap = {
272
276
  alias: '--logo <logo>',
273
277
  description: 'The ANT logo',
274
278
  },
279
+ token: {
280
+ alias: '-t, --token <type>',
281
+ description: 'Crypto token type for wallet or action',
282
+ default: 'arweave',
283
+ },
275
284
  };
276
285
  exports.walletOptions = [
277
286
  exports.optionMap.walletFile,
287
+ exports.optionMap.token,
278
288
  // optionMap.mnemonic,
279
289
  exports.optionMap.privateKey,
280
290
  ];
@@ -292,6 +302,7 @@ exports.arnsPurchaseOptions = [
292
302
  ...exports.writeActionOptions,
293
303
  exports.optionMap.name,
294
304
  exports.optionMap.fundFrom,
305
+ exports.optionMap.paymentUrl,
295
306
  ];
296
307
  exports.epochOptions = [exports.optionMap.epochIndex, exports.optionMap.timestamp];
297
308
  exports.addressAndVaultIdOptions = [exports.optionMap.address, exports.optionMap.vaultId];
@@ -315,6 +326,7 @@ exports.tokenCostOptions = [
315
326
  exports.optionMap.quantity,
316
327
  exports.optionMap.address,
317
328
  exports.optionMap.fundFrom,
329
+ exports.optionMap.paymentUrl,
318
330
  ];
319
331
  exports.transferOptions = [
320
332
  ...exports.writeActionOptions,
@@ -13,6 +13,7 @@ exports.requiredJwkFromOptions = requiredJwkFromOptions;
13
13
  exports.jwkToAddress = jwkToAddress;
14
14
  exports.getLoggerFromOptions = getLoggerFromOptions;
15
15
  exports.readARIOFromOptions = readARIOFromOptions;
16
+ exports.contractSignerFromOptions = contractSignerFromOptions;
16
17
  exports.requiredContractSignerFromOptions = requiredContractSignerFromOptions;
17
18
  exports.requiredAoSignerFromOptions = requiredAoSignerFromOptions;
18
19
  exports.writeARIOFromOptions = writeARIOFromOptions;
@@ -60,6 +61,7 @@ exports.assertLockLengthInRange = assertLockLengthInRange;
60
61
  * See the License for the specific language governing permissions and
61
62
  * limitations under the License.
62
63
  */
64
+ const arbundles_1 = require("@dha-team/arbundles");
63
65
  const aoconnect_1 = require("@permaweb/aoconnect");
64
66
  const commander_1 = require("commander");
65
67
  const fs_1 = require("fs");
@@ -124,7 +126,7 @@ function arioProcessIdFromOptions({ arioProcessId, devnet, testnet, }) {
124
126
  }
125
127
  return index_js_1.ARIO_MAINNET_PROCESS_ID;
126
128
  }
127
- function jwkFromOptions({ privateKey, walletFile, }) {
129
+ function walletFromOptions({ privateKey, walletFile, }) {
128
130
  if (privateKey !== undefined) {
129
131
  return JSON.parse(privateKey);
130
132
  }
@@ -134,7 +136,7 @@ function jwkFromOptions({ privateKey, walletFile, }) {
134
136
  return undefined;
135
137
  }
136
138
  function requiredJwkFromOptions(options) {
137
- const jwk = jwkFromOptions(options);
139
+ const jwk = walletFromOptions(options);
138
140
  if (jwk === undefined) {
139
141
  throw new Error('No JWK provided for signing!\nPlease provide a stringified JWK with `--private-key` or the file path of a jwk.json file with `--wallet-file`');
140
142
  }
@@ -162,15 +164,39 @@ function aoProcessFromOptions(options) {
162
164
  }
163
165
  function readARIOFromOptions(options) {
164
166
  setLoggerIfDebug(options);
167
+ console.log('options', {
168
+ cuUrl: 'https://cu.ardrive.io', // default to ardrive cu for ARIO process
169
+ ...options,
170
+ });
165
171
  return index_js_1.ARIO.init({
166
- process: aoProcessFromOptions(options),
172
+ process: aoProcessFromOptions({
173
+ cuUrl: 'https://cu.ardrive.io', // default to ardrive cu for ARIO process
174
+ ...options,
175
+ }),
176
+ paymentUrl: options.paymentUrl,
167
177
  });
168
178
  }
169
- function requiredContractSignerFromOptions(options) {
179
+ function contractSignerFromOptions(options) {
180
+ const wallet = walletFromOptions(options);
181
+ if (wallet === undefined) {
182
+ return undefined;
183
+ }
184
+ const token = options.token ?? 'arweave';
185
+ if (token === 'ethereum') {
186
+ const signer = new arbundles_1.EthereumSigner(wallet);
187
+ // For EthereumSigner, we need to convert the JWK to a string
188
+ return { signer, signerAddress: signer.publicKey.toString('hex') };
189
+ }
170
190
  // TODO: Support other wallet types
171
- const jwk = requiredJwkFromOptions(options);
172
- const signer = new index_js_1.ArweaveSigner(jwk);
173
- return { signer, signerAddress: jwkToAddress(jwk) };
191
+ const signer = new index_js_1.ArweaveSigner(wallet);
192
+ return { signer, signerAddress: jwkToAddress(wallet) };
193
+ }
194
+ function requiredContractSignerFromOptions(options) {
195
+ const contractSigner = contractSignerFromOptions(options);
196
+ if (contractSigner === undefined) {
197
+ throw new Error('No signer provided for signing!\nPlease provide a stringified JWK or Ethereum private key with `--private-key` or the file path of an arweave.jwk.json or eth.private.key.txt file with `--wallet-file`');
198
+ }
199
+ return contractSigner;
174
200
  }
175
201
  function requiredAoSignerFromOptions(options) {
176
202
  return (0, index_js_1.createAoSigner)(requiredContractSignerFromOptions(options).signer);
@@ -182,6 +208,7 @@ function writeARIOFromOptions(options) {
182
208
  ario: index_js_1.ARIO.init({
183
209
  process: aoProcessFromOptions(options),
184
210
  signer,
211
+ paymentUrl: options.paymentUrl,
185
212
  }),
186
213
  signerAddress,
187
214
  };
@@ -202,10 +229,9 @@ function addressFromOptions(options) {
202
229
  if (options.address !== undefined) {
203
230
  return options.address;
204
231
  }
205
- // TODO: Support other wallet types
206
- const jwk = jwkFromOptions(options);
207
- if (jwk !== undefined) {
208
- return jwkToAddress(jwk);
232
+ const signer = contractSignerFromOptions(options);
233
+ if (signer !== undefined) {
234
+ return signer.signerAddress;
209
235
  }
210
236
  return undefined;
211
237
  }
@@ -328,6 +354,9 @@ function requiredMARIOFromOptions(options, key) {
328
354
  return new index_js_1.ARIOToken(+options[key]).toMARIO();
329
355
  }
330
356
  async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
357
+ if (costDetailsParams.fundFrom === 'turbo') {
358
+ return;
359
+ }
331
360
  const costDetails = await ario.getCostDetails(costDetailsParams);
332
361
  if (costDetails.fundingPlan) {
333
362
  if (costDetails.fundingPlan.shortfall > 0) {
@@ -75,14 +75,14 @@ class ANTVersionsWritable extends ANTVersionsReadable {
75
75
  super(config);
76
76
  this.signer = (0, ao_js_1.createAoSigner)(signer);
77
77
  }
78
- async addVersion(params, { tags }) {
78
+ async addVersion({ version, moduleId, luaSourceId, notes, }, { tags }) {
79
79
  return this.process.send({
80
80
  tags: (0, arweave_js_1.pruneTags)([
81
81
  { name: 'Action', value: 'Add-Version' },
82
- { name: 'Version', value: params.version },
83
- { name: 'Module-Id', value: params.moduleId },
84
- { name: 'Lua-Source-Id', value: params.luaSourceId },
85
- { name: 'Notes', value: params.notes },
82
+ { name: 'Version', value: version },
83
+ { name: 'Module-Id', value: moduleId },
84
+ { name: 'Lua-Source-Id', value: luaSourceId },
85
+ { name: 'Notes', value: notes },
86
86
  ...(tags ?? []),
87
87
  ]),
88
88
  signer: this.signer,
@@ -93,12 +93,12 @@ class AoANTReadable {
93
93
  * ```
94
94
  */
95
95
  async getRecord({ undername }, { strict } = { strict: this.strict }) {
96
- const tags = [
97
- { name: 'Sub-Domain', value: undername },
98
- { name: 'Action', value: 'Record' },
99
- ];
96
+ // TODO: use sortedANTRecords to get priority on all records, even if ANT does not have a priority set
100
97
  const record = await this.process.read({
101
- tags,
98
+ tags: [
99
+ { name: 'Action', value: 'Record' },
100
+ { name: 'Sub-Domain', value: undername },
101
+ ],
102
102
  });
103
103
  if (strict)
104
104
  (0, schema_js_1.parseSchemaResult)(ant_js_1.AntRecordSchema.passthrough(), record);
@@ -38,3 +38,5 @@ __exportStar(require("./faucet.js"), exports);
38
38
  // ao
39
39
  __exportStar(require("./io.js"), exports);
40
40
  __exportStar(require("./contracts/ao-process.js"), exports);
41
+ // wayfinder
42
+ __exportStar(require("./wayfinder/index.js"), exports);