@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
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomInt = void 0;
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
+ const crypto_1 = require("crypto");
20
+ /**
21
+ * Cryptographically secure helper for randomness, does not support seeding
22
+ * @param min - the minimum value
23
+ * @param max - the maximum value
24
+ * @returns a random integer between min and max
25
+ */
26
+ const randomInt = (min, max) => {
27
+ const [rand] = crypto_1.webcrypto.getRandomValues(new Uint32Array(1));
28
+ return min + (rand % (max - min));
29
+ };
30
+ exports.randomInt = randomInt;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.urlWithSearchParams = void 0;
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
+ const urlWithSearchParams = ({ baseUrl, params, }) => {
20
+ const urlObj = new URL(baseUrl);
21
+ Object.entries(params).forEach(([key, value]) => {
22
+ if (value === undefined || value === null)
23
+ return;
24
+ urlObj.searchParams.set(key, value.toString());
25
+ });
26
+ return urlObj.toString();
27
+ };
28
+ exports.urlWithSearchParams = urlWithSearchParams;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const url_js_1 = require("./url.js");
9
+ (0, node_test_1.test)('urlWithSearchParams prunes undefined values but keeps other falsey values', () => {
10
+ const result = (0, url_js_1.urlWithSearchParams)({
11
+ baseUrl: 'https://example.com',
12
+ params: {
13
+ number: 1,
14
+ string: 'string',
15
+ boolean: true,
16
+ empty: '',
17
+ zero: 0,
18
+ false: false,
19
+ null: null,
20
+ undef: undefined,
21
+ },
22
+ });
23
+ node_assert_1.default.strictEqual(result, 'https://example.com/?number=1&string=string&boolean=true&empty=&zero=0&false=false');
24
+ });
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_assert_1 = require("node:assert");
4
4
  const node_test_1 = require("node:test");
5
+ const ao_js_1 = require("./ao.js");
5
6
  const arweave_js_1 = require("./arweave.js");
6
- const index_js_1 = require("./index.js");
7
7
  (0, node_test_1.describe)('pruneTags', () => {
8
8
  (0, node_test_1.it)('should remove tags with undefined values', () => {
9
9
  const tags = [
@@ -45,7 +45,7 @@ const index_js_1 = require("./index.js");
45
45
  const output = {
46
46
  Error: 'Error message',
47
47
  };
48
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
48
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
49
49
  node_assert_1.strict.equal(errorMessage, 'Error message');
50
50
  });
51
51
  (0, node_test_1.it)('should return error message from Error tag', () => {
@@ -56,7 +56,7 @@ const index_js_1 = require("./index.js");
56
56
  },
57
57
  ],
58
58
  };
59
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
59
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
60
60
  node_assert_1.strict.equal(errorMessage, 'Error message');
61
61
  });
62
62
  (0, node_test_1.it)('should return error message from Error tag if Error field is undefined', () => {
@@ -67,7 +67,7 @@ const index_js_1 = require("./index.js");
67
67
  },
68
68
  ],
69
69
  };
70
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
70
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
71
71
  node_assert_1.strict.equal(errorMessage, 'Error message');
72
72
  });
73
73
  (0, node_test_1.it)('should return undefined if no error message is present', () => {
@@ -78,21 +78,21 @@ const index_js_1 = require("./index.js");
78
78
  },
79
79
  ],
80
80
  };
81
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
81
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
82
82
  node_assert_1.strict.equal(errorMessage, undefined);
83
83
  });
84
84
  (0, node_test_1.it)('should return error message with line number', () => {
85
85
  const output = {
86
86
  Error: '[string "aos"]:123: Error message',
87
87
  };
88
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
88
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
89
89
  node_assert_1.strict.equal(errorMessage, 'Error message (line 123)');
90
90
  });
91
91
  (0, node_test_1.it)('should return error message with line number and remove unicode', () => {
92
92
  const output = {
93
93
  Error: '[string "aos"]:123: Error message\u001b[0m',
94
94
  };
95
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
95
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
96
96
  node_assert_1.strict.equal(errorMessage, 'Error message (line 123)');
97
97
  });
