@ar.io/sdk 3.4.0-alpha.1 → 3.4.0-alpha.3
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 +73 -2
- package/bundles/web.bundle.min.js +3 -3
- package/lib/cjs/cli/cli.js +16 -19
- package/lib/cjs/cli/commands/antCommands.js +48 -0
- package/lib/cjs/cli/options.js +11 -1
- package/lib/cjs/cli/utils.js +5 -2
- package/lib/cjs/common/ant.js +96 -7
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +17 -20
- package/lib/esm/cli/commands/antCommands.js +42 -0
- package/lib/esm/cli/options.js +10 -0
- package/lib/esm/cli/utils.js +4 -1
- package/lib/esm/common/ant.js +96 -7
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +21 -0
- package/lib/types/cli/options.d.ts +8 -0
- package/lib/types/cli/types.d.ts +3 -0
- package/lib/types/cli/utils.d.ts +1 -0
- package/lib/types/common/ant.d.ts +80 -8
- package/lib/types/types/ant.d.ts +44 -31
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/cli/cli.js
CHANGED
|
@@ -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");
|
|
@@ -519,25 +520,21 @@ const utils_js_1 = require("./utils.js");
|
|
|
519
520
|
});
|
|
520
521
|
(0, utils_js_1.makeCommand)({
|
|
521
522
|
name: 'set-ant-record',
|
|
522
|
-
description: 'Set a record of an ANT process',
|
|
523
|
-
options:
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
action:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
transactionId,
|
|
538
|
-
ttlSeconds,
|
|
539
|
-
}, (0, utils_js_1.writeActionTagsFromOptions)(options));
|
|
540
|
-
},
|
|
523
|
+
description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
|
|
524
|
+
options: options_js_1.setAntUndernameOptions,
|
|
525
|
+
action: antCommands_js_1.setAntRecordCLICommand,
|
|
526
|
+
});
|
|
527
|
+
(0, utils_js_1.makeCommand)({
|
|
528
|
+
name: 'set-ant-base-name',
|
|
529
|
+
description: 'Set the base name of an ANT process',
|
|
530
|
+
options: options_js_1.setAntBaseNameOptions,
|
|
531
|
+
action: antCommands_js_1.setAntBaseNameCLICommand,
|
|
532
|
+
});
|
|
533
|
+
(0, utils_js_1.makeCommand)({
|
|
534
|
+
name: 'set-ant-undername',
|
|
535
|
+
description: 'Set an undername of an ANT process',
|
|
536
|
+
options: options_js_1.setAntUndernameOptions,
|
|
537
|
+
action: antCommands_js_1.setAntRecordCLICommand,
|
|
541
538
|
});
|
|
542
539
|
(0, utils_js_1.makeCommand)({
|
|
543
540
|
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;
|
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.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>',
|
|
@@ -354,3 +354,13 @@ exports.antStateOptions = [
|
|
|
354
354
|
exports.optionMap.controllers,
|
|
355
355
|
exports.optionMap.ttlSeconds,
|
|
356
356
|
];
|
|
357
|
+
exports.setAntBaseNameOptions = [
|
|
358
|
+
exports.optionMap.processId,
|
|
359
|
+
exports.optionMap.transactionId,
|
|
360
|
+
exports.optionMap.ttlSeconds,
|
|
361
|
+
...exports.writeActionOptions,
|
|
362
|
+
];
|
|
363
|
+
exports.setAntUndernameOptions = [
|
|
364
|
+
...exports.setAntBaseNameOptions,
|
|
365
|
+
exports.optionMap.undername,
|
|
366
|
+
];
|
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.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.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
|
|
432
|
+
ttlSeconds: options.ttlSeconds !== undefined
|
|
433
|
+
? +options.ttlSeconds
|
|
434
|
+
: exports.defaultTtlSecondsCLI,
|
|
432
435
|
});
|
|
433
436
|
}
|
|
434
437
|
exports.getANTStateFromOptions = getANTStateFromOptions;
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -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' }];
|
|
@@ -285,16 +287,15 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
285
287
|
});
|
|
286
288
|
}
|
|
287
289
|
/**
|
|
290
|
+
* Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
|
|
291
|
+
*
|
|
292
|
+
* @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
|
|
288
293
|
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
289
294
|
* @param transactionId @type {string} The transactionId of the record.
|
|
290
295
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
291
296
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
292
|
-
* @example
|
|
293
|
-
* ```ts
|
|
294
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
295
|
-
* ```
|
|
296
297
|
*/
|
|
297
|
-
async setRecord({ undername, transactionId, ttlSeconds
|
|
298
|
+
async setRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
298
299
|
return this.process.send({
|
|
299
300
|
tags: [
|
|
300
301
|
...(options?.tags ?? []),
|
|
@@ -307,11 +308,64 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
307
308
|
});
|
|
308
309
|
}
|
|
309
310
|
/**
|
|
311
|
+
* 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)
|
|
312
|
+
*
|
|
313
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
314
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
315
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
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
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
|
|
322
|
+
return this.setRecord({
|
|
323
|
+
transactionId,
|
|
324
|
+
ttlSeconds,
|
|
325
|
+
undername: '@',
|
|
326
|
+
}, options);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
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)
|
|
330
|
+
*
|
|
331
|
+
* @param undername @type {string} The undername of the ANT.
|
|
332
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
333
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
334
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
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
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
341
|
+
return this.setRecord({
|
|
342
|
+
undername,
|
|
343
|
+
transactionId,
|
|
344
|
+
ttlSeconds,
|
|
345
|
+
}, options);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
|
349
|
+
*
|
|
350
|
+
* @param undername @type {string} The undername you want to remove.
|
|
351
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
async removeUndernameRecord({ undername, }) {
|
|
358
|
+
return this.removeRecord({ undername });
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
|
|
362
|
+
*
|
|
363
|
+
* @deprecated Use removeUndernameRecord instead.
|
|
310
364
|
* @param undername @type {string} The record you want to remove.
|
|
311
365
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
312
366
|
* @example
|
|
313
367
|
* ```ts
|
|
314
|
-
* ant.removeRecord({
|
|
368
|
+
* ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
|
|
315
369
|
* ```
|
|
316
370
|
*/
|
|
317
371
|
async removeRecord({ undername, }, options) {
|
|
@@ -325,6 +379,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
325
379
|
});
|
|
326
380
|
}
|
|
327
381
|
/**
|
|
382
|
+
* Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
|
|
383
|
+
*
|
|
328
384
|
* @param ticker @type {string} Sets the ANT Ticker.
|
|
329
385
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
330
386
|
* @example
|
|
@@ -343,6 +399,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
343
399
|
});
|
|
344
400
|
}
|
|
345
401
|
/**
|
|
402
|
+
* Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
|
|
403
|
+
*
|
|
346
404
|
* @param name @type {string} Sets the Name of the ANT.
|
|
347
405
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
348
406
|
* @example
|
|
@@ -361,6 +419,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
361
419
|
});
|
|
362
420
|
}
|
|
363
421
|
/**
|
|
422
|
+
* Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
|
|
423
|
+
*
|
|
364
424
|
* @param description @type {string} Sets the ANT Description.
|
|
365
425
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
366
426
|
* @example
|
|
@@ -379,6 +439,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
379
439
|
});
|
|
380
440
|
}
|
|
381
441
|
/**
|
|
442
|
+
* Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
|
|
443
|
+
*
|
|
382
444
|
* @param keywords @type {string[]} Sets the ANT Keywords.
|
|
383
445
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
384
446
|
* @example
|
|
@@ -397,6 +459,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
397
459
|
});
|
|
398
460
|
}
|
|
399
461
|
/**
|
|
462
|
+
* 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.
|
|
463
|
+
*
|
|
400
464
|
* @param txId @type {string} - Arweave transaction id of the logo we want to set
|
|
401
465
|
* @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
|
|
402
466
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -416,6 +480,9 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
416
480
|
});
|
|
417
481
|
}
|
|
418
482
|
/**
|
|
483
|
+
* 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.
|
|
484
|
+
*
|
|
485
|
+
*
|
|
419
486
|
* @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
487
|
* @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
|
|
421
488
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
@@ -437,7 +504,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
437
504
|
});
|
|
438
505
|
}
|
|
439
506
|
/**
|
|
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.
|
|
507
|
+
* 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.
|
|
508
|
+
*
|
|
441
509
|
* @param name @type {string} The name you want to reassign.
|
|
442
510
|
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
443
511
|
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
@@ -462,6 +530,15 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
462
530
|
}
|
|
463
531
|
/**
|
|
464
532
|
* Approves a primary name request for a given name or address.
|
|
533
|
+
*
|
|
534
|
+
* @param name @type {string} The name you want to approve.
|
|
535
|
+
* @param address @type {WalletAddress} The address you want to approve.
|
|
536
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
537
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
538
|
+
* @example
|
|
539
|
+
* ```ts
|
|
540
|
+
* ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
|
|
541
|
+
* ```
|
|
465
542
|
*/
|
|
466
543
|
async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
|
|
467
544
|
return this.process.send({
|
|
@@ -476,6 +553,18 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
476
553
|
signer: this.signer,
|
|
477
554
|
});
|
|
478
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* 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.
|
|
558
|
+
*
|
|
559
|
+
* @param names @type {string[]} The names you want to remove.
|
|
560
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
561
|
+
* @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
|
|
562
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
563
|
+
* @example
|
|
564
|
+
* ```ts
|
|
565
|
+
* 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"
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
479
568
|
async removePrimaryNames({ names, arioProcessId, notifyOwners = false, }, options) {
|
|
480
569
|
return this.process.send({
|
|
481
570
|
tags: [
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -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
26
|
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
|
+
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')
|
|
@@ -517,25 +518,21 @@ makeCommand({
|
|
|
517
518
|
});
|
|
518
519
|
makeCommand({
|
|
519
520
|
name: 'set-ant-record',
|
|
520
|
-
description: 'Set a record of an ANT process',
|
|
521
|
-
options:
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
action:
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
transactionId,
|
|
536
|
-
ttlSeconds,
|
|
537
|
-
}, writeActionTagsFromOptions(options));
|
|
538
|
-
},
|
|
521
|
+
description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
|
|
522
|
+
options: setAntUndernameOptions,
|
|
523
|
+
action: setAntRecordCLICommand,
|
|
524
|
+
});
|
|
525
|
+
makeCommand({
|
|
526
|
+
name: 'set-ant-base-name',
|
|
527
|
+
description: 'Set the base name of an ANT process',
|
|
528
|
+
options: setAntBaseNameOptions,
|
|
529
|
+
action: setAntBaseNameCLICommand,
|
|
530
|
+
});
|
|
531
|
+
makeCommand({
|
|
532
|
+
name: 'set-ant-undername',
|
|
533
|
+
description: 'Set an undername of an ANT process',
|
|
534
|
+
options: setAntUndernameOptions,
|
|
535
|
+
action: setAntRecordCLICommand,
|
|
539
536
|
});
|
|
540
537
|
makeCommand({
|
|
541
538
|
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
|
+
}
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -351,3 +351,13 @@ export const antStateOptions = [
|
|
|
351
351
|
optionMap.controllers,
|
|
352
352
|
optionMap.ttlSeconds,
|
|
353
353
|
];
|
|
354
|
+
export const setAntBaseNameOptions = [
|
|
355
|
+
optionMap.processId,
|
|
356
|
+
optionMap.transactionId,
|
|
357
|
+
optionMap.ttlSeconds,
|
|
358
|
+
...writeActionOptions,
|
|
359
|
+
];
|
|
360
|
+
export const setAntUndernameOptions = [
|
|
361
|
+
...setAntBaseNameOptions,
|
|
362
|
+
optionMap.undername,
|
|
363
|
+
];
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ import { readFileSync } from 'fs';
|
|
|
19
19
|
import prompts from 'prompts';
|
|
20
20
|
import { ANT, AOProcess, ARIO, ARIOToken, ARIO_DEVNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, ArweaveSigner, Logger, createAoSigner, fromB64Url, fundFromOptions, initANTStateForAddress, isValidFundFrom, isValidIntent, mARIOToken, sha256B64Url, validIntents, } from '../node/index.js';
|
|
21
21
|
import { globalOptions } from './options.js';
|
|
22
|
+
export const defaultTtlSecondsCLI = 3600;
|
|
22
23
|
export function stringifyJsonForCLIDisplay(json) {
|
|
23
24
|
return JSON.stringify(json, null, 2);
|
|
24
25
|
}
|
|
@@ -385,7 +386,9 @@ export function getANTStateFromOptions(options) {
|
|
|
385
386
|
ticker: options.ticker,
|
|
386
387
|
name: options.name,
|
|
387
388
|
keywords: options.keywords,
|
|
388
|
-
ttlSeconds: options.ttlSeconds !== undefined
|
|
389
|
+
ttlSeconds: options.ttlSeconds !== undefined
|
|
390
|
+
? +options.ttlSeconds
|
|
391
|
+
: defaultTtlSecondsCLI,
|
|
389
392
|
});
|
|
390
393
|
}
|
|
391
394
|
export function getTokenCostParamsFromOptions(o) {
|