@ar.io/sdk 2.7.0-alpha.6 → 3.0.0-alpha.1

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 (39) hide show
  1. package/README.md +155 -239
  2. package/bundles/web.bundle.min.js +74 -74
  3. package/lib/cjs/cli/cli.js +32 -38
  4. package/lib/cjs/cli/commands/gatewayWriteCommands.js +39 -39
  5. package/lib/cjs/cli/commands/readCommands.js +28 -45
  6. package/lib/cjs/cli/commands/transfer.js +7 -7
  7. package/lib/cjs/cli/options.js +4 -11
  8. package/lib/cjs/cli/utils.js +22 -22
  9. package/lib/cjs/common/ant.js +18 -14
  10. package/lib/cjs/common/io.js +15 -68
  11. package/lib/cjs/constants.js +5 -5
  12. package/lib/cjs/types/token.js +14 -14
  13. package/lib/cjs/utils/processes.js +4 -4
  14. package/lib/cjs/version.js +1 -1
  15. package/lib/esm/cli/cli.js +36 -42
  16. package/lib/esm/cli/commands/gatewayWriteCommands.js +41 -41
  17. package/lib/esm/cli/commands/readCommands.js +27 -43
  18. package/lib/esm/cli/commands/transfer.js +8 -8
  19. package/lib/esm/cli/options.js +3 -10
  20. package/lib/esm/cli/utils.js +18 -18
  21. package/lib/esm/common/ant.js +18 -14
  22. package/lib/esm/common/io.js +12 -65
  23. package/lib/esm/constants.js +4 -4
  24. package/lib/esm/types/token.js +12 -12
  25. package/lib/esm/utils/processes.js +6 -6
  26. package/lib/esm/version.js +1 -1
  27. package/lib/types/cli/commands/readCommands.d.ts +3 -4
  28. package/lib/types/cli/options.d.ts +1 -5
  29. package/lib/types/cli/types.d.ts +2 -4
  30. package/lib/types/cli/utils.d.ts +10 -10
  31. package/lib/types/common/ant.d.ts +14 -14
  32. package/lib/types/common/io.d.ts +20 -45
  33. package/lib/types/constants.d.ts +4 -4
  34. package/lib/types/types/ant.d.ts +8 -8
  35. package/lib/types/types/io.d.ts +14 -49
  36. package/lib/types/types/token.d.ts +8 -8
  37. package/lib/types/utils/processes.d.ts +4 -4
  38. package/lib/types/version.d.ts +1 -1
  39. package/package.json +1 -1
@@ -34,22 +34,22 @@ const utils_js_1 = require("./utils.js");
34
34
  (0, utils_js_1.makeCommand)({
35
35
  name: 'info',
36
36
  description: 'Get network info',
37
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getInfo(),
37
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getInfo(),
38
38
  });
39
39
  (0, utils_js_1.makeCommand)({
40
40
  name: 'token-supply',
41
41
  description: 'Get the total token supply',
42
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getTokenSupply(),
42
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getTokenSupply(),
43
43
  });
44
44
  (0, utils_js_1.makeCommand)({
45
45
  name: 'get-registration-fees',
46
46
  description: 'Get registration fees',
47
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getRegistrationFees(),
47
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRegistrationFees(),
48
48
  });
49
49
  (0, utils_js_1.makeCommand)({
50
50
  name: 'get-demand-factor',
51
51
  description: 'Get demand factor',
52
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getDemandFactor(),
52
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getDemandFactor(),
53
53
  });
54
54
  (0, utils_js_1.makeCommand)({
55
55
  name: 'get-gateway',
@@ -106,22 +106,16 @@ const utils_js_1 = require("./utils.js");
106
106
  action: readCommands_js_1.listArNSReservedNames,
107
107
  });
108
108
  (0, utils_js_1.makeCommand)({
109
- name: 'get-arns-auction',
110
- description: 'Get an ArNS auction by name',
109
+ name: 'get-arns-returned-name',
110
+ description: 'Get an ArNS returned name by name',
111
111
  options: options_js_1.nameOptions,
112
- action: readCommands_js_1.getArNSAuction,
112
+ action: readCommands_js_1.getArNSReturnedName,
113
113
  });
114
114
  (0, utils_js_1.makeCommand)({
115
- name: 'list-arns-auctions',
116
- description: 'Get all ArNS auctions',
115
+ name: 'list-arns-returned-names',
116
+ description: 'Get all ArNS recently returned names',
117
117
  options: options_js_1.paginationOptions,
118
- action: readCommands_js_1.listArNSAuctions,
119
- });
120
- (0, utils_js_1.makeCommand)({
121
- name: 'get-arns-auction-prices',
122
- description: 'Get ArNS auction prices',
123
- options: options_js_1.arNSAuctionPricesOptions,
124
- action: readCommands_js_1.getArNSAuctionPrices,
118
+ action: readCommands_js_1.listArNSReturnedNames,
125
119
  });
