@ar.io/sdk 3.4.0-alpha.2 → 3.4.0-alpha.4

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.
@@ -21,6 +21,7 @@ const commander_1 = require("commander");
21
21
  const index_js_1 = require("../node/index.js");
22
22
  const token_js_1 = require("../types/token.js");
23
23
  const version_js_1 = require("../version.js");
24
+ const antCommands_js_1 = require("./commands/antCommands.js");
24
25
  const arnsPurchaseCommands_js_1 = require("./commands/arnsPurchaseCommands.js");
25
26
  const gatewayWriteCommands_js_1 = require("./commands/gatewayWriteCommands.js");
26
27
  const readCommands_js_1 = require("./commands/readCommands.js");
@@ -282,6 +283,24 @@ const utils_js_1 = require("./utils.js");
282
283
  options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.recipient],
283
284
  action: transfer_js_1.revokeVaultCLICommand,
284
285
  });
286
+ (0, utils_js_1.makeCommand)({
287
+ name: 'create-vault',
288
+ description: 'Create a locked vault with balance from the sender',
289
+ options: [...options_js_1.writeActionOptions, options_js_1.optionMap.lockLengthMs, options_js_1.optionMap.quantity],
290
+ action: transfer_js_1.createVaultCLICommand,
291
+ });
292
+ (0, utils_js_1.makeCommand)({
293
+ name: 'extend-vault',
294
+ description: 'Extend the lock length of a vault as the recipient',
295
+ options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.extendLengthMs],
296
+ action: transfer_js_1.extendVaultCLICommand,
297
+ });
298
+ (0, utils_js_1.makeCommand)({
299
+ name: 'increase-vault',
300
+ description: 'Increase the balance of a locked vault as the recipient',
301
+ options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.quantity],
302
+ action: transfer_js_1.increaseVaultCLICommand,
303
+ });
285
304
  (0, utils_js_1.makeCommand)({
286
305
  name: 'join-network',
287
306
  description: 'Join a gateway to the AR.IO network',
@@ -519,25 +538,21 @@ const utils_js_1 = require("./utils.js");
519
538
  });
