@ar.io/sdk 3.4.0-alpha.2 → 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/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 +11 -17
- 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 +11 -17
- 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 +5 -19
- package/lib/types/types/ant.d.ts +44 -43
- 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' }];
|
|
@@ -292,12 +294,8 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
292
294
|
* @param transactionId @type {string} The transactionId of the record.
|
|
293
295
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
294
296
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
295
|
-
* @example
|
|
296
|
-
* ```ts
|
|
297
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
298
|
-
* ```
|
|
299
297
|
*/
|
|
300
|
-
async setRecord({ undername, transactionId, ttlSeconds
|
|
298
|
+
async setRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
301
299
|
return this.process.send({
|
|
302
300
|
tags: [
|
|
303
301
|
...(options?.tags ?? []),
|
|
@@ -320,16 +318,12 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
320
318
|
* ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
321
319
|
* ```
|
|
322
320
|
*/
|
|
323
|
-
async setBaseNameRecord({ transactionId, ttlSeconds,
|
|
324
|
-
return this.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
330
|
-
],
|
|
331
|
-
signer: this.signer,
|
|
332
|
-
});
|
|
321
|
+
async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
|
|
322
|
+
return this.setRecord({
|
|
323
|
+
transactionId,
|
|
324
|
+
ttlSeconds,
|
|
325
|
+
undername: '@',
|
|
326
|
+
}, options);
|
|
333
327
|
}
|
|
334
328
|
/**
|
|
335
329
|
* Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
|
|
@@ -343,12 +337,12 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
343
337
|
* ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
344
338
|
* ```
|
|
345
339
|
*/
|
|
346
|
-
async setUndernameRecord({ undername, transactionId, ttlSeconds,
|
|
340
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
347
341
|
return this.setRecord({
|
|
348
342
|
undername,
|
|
349
343
|
transactionId,
|
|
350
344
|
ttlSeconds,
|
|
351
|
-
});
|
|
345
|
+
}, options);
|
|
352
346
|
}
|
|
353
347
|
/**
|
|
354
348
|
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
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) {
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -30,6 +30,7 @@ export class ANT {
|
|
|
30
30
|
}
|
|
31
31
|
export class AoANTReadable {
|
|
32
32
|
process;
|
|
33
|
+
processId;
|
|
33
34
|
strict;
|
|
34
35
|
constructor(config) {
|
|
35
36
|
this.strict = config.strict || false;
|
|
@@ -44,6 +45,7 @@ export class AoANTReadable {
|
|
|
44
45
|
else {
|
|
45
46
|
throw new InvalidContractConfigurationError();
|
|
46
47
|
}
|
|
48
|
+
this.processId = this.process.processId;
|
|
47
49
|
}
|
|
48
50
|
async getState({ strict } = { strict: this.strict }) {
|
|
49
51
|
const tags = [{ name: 'Action', value: 'State' }];
|
|
@@ -287,12 +289,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
287
289
|
* @param transactionId @type {string} The transactionId of the record.
|
|
288
290
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
289
291
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
290
|
-
* @example
|
|
291
|
-
* ```ts
|
|
292
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
293
|
-
* ```
|
|
294
292
|
*/
|
|
295
|
-
async setRecord({ undername, transactionId, ttlSeconds
|
|
293
|
+
async setRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
296
294
|
return this.process.send({
|
|
297
295
|
tags: [
|
|
298
296
|
...(options?.tags ?? []),
|
|
@@ -315,16 +313,12 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
315
313
|
* 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
314
|
* ```
|
|
317
315
|
*/
|
|
318
|
-
async setBaseNameRecord({ transactionId, ttlSeconds,
|
|
319
|
-
return this.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
325
|
-
],
|
|
326
|
-
signer: this.signer,
|
|
327
|
-
});
|
|
316
|
+
async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
|
|
317
|
+
return this.setRecord({
|
|
318
|
+
transactionId,
|
|
319
|
+
ttlSeconds,
|
|
320
|
+
undername: '@',
|
|
321
|
+
}, options);
|
|
328
322
|
}
|
|
329
323
|
/**
|
|
330
324
|
* 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)
|
|
@@ -338,12 +332,12 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
338
332
|
* 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
333
|
* ```
|
|
340
334
|
*/
|
|
341
|
-
async setUndernameRecord({ undername, transactionId, ttlSeconds,
|
|
335
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
342
336
|
return this.setRecord({
|
|
343
337
|
undername,
|
|
344
338
|
transactionId,
|
|
345
339
|
ttlSeconds,
|
|
346
|
-
});
|
|
340
|
+
}, options);
|
|
347
341
|
}
|
|
348
342
|
/**
|
|
349
343
|
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
package/lib/esm/version.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams } from '../../types/ant.js';
|
|
17
|
+
import { CLIWriteOptionsFromAoAntParams } from '../types.js';
|
|
18
|
+
/** @deprecated -- use set-ant-base-name and set-ant-undername */
|
|
19
|
+
export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
|
+
export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
|
+
export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -333,3 +333,11 @@ export declare const antStateOptions: {
|
|
|
333
333
|
alias: string;
|
|
334
334
|
description: string;
|
|
335
335
|
}[];
|
|
336
|
+
export declare const setAntBaseNameOptions: {
|
|
337
|
+
alias: string;
|
|
338
|
+
description: string;
|
|
339
|
+
}[];
|
|
340
|
+
export declare const setAntUndernameOptions: {
|
|
341
|
+
alias: string;
|
|
342
|
+
description: string;
|
|
343
|
+
}[];
|
package/lib/types/cli/types.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ export type CLIOptionsFromAoParams<T> = {
|
|
|
49
49
|
};
|
|
50
50
|
export type CLIReadOptionsFromAoParams<T> = CLIOptionsFromAoParams<T> & GlobalCLIOptions;
|
|
51
51
|
export type CLIWriteOptionsFromAoParams<T> = WriteActionCLIOptions & CLIOptionsFromAoParams<T>;
|
|
52
|
+
export type CLIWriteOptionsFromAoAntParams<T> = CLIWriteOptionsFromAoParams<T & {
|
|
53
|
+
processId: string;
|
|
54
|
+
}>;
|
|
52
55
|
export type PaginationCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<PaginationParams>;
|
|
53
56
|
export type AddressCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoAddressParams>;
|
|
54
57
|
export type ProcessIdCLIOptions = GlobalCLIOptions & {
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { JWKInterface } from 'arweave/node/lib/wallet.js';
|
|
|
2
2
|
import { Command, OptionValues } from 'commander';
|
|
3
3
|
import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
|
|
4
4
|
import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
|
|
5
|
+
export declare const defaultTtlSecondsCLI = 3600;
|
|
5
6
|
export declare function stringifyJsonForCLIDisplay(json: JsonSerializable | unknown): string;
|
|
6
7
|
export declare function runCommand<O extends OptionValues>(command: Command, action: (options: O) => Promise<JsonSerializable>): Promise<void>;
|
|
7
8
|
export interface CommanderOption {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTState, AoANTWrite } from '../types/ant.js';
|
|
1
|
+
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTWrite } from '../types/ant.js';
|
|
2
2
|
import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './index.js';
|
|
4
4
|
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
@@ -12,6 +12,7 @@ export declare class ANT {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class AoANTReadable implements AoANTRead {
|
|
14
14
|
protected process: AOProcess;
|
|
15
|
+
readonly processId: string;
|
|
15
16
|
private strict;
|
|
16
17
|
constructor(config: ANTConfigOptionalStrict);
|
|
17
18
|
getState({ strict }?: AntReadOptions): Promise<AoANTState>;
|
|
@@ -154,16 +155,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
154
155
|
* @param transactionId @type {string} The transactionId of the record.
|
|
155
156
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
156
157
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
160
|
-
* ```
|
|
161
158
|
*/
|
|
162
|
-
setRecord({ undername, transactionId, ttlSeconds
|
|
163
|
-
undername: string;
|
|
164
|
-
transactionId: string;
|
|
165
|
-
ttlSeconds: number;
|
|
166
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
159
|
+
setRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
167
160
|
/**
|
|
168
161
|
* 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)
|
|
169
162
|
*
|
|
@@ -175,10 +168,7 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
175
168
|
* 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
|
|
176
169
|
* ```
|
|
177
170
|
*/
|
|
178
|
-
setBaseNameRecord({ transactionId, ttlSeconds
|
|
179
|
-
transactionId: string;
|
|
180
|
-
ttlSeconds: number;
|
|
181
|
-
}): Promise<AoMessageResult>;
|
|
171
|
+
setBaseNameRecord({ transactionId, ttlSeconds }: AoANTSetBaseNameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
182
172
|
/**
|
|
183
173
|
* 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)
|
|
184
174
|
*
|
|
@@ -191,11 +181,7 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
191
181
|
* 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
|
|
192
182
|
* ```
|
|
193
183
|
*/
|
|
194
|
-
setUndernameRecord({ undername, transactionId, ttlSeconds
|
|
195
|
-
undername: string;
|
|
196
|
-
transactionId: string;
|
|
197
|
-
ttlSeconds: number;
|
|
198
|
-
}): Promise<AoMessageResult>;
|
|
184
|
+
setUndernameRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
199
185
|
/**
|
|
200
186
|
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
|
201
187
|
*
|