126
120
  (0, utils_js_1.makeCommand)({
127
121
  name: 'get-epoch',
@@ -132,7 +126,7 @@ const utils_js_1 = require("./utils.js");
132
126
  (0, utils_js_1.makeCommand)({
133
127
  name: 'get-current-epoch',
134
128
  description: 'Get current epoch data',
135
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getCurrentEpoch(),
129
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getCurrentEpoch(),
136
130
  });
137
131
  (0, utils_js_1.makeCommand)({
138
132
  name: 'get-prescribed-observers',
@@ -150,13 +144,13 @@ const utils_js_1 = require("./utils.js");
150
144
  name: 'get-observations',
151
145
  description: 'Get observations for an epoch',
152
146
  options: options_js_1.epochOptions,
153
- action: (o) => (0, utils_js_1.readIOFromOptions)(o).getObservations((0, utils_js_1.epochInputFromOptions)(o)),
147
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o).getObservations((0, utils_js_1.epochInputFromOptions)(o)),
154
148
  });
155
149
  (0, utils_js_1.makeCommand)({
156
150
  name: 'get-distributions',
157
151
  description: 'Get distributions for an epoch',
158
152
  options: options_js_1.epochOptions,
159
- action: (o) => (0, utils_js_1.readIOFromOptions)(o).getDistributions((0, utils_js_1.epochInputFromOptions)(o)),
153
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o).getDistributions((0, utils_js_1.epochInputFromOptions)(o)),
160
154
  });
161
155
  (0, utils_js_1.makeCommand)({
162
156
  name: 'get-token-cost',
@@ -168,7 +162,7 @@ const utils_js_1 = require("./utils.js");
168
162
  name: 'list-vaults',
169
163
  description: 'Get all wallet vaults',
170
164
  options: options_js_1.paginationOptions,
171
- action: (o) => (0, utils_js_1.readIOFromOptions)(o)
165
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
172
166
  .getVaults((0, utils_js_1.paginationParamsFromOptions)(o))
173
167
  .then((result) => result.items.length ? result : { message: 'No vaults found' }),
174
168
  });
@@ -177,7 +171,7 @@ const utils_js_1 = require("./utils.js");
177
171
  name: 'get-primary-name-request',
178
172
  description: 'Get primary name request',
179
173
  options: options_js_1.initiatorOptions,
180
- action: (o) => (0, utils_js_1.readIOFromOptions)(o)
174
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
181
175
  .getPrimaryNameRequest({
182
176
  initiator: (0, utils_js_1.requiredStringFromOptions)(o, 'initiator'),
183
177
  })
@@ -189,7 +183,7 @@ const utils_js_1 = require("./utils.js");
189
183
  name: 'list-primary-name-requests',
190
184
  description: 'Get primary name requests',
191
185
  options: options_js_1.paginationOptions,
192
- action: (o) => (0, utils_js_1.readIOFromOptions)(o)
186
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
193
187
  .getPrimaryNameRequests((0, utils_js_1.paginationParamsFromOptions)(o))
194
188
  .then((result) => result.items.length ? result : { message: 'No requests found' }),
195
189
  });
@@ -203,7 +197,7 @@ const utils_js_1 = require("./utils.js");
203
197
  name: 'list-primary-names',
204
198
  description: 'Get primary names',
205
199
  options: options_js_1.paginationOptions,
206
- action: (o) => (0, utils_js_1.readIOFromOptions)(o)
200
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
207
201
  .getPrimaryNames((0, utils_js_1.paginationParamsFromOptions)(o))
208
202
  .then((result) => result.items.length ? result : { message: 'No names found' }),
209
203
  });
@@ -211,19 +205,19 @@ const utils_js_1 = require("./utils.js");
211
205
  name: 'balance',
212
206
  description: 'Get the balance of an address',
213
207
  options: options_js_1.addressOptions,
214
- action: (options) => (0, utils_js_1.readIOFromOptions)(options)
208
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options)
215
209
  .getBalance({ address: (0, utils_js_1.requiredAddressFromOptions)(options) })
216
210
  .then((result) => ({
217
211
  address: (0, utils_js_1.requiredAddressFromOptions)(options),
218
212
  mIOBalance: result,
219
- message: `Provided address current has a balance of ${(0, utils_js_1.formatIOWithCommas)(new token_js_1.mIOToken(result).toIO())} IO`,
213
+ message: `Provided address current has a balance of ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(result).toARIO())} ARIO`,
220
214
  })),
221
215
  });
222
216
  (0, utils_js_1.makeCommand)({
223
217
  name: 'list-balances',
224
218
  description: 'List all balances',
225
219
  options: options_js_1.paginationOptions,
226
- action: (o) => (0, utils_js_1.readIOFromOptions)(o)
220
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
227
221
  .getBalances((0, utils_js_1.paginationParamsFromOptions)(o))
228
222
  .then((result) => result.items.length ? result : { message: 'No balances found' }),
229
223
  });
@@ -231,7 +225,7 @@ const utils_js_1 = require("./utils.js");
231
225
  name: 'get-redelegation-fee',
232
226
  description: 'Get redelegation fee',
233
227
  options: options_js_1.addressOptions,
234
- action: (options) => (0, utils_js_1.readIOFromOptions)(options).getRedelegationFee({
228
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRedelegationFee({
235
229
  address: (0, utils_js_1.requiredAddressFromOptions)(options),
236
230
  }),
237
231
  });
@@ -249,7 +243,7 @@ const utils_js_1 = require("./utils.js");
249
243
  });