98
98
  const knownErrorMessages = '\u001b[31mError\u001b[90m handling message with Action = Register\u001b[0m\n\u001b[32m[string ".handlers"]:723: [string "aos"]:128: Already registered\u001b[0m\n\n\u001b[90mstack traceback:\n\t[string ".process"]:871: in function \'.process.handle\'\u001b[0m\n\n\u001b[31merror:\n\u001b[0m[string ".handlers"]:723: [string "aos"]:128: Already registered';
@@ -100,7 +100,7 @@ const index_js_1 = require("./index.js");
100
100
  const output = {
101
101
  Error: knownErrorMessages,
102
102
  };
103
- const errorMessage = (0, index_js_1.errorMessageFromOutput)(output);
103
+ const errorMessage = (0, ao_js_1.errorMessageFromOutput)(output);
104
104
  node_assert_1.strict.equal(errorMessage, 'Already registered (line 128)');
105
105
  });
106
106
  });
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '3.10.2';
20
+ exports.version = '3.11.0-alpha.10';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ArconnectSigner = exports.ArweaveSigner = void 0;
17
+ exports.EthereumSigner = exports.InjectedEthereumSigner = exports.ArconnectSigner = exports.ArweaveSigner = void 0;
18
18
  /**
19
19
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
20
20
  *
@@ -33,6 +33,8 @@ exports.ArconnectSigner = exports.ArweaveSigner = void 0;
33
33
  var arbundles_1 = require("@dha-team/arbundles");
34
34
  Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return arbundles_1.ArweaveSigner; } });
35
35
  Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return arbundles_1.ArconnectSigner; } });
36
+ Object.defineProperty(exports, "InjectedEthereumSigner", { enumerable: true, get: function () { return arbundles_1.InjectedEthereumSigner; } });
37
+ Object.defineProperty(exports, "EthereumSigner", { enumerable: true, get: function () { return arbundles_1.EthereumSigner; } });
36
38
  __exportStar(require("../types/index.js"), exports);
37
39
  __exportStar(require("../common/index.js"), exports);
38
40
  __exportStar(require("../constants.js"), exports);
@@ -22,7 +22,7 @@ import { version } from '../version.js';
22
22
  import { setAntBaseNameCLICommand, setAntRecordCLICommand, } from './commands/antCommands.js';
23
23
  import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
24
24
  import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
25
- import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
25
+ import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
26
26
  import { createVaultCLICommand, extendVaultCLICommand, increaseVaultCLICommand, revokeVaultCLICommand, transferCLICommand, vaultedTransferCLICommand, } from './commands/transfer.js';
27
27
  import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, setAntBaseNameOptions, setAntUndernameOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, vaultedTransferOptions, writeActionOptions, } from './options.js';
28
28
  import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, customTagsFromOptions, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, } from './utils.js';
@@ -31,6 +31,7 @@ applyOptions(program
31
31
  .version(version)
32
32
  .description('AR.IO Network CLI')
33
33
  .helpCommand(true), globalOptions);
34
+ // # Getters
34
35
  makeCommand({
35
36
  name: 'info',
36
37
  description: 'Get network info',
@@ -41,6 +42,18 @@ makeCommand({
41
42
  description: 'Get the total token supply',
42
43
  action: (options) => readARIOFromOptions(options).getTokenSupply(),
43
44
  });
45
+ makeCommand({
46
+ name: 'balance',
47
+ description: 'Get the balance of an address',
48
+ options: [optionMap.address],
49
+ action: (options) => readARIOFromOptions(options)
50
+ .getBalance({ address: requiredAddressFromOptions(options) })
51
+ .then((result) => ({
52
+ address: requiredAddressFromOptions(options),
53
+ mARIOBalance: result,
54
+ message: `Provided address current has a balance of ${formatARIOWithCommas(new mARIOToken(result).toARIO())} ARIO`,
55
+ })),
56
+ });
44
57
  makeCommand({
45
58
  name: 'get-registration-fees',
46
59
  description: 'Get registration fees',
@@ -67,24 +80,18 @@ makeCommand({
67
80
  options: [optionMap.address],
68
81
  action: getGateway,
69
82
  });
70
- makeCommand({
71
- name: 'list-gateways',
72
- description: 'List the gateways of the network',
73
- options: paginationOptions,
74
- action: listGateways,
75
- });
76
- makeCommand({
77
- name: 'list-all-delegates',
78
- description: 'List all paginated delegates from all gateways',
79
- options: paginationOptions,
80
- action: listAllDelegatesCLICommand,
81
- });
82
83
  makeCommand({
83
84
  name: 'get-gateway-delegates',
84
85
  description: 'Get the delegates of a gateway',
85
86
  options: paginationAddressOptions,
86
87
  action: getGatewayDelegates,
87
88
  });
89
+ makeCommand({
90
+ name: 'get-gateway-vaults',
91
+ description: 'Get the vaults of a gateway',
92
+ options: paginationAddressOptions,
93
+ action: getGatewayVaults,
94
+ });
88
95
  makeCommand({
89
96
  name: 'get-delegations',
90
97
  description: 'Get all stake delegated to gateways from this address',
@@ -103,36 +110,18 @@ makeCommand({
103
110
  options: [optionMap.name],
104
111
  action: getArNSRecord,
105
112
  });
106
- makeCommand({
107
- name: 'list-arns-records',
108
- description: 'List all ArNS records',
109
- options: paginationOptions,
110
- action: listArNSRecords,
111
- });
112
113
  makeCommand({
113
114
  name: 'get-arns-reserved-name',
114
115
  description: 'Get a reserved ArNS name',
115
116
  options: [optionMap.name],
116
117
  action: getArNSReservedName,
117
118
  });
118
- makeCommand({
119
- name: 'list-arns-reserved-names',
120
- description: 'Get all reserved ArNS names',
121
- options: paginationOptions,
122
- action: listArNSReservedNames,
123
- });
124
119
  makeCommand({
125
120
  name: 'get-arns-returned-name',
126
121
  description: 'Get an ArNS returned name by name',
127
122
  options: [optionMap.name],
128
123
  action: getArNSReturnedName,
129
124
  });
130
- makeCommand({
131
- name: 'list-arns-returned-names',
132
- description: 'Get all ArNS recently returned names',
133
- options: paginationOptions,
134
- action: listArNSReturnedNames,
135
- });
136
125
  makeCommand({
137
126
  name: 'get-epoch',
138
127
  description: 'Get epoch data',
@@ -193,14 +182,11 @@ makeCommand({
193
182
  action: getCostDetails,
194
183
  });
195
184
  makeCommand({
196
- name: 'list-vaults',
197
- description: 'Get all wallet vaults',
198
- options: paginationOptions,
199
- action: (o) => readARIOFromOptions(o)
200
- .getVaults(paginationParamsFromOptions(o))
201
- .then((result) => result.items.length ? result : { message: 'No vaults found' }),
185
+ name: 'get-primary-name',
186
+ description: 'Get primary name',
187
+ options: [optionMap.address, optionMap.name],
188
+ action: getPrimaryName,
202
189
  });
203
- // TODO: Could assert valid arweave (or ETH) addresses at CLI level when coming from options (no need from wallet)
204
190
  makeCommand({
205
191
  name: 'get-primary-name-request',
206
192
  description: 'Get primary name request',
@@ -213,6 +199,66 @@ makeCommand({
213
199
  message: `No primary name request found`,
214
200
  }),
215
201
  });
202
+ makeCommand({
203
+ name: 'get-redelegation-fee',
204
+ description: 'Get redelegation fee',
205
+ options: [optionMap.address],
206
+ action: (options) => readARIOFromOptions(options).getRedelegationFee({
207
+ address: requiredAddressFromOptions(options),
208
+ }),
209
+ });
210
+ makeCommand({
211
+ name: 'get-vault',
212
+ description: 'Get the vault of provided address and vault ID',
213
+ options: getVaultOptions,
214
+ action: getVault,
215
+ });
216
+ // # ArNS Resolution
217
+ makeCommand({
218
+ name: 'resolve-arns-name',
219
+ description: 'Resolve an ArNS name',
220
+ options: [optionMap.name],
221
+ action: resolveArNSName,
222
+ });
223
+ // # Paginated handlers
224
+ makeCommand({
225
+ name: 'list-gateways',
226
+ description: 'List the gateways of the network',
227
+ options: paginationOptions,
228
+ action: listGateways,
229
+ });
230
+ makeCommand({
231
+ name: 'list-all-delegates',
232
+ description: 'List all paginated delegates from all gateways',
233
+ options: paginationOptions,
234
+ action: listAllDelegatesCLICommand,
235
+ });
236
+ makeCommand({
237
+ name: 'list-arns-records',
238
+ description: 'List all ArNS records',
239
+ options: paginationOptions,
240
+ action: listArNSRecords,
241
+ });
242
+ makeCommand({
243
+ name: 'list-arns-reserved-names',
244
+ description: 'Get all reserved ArNS names',
245
+ options: paginationOptions,
246
+ action: listArNSReservedNames,
247
+ });
248
+ makeCommand({
249
+ name: 'list-arns-returned-names',
250
+ description: 'Get all ArNS recently returned names',
251
+ options: paginationOptions,
252
+ action: listArNSReturnedNames,
253
+ });
254
+ makeCommand({
255
+ name: 'list-vaults',
256
+ description: 'Get all wallet vaults',
257
+ options: paginationOptions,
258
+ action: (o) => readARIOFromOptions(o)
259
+ .getVaults(paginationParamsFromOptions(o))
260
+ .then((result) => result.items.length ? result : { message: 'No vaults found' }),
261
+ });
216
262
  makeCommand({
217
263
  name: 'list-primary-name-requests',
218
264
  description: 'Get primary name requests',
@@ -221,12 +267,6 @@ makeCommand({
221
267
  .getPrimaryNameRequests(paginationParamsFromOptions(o))
222
268
  .then((result) => result.items.length ? result : { message: 'No requests found' }),
223
269
  });
224
- makeCommand({
225
- name: 'get-primary-name',
226
- description: 'Get primary name',
227
- options: [optionMap.address, optionMap.name],
228
- action: getPrimaryName,
229
- });
230
270
  makeCommand({
231
271
  name: 'list-primary-names',
232
272
  description: 'Get primary names',
@@ -235,18 +275,6 @@ makeCommand({
235
275
  .getPrimaryNames(paginationParamsFromOptions(o))
236
276
  .then((result) => result.items.length ? result : { message: 'No names found' }),
237
277
  });
238
- makeCommand({
239
- name: 'balance',
240
- description: 'Get the balance of an address',
241
- options: [optionMap.address],
242
- action: (options) => readARIOFromOptions(options)
243
- .getBalance({ address: requiredAddressFromOptions(options) })
244
- .then((result) => ({
245
- address: requiredAddressFromOptions(options),
246
- mARIOBalance: result,
247
- message: `Provided address current has a balance of ${formatARIOWithCommas(new mARIOToken(result).toARIO())} ARIO`,
248
- })),
249
- });
250
278
  makeCommand({
251
279
  name: 'list-balances',
252
280
  description: 'List all balances',
@@ -255,32 +283,13 @@ makeCommand({
255
283
  .getBalances(paginationParamsFromOptions(o))
256
284
  .then((result) => result.items.length ? result : { message: 'No balances found' }),
257
285
  });
258
- makeCommand({
259
- name: 'get-redelegation-fee',
260
- description: 'Get redelegation fee',
261
- options: [optionMap.address],
262
- action: (options) => readARIOFromOptions(options).getRedelegationFee({
263
- address: requiredAddressFromOptions(options),
264
- }),
265
- });
266
- makeCommand({
267
- name: 'get-vault',
268
- description: 'Get the vault of provided address and vault ID',
269
- options: getVaultOptions,
270
- action: getVault,
271
- });
272
- makeCommand({
273
- name: 'get-gateway-vaults',
274
- description: 'Get the vaults of a gateway',
275
- options: paginationAddressOptions,
276
- action: getGatewayVaults,
277
- });
278
286
  makeCommand({
279
287
  name: 'list-all-gateway-vaults',
280
288
  description: 'List vaults from all gateways',
281
289
  options: paginationAddressOptions,
282
290
  action: getAllGatewayVaults,
283
291
  });
292
+ // # Actions
284
293
  makeCommand({
285
294
  name: 'transfer',
286
295
  description: 'Transfer ARIO to another address',
@@ -416,24 +425,8 @@ makeCommand({
416
425
  options: arnsPurchaseOptions,
417
426
  action: requestPrimaryNameCLICommand,
418
427
  });
419
- makeCommand({
420
- name: 'spawn-ant',
421
- description: 'Spawn an ANT process',
422
- options: antStateOptions,
423
- action: async (options) => {
424
- const state = getANTStateFromOptions(options);
425
- const antProcessId = await spawnANT({
426
- state,
427
- signer: requiredAoSignerFromOptions(options),
428
- logger: getLoggerFromOptions(options),
429
- });
430
- return {
431
- processId: antProcessId,
432
- state,
433
- message: `Spawned ANT process with process ID ${antProcessId}`,
434
- };
435
- },
436
- });
428
+ // # ANTS
429
+ // # Getters
437
430
  makeCommand({
438
431
  name: 'get-ant-state',
439
432
  description: 'Get the state of an ANT process',
@@ -460,14 +453,6 @@ makeCommand({
460
453
  })) ?? { message: 'No record found' });
461
454
  },
462
455
  });
463
- makeCommand({
464
- name: 'list-ant-records',
465
- description: 'Get the records of an ANT process',
466
- options: [optionMap.processId],
467
- action: async (options) => {
468
- return readANTFromOptions(options).getRecords();
469
- },
470
- });
471
456
  makeCommand({
472
457
  name: 'get-ant-owner',
473
458
  description: 'Get the owner of an ANT process',
@@ -476,14 +461,6 @@ makeCommand({
476
461
  return readANTFromOptions(options).getOwner();
477
462
  },
478
463
  });
479
- makeCommand({
480
- name: 'list-ant-controllers',
481
- description: 'List the controllers of an ANT process',
482
- options: [optionMap.processId],
483
- action: async (options) => {
484
- return readANTFromOptions(options).getControllers();
485
- },
486
- });
487
464
  makeCommand({
488
465
  name: 'get-ant-name',
489
466
  description: 'Get the name of an ANT process',
@@ -510,6 +487,42 @@ makeCommand({
510
487
  });
511
488
  },
512
489
  });
490
+ // # Spawn
491
+ makeCommand({
492
+ name: 'spawn-ant',
493
+ description: 'Spawn an ANT process',
494
+ options: antStateOptions,
495
+ action: async (options) => {
496
+ const state = getANTStateFromOptions(options);
497
+ const antProcessId = await spawnANT({
498
+ state,
499
+ signer: requiredAoSignerFromOptions(options),
500
+ logger: getLoggerFromOptions(options),
501
+ });
502
+ return {
503
+ processId: antProcessId,
504
+ state,
505
+ message: `Spawned ANT process with process ID ${antProcessId}`,
506
+ };
507
+ },
508
+ });
509
+ // # ANT Paginated Handlers
510
+ makeCommand({
511
+ name: 'list-ant-records',
512
+ description: 'Get the records of an ANT process',
513
+ options: [optionMap.processId],
514
+ action: async (options) => {
515
+ return readANTFromOptions(options).getRecords();
516
+ },
517
+ });
518
+ makeCommand({
519
+ name: 'list-ant-controllers',
520
+ description: 'List the controllers of an ANT process',
521
+ options: [optionMap.processId],
522
+ action: async (options) => {
523
+ return readANTFromOptions(options).getControllers();
524
+ },
525
+ });
513
526
  makeCommand({
514
527
  name: 'list-ant-balances',
515
528
  description: 'Get the balances of an ANT process',
@@ -518,6 +531,7 @@ makeCommand({
518
531
  return readANTFromOptions(options).getBalances();
519
532
  },
520
533
  });
534
+ // # Actions
521
535
  makeCommand({
522
536
  name: 'transfer-ant-ownership',
523
537
  description: 'Transfer ownership of an ANT process',
@@ -552,6 +566,18 @@ makeCommand({
552
566
  }, customTagsFromOptions(options));
553
567
  },
554
568
  });
569
+ makeCommand({
570
+ name: 'remove-ant-record',
571
+ description: 'Remove a record from an ANT process',
572
+ options: [optionMap.processId, optionMap.undername, ...writeActionOptions],
573
+ action: async (options) => {
574
+ const undername = requiredStringFromOptions(options, 'undername');
575
+ await assertConfirmationPrompt(`Are you sure you want to remove the record with undername ${undername}?`, options);
576
+ return writeANTFromOptions(options).removeRecord({
577
+ undername,
578
+ }, customTagsFromOptions(options));
579
+ },
580
+ });
555
581
  makeCommand({
556
582
  name: 'set-ant-record',
557
583
  description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
@@ -570,18 +596,6 @@ makeCommand({
570
596
  options: setAntUndernameOptions,
571
597
  action: setAntRecordCLICommand,
572
598
  });
573
- makeCommand({
574
- name: 'remove-ant-record',
575
- description: 'Remove a record from an ANT process',
576
- options: [optionMap.processId, optionMap.undername, ...writeActionOptions],
577
- action: async (options) => {
578
- const undername = requiredStringFromOptions(options, 'undername');
579
- await assertConfirmationPrompt(`Are you sure you want to remove the record with undername ${undername}?`, options);
580
- return writeANTFromOptions(options).removeRecord({
581
- undername,
582
- }, customTagsFromOptions(options));
583
- },
584
- });
585
599
  makeCommand({
586
600
  name: 'set-ant-ticker',
587
601
  description: 'Set the ticker of an ANT process',
@@ -642,11 +656,11 @@ makeCommand({
642
656
  const txId = requiredStringFromOptions(options, 'transactionId');
643
657
  await assertConfirmationPrompt(`Are you sure you want to set the ANT logo to target Arweave TxID ${txId}?`, options);
644
658
  return writeANTFromOptions(options).setLogo({
645
- // TODO: Could take a logo file, upload it to Arweave, get transaction ID
646
659
  txId,
647
660
  }, customTagsFromOptions(options));
648
661
  },
649
662
  });
663
+ // # ARIO Actions
650
664
  makeCommand({
651
665
  name: 'release-name',
652
666
  description: 'Release the name of an ANT process',
@@ -713,6 +727,7 @@ makeCommand({
713
727
  }, customTagsFromOptions(options));
714
728
  },
715
729
  });
730
+ // # Utilities
716
731
  makeCommand({
717
732
  name: 'write-action',
718
733
  description: 'Send a write action to an AO Process',
@@ -165,3 +165,8 @@ export async function getVault(o) {
165
165
  message: `No vault found for provided address and vault ID`,
166
166
  });
167
167
  }
168
+ export async function resolveArNSName(o) {
169
+ const name = requiredStringFromOptions(o, 'name');
170
+ const result = await readARIOFromOptions(o).resolveArNSName({ name });
171
+ return result ?? { message: `No record found for name ${name}` };
172
+ }
@@ -49,6 +49,10 @@ export const optionMap = {
49
49
  alias: '--cu-url <cuUrl>',
50
50
  description: 'The URL for a custom compute unit',
51
51
  },
52
+ paymentUrl: {
53
+ alias: '--payment-url <paymentUrl>',
54
+ description: 'The URL for a custom turbo payment service',
55
+ },
52
56
  processId: {
53
57
  alias: '--process-id <processId>',
54
58
  description: 'The process ID to interact with',
@@ -269,9 +273,15 @@ export const optionMap = {
269
273
  alias: '--logo <logo>',
270
274
  description: 'The ANT logo',
271
275
  },
276
+ token: {
277
+ alias: '-t, --token <type>',
278
+ description: 'Crypto token type for wallet or action',
279
+ default: 'arweave',
280
+ },
272
281
  };
273
282
  export const walletOptions = [
274
283
  optionMap.walletFile,
284
+ optionMap.token,
275
285
  // optionMap.mnemonic,
276
286
  optionMap.privateKey,
277
287
  ];
@@ -289,6 +299,7 @@ export const arnsPurchaseOptions = [
289
299
  ...writeActionOptions,
290
300
  optionMap.name,
291
301
  optionMap.fundFrom,
302
+ optionMap.paymentUrl,
292
303
  ];
293
304
  export const epochOptions = [optionMap.epochIndex, optionMap.timestamp];
294
305
  export const addressAndVaultIdOptions = [optionMap.address, optionMap.vaultId];
@@ -312,6 +323,7 @@ export const tokenCostOptions = [
312
323
  optionMap.quantity,
313
324
  optionMap.address,
314
325
  optionMap.fundFrom,
326
+ optionMap.paymentUrl,
315
327
  ];
316
328
  export const transferOptions = [
317
329
  ...writeActionOptions,