@ar.io/sdk 3.19.0-alpha.9 → 3.20.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -7
- package/bundles/web.bundle.min.js +56 -56
- package/lib/cjs/cli/cli.js +8 -1
- package/lib/cjs/cli/commands/antCommands.js +32 -16
- package/lib/cjs/cli/options.js +25 -1
- package/lib/cjs/cli/utils.js +14 -0
- package/lib/cjs/common/ant.js +70 -12
- package/lib/cjs/common/io.js +2 -2
- package/lib/cjs/types/ant.js +18 -0
- package/lib/cjs/utils/processes.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +10 -3
- package/lib/esm/cli/commands/antCommands.js +32 -17
- package/lib/esm/cli/options.js +24 -0
- package/lib/esm/cli/utils.js +13 -0
- package/lib/esm/common/ant.js +70 -12
- package/lib/esm/common/io.js +2 -2
- package/lib/esm/types/ant.js +18 -0
- package/lib/esm/utils/processes.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +4 -0
- package/lib/types/cli/options.d.ts +16 -0
- package/lib/types/cli/types.d.ts +1 -0
- package/lib/types/cli/utils.d.ts +13 -0
- package/lib/types/common/ant.d.ts +33 -3
- package/lib/types/common/io.d.ts +1 -1
- package/lib/types/types/ant.d.ts +97 -8
- package/lib/types/utils/processes.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +3 -2
package/lib/cjs/cli/cli.js
CHANGED
|
@@ -536,6 +536,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
536
536
|
state,
|
|
537
537
|
signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
|
|
538
538
|
logger: (0, utils_js_1.getLoggerFromOptions)(options),
|
|
539
|
+
...(options.module !== undefined ? { module: options.module } : {}),
|
|
539
540
|
});
|
|
540
541
|
return {
|
|
541
542
|
processId: antProcessId,
|
|
@@ -632,7 +633,13 @@ const utils_js_1 = require("./utils.js");
|
|
|
632
633
|
name: 'set-ant-undername',
|
|
633
634
|
description: 'Set an undername of an ANT process',
|
|
634
635
|
options: options_js_1.setAntUndernameOptions,
|
|
635
|
-
action: antCommands_js_1.
|
|
636
|
+
action: antCommands_js_1.setAntUndernameCLICommand,
|
|
637
|
+
});
|
|
638
|
+
(0, utils_js_1.makeCommand)({
|
|
639
|
+
name: 'transfer-record',
|
|
640
|
+
description: 'Transfer ownership of a specific record (undername) to another address',
|
|
641
|
+
options: options_js_1.transferRecordOwnershipOptions,
|
|
642
|
+
action: antCommands_js_1.transferRecordOwnershipCLICommand,
|
|
636
643
|
});
|
|
637
644
|
(0, utils_js_1.makeCommand)({
|
|
638
645
|
name: 'upgrade-ant',
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setAntRecordCLICommand = setAntRecordCLICommand;
|
|
4
4
|
exports.setAntBaseNameCLICommand = setAntBaseNameCLICommand;
|
|
5
5
|
exports.setAntUndernameCLICommand = setAntUndernameCLICommand;
|
|
6
|
+
exports.transferRecordOwnershipCLICommand = transferRecordOwnershipCLICommand;
|
|
6
7
|
exports.upgradeAntCLICommand = upgradeAntCLICommand;
|
|
7
8
|
const utils_js_1 = require("../utils.js");
|
|
8
9
|
/** @deprecated -- use set-ant-base-name and set-ant-undername */
|
|
@@ -11,40 +12,55 @@ async function setAntRecordCLICommand(o) {
|
|
|
11
12
|
const undername = (0, utils_js_1.requiredStringFromOptions)(o, 'undername');
|
|
12
13
|
const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
|
|
13
14
|
const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
|
|
14
|
-
|
|
15
|
-
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);
|
|
16
|
-
}
|
|
17
|
-
return (0, utils_js_1.writeANTFromOptions)(o).setRecord({
|
|
15
|
+
const recordParams = {
|
|
18
16
|
undername,
|
|
19
17
|
transactionId,
|
|
20
18
|
ttlSeconds,
|
|
21
|
-
|
|
19
|
+
...(0, utils_js_1.antRecordMetadataFromOptions)(o),
|
|
20
|
+
};
|
|
21
|
+
if (!o.skipConfirmation) {
|
|
22
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this record on the ANT process ${writeAnt.processId}?\n${JSON.stringify(recordParams, null, 2)}`, o);
|
|
23
|
+
}
|
|
24
|
+
return (0, utils_js_1.writeANTFromOptions)(o).setRecord(recordParams, (0, utils_js_1.customTagsFromOptions)(o));
|
|
22
25
|
}
|
|
23
26
|
async function setAntBaseNameCLICommand(o) {
|
|
24
27
|
const ttlSeconds = +(o.ttlSeconds ?? utils_js_1.defaultTtlSecondsCLI);
|
|
25
28
|
const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
|
|
29
|
+
const params = {
|
|
30
|
+
transactionId,
|
|
31
|
+
ttlSeconds,
|
|
32
|
+
...(0, utils_js_1.antRecordMetadataFromOptions)(o),
|
|
33
|
+
};
|
|
26
34
|
const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
|
|
27
35
|
if (!o.skipConfirmation) {
|
|
28
|
-
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(
|
|
36
|
+
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(params, null, 2)}`, o);
|
|
29
37
|
}
|
|
30
|
-
return (0, utils_js_1.writeANTFromOptions)(o).setBaseNameRecord(
|
|
31
|
-
transactionId,
|
|
32
|
-
ttlSeconds,
|
|
33
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
38
|
+
return (0, utils_js_1.writeANTFromOptions)(o).setBaseNameRecord(params, (0, utils_js_1.customTagsFromOptions)(o));
|
|
34
39
|
}
|
|
35
40
|
async function setAntUndernameCLICommand(o) {
|
|
36
41
|
const ttlSeconds = +(o.ttlSeconds ?? utils_js_1.defaultTtlSecondsCLI);
|
|
37
42
|
const undername = (0, utils_js_1.requiredStringFromOptions)(o, 'undername');
|
|
38
43
|
const transactionId = (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId');
|
|
39
|
-
const
|
|
40
|
-
if (!o.skipConfirmation) {
|
|
41
|
-
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);
|
|
42
|
-
}
|
|
43
|
-
return (0, utils_js_1.writeANTFromOptions)(o).setUndernameRecord({
|
|
44
|
+
const params = {
|
|
44
45
|
undername,
|
|
45
46
|
transactionId,
|
|
46
47
|
ttlSeconds,
|
|
47
|
-
|
|
48
|
+
...(0, utils_js_1.antRecordMetadataFromOptions)(o),
|
|
49
|
+
};
|
|
50
|
+
const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
|
|
51
|
+
if (!o.skipConfirmation) {
|
|
52
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set this undername on the ANT process ${writeAnt.processId}?\n${JSON.stringify(params, null, 2)}`, o);
|
|
53
|
+
}
|
|
54
|
+
return (0, utils_js_1.writeANTFromOptions)(o).setUndernameRecord(params, (0, utils_js_1.customTagsFromOptions)(o));
|
|
55
|
+
}
|
|
56
|
+
async function transferRecordOwnershipCLICommand(o) {
|
|
57
|
+
const undername = (0, utils_js_1.requiredStringFromOptions)(o, 'undername');
|
|
58
|
+
const recipient = (0, utils_js_1.requiredStringFromOptions)(o, 'recipient');
|
|
59
|
+
const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
|
|
60
|
+
if (!o.skipConfirmation) {
|
|
61
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to transfer ownership of "${undername}" to "${recipient}" on ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, recipient }, null, 2)}`, o);
|
|
62
|
+
}
|
|
63
|
+
return (0, utils_js_1.writeANTFromOptions)(o).transferRecord({ undername, recipient }, (0, utils_js_1.customTagsFromOptions)(o));
|
|
48
64
|
}
|
|
49
65
|
async function upgradeAntCLICommand(o) {
|
|
50
66
|
const writeAnt = (0, utils_js_1.writeANTFromOptions)(o);
|
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.upgradeAntOptions = 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;
|
|
18
|
+
exports.transferRecordOwnershipOptions = exports.upgradeAntOptions = 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>',
|
|
@@ -254,6 +254,14 @@ exports.optionMap = {
|
|
|
254
254
|
description: 'The keywords for the ANT',
|
|
255
255
|
type: 'array',
|
|
256
256
|
},
|
|
257
|
+
owner: {
|
|
258
|
+
alias: '--owner <owner>',
|
|
259
|
+
description: 'The owner address for the record',
|
|
260
|
+
},
|
|
261
|
+
displayName: {
|
|
262
|
+
alias: '--display-name <displayName>',
|
|
263
|
+
description: 'The display name for the record',
|
|
264
|
+
},
|
|
257
265
|
names: {
|
|
258
266
|
alias: '--names <names...>',
|
|
259
267
|
description: 'The names to interact with',
|
|
@@ -289,6 +297,10 @@ exports.optionMap = {
|
|
|
289
297
|
alias: '--logo <logo>',
|
|
290
298
|
description: 'The ANT logo',
|
|
291
299
|
},
|
|
300
|
+
module: {
|
|
301
|
+
alias: '--module <module>',
|
|
302
|
+
description: 'The module ID to use for spawning the ANT process',
|
|
303
|
+
},
|
|
292
304
|
token: {
|
|
293
305
|
alias: '-t, --token <type>',
|
|
294
306
|
description: 'Crypto token type for wallet or action',
|
|
@@ -416,11 +428,17 @@ exports.antStateOptions = [
|
|
|
416
428
|
exports.optionMap.controllers,
|
|
417
429
|
exports.optionMap.ttlSeconds,
|
|
418
430
|
exports.optionMap.logo,
|
|
431
|
+
exports.optionMap.module,
|
|
419
432
|
];
|
|
420
433
|
exports.setAntBaseNameOptions = [
|
|
421
434
|
exports.optionMap.processId,
|
|
422
435
|
exports.optionMap.transactionId,
|
|
423
436
|
exports.optionMap.ttlSeconds,
|
|
437
|
+
exports.optionMap.owner,
|
|
438
|
+
exports.optionMap.displayName,
|
|
439
|
+
exports.optionMap.logo,
|
|
440
|
+
exports.optionMap.description,
|
|
441
|
+
exports.optionMap.keywords,
|
|
424
442
|
...exports.writeActionOptions,
|
|
425
443
|
];
|
|
426
444
|
exports.setAntUndernameOptions = [
|
|
@@ -433,3 +451,9 @@ exports.upgradeAntOptions = [
|
|
|
433
451
|
exports.optionMap.reassignAffiliatedNames,
|
|
434
452
|
...exports.writeActionOptions,
|
|
435
453
|
];
|
|
454
|
+
exports.transferRecordOwnershipOptions = [
|
|
455
|
+
exports.optionMap.processId,
|
|
456
|
+
exports.optionMap.undername,
|
|
457
|
+
exports.optionMap.recipient,
|
|
458
|
+
...exports.writeActionOptions,
|
|
459
|
+
];
|
package/lib/cjs/cli/utils.js
CHANGED
|
@@ -50,6 +50,7 @@ exports.getTokenCostParamsFromOptions = getTokenCostParamsFromOptions;
|
|
|
50
50
|
exports.fundFromFromOptions = fundFromFromOptions;
|
|
51
51
|
exports.referrerFromOptions = referrerFromOptions;
|
|
52
52
|
exports.assertLockLengthInRange = assertLockLengthInRange;
|
|
53
|
+
exports.antRecordMetadataFromOptions = antRecordMetadataFromOptions;
|
|
53
54
|
/**
|
|
54
55
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
55
56
|
*
|
|
@@ -559,3 +560,16 @@ function assertLockLengthInRange(lockLengthMs, assertMin = true) {
|
|
|
559
560
|
throw new Error(`Lock length must be at least 14 days (1209600000 ms). Provided lock length: ${lockLengthMs} ms`);
|
|
560
561
|
}
|
|
561
562
|
}
|
|
563
|
+
function antRecordMetadataFromOptions(options) {
|
|
564
|
+
return {
|
|
565
|
+
...(options.owner != null &&
|
|
566
|
+
options.owner !== '' && { owner: options.owner }),
|
|
567
|
+
...(options.displayName != null &&
|
|
568
|
+
options.displayName !== '' && { displayName: options.displayName }),
|
|
569
|
+
...(options.logo != null && options.logo !== '' && { logo: options.logo }),
|
|
570
|
+
...(options.description != null &&
|
|
571
|
+
options.description !== '' && { description: options.description }),
|
|
572
|
+
...(options.keywords != null &&
|
|
573
|
+
options.keywords.length > 0 && { keywords: options.keywords }),
|
|
574
|
+
};
|
|
575
|
+
}
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -396,7 +396,7 @@ class AoANTReadable {
|
|
|
396
396
|
query {
|
|
397
397
|
transactions(
|
|
398
398
|
ids: ["${this.processId}"]
|
|
399
|
-
first: 1
|
|
399
|
+
first: 1
|
|
400
400
|
) {
|
|
401
401
|
edges {
|
|
402
402
|
node {
|
|
@@ -763,17 +763,31 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
763
763
|
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
764
764
|
* @param transactionId @type {string} The transactionId of the record.
|
|
765
765
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
766
|
+
* @param owner @type {string} Optional owner address for the record.
|
|
767
|
+
* @param displayName @type {string} Optional display name for the record.
|
|
768
|
+
* @param logo @type {string} Optional logo transaction ID for the record.
|
|
769
|
+
* @param description @type {string} Optional description for the record.
|
|
770
|
+
* @param keywords @type {string[]} Optional keywords array for the record.
|
|
766
771
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
767
772
|
*/
|
|
768
|
-
async setRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
773
|
+
async setRecord({ undername, transactionId, ttlSeconds, owner, displayName, logo, description, keywords, }, options) {
|
|
774
|
+
const tags = [
|
|
775
|
+
...(options?.tags ?? []),
|
|
776
|
+
{ name: 'Action', value: 'Set-Record' },
|
|
777
|
+
{ name: 'Sub-Domain', value: undername },
|
|
778
|
+
{ name: 'Transaction-Id', value: transactionId },
|
|
779
|
+
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
780
|
+
{ name: 'Record-Owner', value: owner },
|
|
781
|
+
{ name: 'Display-Name', value: displayName },
|
|
782
|
+
{ name: 'Logo', value: logo },
|
|
783
|
+
{ name: 'Description', value: description },
|
|
784
|
+
{
|
|
785
|
+
name: 'Keywords',
|
|
786
|
+
value: keywords ? JSON.stringify(keywords) : undefined,
|
|
787
|
+
},
|
|
788
|
+
].filter((tag) => tag.value !== undefined);
|
|
769
789
|
return this.process.send({
|
|
770
|
-
tags
|
|
771
|
-
...(options?.tags ?? []),
|
|
772
|
-
{ name: 'Action', value: 'Set-Record' },
|
|
773
|
-
{ name: 'Sub-Domain', value: undername },
|
|
774
|
-
{ name: 'Transaction-Id', value: transactionId },
|
|
775
|
-
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
776
|
-
],
|
|
790
|
+
tags,
|
|
777
791
|
signer: this.signer,
|
|
778
792
|
});
|
|
779
793
|
}
|
|
@@ -782,17 +796,27 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
782
796
|
*
|
|
783
797
|
* @param transactionId @type {string} The transactionId of the record.
|
|
784
798
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
799
|
+
* @param owner @type {string} Optional owner address for the record.
|
|
800
|
+
* @param displayName @type {string} Optional display name for the record.
|
|
801
|
+
* @param logo @type {string} Optional logo transaction ID for the record.
|
|
802
|
+
* @param description @type {string} Optional description for the record.
|
|
803
|
+
* @param keywords @type {string[]} Optional keywords array for the record.
|
|
785
804
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
786
805
|
* @example
|
|
787
806
|
* ```ts
|
|
788
807
|
* 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
|
|
789
808
|
* ```
|
|
790
809
|
*/
|
|
791
|
-
async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
|
|
810
|
+
async setBaseNameRecord({ transactionId, ttlSeconds, owner, displayName, logo, description, keywords, }, options) {
|
|
792
811
|
return this.setRecord({
|
|
793
812
|
transactionId,
|
|
794
813
|
ttlSeconds,
|
|
795
814
|
undername: '@',
|
|
815
|
+
owner,
|
|
816
|
+
displayName,
|
|
817
|
+
logo,
|
|
818
|
+
description,
|
|
819
|
+
keywords,
|
|
796
820
|
}, options);
|
|
797
821
|
}
|
|
798
822
|
/**
|
|
@@ -801,17 +825,27 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
801
825
|
* @param undername @type {string} The undername of the ANT.
|
|
802
826
|
* @param transactionId @type {string} The transactionId of the record.
|
|
803
827
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
828
|
+
* @param owner @type {string} Optional owner address for the record.
|
|
829
|
+
* @param displayName @type {string} Optional display name for the record.
|
|
830
|
+
* @param logo @type {string} Optional logo transaction ID for the record.
|
|
831
|
+
* @param description @type {string} Optional description for the record.
|
|
832
|
+
* @param keywords @type {string[]} Optional keywords array for the record.
|
|
804
833
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
805
834
|
* @example
|
|
806
835
|
* ```ts
|
|
807
836
|
* 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
|
|
808
837
|
* ```
|
|
809
838
|
*/
|
|
810
|
-
async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
839
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds, owner, displayName, logo, description, keywords, }, options) {
|
|
811
840
|
return this.setRecord({
|
|
812
841
|
undername,
|
|
813
842
|
transactionId,
|
|
814
843
|
ttlSeconds,
|
|
844
|
+
owner,
|
|
845
|
+
displayName,
|
|
846
|
+
logo,
|
|
847
|
+
description,
|
|
848
|
+
keywords,
|
|
815
849
|
}, options);
|
|
816
850
|
}
|
|
817
851
|
/**
|
|
@@ -1034,7 +1068,9 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
1034
1068
|
* ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_MAINNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
|
|
1035
1069
|
* ```
|
|
1036
1070
|
*/
|
|
1037
|
-
async removePrimaryNames({ names, arioProcessId,
|
|
1071
|
+
async removePrimaryNames({ names, arioProcessId,
|
|
1072
|
+
// TODO: remove this param, its not used on the ANT contract
|
|
1073
|
+
notifyOwners = false, }, options) {
|
|
1038
1074
|
return this.process.send({
|
|
1039
1075
|
tags: [
|
|
1040
1076
|
...(options?.tags ?? []),
|
|
@@ -1103,5 +1139,27 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
1103
1139
|
});
|
|
1104
1140
|
}
|
|
1105
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Transfers ownership of a specific record (undername) to another address. This allows delegation of control for individual records within an ANT while maintaining the ANT owner's ultimate authority.
|
|
1144
|
+
*
|
|
1145
|
+
* @param undername @type {string} The subdomain/record whose ownership you want to transfer.
|
|
1146
|
+
* @param recipient @type {string} The address of the new owner for this record.
|
|
1147
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* ant.transferRecord({ undername: "alice", recipient: "new-owner-address-123..." }); // transfers ownership of the "alice" record to the new owner
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
async transferRecord({ undername, recipient, }, options) {
|
|
1154
|
+
return this.process.send({
|
|
1155
|
+
tags: [
|
|
1156
|
+
...(options?.tags ?? []),
|
|
1157
|
+
{ name: 'Action', value: 'Transfer-Record' },
|
|
1158
|
+
{ name: 'Sub-Domain', value: undername },
|
|
1159
|
+
{ name: 'Recipient', value: recipient },
|
|
1160
|
+
],
|
|
1161
|
+
signer: this.signer,
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1106
1164
|
}
|
|
1107
1165
|
exports.AoANTWriteable = AoANTWriteable;
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -684,12 +684,12 @@ class ARIOReadable {
|
|
|
684
684
|
* @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
|
|
685
685
|
*/
|
|
686
686
|
async getArNSRecordsForAddress(params) {
|
|
687
|
-
const {
|
|
687
|
+
const { antRegistryProcessId = constants_js_1.ANT_REGISTRY_ID, address } = params;
|
|
688
688
|
const antRegistry = ant_registry_js_1.ANTRegistry.init({
|
|
689
689
|
hyperbeamUrl: this.hyperbeamUrl,
|
|
690
690
|
process: new ao_process_js_1.AOProcess({
|
|
691
691
|
ao: this.process.ao,
|
|
692
|
-
processId:
|
|
692
|
+
processId: antRegistryProcessId,
|
|
693
693
|
}),
|
|
694
694
|
});
|
|
695
695
|
// Note: there could be a race condition here if the ACL changes during pagination requests, resulting in different results from the `getArNSRecords`.
|
package/lib/cjs/types/ant.js
CHANGED
|
@@ -55,6 +55,23 @@ exports.AntRecordSchema = zod_1.z.object({
|
|
|
55
55
|
transactionId: exports.ArweaveTxIdSchema.describe('The Target ID of the undername'),
|
|
56
56
|
ttlSeconds: zod_1.z.number(),
|
|
57
57
|
priority: zod_1.z.number().optional(),
|
|
58
|
+
owner: exports.AOAddressSchema.describe('The owner address of the record').optional(),
|
|
59
|
+
displayName: zod_1.z
|
|
60
|
+
.string()
|
|
61
|
+
.max(61)
|
|
62
|
+
.describe('Display name of the record (max 61 chars)')
|
|
63
|
+
.optional(),
|
|
64
|
+
logo: exports.ArweaveTxIdSchema.describe('Logo transaction ID for the record').optional(),
|
|
65
|
+
description: zod_1.z
|
|
66
|
+
.string()
|
|
67
|
+
.max(512)
|
|
68
|
+
.describe('Description of the record (max 512 chars)')
|
|
69
|
+
.optional(),
|
|
70
|
+
keywords: zod_1.z
|
|
71
|
+
.array(zod_1.z.string().max(32))
|
|
72
|
+
.max(16)
|
|
73
|
+
.describe('Keywords array (max 16, each max 32 chars)')
|
|
74
|
+
.optional(),
|
|
58
75
|
});
|
|
59
76
|
exports.AntRecordsSchema = zod_1.z.record(zod_1.z.string(), exports.AntRecordSchema);
|
|
60
77
|
exports.AntControllersSchema = zod_1.z.array(exports.AOAddressSchema.describe('Controller address'));
|
|
@@ -120,6 +137,7 @@ exports.AntWriteHandlers = [
|
|
|
120
137
|
'reassignName',
|
|
121
138
|
'approvePrimaryName',
|
|
122
139
|
'removePrimaryNames',
|
|
140
|
+
'transferRecordOwnership',
|
|
123
141
|
];
|
|
124
142
|
exports.AntHandlerNames = [...exports.AntReadHandlers, ...exports.AntWriteHandlers];
|
|
125
143
|
exports.AntHandlersSchema = zod_1.z
|
|
@@ -26,7 +26,7 @@ const io_js_1 = require("../common/io.js");
|
|
|
26
26
|
const logger_js_1 = require("../common/logger.js");
|
|
27
27
|
const constants_js_1 = require("../constants.js");
|
|
28
28
|
/**
|
|
29
|
-
* @
|
|
29
|
+
* @deprecated Use getArNSRecordsForAddress instead
|
|
30
30
|
*/
|
|
31
31
|
const getANTProcessesOwnedByWallet = async ({ address, registry = ant_registry_js_1.ANTRegistry.init(), }) => {
|
|
32
32
|
const res = await registry.accessControlList({ address });
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -19,12 +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, upgradeAntCLICommand, } from './commands/antCommands.js';
|
|
22
|
+
import { setAntBaseNameCLICommand, setAntRecordCLICommand, setAntUndernameCLICommand, transferRecordOwnershipCLICommand, upgradeAntCLICommand, } from './commands/antCommands.js';
|
|
23
23
|
import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, setPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
|
|
24
24
|
import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
|
|
25
25
|
import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listAntsForAddress, listArNSRecords, listArNSRecordsForAddress, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
|
|
26
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, upgradeAntOptions, vaultedTransferOptions, writeActionOptions, } from './options.js';
|
|
27
|
+
import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, setAntBaseNameOptions, setAntUndernameOptions, tokenCostOptions, transferOptions, transferRecordOwnershipOptions, updateGatewaySettingsOptions, upgradeAntOptions, 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';
|
|
29
29
|
applyOptions(program
|
|
30
30
|
.name('ar.io')
|
|
@@ -534,6 +534,7 @@ makeCommand({
|
|
|
534
534
|
state,
|
|
535
535
|
signer: requiredAoSignerFromOptions(options),
|
|
536
536
|
logger: getLoggerFromOptions(options),
|
|
537
|
+
...(options.module !== undefined ? { module: options.module } : {}),
|
|
537
538
|
});
|
|
538
539
|
return {
|
|
539
540
|
processId: antProcessId,
|
|
@@ -630,7 +631,13 @@ makeCommand({
|
|
|
630
631
|
name: 'set-ant-undername',
|
|
631
632
|
description: 'Set an undername of an ANT process',
|
|
632
633
|
options: setAntUndernameOptions,
|
|
633
|
-
action:
|
|
634
|
+
action: setAntUndernameCLICommand,
|
|
635
|
+
});
|
|
636
|
+
makeCommand({
|
|
637
|
+
name: 'transfer-record',
|
|
638
|
+
description: 'Transfer ownership of a specific record (undername) to another address',
|
|
639
|
+
options: transferRecordOwnershipOptions,
|
|
640
|
+
action: transferRecordOwnershipCLICommand,
|
|
634
641
|
});
|
|
635
642
|
makeCommand({
|
|
636
643
|
name: 'upgrade-ant',
|
|
@@ -1,44 +1,59 @@
|
|
|
1
|
-
import { arioProcessIdFromOptions, assertConfirmationPrompt, booleanFromOptions, customTagsFromOptions, defaultTtlSecondsCLI, readARIOFromOptions, requiredStringFromOptions, stringArrayFromOptions, writeANTFromOptions, } from '../utils.js';
|
|
1
|
+
import { antRecordMetadataFromOptions, arioProcessIdFromOptions, assertConfirmationPrompt, booleanFromOptions, customTagsFromOptions, defaultTtlSecondsCLI, readARIOFromOptions, requiredStringFromOptions, stringArrayFromOptions, writeANTFromOptions, } from '../utils.js';
|
|
2
2
|
/** @deprecated -- use set-ant-base-name and set-ant-undername */
|
|
3
3
|
export async function setAntRecordCLICommand(o) {
|
|
4
4
|
const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
|
|
5
5
|
const undername = requiredStringFromOptions(o, 'undername');
|
|
6
6
|
const transactionId = requiredStringFromOptions(o, 'transactionId');
|
|
7
7
|
const writeAnt = writeANTFromOptions(o);
|
|
8
|
-
|
|
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({
|
|
8
|
+
const recordParams = {
|
|
12
9
|
undername,
|
|
13
10
|
transactionId,
|
|
14
11
|
ttlSeconds,
|
|
15
|
-
|
|
12
|
+
...antRecordMetadataFromOptions(o),
|
|
13
|
+
};
|
|
14
|
+
if (!o.skipConfirmation) {
|
|
15
|
+
await assertConfirmationPrompt(`Are you sure you want to set this record on the ANT process ${writeAnt.processId}?\n${JSON.stringify(recordParams, null, 2)}`, o);
|
|
16
|
+
}
|
|
17
|
+
return writeANTFromOptions(o).setRecord(recordParams, customTagsFromOptions(o));
|
|
16
18
|
}
|
|
17
19
|
export async function setAntBaseNameCLICommand(o) {
|
|
18
20
|
const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
|
|
19
21
|
const transactionId = requiredStringFromOptions(o, 'transactionId');
|
|
22
|
+
const params = {
|
|
23
|
+
transactionId,
|
|
24
|
+
ttlSeconds,
|
|
25
|
+
...antRecordMetadataFromOptions(o),
|
|
26
|
+
};
|
|
20
27
|
const writeAnt = writeANTFromOptions(o);
|
|
21
28
|
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(
|
|
29
|
+
await assertConfirmationPrompt(`Are you sure you want to set this base name on the ANT process ${writeAnt.processId}?\n${JSON.stringify(params, null, 2)}`, o);
|
|
23
30
|
}
|
|
24
|
-
return writeANTFromOptions(o).setBaseNameRecord(
|
|
25
|
-
transactionId,
|
|
26
|
-
ttlSeconds,
|
|
27
|
-
}, customTagsFromOptions(o));
|
|
31
|
+
return writeANTFromOptions(o).setBaseNameRecord(params, customTagsFromOptions(o));
|
|
28
32
|
}
|
|
29
33
|
export async function setAntUndernameCLICommand(o) {
|
|
30
34
|
const ttlSeconds = +(o.ttlSeconds ?? defaultTtlSecondsCLI);
|
|
31
35
|
const undername = requiredStringFromOptions(o, 'undername');
|
|
32
36
|
const transactionId = requiredStringFromOptions(o, 'transactionId');
|
|
33
|
-
const
|
|
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({
|
|
37
|
+
const params = {
|
|
38
38
|
undername,
|
|
39
39
|
transactionId,
|
|
40
40
|
ttlSeconds,
|
|
41
|
-
|
|
41
|
+
...antRecordMetadataFromOptions(o),
|
|
42
|
+
};
|
|
43
|
+
const writeAnt = writeANTFromOptions(o);
|
|
44
|
+
if (!o.skipConfirmation) {
|
|
45
|
+
await assertConfirmationPrompt(`Are you sure you want to set this undername on the ANT process ${writeAnt.processId}?\n${JSON.stringify(params, null, 2)}`, o);
|
|
46
|
+
}
|
|
47
|
+
return writeANTFromOptions(o).setUndernameRecord(params, customTagsFromOptions(o));
|
|
48
|
+
}
|
|
49
|
+
export async function transferRecordOwnershipCLICommand(o) {
|
|
50
|
+
const undername = requiredStringFromOptions(o, 'undername');
|
|
51
|
+
const recipient = requiredStringFromOptions(o, 'recipient');
|
|
52
|
+
const writeAnt = writeANTFromOptions(o);
|
|
53
|
+
if (!o.skipConfirmation) {
|
|
54
|
+
await assertConfirmationPrompt(`Are you sure you want to transfer ownership of "${undername}" to "${recipient}" on ANT process ${writeAnt.processId}?\n${JSON.stringify({ undername, recipient }, null, 2)}`, o);
|
|
55
|
+
}
|
|
56
|
+
return writeANTFromOptions(o).transferRecord({ undername, recipient }, customTagsFromOptions(o));
|
|
42
57
|
}
|
|
43
58
|
export async function upgradeAntCLICommand(o) {
|
|
44
59
|
const writeAnt = writeANTFromOptions(o);
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -251,6 +251,14 @@ export const optionMap = {
|
|
|
251
251
|
description: 'The keywords for the ANT',
|
|
252
252
|
type: 'array',
|
|
253
253
|
},
|
|
254
|
+
owner: {
|
|
255
|
+
alias: '--owner <owner>',
|
|
256
|
+
description: 'The owner address for the record',
|
|
257
|
+
},
|
|
258
|
+
displayName: {
|
|
259
|
+
alias: '--display-name <displayName>',
|
|
260
|
+
description: 'The display name for the record',
|
|
261
|
+
},
|
|
254
262
|
names: {
|
|
255
263
|
alias: '--names <names...>',
|
|
256
264
|
description: 'The names to interact with',
|
|
@@ -286,6 +294,10 @@ export const optionMap = {
|
|
|
286
294
|
alias: '--logo <logo>',
|
|
287
295
|
description: 'The ANT logo',
|
|
288
296
|
},
|
|
297
|
+
module: {
|
|
298
|
+
alias: '--module <module>',
|
|
299
|
+
description: 'The module ID to use for spawning the ANT process',
|
|
300
|
+
},
|
|
289
301
|
token: {
|
|
290
302
|
alias: '-t, --token <type>',
|
|
291
303
|
description: 'Crypto token type for wallet or action',
|
|
@@ -413,11 +425,17 @@ export const antStateOptions = [
|
|
|
413
425
|
optionMap.controllers,
|
|
414
426
|
optionMap.ttlSeconds,
|
|
415
427
|
optionMap.logo,
|
|
428
|
+
optionMap.module,
|
|
416
429
|
];
|
|
417
430
|
export const setAntBaseNameOptions = [
|
|
418
431
|
optionMap.processId,
|
|
419
432
|
optionMap.transactionId,
|
|
420
433
|
optionMap.ttlSeconds,
|
|
434
|
+
optionMap.owner,
|
|
435
|
+
optionMap.displayName,
|
|
436
|
+
optionMap.logo,
|
|
437
|
+
optionMap.description,
|
|
438
|
+
optionMap.keywords,
|
|
421
439
|
...writeActionOptions,
|
|
422
440
|
];
|
|
423
441
|
export const setAntUndernameOptions = [
|
|
@@ -430,3 +448,9 @@ export const upgradeAntOptions = [
|
|
|
430
448
|
optionMap.reassignAffiliatedNames,
|
|
431
449
|
...writeActionOptions,
|
|
432
450
|
];
|
|
451
|
+
export const transferRecordOwnershipOptions = [
|
|
452
|
+
optionMap.processId,
|
|
453
|
+
optionMap.undername,
|
|
454
|
+
optionMap.recipient,
|
|
455
|
+
...writeActionOptions,
|
|
456
|
+
];
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -507,3 +507,16 @@ export function assertLockLengthInRange(lockLengthMs, assertMin = true) {
|
|
|
507
507
|
throw new Error(`Lock length must be at least 14 days (1209600000 ms). Provided lock length: ${lockLengthMs} ms`);
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
+
export function antRecordMetadataFromOptions(options) {
|
|
511
|
+
return {
|
|
512
|
+
...(options.owner != null &&
|
|
513
|
+
options.owner !== '' && { owner: options.owner }),
|
|
514
|
+
...(options.displayName != null &&
|
|
515
|
+
options.displayName !== '' && { displayName: options.displayName }),
|
|
516
|
+
...(options.logo != null && options.logo !== '' && { logo: options.logo }),
|
|
517
|
+
...(options.description != null &&
|
|
518
|
+
options.description !== '' && { description: options.description }),
|
|
519
|
+
...(options.keywords != null &&
|
|
520
|
+
options.keywords.length > 0 && { keywords: options.keywords }),
|
|
521
|
+
};
|
|
522
|
+
}
|