250
244
  (0, utils_js_1.makeCommand)({
251
245
  name: 'transfer',
252
- description: 'Transfer IO to another address',
246
+ description: 'Transfer ARIO to another address',
253
247
  options: options_js_1.transferOptions,
254
248
  action: transfer_js_1.transfer,
255
249
  });
@@ -327,7 +321,7 @@ const utils_js_1 = require("./utils.js");
327
321
  description: 'Buy a record',
328
322
  options: options_js_1.buyRecordOptions,
329
323
  action: async (options) => {
330
- const io = (0, utils_js_1.writeIOFromOptions)(options).io;
324
+ const ario = (0, utils_js_1.writeARIOFromOptions)(options).ario;
331
325
  const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
332
326
  const type = (0, utils_js_1.recordTypeFromOptions)(options);
333
327
  const years = (0, utils_js_1.positiveIntegerFromOptions)(options, 'years');
@@ -339,7 +333,7 @@ const utils_js_1 = require("./utils.js");
339
333
  throw new Error('Process ID must be provided for buy-record');
340
334
  }
341
335
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to ${type} the record ${name}?`, options);
342
- return io.buyRecord({
336
+ return ario.buyRecord({
343
337
  name: (0, utils_js_1.requiredStringFromOptions)(options, 'name'),
344
338
  processId,
345
339
  type,
@@ -355,7 +349,7 @@ const utils_js_1 = require("./utils.js");
355
349
  action: async (options) => {
356
350
  const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
357
351
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to upgrade the lease of ${name} to a permabuy?`, options);
358
- return (0, utils_js_1.writeIOFromOptions)(options).io.upgradeRecord({
352
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.upgradeRecord({
359
353
  name,
360
354
  });
361
355
  },
@@ -368,7 +362,7 @@ const utils_js_1 = require("./utils.js");
368
362
  const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
369
363
  const years = (0, utils_js_1.requiredPositiveIntegerFromOptions)(options, 'years');
370
364
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to extend the lease of ${name} by ${years}?`, options);
371
- return (0, utils_js_1.writeIOFromOptions)(options).io.extendLease({
365
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.extendLease({
372
366
  name,
373
367
  years,
374
368
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
@@ -382,7 +376,7 @@ const utils_js_1 = require("./utils.js");
382
376
  const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
383
377
  const increaseCount = (0, utils_js_1.requiredPositiveIntegerFromOptions)(options, 'increaseCount');
384
378
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to increase the undername limit of ${name} by ${increaseCount}?`, options);
385
- return (0, utils_js_1.writeIOFromOptions)(options).io.increaseUndernameLimit({
379
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.increaseUndernameLimit({
386
380
  name,
387
381
  increaseCount,
388
382
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
@@ -398,7 +392,7 @@ const utils_js_1 = require("./utils.js");
398
392
  // TODO: More assertions?
399
393
  const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
400
394
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to request the primary name ${name}?`, options);
401
- return (0, utils_js_1.writeIOFromOptions)(options).io.requestPrimaryName({
395
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.requestPrimaryName({
402
396
  name,
403
397
  });
404
398
  },
@@ -647,7 +641,7 @@ const utils_js_1 = require("./utils.js");
647
641
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to release the name ${name} back to the protocol?`, options);
648
642
  return (0, utils_js_1.writeANTFromOptions)(options).releaseName({
649
643
  name,
650
- ioProcessId: (0, utils_js_1.ioProcessIdFromOptions)(options),
644
+ arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
651
645
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
652
646
  },
653
647
  });
@@ -666,7 +660,7 @@ const utils_js_1 = require("./utils.js");
666
660
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to reassign the name ${name} to ANT process ${targetProcess}?`, options);
667
661
  return (0, utils_js_1.writeANTFromOptions)(options).reassignName({
668
662
  name,
669
- ioProcessId: (0, utils_js_1.ioProcessIdFromOptions)(options),
663
+ arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
670
664
  antProcessId: targetProcess,
671
665
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
672
666
  },
@@ -687,7 +681,7 @@ const utils_js_1 = require("./utils.js");
687
681
  return (0, utils_js_1.writeANTFromOptions)(options).approvePrimaryNameRequest({
688
682
  name,
689
683
  address,
690
- ioProcessId: (0, utils_js_1.ioProcessIdFromOptions)(options),
684
+ arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
691
685
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
692
686
  },
693
687
  });
@@ -700,7 +694,7 @@ const utils_js_1 = require("./utils.js");
700
694
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the primary names ${names}?`, options);
701
695
  return (0, utils_js_1.writeANTFromOptions)(options).removePrimaryNames({
702
696
  names,
703
- ioProcessId: (0, utils_js_1.ioProcessIdFromOptions)(options),
697
+ arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
704
698
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
705
699
  },
706
700
  });
@@ -23,7 +23,7 @@ const prompts_1 = __importDefault(require("prompts"));
23
23
  const index_js_1 = require("../../node/index.js");
24
24
  const utils_js_1 = require("../utils.js");
