@ar.io/sdk 3.3.1 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -2
- package/bundles/web.bundle.min.js +2 -2
- package/lib/cjs/cli/cli.js +13 -1
- package/lib/cjs/cli/commands/transfer.js +59 -3
- package/lib/cjs/cli/options.js +21 -1
- package/lib/cjs/cli/utils.js +5 -1
- package/lib/cjs/common/ant.js +97 -2
- package/lib/cjs/common/io.js +26 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +15 -3
- package/lib/esm/cli/commands/transfer.js +56 -2
- package/lib/esm/cli/options.js +20 -0
- package/lib/esm/cli/utils.js +3 -0
- package/lib/esm/common/ant.js +97 -2
- package/lib/esm/common/io.js +26 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/transfer.d.ts +5 -2
- package/lib/types/cli/options.d.ts +17 -0
- package/lib/types/cli/utils.d.ts +1 -0
- package/lib/types/common/ant.d.ts +88 -2
- package/lib/types/common/io.d.ts +3 -1
- package/lib/types/types/ant.d.ts +12 -0
- package/lib/types/types/io.d.ts +12 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/cli/options.js
CHANGED
|
@@ -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.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.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>',
|
|
@@ -241,6 +241,19 @@ exports.optionMap = {
|
|
|
241
241
|
alias: '--fund-from <fundFrom>',
|
|
242
242
|
description: 'Where to fund the action from. e.g. "balance", "stakes", or "any',
|
|
243
243
|
},
|
|
244
|
+
revokable: {
|
|
245
|
+
alias: '--revokable',
|
|
246
|
+
description: 'Whether the vaulted transfer is revokable by the sender. Defaults to false',
|
|
247
|
+
type: 'boolean',
|
|
248
|
+
},
|
|
249
|
+
lockLengthMs: {
|
|
250
|
+
alias: '--lock-length-ms <lockLengthMs>',
|
|
251
|
+
description: 'The length of time in milliseconds to lock the transfer for',
|
|
252
|
+
},
|
|
253
|
+
recipient: {
|
|
254
|
+
alias: '--recipient <recipient>',
|
|
255
|
+
description: 'The recipient to interact with',
|
|
256
|
+
},
|
|
244
257
|
};
|
|
245
258
|
exports.walletOptions = [
|
|
246
259
|
exports.optionMap.walletFile,
|
|
@@ -288,6 +301,13 @@ exports.transferOptions = [
|
|
|
288
301
|
exports.optionMap.quantity,
|
|
289
302
|
exports.optionMap.target,
|
|
290
303
|
];
|
|
304
|
+
exports.vaultedTransferOptions = [
|
|
305
|
+
...exports.writeActionOptions,
|
|
306
|
+
exports.optionMap.quantity,
|
|
307
|
+
exports.optionMap.recipient,
|
|
308
|
+
exports.optionMap.lockLengthMs,
|
|
309
|
+
exports.optionMap.revokable,
|
|
310
|
+
];
|
|
291
311
|
exports.operatorStakeOptions = [
|
|
292
312
|
...exports.writeActionOptions,
|
|
293
313
|
exports.optionMap.operatorStake,
|
package/lib/cjs/cli/utils.js
CHANGED
|
@@ -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.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.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;
|
|
7
7
|
/**
|
|
8
8
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
9
9
|
*
|
|
@@ -376,6 +376,10 @@ function writeANTFromOptions(options, signer) {
|
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
378
|
exports.writeANTFromOptions = writeANTFromOptions;
|
|
379
|
+
function booleanFromOptions(options, key) {
|
|
380
|
+
return !!options[key];
|
|
381
|
+
}
|
|
382
|
+
exports.booleanFromOptions = booleanFromOptions;
|
|
379
383
|
function requiredStringFromOptions(options, key) {
|
|
380
384
|
const value = options[key];
|
|
381
385
|
if (value === undefined) {
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -285,6 +285,9 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
288
|
+
* Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
|
|
289
|
+
*
|
|
290
|
+
* @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
|
|
288
291
|
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
289
292
|
* @param transactionId @type {string} The transactionId of the record.
|
|
290
293
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
@@ -307,11 +310,68 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
307
310
|
});
|
|
308
311
|
}
|
|
309
312
|
/**
|
|
313
|
+
* Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
|
|
314
|
+
*
|
|
315
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
316
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
317
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* 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
|
+
* ```
|
|
322
|
+
*/
|
|
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
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* 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)
|
|
336
|
+
*
|
|
337
|
+
* @param undername @type {string} The undername of the ANT.
|
|
338
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
339
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
340
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
341
|
+
* @example
|
|
342
|
+
* ```ts
|
|
343
|
+
* 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
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds, }) {
|
|
347
|
+
return this.setRecord({
|
|
348
|
+
undername,
|
|
349
|
+
transactionId,
|
|
350
|
+
ttlSeconds,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
|
355
|
+
*
|
|
356
|
+
* @param undername @type {string} The undername you want to remove.
|
|
357
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
async removeUndernameRecord({ undername, }) {
|
|
364
|
+
return this.removeRecord({ undername });
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
|
|
368
|
+
*
|
|
369
|
+
* @deprecated Use removeUndernameRecord instead.
|
|
310
370
|
* @param undername @type {string} The record you want to remove.
|
|
311
371
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
312
372
|
* @example
|
|
313
373
|
* ```ts
|
|
314
|
-
* ant.removeRecord({
|
|
374
|
+
* ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
315
375
|
* ```
|
|
316
376
|
*/
|
|
317
377
|
async removeRecord({ undername, }, options) {
|
|
@@ -325,6 +385,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
325
385
|
});
|
|
326
386
|
}
|
|
327
387
|
/**
|
|
388
|
+
* Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
|
|
389
|
+
*
|
|
328
390
|
* @param ticker @type {string} Sets the ANT Ticker.
|
|
329
391
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
330
392
|
* @example
|
|
@@ -343,6 +405,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
343
405
|
});
|
|
344
406
|
}
|
|
345
407
|
/**
|
|
408
|
+
* Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
|
|
409
|
+
*
|
|
346
410
|
* @param name @type {string} Sets the Name of the ANT.
|
|
347
411
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
348
412
|
* @example
|
|
@@ -361,6 +425,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
361
425
|
});
|
|
362
426
|
}
|
|
363
427
|
/**
|
|
428
|
+
* Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
|
|
429
|
+
*
|
|
364
430
|
* @param description @type {string} Sets the ANT Description.
|
|
365
431
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
366
432
|
* @example
|
|
@@ -379,6 +445,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
379
445
|
});
|
|
380
446
|
}
|
|
381
447
|
/**
|
|
448
|
+
* Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
|
|
449
|
+
*
|
|
382
450
|
* @param keywords @type {string[]} Sets the ANT Keywords.
|
|
383
451
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
384
452
|
* @example
|
|
@@ -397,6 +465,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
397
465
|
});
|
|
398
466
|
}
|
|
399
467
|
/**
|
|
468
|
+
* Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT.
|
|
469
|
+
*
|
|
400
470
|
* @param txId @type {string} - Arweave transaction id of the logo we want to set
|
|
401
471
|
* @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
|
|
402
472
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -416,6 +486,9 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
416
486
|
});
|
|
417
487
|
}
|
|
418
488
|
/**
|
|
489
|
+
* Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released.
|
|
490
|
+
*
|
|
491
|
+
*
|
|
419
492
|
* @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone.
|
|
420
493
|
* @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
|
|
421
494
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -437,7 +510,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
437
510
|
});
|
|
438
511
|
}
|
|
439
512
|
/**
|
|
440
|
-
* Sends a message to the ARIO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
|
|
513
|
+
* Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT.
|
|
514
|
+
*
|
|
441
515
|
* @param name @type {string} The name you want to reassign.
|
|
442
516
|
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
443
517
|
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
@@ -462,6 +536,15 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
462
536
|
}
|
|
463
537
|
/**
|
|
464
538
|
* Approves a primary name request for a given name or address.
|
|
539
|
+
*
|
|
540
|
+
* @param name @type {string} The name you want to approve.
|
|
541
|
+
* @param address @type {WalletAddress} The address you want to approve.
|
|
542
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
543
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
|
|
547
|
+
* ```
|
|
465
548
|
*/
|
|
466
549
|
async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
|
|
467
550
|
return this.process.send({
|
|
@@ -476,6 +559,18 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
476
559
|
signer: this.signer,
|
|
477
560
|
});
|
|
478
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released.
|
|
564
|
+
*
|
|
565
|
+
* @param names @type {string[]} The names you want to remove.
|
|
566
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
567
|
+
* @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
|
|
568
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
479
574
|
async removePrimaryNames({ names, arioProcessId, notifyOwners = false, }, options) {
|
|
480
575
|
return this.process.send({
|
|
481
576
|
tags: [
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -492,6 +492,32 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
492
492
|
signer: this.signer,
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
|
+
async vaultedTransfer({ recipient, quantity, lockLengthMs, revokable = false, }, options) {
|
|
496
|
+
const { tags = [] } = options || {};
|
|
497
|
+
return this.process.send({
|
|
498
|
+
tags: [
|
|
499
|
+
...tags,
|
|
500
|
+
{ name: 'Action', value: 'Vaulted-Transfer' },
|
|
501
|
+
{ name: 'Recipient', value: recipient },
|
|
502
|
+
{ name: 'Quantity', value: quantity.toString() },
|
|
503
|
+
{ name: 'Lock-Length', value: lockLengthMs.toString() },
|
|
504
|
+
{ name: 'Revokable', value: `${revokable}` },
|
|
505
|
+
],
|
|
506
|
+
signer: this.signer,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
async revokeVault({ vaultId, recipient }, options) {
|
|
510
|
+
const { tags = [] } = options || {};
|
|
511
|
+
return this.process.send({
|
|
512
|
+
tags: [
|
|
513
|
+
...tags,
|
|
514
|
+
{ name: 'Action', value: 'Revoke-Vault' },
|
|
515
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
516
|
+
{ name: 'Recipient', value: recipient },
|
|
517
|
+
],
|
|
518
|
+
signer: this.signer,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
495
521
|
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
496
522
|
const { tags = [] } = options || {};
|
|
497
523
|
const allTags = [
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -22,8 +22,8 @@ import { version } from '../version.js';
|
|
|
22
22
|
import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
|
|
23
23
|
import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
|
|
24
24
|
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 {
|
|
26
|
-
import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, writeActionOptions, } from './options.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';
|
|
27
27
|
import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
|
|
28
28
|
applyOptions(program
|
|
29
29
|
.name('ar.io')
|
|
@@ -266,7 +266,19 @@ makeCommand({
|
|
|
266
266
|
name: 'transfer',
|
|
267
267
|
description: 'Transfer ARIO to another address',
|
|
268
268
|
options: transferOptions,
|
|
269
|
-
action:
|
|
269
|
+
action: transferCLICommand,
|
|
270
|
+
});
|
|
271
|
+
makeCommand({
|
|
272
|
+
name: 'vaulted-transfer',
|
|
273
|
+
description: 'Transfer ARIO to another address into a locked vault',
|
|
274
|
+
options: vaultedTransferOptions,
|
|
275
|
+
action: vaultedTransferCLICommand,
|
|
276
|
+
});
|
|
277
|
+
makeCommand({
|
|
278
|
+
name: 'revoke-vault',
|
|
279
|
+
description: 'Revoke a vaulted transfer as the controller',
|
|
280
|
+
options: [...writeActionOptions, optionMap.vaultId, optionMap.recipient],
|
|
281
|
+
action: revokeVaultCLICommand,
|
|
270
282
|
});
|
|
271
283
|
makeCommand({
|
|
272
284
|
name: 'join-network',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertEnoughMARIOBalance, confirmationPrompt, formatARIOWithCommas, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
2
|
-
export async function
|
|
1
|
+
import { assertEnoughMARIOBalance, confirmationPrompt, formatARIOWithCommas, formatMARIOToARIOWithCommas, requiredMARIOFromOptions, requiredPositiveIntegerFromOptions, requiredStringFromOptions, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
2
|
+
export async function transferCLICommand(options) {
|
|
3
3
|
const { target, arioQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
4
4
|
const { ario, signerAddress } = writeARIOFromOptions(options);
|
|
5
5
|
if (!options.skipConfirmation) {
|
|
@@ -24,3 +24,57 @@ export async function transfer(options) {
|
|
|
24
24
|
};
|
|
25
25
|
return output;
|
|
26
26
|
}
|
|
27
|
+
export async function vaultedTransferCLICommand(o) {
|
|
28
|
+
const mARIOQuantity = requiredMARIOFromOptions(o, 'quantity');
|
|
29
|
+
const recipient = requiredStringFromOptions(o, 'recipient');
|
|
30
|
+
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
31
|
+
const lockLengthMs = requiredPositiveIntegerFromOptions(o, 'lockLengthMs');
|
|
32
|
+
if (!o.skipConfirmation) {
|
|
33
|
+
await assertEnoughMARIOBalance({
|
|
34
|
+
ario,
|
|
35
|
+
address: signerAddress,
|
|
36
|
+
mARIOQuantity,
|
|
37
|
+
});
|
|
38
|
+
const confirm = await confirmationPrompt(`Are you sure you want transfer ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO to ${recipient}, locked in a ${o.revokable ? '' : 'non-'}revokable vault for ${lockLengthMs}ms?`);
|
|
39
|
+
if (!confirm) {
|
|
40
|
+
return { message: 'Transfer aborted by user' };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const result = await ario.vaultedTransfer({
|
|
44
|
+
recipient,
|
|
45
|
+
quantity: mARIOQuantity,
|
|
46
|
+
lockLengthMs,
|
|
47
|
+
revokable: o.revokable,
|
|
48
|
+
}, writeActionTagsFromOptions(o));
|
|
49
|
+
const output = {
|
|
50
|
+
senderAddress: signerAddress,
|
|
51
|
+
transferResult: result,
|
|
52
|
+
message: `Successfully vaulted transferred ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO to ${recipient}`,
|
|
53
|
+
};
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
export async function revokeVaultCLICommand(o) {
|
|
57
|
+
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
58
|
+
const vaultId = requiredStringFromOptions(o, 'vaultId');
|
|
59
|
+
const recipient = requiredStringFromOptions(o, 'recipient');
|
|
60
|
+
if (!o.skipConfirmation) {
|
|
61
|
+
const vault = await ario.getVault({ vaultId, address: recipient });
|
|
62
|
+
if (!vault) {
|
|
63
|
+
throw new Error(`Vault for recipient '${recipient}' with vault id '${vaultId}' not found`);
|
|
64
|
+
}
|
|
65
|
+
const confirm = await confirmationPrompt(`Are you sure you want to revoke vault with id ${vaultId} from ${recipient}?`);
|
|
66
|
+
if (!confirm) {
|
|
67
|
+
return { message: 'Revoke aborted by user' };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const result = await ario.revokeVault({
|
|
71
|
+
vaultId,
|
|
72
|
+
recipient,
|
|
73
|
+
}, writeActionTagsFromOptions(o));
|
|
74
|
+
const output = {
|
|
75
|
+
senderAddress: signerAddress,
|
|
76
|
+
transferResult: result,
|
|
77
|
+
message: `Successfully revoked vault with id ${vaultId}`,
|
|
78
|
+
};
|
|
79
|
+
return output;
|
|
80
|
+
}
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -238,6 +238,19 @@ export const optionMap = {
|
|
|
238
238
|
alias: '--fund-from <fundFrom>',
|
|
239
239
|
description: 'Where to fund the action from. e.g. "balance", "stakes", or "any',
|
|
240
240
|
},
|
|
241
|
+
revokable: {
|
|
242
|
+
alias: '--revokable',
|
|
243
|
+
description: 'Whether the vaulted transfer is revokable by the sender. Defaults to false',
|
|
244
|
+
type: 'boolean',
|
|
245
|
+
},
|
|
246
|
+
lockLengthMs: {
|
|
247
|
+
alias: '--lock-length-ms <lockLengthMs>',
|
|
248
|
+
description: 'The length of time in milliseconds to lock the transfer for',
|
|
249
|
+
},
|
|
250
|
+
recipient: {
|
|
251
|
+
alias: '--recipient <recipient>',
|
|
252
|
+
description: 'The recipient to interact with',
|
|
253
|
+
},
|
|
241
254
|
};
|
|
242
255
|
export const walletOptions = [
|
|
243
256
|
optionMap.walletFile,
|
|
@@ -285,6 +298,13 @@ export const transferOptions = [
|
|
|
285
298
|
optionMap.quantity,
|
|
286
299
|
optionMap.target,
|
|
287
300
|
];
|
|
301
|
+
export const vaultedTransferOptions = [
|
|
302
|
+
...writeActionOptions,
|
|
303
|
+
optionMap.quantity,
|
|
304
|
+
optionMap.recipient,
|
|
305
|
+
optionMap.lockLengthMs,
|
|
306
|
+
optionMap.revokable,
|
|
307
|
+
];
|
|
288
308
|
export const operatorStakeOptions = [
|
|
289
309
|
...writeActionOptions,
|
|
290
310
|
optionMap.operatorStake,
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -338,6 +338,9 @@ export function writeANTFromOptions(options, signer) {
|
|
|
338
338
|
signer,
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
|
+
export function booleanFromOptions(options, key) {
|
|
342
|
+
return !!options[key];
|
|
343
|
+
}
|
|
341
344
|
export function requiredStringFromOptions(options, key) {
|
|
342
345
|
const value = options[key];
|
|
343
346
|
if (value === undefined) {
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -280,6 +280,9 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
283
|
+
* Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
|
|
284
|
+
*
|
|
285
|
+
* @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
|
|
283
286
|
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
284
287
|
* @param transactionId @type {string} The transactionId of the record.
|
|
285
288
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
@@ -302,11 +305,68 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
302
305
|
});
|
|
303
306
|
}
|
|
304
307
|
/**
|
|
308
|
+
* Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
|
|
309
|
+
*
|
|
310
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
311
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
312
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* 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
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
async setBaseNameRecord({ transactionId, ttlSeconds, }) {
|
|
319
|
+
return this.process.send({
|
|
320
|
+
tags: [
|
|
321
|
+
{ name: 'Action', value: 'Set-Record' },
|
|
322
|
+
{ name: 'Sub-Domain', value: '@' },
|
|
323
|
+
{ name: 'Transaction-Id', value: transactionId },
|
|
324
|
+
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
325
|
+
],
|
|
326
|
+
signer: this.signer,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* 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)
|
|
331
|
+
*
|
|
332
|
+
* @param undername @type {string} The undername of the ANT.
|
|
333
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
334
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
335
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* 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
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds, }) {
|
|
342
|
+
return this.setRecord({
|
|
343
|
+
undername,
|
|
344
|
+
transactionId,
|
|
345
|
+
ttlSeconds,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
|
350
|
+
*
|
|
351
|
+
* @param undername @type {string} The undername you want to remove.
|
|
352
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
async removeUndernameRecord({ undername, }) {
|
|
359
|
+
return this.removeRecord({ undername });
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
|
|
363
|
+
*
|
|
364
|
+
* @deprecated Use removeUndernameRecord instead.
|
|
305
365
|
* @param undername @type {string} The record you want to remove.
|
|
306
366
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
307
367
|
* @example
|
|
308
368
|
* ```ts
|
|
309
|
-
* ant.removeRecord({
|
|
369
|
+
* ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
310
370
|
* ```
|
|
311
371
|
*/
|
|
312
372
|
async removeRecord({ undername, }, options) {
|
|
@@ -320,6 +380,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
320
380
|
});
|
|
321
381
|
}
|
|
322
382
|
/**
|
|
383
|
+
* Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
|
|
384
|
+
*
|
|
323
385
|
* @param ticker @type {string} Sets the ANT Ticker.
|
|
324
386
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
325
387
|
* @example
|
|
@@ -338,6 +400,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
338
400
|
});
|
|
339
401
|
}
|
|
340
402
|
/**
|
|
403
|
+
* Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
|
|
404
|
+
*
|
|
341
405
|
* @param name @type {string} Sets the Name of the ANT.
|
|
342
406
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
343
407
|
* @example
|
|
@@ -356,6 +420,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
356
420
|
});
|
|
357
421
|
}
|
|
358
422
|
/**
|
|
423
|
+
* Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
|
|
424
|
+
*
|
|
359
425
|
* @param description @type {string} Sets the ANT Description.
|
|
360
426
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
361
427
|
* @example
|
|
@@ -374,6 +440,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
374
440
|
});
|
|
375
441
|
}
|
|
376
442
|
/**
|
|
443
|
+
* Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
|
|
444
|
+
*
|
|
377
445
|
* @param keywords @type {string[]} Sets the ANT Keywords.
|
|
378
446
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
379
447
|
* @example
|
|
@@ -392,6 +460,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
392
460
|
});
|
|
393
461
|
}
|
|
394
462
|
/**
|
|
463
|
+
* Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT.
|
|
464
|
+
*
|
|
395
465
|
* @param txId @type {string} - Arweave transaction id of the logo we want to set
|
|
396
466
|
* @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
|
|
397
467
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -411,6 +481,9 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
411
481
|
});
|
|
412
482
|
}
|
|
413
483
|
/**
|
|
484
|
+
* Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released.
|
|
485
|
+
*
|
|
486
|
+
*
|
|
414
487
|
* @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone.
|
|
415
488
|
* @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
|
|
416
489
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -432,7 +505,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
432
505
|
});
|
|
433
506
|
}
|
|
434
507
|
/**
|
|
435
|
-
* Sends a message to the ARIO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
|
|
508
|
+
* Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT.
|
|
509
|
+
*
|
|
436
510
|
* @param name @type {string} The name you want to reassign.
|
|
437
511
|
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
438
512
|
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
@@ -457,6 +531,15 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
457
531
|
}
|
|
458
532
|
/**
|
|
459
533
|
* Approves a primary name request for a given name or address.
|
|
534
|
+
*
|
|
535
|
+
* @param name @type {string} The name you want to approve.
|
|
536
|
+
* @param address @type {WalletAddress} The address you want to approve.
|
|
537
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
538
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
|
|
542
|
+
* ```
|
|
460
543
|
*/
|
|
461
544
|
async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
|
|
462
545
|
return this.process.send({
|
|
@@ -471,6 +554,18 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
471
554
|
signer: this.signer,
|
|
472
555
|
});
|
|
473
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released.
|
|
559
|
+
*
|
|
560
|
+
* @param names @type {string[]} The names you want to remove.
|
|
561
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
562
|
+
* @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
|
|
563
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
564
|
+
* @example
|
|
565
|
+
* ```ts
|
|
566
|
+
* ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
474
569
|
async removePrimaryNames({ names, arioProcessId, notifyOwners = false, }, options) {
|
|
475
570
|
return this.process.send({
|
|
476
571
|
tags: [
|
package/lib/esm/common/io.js
CHANGED
|
@@ -487,6 +487,32 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
487
487
|
signer: this.signer,
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
|
+
async vaultedTransfer({ recipient, quantity, lockLengthMs, revokable = false, }, options) {
|
|
491
|
+
const { tags = [] } = options || {};
|
|
492
|
+
return this.process.send({
|
|
493
|
+
tags: [
|
|
494
|
+
...tags,
|
|
495
|
+
{ name: 'Action', value: 'Vaulted-Transfer' },
|
|
496
|
+
{ name: 'Recipient', value: recipient },
|
|
497
|
+
{ name: 'Quantity', value: quantity.toString() },
|
|
498
|
+
{ name: 'Lock-Length', value: lockLengthMs.toString() },
|
|
499
|
+
{ name: 'Revokable', value: `${revokable}` },
|
|
500
|
+
],
|
|
501
|
+
signer: this.signer,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
async revokeVault({ vaultId, recipient }, options) {
|
|
505
|
+
const { tags = [] } = options || {};
|
|
506
|
+
return this.process.send({
|
|
507
|
+
tags: [
|
|
508
|
+
...tags,
|
|
509
|
+
{ name: 'Action', value: 'Revoke-Vault' },
|
|
510
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
511
|
+
{ name: 'Recipient', value: recipient },
|
|
512
|
+
],
|
|
513
|
+
signer: this.signer,
|
|
514
|
+
});
|
|
515
|
+
}
|
|
490
516
|
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
491
517
|
const { tags = [] } = options || {};
|
|
492
518
|
const allTags = [
|
package/lib/esm/version.js
CHANGED