520
539
  (0, utils_js_1.makeCommand)({
521
540
  name: 'set-ant-record',
522
- description: 'Set a record of an ANT process',
523
- options: [
524
- options_js_1.optionMap.processId,
525
- options_js_1.optionMap.undername,
526
- options_js_1.optionMap.transactionId,
527
- options_js_1.optionMap.ttlSeconds,
528
- ...options_js_1.writeActionOptions,
529
- ],
530
- action: async (options) => {
531
- const ttlSeconds = options.ttlSeconds ?? 3600;
532
- const undername = (0, utils_js_1.requiredStringFromOptions)(options, 'undername');
533
- const transactionId = (0, utils_js_1.requiredStringFromOptions)(options, 'transactionId');
534
- await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this record?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, options);
535
- return (0, utils_js_1.writeANTFromOptions)(options).setRecord({
536
- undername,
537
- transactionId,
538
- ttlSeconds,
539
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
540
- },
541
+ description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
542
+ options: options_js_1.setAntUndernameOptions,
543
+ action: antCommands_js_1.setAntRecordCLICommand,
544
+ });
545
+ (0, utils_js_1.makeCommand)({
546
+ name: 'set-ant-base-name',
547
+ description: 'Set the base name of an ANT process',
548
+ options: options_js_1.setAntBaseNameOptions,
549
+ action: antCommands_js_1.setAntBaseNameCLICommand,
550
+ });
551
+ (0, utils_js_1.makeCommand)({
552
+ name: 'set-ant-undername',
553
+ description: 'Set an undername of an ANT process',
554
+ options: options_js_1.setAntUndernameOptions,
555
+ action: antCommands_js_1.setAntRecordCLICommand,
541
556
  });
542
557
  (0, utils_js_1.makeCommand)({
543
558
  name: 'remove-ant-record',
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setAntUndernameCLICommand = exports.setAntBaseNameCLICommand = exports.setAntRecordCLICommand = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ /** @deprecated -- use set-ant-base-name and set-ant-undername */
6
+ async function setAntRecordCLICommand(o) {
7
+ const ttlSeconds = +(o.ttlSeconds ?? utils_js_1.defaultTtlSecondsCLI);
8
+ const undername = (0, utils_js_1.requiredStringFromOptions)(o, 'undername');
9
+ const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
10
+ const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
11
+ if (!o.skipConfirmation) {
12
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this record on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, o);
13
+ }
14
+ return (0, utils_js_1.writeANTFromOptions)(o).setRecord({
15
+ undername,
16
+ transactionId,
17
+ ttlSeconds,
18
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
19
+ }
20
+ exports.setAntRecordCLICommand = setAntRecordCLICommand;
21
+ async function setAntBaseNameCLICommand(o) {
22
+ const ttlSeconds = +(o.ttlSeconds ?? utils_js_1.defaultTtlSecondsCLI);
23
+ const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
24
+ const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
25
+ if (!o.skipConfirmation) {
26
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this base name on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ transactionId, ttlSeconds }, null, 2)}`, o);
27
+ }
28
+ return (0, utils_js_1.writeANTFromOptions)(o).setBaseNameRecord({
29
+ transactionId,
30
+ ttlSeconds,
31
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
32
+ }
33
+ exports.setAntBaseNameCLICommand = setAntBaseNameCLICommand;
34
+ async function setAntUndernameCLICommand(o) {
35
+ const ttlSeconds = +(o.ttlSeconds ?? utils_js_1.defaultTtlSecondsCLI);
36
+ const undername = (0, utils_js_1.requiredStringFromOptions)(o, 'undername');
37
+ const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
38
+ const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
39
+ if (!o.skipConfirmation) {
40
+ await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this undername on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, o);
41
+ }
42
+ return (0, utils_js_1.writeANTFromOptions)(o).setUndernameRecord({
43
+ undername,
44
+ transactionId,
45
+ ttlSeconds,
46
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
47
+ }
48
+ exports.setAntUndernameCLICommand = setAntUndernameCLICommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.revokeVaultCLICommand = exports.vaultedTransferCLICommand = exports.transferCLICommand = void 0;
3
+ exports.increaseVaultCLICommand = exports.extendVaultCLICommand = exports.createVaultCLICommand = exports.revokeVaultCLICommand = exports.vaultedTransferCLICommand = exports.transferCLICommand = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
5
  async function transferCLICommand(options) {
6
6
  const { target, arioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
@@ -33,6 +33,7 @@ async function vaultedTransferCLICommand(o) {
33
33
  const recipient = (0, utils_js_1.requiredStringFromOptions)(o, 'recipient');
34
34
  const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
35
35
  const lockLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'lockLengthMs');
36
+ (0, utils_js_1.assertLockLengthInRange)(lockLengthMs);
36
37
  if (!o.skipConfirmation) {
37
38
  await (0, utils_js_1.assertEnoughMARIOBalance)({
38
39
  ario,
@@ -84,3 +85,84 @@ async function revokeVaultCLICommand(o) {
84
85
  return output;
85
86
  }
86
87
  exports.revokeVaultCLICommand = revokeVaultCLICommand;
88
+ async function createVaultCLICommand(o) {
89
+ const mARIOQuantity = (0, utils_js_1.requiredMARIOFromOptions)(o, 'quantity');
90
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
91
+ const lockLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'lockLengthMs');
92
+ (0, utils_js_1.assertLockLengthInRange)(lockLengthMs);
93
+ if (!o.skipConfirmation) {
94
+ await (0, utils_js_1.assertEnoughMARIOBalance)({
95
+ ario,
96
+ address: signerAddress,
97
+ mARIOQuantity,
98
+ });
99
+ const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to create a vault with ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO, locked for ${lockLengthMs}ms?`);
100
+ if (!confirm) {
101
+ return { message: 'Vault creation aborted by user' };
102
+ }
103
+ }
104
+ const result = await ario.createVault({
105
+ quantity: mARIOQuantity,
106
+ lockLengthMs,
107
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
108
+ const output = {
109
+ senderAddress: signerAddress,
110
+ transferResult: result,
111
+ message: `Successfully created vault with ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO`,
112
+ };
113
+ return output;
114
+ }
115
+ exports.createVaultCLICommand = createVaultCLICommand;
116
+ async function extendVaultCLICommand(o) {
117
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
118
+ const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
119
+ const extendLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'extendLengthMs');
120
+ (0, utils_js_1.assertLockLengthInRange)(extendLengthMs, false);
121
+ if (!o.skipConfirmation) {
122
+ const vault = await ario.getVault({ vaultId, address: signerAddress });
123
+ if (!vault) {
124
+ throw new Error(`Vault for signer '${signerAddress}' with vault id '${vaultId}' not found`);
125
+ }
126
+ const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to extend vault with id ${vaultId} for ${extendLengthMs}ms?`);
127
+ if (!confirm) {
128
+ return { message: 'Vault extension aborted by user' };
129
+ }
130
+ }
131
+ const result = await ario.extendVault({
132
+ vaultId,
133
+ extendLengthMs,
134
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
135
+ const output = {
136
+ senderAddress: signerAddress,
137
+ transferResult: result,
138
+ message: `Successfully extended vault with id ${vaultId}`,
139
+ };
140
+ return output;
141
+ }
142
+ exports.extendVaultCLICommand = extendVaultCLICommand;
143
+ async function increaseVaultCLICommand(o) {
144
+ const mARIOQuantity = (0, utils_js_1.requiredMARIOFromOptions)(o, 'quantity');
145
+ const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
146
+ const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
147
+ if (!o.skipConfirmation) {
148
+ const vault = await ario.getVault({ vaultId, address: signerAddress });
149
+ if (!vault) {
150
+ throw new Error(`Vault for signer '${signerAddress}' with vault id '${vaultId}' not found`);
151
+ }
152
+ const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to increase vault with id ${vaultId} by ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO?`);
153
+ if (!confirm) {
154
+ return { message: 'Vault increase aborted by user' };
155
+ }
156
+ }
157
+ const result = await ario.increaseVault({
158
+ vaultId,
159
+ quantity: mARIOQuantity,
160
+ }, (0, utils_js_1.writeActionTagsFromOptions)(o));
161
+ const output = {
162
+ senderAddress: signerAddress,
163
+ transferResult: result,
164
+ message: `Successfully increased vault with id ${vaultId} by ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO`,
165
+ };
166
+ return output;
167
+ }
168
+ exports.increaseVaultCLICommand = increaseVaultCLICommand;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.antStateOptions = exports.buyRecordOptions = exports.joinNetworkOptions = exports.updateGatewaySettingsOptions = exports.decreaseDelegateStakeOptions = exports.delegateStakeOptions = exports.redelegateStakeOptions = exports.operatorStakeOptions = exports.vaultedTransferOptions = exports.transferOptions = exports.tokenCostOptions = exports.getVaultOptions = exports.paginationAddressOptions = exports.paginationOptions = exports.nameWriteOptions = exports.addressAndVaultIdOptions = exports.epochOptions = exports.arnsPurchaseOptions = exports.writeActionOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
18
+ exports.setAntUndernameOptions = exports.setAntBaseNameOptions = exports.antStateOptions = exports.buyRecordOptions = exports.joinNetworkOptions = exports.updateGatewaySettingsOptions = exports.decreaseDelegateStakeOptions = exports.delegateStakeOptions = exports.redelegateStakeOptions = exports.operatorStakeOptions = exports.vaultedTransferOptions = exports.transferOptions = exports.tokenCostOptions = exports.getVaultOptions = exports.paginationAddressOptions = exports.paginationOptions = exports.nameWriteOptions = exports.addressAndVaultIdOptions = exports.epochOptions = exports.arnsPurchaseOptions = exports.writeActionOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
19
19
  exports.optionMap = {
20
20
  walletFile: {
21
21
  alias: '-w, --wallet-file <walletFilePath>',
@@ -248,7 +248,11 @@ exports.optionMap = {
248
248
  },
249
249
  lockLengthMs: {
250
250
  alias: '--lock-length-ms <lockLengthMs>',
251
- description: 'The length of time in milliseconds to lock the transfer for',
251
+ description: 'The length of time in milliseconds to lock the vault for',
252
+ },
253
+ extendLengthMs: {
254
+ alias: '--extend-length-ms <extendLengthMs>',
255
+ description: 'The length of time in milliseconds to extend the vault for',
252
256
  },
253
257
  recipient: {
254
258
  alias: '--recipient <recipient>',
@@ -354,3 +358,13 @@ exports.antStateOptions = [
354
358
  exports.optionMap.controllers,
355
359
  exports.optionMap.ttlSeconds,
356
360
  ];
361
+ exports.setAntBaseNameOptions = [
362
+ exports.optionMap.processId,
363
+ exports.optionMap.transactionId,
364
+ exports.optionMap.ttlSeconds,
365
+ ...exports.writeActionOptions,
366
+ ];
367
+ exports.setAntUndernameOptions = [
368
+ ...exports.setAntBaseNameOptions,
369
+ exports.optionMap.undername,
370
+ ];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fundFromFromOptions = exports.getTokenCostParamsFromOptions = exports.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.booleanFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughMARIOBalance = exports.assertEnoughBalanceForArNSPurchase = exports.requiredMARIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.writeActionTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.formatMARIOToARIOWithCommas = exports.formatARIOWithCommas = exports.writeARIOFromOptions = exports.requiredAoSignerFromOptions = exports.requiredContractSignerFromOptions = exports.readARIOFromOptions = exports.getLoggerFromOptions = exports.jwkToAddress = exports.requiredJwkFromOptions = exports.arioProcessIdFromOptions = exports.makeCommand = exports.applyOptions = exports.runCommand = exports.stringifyJsonForCLIDisplay = void 0;
6
+ exports.assertLockLengthInRange = exports.fundFromFromOptions = exports.getTokenCostParamsFromOptions = exports.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.booleanFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughMARIOBalance = exports.assertEnoughBalanceForArNSPurchase = exports.requiredMARIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.writeActionTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.formatMARIOToARIOWithCommas = exports.formatARIOWithCommas = exports.writeARIOFromOptions = exports.requiredAoSignerFromOptions = exports.requiredContractSignerFromOptions = exports.readARIOFromOptions = exports.getLoggerFromOptions = exports.jwkToAddress = exports.requiredJwkFromOptions = exports.arioProcessIdFromOptions = exports.makeCommand = exports.applyOptions = exports.runCommand = exports.stringifyJsonForCLIDisplay = exports.defaultTtlSecondsCLI = void 0;
7
7
  /**
8
8
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
9
9
  *
@@ -25,6 +25,7 @@ const fs_1 = require("fs");
25
25
  const prompts_1 = __importDefault(require("prompts"));
26
26
  const index_js_1 = require("../node/index.js");
27
27
  const options_js_1 = require("./options.js");
28
+ exports.defaultTtlSecondsCLI = 3600;
28
29
  function stringifyJsonForCLIDisplay(json) {
29
30
  return JSON.stringify(json, null, 2);
30
31
  }
@@ -428,7 +429,9 @@ function getANTStateFromOptions(options) {
428
429
  ticker: options.ticker,
429
430
  name: options.name,
430
431
  keywords: options.keywords,
431
- ttlSeconds: options.ttlSeconds !== undefined ? +options.ttlSeconds : 3600,
432
+ ttlSeconds: options.ttlSeconds !== undefined
433
+ ? +options.ttlSeconds
434
+ : exports.defaultTtlSecondsCLI,
432
435
  });
433
436
  }
434
437
  exports.getANTStateFromOptions = getANTStateFromOptions;
@@ -461,3 +464,17 @@ function fundFromFromOptions(o) {
461
464
  return o.fundFrom ?? 'balance';
462
465
  }
463
466
  exports.fundFromFromOptions = fundFromFromOptions;
467
+ function assertLockLengthInRange(lockLengthMs, assertMin = true) {
468
+ const minLockLengthMs = 1209600000; // 14 days
469
+ const maxLockLengthMs = 378432000000; // ~12 years
470
+ if (lockLengthMs > maxLockLengthMs) {
471
+ throw new Error(`Lock length must be at most 12 years (378432000000 ms). Provided lock length: ${lockLengthMs} ms`);
472
+ }
473
+ if (!assertMin) {
474
+ return;
475
+ }
476
+ if (lockLengthMs < minLockLengthMs) {
477
+ throw new Error(`Lock length must be at least 14 days (1209600000 ms). Provided lock length: ${lockLengthMs} ms`);
478
+ }
479
+ }
480
+ exports.assertLockLengthInRange = assertLockLengthInRange;
@@ -34,6 +34,7 @@ class ANT {
34
34
  exports.ANT = ANT;
35
35
  class AoANTReadable {
36
36
  process;
37
+ processId;
37
38
  strict;
38
39
  constructor(config) {
39
40
  this.strict = config.strict || false;
@@ -48,6 +49,7 @@ class AoANTReadable {
48
49
  else {
49
50
  throw new index_js_2.InvalidContractConfigurationError();
50
51
  }
52
+ this.processId = this.process.processId;
51
53
  }
52
54
  async getState({ strict } = { strict: this.strict }) {
53
55
  const tags = [{ name: 'Action', value: 'State' }];
@@ -292,12 +294,8 @@ class AoANTWriteable extends AoANTReadable {
292
294
  * @param transactionId @type {string} The transactionId of the record.
293
295
  * @param ttlSeconds @type {number} The time to live of the record.
294
296
  * @returns {Promise<AoMessageResult>} The result of the interaction.
295
- * @example
296
- * ```ts
297
- * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
298
- * ```
299
297
  */
300
- async setRecord({ undername, transactionId, ttlSeconds, }, options) {
298
+ async setRecord({ undername, transactionId, ttlSeconds }, options) {
301
299
  return this.process.send({
302
300
  tags: [
303
301
  ...(options?.tags ?? []),
@@ -320,16 +318,12 @@ class AoANTWriteable extends AoANTReadable {
320
318
  * ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
321
319
  * ```
322
320
  */
323
- async setBaseNameRecord({ transactionId, ttlSeconds, }) {
324
- return this.process.send({
325
- tags: [
326
- { name: 'Action', value: 'Set-Record' },
327
- { name: 'Sub-Domain', value: '@' },
328
- { name: 'Transaction-Id', value: transactionId },
329
- { name: 'TTL-Seconds', value: ttlSeconds.toString() },
330
- ],
331
- signer: this.signer,
332
- });
321
+ async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
322
+ return this.setRecord({
323
+ transactionId,
324
+ ttlSeconds,
325
+ undername: '@',
326
+ }, options);
333
327
  }
334
328
  /**
335
329
  * Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
@@ -343,12 +337,12 @@ class AoANTWriteable extends AoANTReadable {
343
337
  * ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
344
338
  * ```
345
339
  */
346
- async setUndernameRecord({ undername, transactionId, ttlSeconds, }) {
340
+ async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
347
341
  return this.setRecord({
348
342
  undername,
349
343
  transactionId,
350
344
  ttlSeconds,
351
- });
345
+ }, options);
352
346
  }
353
347
  /**
354
348
  * Removes an undername from the ANT. This will remove the undername from the ANT.
@@ -518,6 +518,42 @@ class ARIOWriteable extends ARIOReadable {
518
518
  signer: this.signer,
519
519
  });
520
520
  }
521
+ async createVault({ lockLengthMs, quantity }, options) {
522
+ const { tags = [] } = options || {};
523
+ return this.process.send({
524
+ tags: [
525
+ ...tags,
526
+ { name: 'Action', value: 'Create-Vault' },
527
+ { name: 'Lock-Length', value: lockLengthMs.toString() },
528
+ { name: 'Quantity', value: quantity.toString() },
529
+ ],
530
+ signer: this.signer,
531
+ });
532
+ }
533
+ async extendVault({ vaultId, extendLengthMs }, options) {
534
+ const { tags = [] } = options || {};
535
+ return this.process.send({
536
+ tags: [
537
+ ...tags,
538
+ { name: 'Action', value: 'Extend-Vault' },
539
+ { name: 'Vault-Id', value: vaultId },
540
+ { name: 'Extend-Length', value: extendLengthMs.toString() },
541
+ ],
542
+ signer: this.signer,
543
+ });
544
+ }
545
+ async increaseVault({ vaultId, quantity }, options) {
546
+ const { tags = [] } = options || {};
547
+ return this.process.send({
548
+ tags: [
549
+ ...tags,
550
+ { name: 'Action', value: 'Increase-Vault' },
551
+ { name: 'Vault-Id', value: vaultId },
552
+ { name: 'Quantity', value: quantity.toString() },
553
+ ],
554
+ signer: this.signer,
555
+ });
556
+ }
521
557
  async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
522
558
  const { tags = [] } = options || {};
523
559
  const allTags = [
@@ -24,7 +24,7 @@ const isValidFundFrom = (fundFrom) => {
24
24
  return exports.fundFromOptions.indexOf(fundFrom) !== -1;
25
25
  };
26
26
  exports.isValidFundFrom = isValidFundFrom;
27
- // Typeguard functions
27
+ // Type-guard functions
28
28
  function isProcessConfiguration(config) {
29
29
  return 'process' in config;
30
30
  }
@@ -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.4.0-alpha.2';
20
+ exports.version = '3.4.0-alpha.4';
@@ -19,11 +19,12 @@ import { program } from 'commander';
19
19
  import { AOProcess, spawnANT } from '../node/index.js';
20
20
  import { mARIOToken } from '../types/token.js';
21
21
  import { version } from '../version.js';
22
+ import { setAntBaseNameCLICommand, setAntRecordCLICommand, } from './commands/antCommands.js';
22
23
  import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
23
24
  import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
24
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 { revokeVaultCLICommand, transferCLICommand, vaultedTransferCLICommand, } from './commands/transfer.js';
26
- import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, vaultedTransferOptions, writeActionOptions, } from './options.js';
26
+ import { createVaultCLICommand, extendVaultCLICommand, increaseVaultCLICommand, revokeVaultCLICommand, transferCLICommand, vaultedTransferCLICommand, } from './commands/transfer.js';
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';
27
28
  import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
28
29
  applyOptions(program
29
30
  .name('ar.io')
@@ -280,6 +281,24 @@ makeCommand({
280
281
  options: [...writeActionOptions, optionMap.vaultId, optionMap.recipient],
281
282
  action: revokeVaultCLICommand,
282
283
  });
284
+ makeCommand({
285
+ name: 'create-vault',
286
+ description: 'Create a locked vault with balance from the sender',
287
+ options: [...writeActionOptions, optionMap.lockLengthMs, optionMap.quantity],
288
+ action: createVaultCLICommand,
289
+ });
290
+ makeCommand({
291
+ name: 'extend-vault',
292
+ description: 'Extend the lock length of a vault as the recipient',
293
+ options: [...writeActionOptions, optionMap.vaultId, optionMap.extendLengthMs],
294
+ action: extendVaultCLICommand,
295
+ });
296
+ makeCommand({
297
+ name: 'increase-vault',
298
+ description: 'Increase the balance of a locked vault as the recipient',
299
+ options: [...writeActionOptions, optionMap.vaultId, optionMap.quantity],
300
+ action: increaseVaultCLICommand,
301
+ });
283
302
  makeCommand({
284
303
  name: 'join-network',
285
304
  description: 'Join a gateway to the AR.IO network',
@@ -517,25 +536,21 @@ makeCommand({
517
536
  });
518
537
  makeCommand({
519
538
  name: 'set-ant-record',
520
- description: 'Set a record of an ANT process',
521
- options: [
522
- optionMap.processId,
523
- optionMap.undername,
524
- optionMap.transactionId,
525
- optionMap.ttlSeconds,
526
- ...writeActionOptions,
527
- ],
528
- action: async (options) => {
529
- const ttlSeconds = options.ttlSeconds ?? 3600;
530
- const undername = requiredStringFromOptions(options, 'undername');
531
- const transactionId = requiredStringFromOptions(options, 'transactionId');
532
- await assertConfirmationPrompt(`Are you sure you want to set this record?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, options);
533
- return writeANTFromOptions(options).setRecord({
534
- undername,
535
- transactionId,
536
- ttlSeconds,
537
- }, writeActionTagsFromOptions(options));
538
- },
539
+ description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
540
+ options: setAntUndernameOptions,
541
+ action: setAntRecordCLICommand,
542
+ });
543
+ makeCommand({
544
+ name: 'set-ant-base-name',
545
+ description: 'Set the base name of an ANT process',
546
+ options: setAntBaseNameOptions,
547
+ action: setAntBaseNameCLICommand,
548
+ });
549
+ makeCommand({
550
+ name: 'set-ant-undername',
551
+ description: 'Set an undername of an ANT process',
552
+ options: setAntUndernameOptions,
553
+ action: setAntRecordCLICommand,
539
554
  });
540
555
  makeCommand({
541
556
  name: 'remove-ant-record',
@@ -0,0 +1,42 @@
1
+ import { assertConfirmationPrompt, defaultTtlSecondsCLI, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from '../utils.js';
2
+ /** @deprecated -- use set-ant-base-name and set-ant-undername */
3
+ export async function setAntRecordCLICommand(o) {
4
+ const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
5
+ const undername = requiredStringFromOptions(o, 'undername');
6
+ const transactionId = requiredStringFromOptions(o, 'transactionId');
7
+ const writeAnt = writeANTFromOptions(o);
8
+ if (!o.skipConfirmation) {
9
+ await assertConfirmationPrompt(`Are you sure you want to set this record on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, o);
10
+ }
11
+ return writeANTFromOptions(o).setRecord({
12
+ undername,
13
+ transactionId,
14
+ ttlSeconds,
15
+ }, writeActionTagsFromOptions(o));
16
+ }
17
+ export async function setAntBaseNameCLICommand(o) {
18
+ const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
19
+ const transactionId = requiredStringFromOptions(o, 'transactionId');
20
+ const writeAnt = writeANTFromOptions(o);
21
+ if (!o.skipConfirmation) {
22
+ await assertConfirmationPrompt(`Are you sure you want to set this base name on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ transactionId, ttlSeconds }, null, 2)}`, o);
23
+ }
24
+ return writeANTFromOptions(o).setBaseNameRecord({
25
+ transactionId,
26
+ ttlSeconds,
27
+ }, writeActionTagsFromOptions(o));
28
+ }
29
+ export async function setAntUndernameCLICommand(o) {
30
+ const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
31
+ const undername = requiredStringFromOptions(o, 'undername');
32
+ const transactionId = requiredStringFromOptions(o, 'transactionId');
33
+ const writeAnt = writeANTFromOptions(o);
34
+ if (!o.skipConfirmation) {
35
+ await assertConfirmationPrompt(`Are you sure you want to set this undername on the ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, transactionId, ttlSeconds }, null, 2)}`, o);
36
+ }
37
+ return writeANTFromOptions(o).setUndernameRecord({
38
+ undername,
39
+ transactionId,
40
+ ttlSeconds,
41
+ }, writeActionTagsFromOptions(o));
42
+ }