25
25
  async function joinNetwork(options) {
26
- const { io, signerAddress } = (0, utils_js_1.writeIOFromOptions)(options);
26
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(options);
27
27
  const mARIOQuantity = (0, utils_js_1.requiredMIOFromOptions)(options, 'operatorStake');
28
28
  const settings = {
29
29
  ...(0, utils_js_1.gatewaySettingsFromOptions)(options),
@@ -36,14 +36,14 @@ async function joinNetwork(options) {
36
36
  throw new Error('FQDN is required. Please provide a --fqdn for your node.');
37
37
  }
38
38
  if (!options.skipConfirmation) {
39
- const settings = await io.getGatewayRegistrySettings();
39
+ const settings = await ario.getGatewayRegistrySettings();
40
40
  if (settings.operators.minStake > mARIOQuantity.valueOf()) {
41
- throw new Error(`The minimum operator stake is ${(0, utils_js_1.formatIOWithCommas)(new index_js_1.mIOToken(settings.operators.minStake).toIO())} IO. Please provide a higher stake.`);
41
+ throw new Error(`The minimum operator stake is ${(0, utils_js_1.formatARIOWithCommas)(new index_js_1.mARIOToken(settings.operators.minStake).toARIO())} IO. Please provide a higher stake.`);
42
42
  }
43
- await (0, utils_js_1.assertEnoughBalance)(io, signerAddress, mARIOQuantity.toIO());
44
- await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${(0, utils_js_1.formatIOWithCommas)(mARIOQuantity.toIO())} IO to join the AR.IO network\nAre you sure?\n`, options);
43
+ await (0, utils_js_1.assertEnoughBalance)(ario, signerAddress, mARIOQuantity.toARIO());
44
+ await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${(0, utils_js_1.formatARIOWithCommas)(mARIOQuantity.toARIO())} IO to join the AR.IO network\nAre you sure?\n`, options);
45
45
  }
46
- const result = await io.joinNetwork(settings, (0, utils_js_1.writeActionTagsFromOptions)(options));
46
+ const result = await ario.joinNetwork(settings, (0, utils_js_1.writeActionTagsFromOptions)(options));
47
47
  const output = {
48
48
  joinNetworkResult: result,
49
49
  joinedAddress: signerAddress,
@@ -53,14 +53,14 @@ async function joinNetwork(options) {
53
53
  }
54
54
  exports.joinNetwork = joinNetwork;
55
55
  async function updateGatewaySettings(options) {
56
- const { io, signerAddress } = (0, utils_js_1.writeIOFromOptions)(options);
56
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(options);
57
57
  const gatewaySettings = (0, utils_js_1.gatewaySettingsFromOptions)(options);
58
58
  if (Object.keys(gatewaySettings).length === 0) {
59
59
  // TODO: The contract accepts empty Update-Gateway-Settings actions, but we'll throw in the CLI for now
60
60
  throw new Error('No gateway settings provided');
61
61
  }
62
62
  await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${(0, utils_js_1.stringifyJsonForCLIDisplay)(gatewaySettings)}\n\nYou are about to update your gateway settings to the above\nAre you sure?\n`, options);
63
- const result = await io.updateGatewaySettings(gatewaySettings, (0, utils_js_1.writeActionTagsFromOptions)(options));
63
+ const result = await ario.updateGatewaySettings(gatewaySettings, (0, utils_js_1.writeActionTagsFromOptions)(options));
64
64
  const output = {
65
65
  updateGatewaySettingsResult: result,
66
66
  updatedGatewayAddress: signerAddress,
@@ -70,9 +70,9 @@ async function updateGatewaySettings(options) {
70
70
  }
71
71
  exports.updateGatewaySettings = updateGatewaySettings;
72
72
  async function leaveNetwork(options) {
73
- const { io, signerAddress } = (0, utils_js_1.writeIOFromOptions)(options);
73
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(options);
74
74
  if (!options.skipConfirmation) {
75
- const gateway = await io.getGateway({ address: signerAddress });
75
+ const gateway = await ario.getGateway({ address: signerAddress });
76
76
  if (!gateway) {
77
77
  throw new Error(`Gateway not found for address: ${signerAddress}`);
78
78
  }
@@ -81,14 +81,14 @@ async function leaveNetwork(options) {
81
81
  '\n\n' +
82
82
  'Are you sure you want to leave the AR.IO network?', options);
83
83
  }
84
- return (0, utils_js_1.writeIOFromOptions)(options).io.leaveNetwork((0, utils_js_1.writeActionTagsFromOptions)(options));
84
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.leaveNetwork((0, utils_js_1.writeActionTagsFromOptions)(options));
85
85
  }
86
86
  exports.leaveNetwork = leaveNetwork;
87
87
  async function saveObservations(o) {
88
88
  const failedGateways = (0, utils_js_1.requiredStringArrayFromOptions)(o, 'failedGateways');
89
89
  const reportTxId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
90
90
  await (0, utils_js_1.assertConfirmationPrompt)(`You are about to save the following failed gateways to the AR.IO network:\n\n${failedGateways.join('\n')}\n\nTransaction ID: ${reportTxId}\n\nAre you sure?`, o);
91
- return (0, utils_js_1.writeIOFromOptions)(o).io.saveObservations({
91
+ return (0, utils_js_1.writeARIOFromOptions)(o).ario.saveObservations({
92
92
  failedGateways: (0, utils_js_1.requiredStringArrayFromOptions)(o, 'failedGateways'),
93
93
  reportTxId: (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId'),
94
94
  }, (0, utils_js_1.writeActionTagsFromOptions)(o));
@@ -96,8 +96,8 @@ async function saveObservations(o) {
96
96
  exports.saveObservations = saveObservations;
97
97
  async function increaseOperatorStake(o) {
98
98
  const increaseQty = (0, utils_js_1.requiredMIOFromOptions)(o, 'operatorStake');
99
- await (0, utils_js_1.assertConfirmationPrompt)(`You are about to increase your operator stake by ${(0, utils_js_1.formatIOWithCommas)(increaseQty.toIO())} IO\nAre you sure?`, o);
100
- return ((0, utils_js_1.writeIOFromOptions)(o).io.increaseOperatorStake({
99
+ await (0, utils_js_1.assertConfirmationPrompt)(`You are about to increase your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(increaseQty.toARIO())} IO\nAre you sure?`, o);
100
+ return ((0, utils_js_1.writeARIOFromOptions)(o).ario.increaseOperatorStake({
101
101
  increaseQty,
102
102
  }),
103
103
  (0, utils_js_1.writeActionTagsFromOptions)(o));
@@ -106,8 +106,8 @@ exports.increaseOperatorStake = increaseOperatorStake;
106
106
  async function decreaseOperatorStake(o) {
107
107
  const decreaseQty = (0, utils_js_1.requiredMIOFromOptions)(o, 'operatorStake');
108
108
  // TODO: Can assert stake is sufficient for action, and new target stake meets contract minimum
109
- await (0, utils_js_1.assertConfirmationPrompt)(`You are about to decrease your operator stake by ${(0, utils_js_1.formatIOWithCommas)(decreaseQty.toIO())} IO\nAre you sure?`, o);
110
- return (0, utils_js_1.writeIOFromOptions)(o).io.decreaseOperatorStake({
109
+ await (0, utils_js_1.assertConfirmationPrompt)(`You are about to decrease your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(decreaseQty.toARIO())} IO\nAre you sure?`, o);
110
+ return (0, utils_js_1.writeARIOFromOptions)(o).ario.decreaseOperatorStake({
111
111
  decreaseQty,
112
112
  }, (0, utils_js_1.writeActionTagsFromOptions)(o));
113
113
  }
@@ -116,7 +116,7 @@ async function instantWithdrawal(o) {
116
116
  const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
117
117
  const gatewayAddress = (0, utils_js_1.requiredAddressFromOptions)(o);
118
118
  await (0, utils_js_1.assertConfirmationPrompt)(`You are about to instantly withdraw from vault ${vaultId} for with gateway address ${gatewayAddress}\nAre you sure?`, o);
119
- return (0, utils_js_1.writeIOFromOptions)(o).io.instantWithdrawal({
119
+ return (0, utils_js_1.writeARIOFromOptions)(o).ario.instantWithdrawal({
120
120
  vaultId,
121
121
  gatewayAddress,
122
122
  }, (0, utils_js_1.writeActionTagsFromOptions)(o));
@@ -126,22 +126,22 @@ async function cancelWithdrawal(o) {
126
126
  const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
127
127
  const gatewayAddress = (0, utils_js_1.requiredAddressFromOptions)(o);
128
128
  await (0, utils_js_1.assertConfirmationPrompt)(`You are about to cancel the pending withdrawal from vault ${vaultId} for with gateway address ${gatewayAddress}\nAre you sure?`, o);
129
- return (0, utils_js_1.writeIOFromOptions)(o).io.cancelWithdrawal({
129
+ return (0, utils_js_1.writeARIOFromOptions)(o).ario.cancelWithdrawal({
130
130
  vaultId,
131
131
  gatewayAddress,
132
132
  }, (0, utils_js_1.writeActionTagsFromOptions)(o));
133
133
  }
134
134
  exports.cancelWithdrawal = cancelWithdrawal;
135
135
  async function delegateStake(options) {
136
- const { io, signerAddress } = (0, utils_js_1.writeIOFromOptions)(options);
137
- const { target, ioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
138
- const mIOQuantity = ioQuantity.toMIO();
136
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(options);
137
+ const { target, arioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
138
+ const mARIOQuantity = arioQuantity.toMARIO();
139
139
  if (!options.skipConfirmation) {
140
- const balance = await io.getBalance({ address: signerAddress });
141
- if (balance < mIOQuantity.valueOf()) {
142
- throw new Error(`Insufficient IO balance for delegating stake. Balance available: ${new index_js_1.mIOToken(balance).toIO()} IO`);
140
+ const balance = await ario.getBalance({ address: signerAddress });
141
+ if (balance < mARIOQuantity.valueOf()) {
142
+ throw new Error(`Insufficient ARIO balance for delegating stake. Balance available: ${new index_js_1.mARIOToken(balance).toARIO()} ARIO`);
143
143
  }
144
- const targetGateway = await io.getGateway({ address: target });
144
+ const targetGateway = await ario.getGateway({ address: target });
145
145
  if (targetGateway === undefined) {
146
146
  throw new Error(`Gateway not found for address: ${target}`);
147
147
  }
@@ -153,58 +153,58 @@ async function delegateStake(options) {
153
153
  const { confirm } = await (0, prompts_1.default)({
154
154
  type: 'confirm',
155
155
  name: 'confirm',
156
- message: `Target Gateway:\n${JSON.stringify(targetGateway, null, 2)}\n\nAre you sure you want to delegate ${(0, utils_js_1.formatIOWithCommas)(ioQuantity)} IO to ${target}?`,
156
+ message: `Target Gateway:\n${JSON.stringify(targetGateway, null, 2)}\n\nAre you sure you want to delegate ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO to ${target}?`,
157
157
  });
158
158
  if (!confirm) {
159
159
  return { message: 'Delegate stake aborted by user' };
160
160
  }
161
161
  }
162
- const result = await io.delegateStake({
162
+ const result = await ario.delegateStake({
163
163
  target,
164
- stakeQty: ioQuantity.toMIO(),
164
+ stakeQty: arioQuantity.toMARIO(),
165
165
  }, (0, utils_js_1.writeActionTagsFromOptions)(options));
166
166
  const output = {
167
167
  senderAddress: signerAddress,
168
168
  transferResult: result,
169
- message: `Successfully delegated ${(0, utils_js_1.formatIOWithCommas)(ioQuantity)} IO to ${target}`,
169
+ message: `Successfully delegated ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO to ${target}`,
170
170
  };
171
171
  return output;
172
172
  }
173
173
  exports.delegateStake = delegateStake;
174
174
  async function decreaseDelegateStake(options) {
175
- const io = (0, utils_js_1.writeIOFromOptions)(options).io;
176
- const { target, ioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
175
+ const ario = (0, utils_js_1.writeARIOFromOptions)(options).ario;
176
+ const { target, arioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
177
177
  const instant = options.instant ?? false;
178
178
  // TODO: Could assert sender is a delegate with enough stake to decrease
179
179
  // TODO: Could assert new target stake meets contract and target gateway minimums
180
180
  // TODO: Could present confirmation prompt with any fee for instant withdrawal (50% of the stake is put back into protocol??)
181
- await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you'd like to decrease delegated stake of ${(0, utils_js_1.formatIOWithCommas)(ioQuantity)} IO on gateway ${target}?`, options);
182
- const result = await io.decreaseDelegateStake({
181
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you'd like to decrease delegated stake of ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO on gateway ${target}?`, options);
182
+ const result = await ario.decreaseDelegateStake({
183
183
  target,
184
- decreaseQty: ioQuantity.toMIO(),
184
+ decreaseQty: arioQuantity.toMARIO(),
185
185
  instant,
186
186
  });
187
187
  const output = {
188
188
  targetGateway: target,
189
189
  decreaseDelegateStakeResult: result,
190
- message: `Successfully decreased delegated stake of ${(0, utils_js_1.formatIOWithCommas)(ioQuantity)} IO to ${target}`,
190
+ message: `Successfully decreased delegated stake of ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO to ${target}`,
191
191
  };
192
192
  return output;
193
193
  }
194
194
  exports.decreaseDelegateStake = decreaseDelegateStake;
195
195
  async function redelegateStake(options) {
196
- const io = (0, utils_js_1.writeIOFromOptions)(options).io;
196
+ const ario = (0, utils_js_1.writeARIOFromOptions)(options).ario;
197
197
  const params = (0, utils_js_1.redelegateParamsFromOptions)(options);
198
198
  // TODO: Could assert target gateway exists
199
199
  // TODO: Could do assertion on source has enough stake to redelegate
200
200
  // TODO: Could do assertions on source/target min delegate stakes are met
201
- await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you'd like to redelegate stake of ${(0, utils_js_1.formatIOWithCommas)(params.stakeQty.toIO())} IO from ${params.source} to ${params.target}?`, options);
202
- const result = await io.redelegateStake(params);
201
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you'd like to redelegate stake of ${(0, utils_js_1.formatARIOWithCommas)(params.stakeQty.toARIO())} ARIO from ${params.source} to ${params.target}?`, options);
202
+ const result = await ario.redelegateStake(params);
203
203
  const output = {
204
204
  sourceGateway: params.source,
205
205
  targetGateway: params.target,
206
206
  redelegateStakeResult: result,
207
- message: `Successfully re-delegated stake of ${(0, utils_js_1.formatIOWithCommas)(params.stakeQty.toIO())} IO from ${params.source} to ${params.target}`,
207
+ message: `Successfully re-delegated stake of ${(0, utils_js_1.formatARIOWithCommas)(params.stakeQty.toARIO())} ARIO from ${params.source} to ${params.target}`,
208
208
  };
209
209
  return output;
210
210
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVault = exports.getGatewayVaults = exports.getPrimaryName = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.getArNSAuctionPrices = exports.listArNSAuctions = exports.getArNSAuction = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listGateways = exports.getGateway = void 0;
3
+ exports.getVault = exports.getGatewayVaults = exports.getPrimaryName = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.listArNSReturnedNames = exports.getArNSReturnedName = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listGateways = exports.getGateway = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -21,20 +21,20 @@ const token_js_1 = require("../../types/token.js");
21
21
  const utils_js_1 = require("../utils.js");
22
22
  async function getGateway(o) {
23
23
  const address = (0, utils_js_1.requiredAddressFromOptions)(o);
24
- const gateway = await (0, utils_js_1.readIOFromOptions)(o).getGateway({
24
+ const gateway = await (0, utils_js_1.readARIOFromOptions)(o).getGateway({
25
25
  address,
26
26
  });
27
27
  return gateway ?? { message: `No gateway found for address ${address}` };
28
28
  }
29
29
  exports.getGateway = getGateway;
30
30
  async function listGateways(o) {
31
- const gateways = await (0, utils_js_1.readIOFromOptions)(o).getGateways((0, utils_js_1.paginationParamsFromOptions)(o));
31
+ const gateways = await (0, utils_js_1.readARIOFromOptions)(o).getGateways((0, utils_js_1.paginationParamsFromOptions)(o));
32
32
  return gateways.items.length ? gateways : { message: 'No gateways found' };
33
33
  }
34
34
  exports.listGateways = listGateways;
35
35
  async function getGatewayDelegates(o) {
36
36
  const address = (0, utils_js_1.requiredAddressFromOptions)(o);
37
- const result = await (0, utils_js_1.readIOFromOptions)(o).getGatewayDelegates({
37
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getGatewayDelegates({
38
38
  address,
39
39
  ...(0, utils_js_1.paginationParamsFromOptions)(o),
40
40
  });
@@ -47,7 +47,7 @@ async function getGatewayDelegates(o) {
47
47
  exports.getGatewayDelegates = getGatewayDelegates;
48
48
  async function getDelegations(o) {
49
49
  const address = (0, utils_js_1.requiredAddressFromOptions)(o);
50
- const result = await (0, utils_js_1.readIOFromOptions)(o).getDelegations({
50
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getDelegations({
51
51
  address,
52
52
  ...(0, utils_js_1.paginationParamsFromOptions)(o),
53
53
  });
@@ -60,7 +60,7 @@ async function getDelegations(o) {
60
60
  exports.getDelegations = getDelegations;
61
61
  async function getAllowedDelegates(o) {
62
62
  const address = (0, utils_js_1.requiredAddressFromOptions)(o);
63
- const result = await (0, utils_js_1.readIOFromOptions)(o).getAllowedDelegates({
63
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getAllowedDelegates({
64
64
  address,
65
65
  ...(0, utils_js_1.paginationParamsFromOptions)(o),
66
66
  });
@@ -73,68 +73,51 @@ async function getAllowedDelegates(o) {
73
73
  exports.getAllowedDelegates = getAllowedDelegates;
74
74
  async function getArNSRecord(o) {
75
75
  const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
76
- return ((await (0, utils_js_1.readIOFromOptions)(o).getArNSRecord({
76
+ return ((await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecord({
77
77
  name,
78
78
  })) ?? { message: `No record found for name ${name}` });
79
79
  }
80
80
  exports.getArNSRecord = getArNSRecord;
81
81
  async function listArNSRecords(o) {
82
- const records = await (0, utils_js_1.readIOFromOptions)(o).getArNSRecords((0, utils_js_1.paginationParamsFromOptions)(o));
82
+ const records = await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecords((0, utils_js_1.paginationParamsFromOptions)(o));
83
83
  return records.items.length ? records : { message: 'No records found' };
84
84
  }
85
85
  exports.listArNSRecords = listArNSRecords;
86
86
  async function getArNSReservedName(o) {
87
87
  const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
88
- return ((await (0, utils_js_1.readIOFromOptions)(o).getArNSReservedName({
88
+ return ((await (0, utils_js_1.readARIOFromOptions)(o).getArNSReservedName({
89
89
  name,
90
90
  })) ?? { message: `No reserved name found for name ${name}` });
91
91
  }
92
92
  exports.getArNSReservedName = getArNSReservedName;
93
93
  async function listArNSReservedNames(o) {
94
- const reservedNames = await (0, utils_js_1.readIOFromOptions)(o).getArNSReservedNames((0, utils_js_1.paginationParamsFromOptions)(o));
94
+ const reservedNames = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReservedNames((0, utils_js_1.paginationParamsFromOptions)(o));
95
95
  return reservedNames.items.length
96
96
  ? reservedNames
97
97
  : { message: 'No reserved names found' };
98
98
  }
99
99
  exports.listArNSReservedNames = listArNSReservedNames;
100
- async function getArNSAuction(o) {
100
+ async function getArNSReturnedName(o) {
101
101
  const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
102
- const result = await (0, utils_js_1.readIOFromOptions)(o).getArNSAuction({ name });
103
- return result ?? { message: `No auction found for name ${name}` };
102
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReturnedName({ name });
103
+ return result ?? { message: `No returned name found for name ${name}` };
104
104
  }
105
- exports.getArNSAuction = getArNSAuction;
106
- async function listArNSAuctions(o) {
107
- const auctions = await (0, utils_js_1.readIOFromOptions)(o).getArNSAuctions((0, utils_js_1.paginationParamsFromOptions)(o));
108
- return auctions.items.length ? auctions : { message: 'No auctions found' };
105
+ exports.getArNSReturnedName = getArNSReturnedName;
106
+ async function listArNSReturnedNames(o) {
107
+ const returnedNames = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReturnedNames((0, utils_js_1.paginationParamsFromOptions)(o));
108
+ return returnedNames.items.length
109
+ ? returnedNames
110
+ : { message: 'No returned names found' };
109
111
  }
110
- exports.listArNSAuctions = listArNSAuctions;
111
- async function getArNSAuctionPrices(o) {
112
- o.type ??= 'lease';
113
- if (o.type !== 'lease' && o.type !== 'permabuy') {
114
- throw new Error(`Invalid type. Valid types are: lease, permabuy`);
115
- // TODY: type and years helper
116
- }
117
- const result = await (0, utils_js_1.readIOFromOptions)(o).getArNSAuctionPrices({
118
- name: (0, utils_js_1.requiredStringFromOptions)(o, 'name'),
119
- type: o.type,
120
- // TODO: intervalMS helper, assert and format
121
- intervalMs: o.intervalMs !== undefined ? +o.intervalMs : undefined,
122
- // TODO: timestamp helper, assert and format
123
- timestamp: o.timestamp !== undefined ? +o.timestamp : undefined,
124
- // todo: assert years if 'lease'
125
- years: (0, utils_js_1.positiveIntegerFromOptions)(o, 'years'),
126
- });
127
- return result ?? { message: `No auction prices found` };
128
- }
129
- exports.getArNSAuctionPrices = getArNSAuctionPrices;
112
+ exports.listArNSReturnedNames = listArNSReturnedNames;
130
113
  async function getEpoch(o) {
131
- const epoch = await (0, utils_js_1.readIOFromOptions)(o).getEpoch((0, utils_js_1.epochInputFromOptions)(o));
114
+ const epoch = await (0, utils_js_1.readARIOFromOptions)(o).getEpoch((0, utils_js_1.epochInputFromOptions)(o));
132
115
  return epoch ?? { message: `No epoch found for provided input` };
133
116
  }
134
117
  exports.getEpoch = getEpoch;
135
118
  async function getPrescribedObservers(o) {
136
119
  const epoch = (0, utils_js_1.epochInputFromOptions)(o);
137
- const result = await (0, utils_js_1.readIOFromOptions)(o).getPrescribedObservers(epoch);
120
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrescribedObservers(epoch);
138
121
  return result?.length
139
122
  ? result
140
123
  : { message: `No prescribed observers found for epoch ${epoch}` };
@@ -142,7 +125,7 @@ async function getPrescribedObservers(o) {
142
125
  exports.getPrescribedObservers = getPrescribedObservers;
143
126
  async function getPrescribedNames(o) {
144
127
  const epoch = (0, utils_js_1.epochInputFromOptions)(o);
145
- const result = await (0, utils_js_1.readIOFromOptions)(o).getPrescribedNames((0, utils_js_1.epochInputFromOptions)(o));
128
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrescribedNames((0, utils_js_1.epochInputFromOptions)(o));
146
129
  return result?.length
147
130
  ? result
148
131
  : { message: `No prescribed names found for epoch ${epoch}` };
@@ -162,7 +145,7 @@ async function getTokenCost(o) {
162
145
  o.years === undefined) {
163
146
  throw new Error('Years is required for lease type');
164
147
  }
165
- const tokenCost = await (0, utils_js_1.readIOFromOptions)(o).getTokenCost({
148
+ const tokenCost = await (0, utils_js_1.readARIOFromOptions)(o).getTokenCost({
166
149
  type: o.type,
167
150
  quantity: o.quantity !== undefined ? +o.quantity : undefined,
168
151
  years: o.years !== undefined ? +o.years : undefined,
@@ -171,7 +154,7 @@ async function getTokenCost(o) {
171
154
  });
172
155
  const output = {
173
156
  mIOTokenCost: tokenCost,
174
- message: `The cost of the provided action is ${(0, utils_js_1.formatIOWithCommas)(new token_js_1.mIOToken(tokenCost).toIO())} IO`,
157
+ message: `The cost of the provided action is ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(tokenCost).toARIO())} ARIO`,
175
158
  };
176
159
  return output;
177
160
  }
@@ -187,7 +170,7 @@ async function getPrimaryName(o) {
187
170
  if (params === undefined) {
188
171
  throw new Error('Either --address or --name is required');
189
172
  }
190
- const result = await (0, utils_js_1.readIOFromOptions)(o).getPrimaryName(params);
173
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrimaryName(params);
191
174
  return (result ?? {
192
175
  message: `No primary name found`,
193
176
  });
@@ -195,7 +178,7 @@ async function getPrimaryName(o) {
195
178
  exports.getPrimaryName = getPrimaryName;
196
179
  async function getGatewayVaults(o) {
197
180
  const address = (0, utils_js_1.requiredAddressFromOptions)(o);
198
- const result = await (0, utils_js_1.readIOFromOptions)(o).getGatewayVaults({
181
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getGatewayVaults({
199
182
  address,
200
183
  ...(0, utils_js_1.paginationParamsFromOptions)(o),
201
184
  });
@@ -207,7 +190,7 @@ async function getGatewayVaults(o) {
207
190
  }
208
191
  exports.getGatewayVaults = getGatewayVaults;
209
192
  async function getVault(o) {
210
- return (0, utils_js_1.readIOFromOptions)(o)
193
+ return (0, utils_js_1.readARIOFromOptions)(o)
211
194
  .getVault({
212
195
  address: (0, utils_js_1.requiredAddressFromOptions)(o),
213
196
  vaultId: (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId'),