@ar.io/sdk 2.7.0-alpha.7 → 3.0.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 +147 -147
- package/bundles/web.bundle.min.js +2 -2
- package/lib/cjs/cli/cli.js +26 -26
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +39 -39
- package/lib/cjs/cli/commands/readCommands.js +19 -19
- package/lib/cjs/cli/commands/transfer.js +7 -7
- package/lib/cjs/cli/options.js +3 -3
- package/lib/cjs/cli/utils.js +22 -22
- package/lib/cjs/common/ant.js +18 -14
- package/lib/cjs/common/io.js +11 -11
- package/lib/cjs/constants.js +5 -5
- package/lib/cjs/types/token.js +14 -14
- package/lib/cjs/utils/processes.js +4 -4
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +28 -28
- package/lib/esm/cli/commands/gatewayWriteCommands.js +41 -41
- package/lib/esm/cli/commands/readCommands.js +21 -21
- package/lib/esm/cli/commands/transfer.js +8 -8
- package/lib/esm/cli/options.js +3 -3
- package/lib/esm/cli/utils.js +18 -18
- package/lib/esm/common/ant.js +18 -14
- package/lib/esm/common/io.js +8 -8
- package/lib/esm/constants.js +4 -4
- package/lib/esm/types/token.js +12 -12
- package/lib/esm/utils/processes.js +6 -6
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/options.d.ts +1 -1
- package/lib/types/cli/types.d.ts +1 -1
- package/lib/types/cli/utils.d.ts +10 -10
- package/lib/types/common/ant.d.ts +14 -14
- package/lib/types/common/io.d.ts +16 -16
- package/lib/types/constants.d.ts +4 -4
- package/lib/types/types/ant.d.ts +8 -8
- package/lib/types/types/io.d.ts +9 -9
- package/lib/types/types/token.d.ts +8 -8
- package/lib/types/utils/processes.d.ts +4 -4
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
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.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughBalance = exports.requiredMIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.writeActionTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.
|
|
6
|
+
exports.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughBalance = exports.requiredMIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.writeActionTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.formatARIOWithCommas = exports.writeARIOFromOptions = exports.requiredAoSignerFromOptions = exports.requiredContractSignerFromOptions = exports.readARIOFromOptions = exports.getLoggerFromOptions = exports.jwkToAddress = exports.requiredJwkFromOptions = exports.arioProcessIdFromOptions = exports.makeCommand = exports.applyOptions = exports.runCommand = exports.stringifyJsonForCLIDisplay = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
9
9
|
*
|
|
@@ -74,14 +74,14 @@ function makeCommand({ description, name, options = [], action, }) {
|
|
|
74
74
|
return appliedCommand;
|
|
75
75
|
}
|
|
76
76
|
exports.makeCommand = makeCommand;
|
|
77
|
-
function
|
|
78
|
-
return
|
|
79
|
-
?
|
|
77
|
+
function arioProcessIdFromOptions({ arioProcessId, dev, }) {
|
|
78
|
+
return arioProcessId !== undefined
|
|
79
|
+
? arioProcessId
|
|
80
80
|
: dev
|
|
81
|
-
? index_js_1.
|
|
82
|
-
: index_js_1.
|
|
81
|
+
? index_js_1.ARIO_DEVNET_PROCESS_ID
|
|
82
|
+
: index_js_1.ARIO_TESTNET_PROCESS_ID;
|
|
83
83
|
}
|
|
84
|
-
exports.
|
|
84
|
+
exports.arioProcessIdFromOptions = arioProcessIdFromOptions;
|
|
85
85
|
function jwkFromOptions({ privateKey, walletFile, }) {
|
|
86
86
|
if (privateKey !== undefined) {
|
|
87
87
|
return JSON.parse(privateKey);
|
|
@@ -115,19 +115,19 @@ function getLoggerFromOptions(options) {
|
|
|
115
115
|
exports.getLoggerFromOptions = getLoggerFromOptions;
|
|
116
116
|
function aoProcessFromOptions(options) {
|
|
117
117
|
return new index_js_1.AOProcess({
|
|
118
|
-
processId:
|
|
118
|
+
processId: arioProcessIdFromOptions(options),
|
|
119
119
|
ao: (0, aoconnect_1.connect)({
|
|
120
120
|
CU_URL: options.cuUrl,
|
|
121
121
|
}),
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function readARIOFromOptions(options) {
|
|
125
125
|
setLoggerIfDebug(options);
|
|
126
|
-
return index_js_1.
|
|
126
|
+
return index_js_1.ARIO.init({
|
|
127
127
|
process: aoProcessFromOptions(options),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
exports.
|
|
130
|
+
exports.readARIOFromOptions = readARIOFromOptions;
|
|
131
131
|
function requiredContractSignerFromOptions(options) {
|
|
132
132
|
// TODO: Support other wallet types
|
|
133
133
|
const jwk = requiredJwkFromOptions(options);
|
|
@@ -139,19 +139,19 @@ function requiredAoSignerFromOptions(options) {
|
|
|
139
139
|
return (0, index_js_1.createAoSigner)(requiredContractSignerFromOptions(options).signer);
|
|
140
140
|
}
|
|
141
141
|
exports.requiredAoSignerFromOptions = requiredAoSignerFromOptions;
|
|
142
|
-
function
|
|
142
|
+
function writeARIOFromOptions(options) {
|
|
143
143
|
const { signer, signerAddress } = requiredContractSignerFromOptions(options);
|
|
144
144
|
setLoggerIfDebug(options);
|
|
145
145
|
return {
|
|
146
|
-
|
|
146
|
+
ario: index_js_1.ARIO.init({
|
|
147
147
|
process: aoProcessFromOptions(options),
|
|
148
148
|
signer,
|
|
149
149
|
}),
|
|
150
150
|
signerAddress,
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
exports.
|
|
154
|
-
function
|
|
153
|
+
exports.writeARIOFromOptions = writeARIOFromOptions;
|
|
154
|
+
function formatARIOWithCommas(value) {
|
|
155
155
|
const [integerPart, decimalPart] = value.toString().split('.');
|
|
156
156
|
const integerWithCommas = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
157
157
|
if (decimalPart === undefined) {
|
|
@@ -159,7 +159,7 @@ function formatIOWithCommas(value) {
|
|
|
159
159
|
}
|
|
160
160
|
return integerWithCommas + '.' + decimalPart;
|
|
161
161
|
}
|
|
162
|
-
exports.
|
|
162
|
+
exports.formatARIOWithCommas = formatARIOWithCommas;
|
|
163
163
|
/** helper to get address from --address option first, then check wallet options */
|
|
164
164
|
function addressFromOptions(options) {
|
|
165
165
|
if (options.address !== undefined) {
|
|
@@ -268,12 +268,12 @@ function requiredTargetAndQuantityFromOptions(options) {
|
|
|
268
268
|
}
|
|
269
269
|
return {
|
|
270
270
|
target: options.target,
|
|
271
|
-
|
|
271
|
+
arioQuantity: new index_js_1.ARIOToken(+options.quantity),
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
exports.requiredTargetAndQuantityFromOptions = requiredTargetAndQuantityFromOptions;
|
|
275
275
|
function redelegateParamsFromOptions(options) {
|
|
276
|
-
const { target,
|
|
276
|
+
const { target, arioQuantity: aRIOQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
277
277
|
const source = options.source;
|
|
278
278
|
if (source === undefined) {
|
|
279
279
|
throw new Error('No source provided. Use --source');
|
|
@@ -282,7 +282,7 @@ function redelegateParamsFromOptions(options) {
|
|
|
282
282
|
target,
|
|
283
283
|
source,
|
|
284
284
|
vaultId: options.vaultId,
|
|
285
|
-
stakeQty:
|
|
285
|
+
stakeQty: aRIOQuantity.toMARIO(),
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
exports.redelegateParamsFromOptions = redelegateParamsFromOptions;
|
|
@@ -298,13 +298,13 @@ function requiredMIOFromOptions(options, key) {
|
|
|
298
298
|
if (options[key] === undefined) {
|
|
299
299
|
throw new Error(`No ${key} provided. Use --${key} denominated in IO`);
|
|
300
300
|
}
|
|
301
|
-
return new index_js_1.
|
|
301
|
+
return new index_js_1.ARIOToken(+options[key]).toMARIO();
|
|
302
302
|
}
|
|
303
303
|
exports.requiredMIOFromOptions = requiredMIOFromOptions;
|
|
304
304
|
async function assertEnoughBalance(io, address, ioQuantity) {
|
|
305
305
|
const balance = await io.getBalance({ address });
|
|
306
|
-
if (balance < ioQuantity.
|
|
307
|
-
throw new Error(`Insufficient IO balance for action. Balance available: ${new index_js_1.
|
|
306
|
+
if (balance < ioQuantity.toMARIO().valueOf()) {
|
|
307
|
+
throw new Error(`Insufficient IO balance for action. Balance available: ${new index_js_1.mARIOToken(balance).toARIO()} IO`);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
exports.assertEnoughBalance = assertEnoughBalance;
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -412,43 +412,45 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
415
|
-
* @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the
|
|
416
|
-
* @param
|
|
415
|
+
* @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.
|
|
416
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
|
|
417
417
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
418
418
|
* @example
|
|
419
419
|
* ```ts
|
|
420
|
-
* ant.releaseName({ name: "ardrive",
|
|
420
|
+
* ant.releaseName({ name: "ardrive", arioProcessId: AR_TESTNET_PROCESS_ID });
|
|
421
421
|
* ```
|
|
422
422
|
*/
|
|
423
|
-
async releaseName({ name,
|
|
423
|
+
async releaseName({ name, arioProcessId }, options) {
|
|
424
424
|
return this.process.send({
|
|
425
425
|
tags: [
|
|
426
426
|
...(options?.tags ?? []),
|
|
427
427
|
{ name: 'Action', value: 'Release-Name' },
|
|
428
428
|
{ name: 'Name', value: name },
|
|
429
|
-
{ name: 'IO-Process-Id', value:
|
|
429
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
430
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
430
431
|
],
|
|
431
432
|
signer: this.signer,
|
|
432
433
|
});
|
|
433
434
|
}
|
|
434
435
|
/**
|
|
435
|
-
* Sends a message to the
|
|
436
|
+
* 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.
|
|
436
437
|
* @param name @type {string} The name you want to reassign.
|
|
437
|
-
* @param
|
|
438
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
438
439
|
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
439
440
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
440
441
|
* @example
|
|
441
442
|
* ```ts
|
|
442
|
-
* ant.reassignName({ name: "ardrive",
|
|
443
|
+
* ant.reassignName({ name: "ardrive", arioProcessId: ARIO_TESTNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID });
|
|
443
444
|
* ```
|
|
444
445
|
*/
|
|
445
|
-
async reassignName({ name,
|
|
446
|
+
async reassignName({ name, arioProcessId, antProcessId, }, options) {
|
|
446
447
|
return this.process.send({
|
|
447
448
|
tags: [
|
|
448
449
|
...(options?.tags ?? []),
|
|
449
450
|
{ name: 'Action', value: 'Reassign-Name' },
|
|
450
451
|
{ name: 'Name', value: name },
|
|
451
|
-
{ name: 'IO-Process-Id', value:
|
|
452
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
453
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
452
454
|
{ name: 'Process-Id', value: antProcessId },
|
|
453
455
|
],
|
|
454
456
|
signer: this.signer,
|
|
@@ -457,25 +459,27 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
457
459
|
/**
|
|
458
460
|
* Approves a primary name request for a given name or address.
|
|
459
461
|
*/
|
|
460
|
-
async approvePrimaryNameRequest({ name, address,
|
|
462
|
+
async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
|
|
461
463
|
return this.process.send({
|
|
462
464
|
tags: [
|
|
463
465
|
...(options?.tags ?? []),
|
|
464
466
|
{ name: 'Action', value: 'Approve-Primary-Name' },
|
|
465
467
|
{ name: 'Name', value: name },
|
|
466
468
|
{ name: 'Recipient', value: address },
|
|
467
|
-
{ name: 'IO-Process-Id', value:
|
|
469
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
470
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
468
471
|
],
|
|
469
472
|
signer: this.signer,
|
|
470
473
|
});
|
|
471
474
|
}
|
|
472
|
-
async removePrimaryNames({ names,
|
|
475
|
+
async removePrimaryNames({ names, arioProcessId }, options) {
|
|
473
476
|
return this.process.send({
|
|
474
477
|
tags: [
|
|
475
478
|
...(options?.tags ?? []),
|
|
476
479
|
{ name: 'Action', value: 'Remove-Primary-Names' },
|
|
477
480
|
{ name: 'Names', value: names.join(',') },
|
|
478
|
-
{ name: 'IO-Process-Id', value:
|
|
481
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
482
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
479
483
|
],
|
|
480
484
|
signer: this.signer,
|
|
481
485
|
});
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ARIOWriteable = exports.ARIOReadable = exports.ARIO = void 0;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const io_js_1 = require("../types/io.js");
|
|
6
6
|
const ao_js_1 = require("../utils/ao.js");
|
|
@@ -8,26 +8,26 @@ const arweave_js_1 = require("../utils/arweave.js");
|
|
|
8
8
|
const arweave_js_2 = require("./arweave.js");
|
|
9
9
|
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
10
10
|
const error_js_1 = require("./error.js");
|
|
11
|
-
class
|
|
11
|
+
class ARIO {
|
|
12
12
|
static init(config) {
|
|
13
13
|
if (config && config.signer) {
|
|
14
14
|
const { signer, ...rest } = config;
|
|
15
|
-
return new
|
|
15
|
+
return new ARIOWriteable({
|
|
16
16
|
...rest,
|
|
17
17
|
signer,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
return new
|
|
20
|
+
return new ARIOReadable(config);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
exports.
|
|
24
|
-
class
|
|
23
|
+
exports.ARIO = ARIO;
|
|
24
|
+
class ARIOReadable {
|
|
25
25
|
process;
|
|
26
26
|
arweave;
|
|
27
27
|
constructor(config, arweave = arweave_js_2.defaultArweave) {
|
|
28
28
|
if (!config) {
|
|
29
29
|
this.process = new ao_process_js_1.AOProcess({
|
|
30
|
-
processId: constants_js_1.
|
|
30
|
+
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
else if ((0, io_js_1.isProcessConfiguration)(config)) {
|
|
@@ -420,14 +420,14 @@ class IOReadable {
|
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
exports.
|
|
424
|
-
class
|
|
423
|
+
exports.ARIOReadable = ARIOReadable;
|
|
424
|
+
class ARIOWriteable extends ARIOReadable {
|
|
425
425
|
signer;
|
|
426
426
|
constructor({ signer, ...config }) {
|
|
427
427
|
if (Object.keys(config).length === 0) {
|
|
428
428
|
super({
|
|
429
429
|
process: new ao_process_js_1.AOProcess({
|
|
430
|
-
processId: constants_js_1.
|
|
430
|
+
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
431
431
|
}),
|
|
432
432
|
});
|
|
433
433
|
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
@@ -783,4 +783,4 @@ class IOWriteable extends IOReadable {
|
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
|
-
exports.
|
|
786
|
+
exports.ARIOWriteable = ARIOWriteable;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SCHEDULER_ID = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.
|
|
3
|
+
exports.DEFAULT_SCHEDULER_ID = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MARIO_PER_ARIO = exports.ANT_REGISTRY_ID = exports.ARIO_TESTNET_PROCESS_ID = exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID = exports.ARNS_DEVNET_REGISTRY_TX = exports.ARNS_TESTNET_REGISTRY_TX = exports.SORT_KEY_REGEX = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -23,12 +23,12 @@ exports.FQDN_REGEX = new RegExp('^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{
|
|
|
23
23
|
exports.SORT_KEY_REGEX = new RegExp('^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$');
|
|
24
24
|
exports.ARNS_TESTNET_REGISTRY_TX = process.env.ARNS_REGISTRY_TX ?? 'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U';
|
|
25
25
|
exports.ARNS_DEVNET_REGISTRY_TX = '_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8';
|
|
26
|
-
exports.
|
|
26
|
+
exports.ARIO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
|
|
27
27
|
// backwards compatibility - TODO: remove in v2.0.0
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
28
|
+
exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID;
|
|
29
|
+
exports.ARIO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
|
|
30
30
|
exports.ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
|
|
31
|
-
exports.
|
|
31
|
+
exports.MARIO_PER_ARIO = 1_000_000;
|
|
32
32
|
exports.AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
|
|
33
33
|
exports.ANT_LUA_ID = '16_FyX-V2QU0RPSh1GIaEETSaUjNb0oVjCFpVbAfQq4';
|
|
34
34
|
exports.DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
|
package/lib/cjs/types/token.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mARIOToken = exports.ARIOToken = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -64,33 +64,33 @@ class PositiveFiniteInteger {
|
|
|
64
64
|
return this.positiveFiniteInteger === other.positiveFiniteInteger;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class ARIOToken {
|
|
68
68
|
value;
|
|
69
69
|
constructor(value) {
|
|
70
70
|
if (!Number.isFinite(value) || value < 0) {
|
|
71
|
-
throw new Error('
|
|
71
|
+
throw new Error('ARIOToken must be a non-negative finite number');
|
|
72
72
|
}
|
|
73
73
|
this.value = +value.toFixed(6);
|
|
74
74
|
}
|
|
75
75
|
valueOf() {
|
|
76
76
|
return this.value;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
return new
|
|
78
|
+
toMARIO() {
|
|
79
|
+
return new mARIOToken(Math.floor(this.value * constants_js_1.MARIO_PER_ARIO));
|
|
80
80
|
}
|
|
81
81
|
toString() {
|
|
82
82
|
return `${this.value}`;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
exports.
|
|
86
|
-
class
|
|
85
|
+
exports.ARIOToken = ARIOToken;
|
|
86
|
+
class mARIOToken extends PositiveFiniteInteger {
|
|
87
87
|
constructor(value) {
|
|
88
88
|
super(value);
|
|
89
89
|
}
|
|
90
90
|
multiply(multiplier) {
|
|
91
91
|
// always round down on multiplication and division
|
|
92
92
|
const result = Math.floor(this.valueOf() * multiplier.valueOf());
|
|
93
|
-
return new
|
|
93
|
+
return new mARIOToken(result);
|
|
94
94
|
}
|
|
95
95
|
divide(divisor) {
|
|
96
96
|
if (divisor.valueOf() === 0) {
|
|
@@ -99,18 +99,18 @@ class mIOToken extends PositiveFiniteInteger {
|
|
|
99
99
|
}
|
|
100
100
|
// always round down on multiplication and division
|
|
101
101
|
const result = Math.floor(this.valueOf() / divisor.valueOf());
|
|
102
|
-
return new
|
|
102
|
+
return new mARIOToken(result);
|
|
103
103
|
}
|
|
104
104
|
plus(addend) {
|
|
105
105
|
const result = super.plus(addend);
|
|
106
|
-
return new
|
|
106
|
+
return new mARIOToken(result.valueOf());
|
|
107
107
|
}
|
|
108
108
|
minus(subtractHend) {
|
|
109
109
|
const result = super.minus(subtractHend);
|
|
110
|
-
return new
|
|
110
|
+
return new mARIOToken(result.valueOf());
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
return new
|
|
112
|
+
toARIO() {
|
|
113
|
+
return new ARIOToken(this.valueOf() / constants_js_1.MARIO_PER_ARIO);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
exports.
|
|
116
|
+
exports.mARIOToken = mARIOToken;
|
|
@@ -53,8 +53,8 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
53
53
|
throttle;
|
|
54
54
|
logger;
|
|
55
55
|
strict;
|
|
56
|
-
constructor({ contract = io_js_1.
|
|
57
|
-
processId: constants_js_1.
|
|
56
|
+
constructor({ contract = io_js_1.ARIO.init({
|
|
57
|
+
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
58
58
|
}), timeoutMs = 60_000, concurrency = 30, logger = logger_js_1.Logger.default, strict = false, } = {}) {
|
|
59
59
|
super();
|
|
60
60
|
this.contract = contract;
|
|
@@ -117,8 +117,8 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
exports.ArNSEventEmitter = ArNSEventEmitter;
|
|
120
|
-
const fetchAllArNSRecords = async ({ contract = io_js_1.
|
|
121
|
-
processId: constants_js_1.
|
|
120
|
+
const fetchAllArNSRecords = async ({ contract = io_js_1.ARIO.init({
|
|
121
|
+
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
122
122
|
}), emitter, logger = logger_js_1.Logger.default, pageSize = 50_000, }) => {
|
|
123
123
|
let cursor;
|
|
124
124
|
const startTimestamp = Date.now();
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
// eslint-disable-next-line header/header -- This is a CLI file
|
|
18
18
|
import { program } from 'commander';
|
|
19
19
|
import { spawnANT } from '../node/index.js';
|
|
20
|
-
import {
|
|
20
|
+
import { mARIOToken } from '../types/token.js';
|
|
21
21
|
import { version } from '../version.js';
|
|
22
22
|
import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
|
|
23
23
|
import { getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
|
|
24
24
|
import { transfer } from './commands/transfer.js';
|
|
25
25
|
import { addressAndVaultIdOptions, addressOptions, antStateOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, initiatorOptions, joinNetworkOptions, nameOptions, nameWriteOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, writeActionOptions, } from './options.js';
|
|
26
|
-
import { applyOptions, assertConfirmationPrompt, epochInputFromOptions,
|
|
26
|
+
import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, positiveIntegerFromOptions, readANTFromOptions, readARIOFromOptions, recordTypeFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredPositiveIntegerFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from './utils.js';
|
|
27
27
|
applyOptions(program
|
|
28
28
|
.name('ar.io')
|
|
29
29
|
.version(version)
|
|
@@ -32,22 +32,22 @@ applyOptions(program
|
|
|
32
32
|
makeCommand({
|
|
33
33
|
name: 'info',
|
|
34
34
|
description: 'Get network info',
|
|
35
|
-
action: (options) =>
|
|
35
|
+
action: (options) => readARIOFromOptions(options).getInfo(),
|
|
36
36
|
});
|
|
37
37
|
makeCommand({
|
|
38
38
|
name: 'token-supply',
|
|
39
39
|
description: 'Get the total token supply',
|
|
40
|
-
action: (options) =>
|
|
40
|
+
action: (options) => readARIOFromOptions(options).getTokenSupply(),
|
|
41
41
|
});
|
|
42
42
|
makeCommand({
|
|
43
43
|
name: 'get-registration-fees',
|
|
44
44
|
description: 'Get registration fees',
|
|
45
|
-
action: (options) =>
|
|
45
|
+
action: (options) => readARIOFromOptions(options).getRegistrationFees(),
|
|
46
46
|
});
|
|
47
47
|
makeCommand({
|
|
48
48
|
name: 'get-demand-factor',
|
|
49
49
|
description: 'Get demand factor',
|
|
50
|
-
action: (options) =>
|
|
50
|
+
action: (options) => readARIOFromOptions(options).getDemandFactor(),
|
|
51
51
|
});
|
|
52
52
|
makeCommand({
|
|
53
53
|
name: 'get-gateway',
|
|
@@ -124,7 +124,7 @@ makeCommand({
|
|
|
124
124
|
makeCommand({
|
|
125
125
|
name: 'get-current-epoch',
|
|
126
126
|
description: 'Get current epoch data',
|
|
127
|
-
action: (options) =>
|
|
127
|
+
action: (options) => readARIOFromOptions(options).getCurrentEpoch(),
|
|
128
128
|
});
|
|
129
129
|
makeCommand({
|
|
130
130
|
name: 'get-prescribed-observers',
|
|
@@ -142,13 +142,13 @@ makeCommand({
|
|
|
142
142
|
name: 'get-observations',
|
|
143
143
|
description: 'Get observations for an epoch',
|
|
144
144
|
options: epochOptions,
|
|
145
|
-
action: (o) =>
|
|
145
|
+
action: (o) => readARIOFromOptions(o).getObservations(epochInputFromOptions(o)),
|
|
146
146
|
});
|
|
147
147
|
makeCommand({
|
|
148
148
|
name: 'get-distributions',
|
|
149
149
|
description: 'Get distributions for an epoch',
|
|
150
150
|
options: epochOptions,
|
|
151
|
-
action: (o) =>
|
|
151
|
+
action: (o) => readARIOFromOptions(o).getDistributions(epochInputFromOptions(o)),
|
|
152
152
|
});
|
|
153
153
|
makeCommand({
|
|
154
154
|
name: 'get-token-cost',
|
|
@@ -160,7 +160,7 @@ makeCommand({
|
|
|
160
160
|
name: 'list-vaults',
|
|
161
161
|
description: 'Get all wallet vaults',
|
|
162
162
|
options: paginationOptions,
|
|
163
|
-
action: (o) =>
|
|
163
|
+
action: (o) => readARIOFromOptions(o)
|
|
164
164
|
.getVaults(paginationParamsFromOptions(o))
|
|
165
165
|
.then((result) => result.items.length ? result : { message: 'No vaults found' }),
|
|
166
166
|
});
|
|
@@ -169,7 +169,7 @@ makeCommand({
|
|
|
169
169
|
name: 'get-primary-name-request',
|
|
170
170
|
description: 'Get primary name request',
|
|
171
171
|
options: initiatorOptions,
|
|
172
|
-
action: (o) =>
|
|
172
|
+
action: (o) => readARIOFromOptions(o)
|
|
173
173
|
.getPrimaryNameRequest({
|
|
174
174
|
initiator: requiredStringFromOptions(o, 'initiator'),
|
|
175
175
|
})
|
|
@@ -181,7 +181,7 @@ makeCommand({
|
|
|
181
181
|
name: 'list-primary-name-requests',
|
|
182
182
|
description: 'Get primary name requests',
|
|
183
183
|
options: paginationOptions,
|
|
184
|
-
action: (o) =>
|
|
184
|
+
action: (o) => readARIOFromOptions(o)
|
|
185
185
|
.getPrimaryNameRequests(paginationParamsFromOptions(o))
|
|
186
186
|
.then((result) => result.items.length ? result : { message: 'No requests found' }),
|
|
187
187
|
});
|
|
@@ -195,7 +195,7 @@ makeCommand({
|
|
|
195
195
|
name: 'list-primary-names',
|
|
196
196
|
description: 'Get primary names',
|
|
197
197
|
options: paginationOptions,
|
|
198
|
-
action: (o) =>
|
|
198
|
+
action: (o) => readARIOFromOptions(o)
|
|
199
199
|
.getPrimaryNames(paginationParamsFromOptions(o))
|
|
200
200
|
.then((result) => result.items.length ? result : { message: 'No names found' }),
|
|
201
201
|
});
|
|
@@ -203,19 +203,19 @@ makeCommand({
|
|
|
203
203
|
name: 'balance',
|
|
204
204
|
description: 'Get the balance of an address',
|
|
205
205
|
options: addressOptions,
|
|
206
|
-
action: (options) =>
|
|
206
|
+
action: (options) => readARIOFromOptions(options)
|
|
207
207
|
.getBalance({ address: requiredAddressFromOptions(options) })
|
|
208
208
|
.then((result) => ({
|
|
209
209
|
address: requiredAddressFromOptions(options),
|
|
210
210
|
mIOBalance: result,
|
|
211
|
-
message: `Provided address current has a balance of ${
|
|
211
|
+
message: `Provided address current has a balance of ${formatARIOWithCommas(new mARIOToken(result).toARIO())} ARIO`,
|
|
212
212
|
})),
|
|
213
213
|
});
|
|
214
214
|
makeCommand({
|
|
215
215
|
name: 'list-balances',
|
|
216
216
|
description: 'List all balances',
|
|
217
217
|
options: paginationOptions,
|
|
218
|
-
action: (o) =>
|
|
218
|
+
action: (o) => readARIOFromOptions(o)
|
|
219
219
|
.getBalances(paginationParamsFromOptions(o))
|
|
220
220
|
.then((result) => result.items.length ? result : { message: 'No balances found' }),
|
|
221
221
|
});
|
|
@@ -223,7 +223,7 @@ makeCommand({
|
|
|
223
223
|
name: 'get-redelegation-fee',
|
|
224
224
|
description: 'Get redelegation fee',
|
|
225
225
|
options: addressOptions,
|
|
226
|
-
action: (options) =>
|
|
226
|
+
action: (options) => readARIOFromOptions(options).getRedelegationFee({
|
|
227
227
|
address: requiredAddressFromOptions(options),
|
|
228
228
|
}),
|
|
229
229
|
});
|
|
@@ -241,7 +241,7 @@ makeCommand({
|
|
|
241
241
|
});
|
|
242
242
|
makeCommand({
|
|
243
243
|
name: 'transfer',
|
|
244
|
-
description: 'Transfer
|
|
244
|
+
description: 'Transfer ARIO to another address',
|
|
245
245
|
options: transferOptions,
|
|
246
246
|
action: transfer,
|
|
247
247
|
});
|
|
@@ -319,7 +319,7 @@ makeCommand({
|
|
|
319
319
|
description: 'Buy a record',
|
|
320
320
|
options: buyRecordOptions,
|
|
321
321
|
action: async (options) => {
|
|
322
|
-
const
|
|
322
|
+
const ario = writeARIOFromOptions(options).ario;
|
|
323
323
|
const name = requiredStringFromOptions(options, 'name');
|
|
324
324
|
const type = recordTypeFromOptions(options);
|
|
325
325
|
const years = positiveIntegerFromOptions(options, 'years');
|
|
@@ -331,7 +331,7 @@ makeCommand({
|
|
|
331
331
|
throw new Error('Process ID must be provided for buy-record');
|
|
332
332
|
}
|
|
333
333
|
await assertConfirmationPrompt(`Are you sure you want to ${type} the record ${name}?`, options);
|
|
334
|
-
return
|
|
334
|
+
return ario.buyRecord({
|
|
335
335
|
name: requiredStringFromOptions(options, 'name'),
|
|
336
336
|
processId,
|
|
337
337
|
type,
|
|
@@ -347,7 +347,7 @@ makeCommand({
|
|
|
347
347
|
action: async (options) => {
|
|
348
348
|
const name = requiredStringFromOptions(options, 'name');
|
|
349
349
|
await assertConfirmationPrompt(`Are you sure you want to upgrade the lease of ${name} to a permabuy?`, options);
|
|
350
|
-
return
|
|
350
|
+
return writeARIOFromOptions(options).ario.upgradeRecord({
|
|
351
351
|
name,
|
|
352
352
|
});
|
|
353
353
|
},
|
|
@@ -360,7 +360,7 @@ makeCommand({
|
|
|
360
360
|
const name = requiredStringFromOptions(options, 'name');
|
|
361
361
|
const years = requiredPositiveIntegerFromOptions(options, 'years');
|
|
362
362
|
await assertConfirmationPrompt(`Are you sure you want to extend the lease of ${name} by ${years}?`, options);
|
|
363
|
-
return
|
|
363
|
+
return writeARIOFromOptions(options).ario.extendLease({
|
|
364
364
|
name,
|
|
365
365
|
years,
|
|
366
366
|
}, writeActionTagsFromOptions(options));
|
|
@@ -374,7 +374,7 @@ makeCommand({
|
|
|
374
374
|
const name = requiredStringFromOptions(options, 'name');
|
|
375
375
|
const increaseCount = requiredPositiveIntegerFromOptions(options, 'increaseCount');
|
|
376
376
|
await assertConfirmationPrompt(`Are you sure you want to increase the undername limit of ${name} by ${increaseCount}?`, options);
|
|
377
|
-
return
|
|
377
|
+
return writeARIOFromOptions(options).ario.increaseUndernameLimit({
|
|
378
378
|
name,
|
|
379
379
|
increaseCount,
|
|
380
380
|
}, writeActionTagsFromOptions(options));
|
|
@@ -390,7 +390,7 @@ makeCommand({
|
|
|
390
390
|
// TODO: More assertions?
|
|
391
391
|
const name = requiredStringFromOptions(options, 'name');
|
|
392
392
|
await assertConfirmationPrompt(`Are you sure you want to request the primary name ${name}?`, options);
|
|
393
|
-
return
|
|
393
|
+
return writeARIOFromOptions(options).ario.requestPrimaryName({
|
|
394
394
|
name,
|
|
395
395
|
});
|
|
396
396
|
},
|
|
@@ -639,7 +639,7 @@ makeCommand({
|
|
|
639
639
|
await assertConfirmationPrompt(`Are you sure you want to release the name ${name} back to the protocol?`, options);
|
|
640
640
|
return writeANTFromOptions(options).releaseName({
|
|
641
641
|
name,
|
|
642
|
-
|
|
642
|
+
arioProcessId: arioProcessIdFromOptions(options),
|
|
643
643
|
}, writeActionTagsFromOptions(options));
|
|
644
644
|
},
|
|
645
645
|
});
|
|
@@ -658,7 +658,7 @@ makeCommand({
|
|
|
658
658
|
await assertConfirmationPrompt(`Are you sure you want to reassign the name ${name} to ANT process ${targetProcess}?`, options);
|
|
659
659
|
return writeANTFromOptions(options).reassignName({
|
|
660
660
|
name,
|
|
661
|
-
|
|
661
|
+
arioProcessId: arioProcessIdFromOptions(options),
|
|
662
662
|
antProcessId: targetProcess,
|
|
663
663
|
}, writeActionTagsFromOptions(options));
|
|
664
664
|
},
|
|
@@ -679,7 +679,7 @@ makeCommand({
|
|
|
679
679
|
return writeANTFromOptions(options).approvePrimaryNameRequest({
|
|
680
680
|
name,
|
|
681
681
|
address,
|
|
682
|
-
|
|
682
|
+
arioProcessId: arioProcessIdFromOptions(options),
|
|
683
683
|
}, writeActionTagsFromOptions(options));
|
|
684
684
|
},
|
|
685
685
|
});
|
|
@@ -692,7 +692,7 @@ makeCommand({
|
|
|
692
692
|
await assertConfirmationPrompt(`Are you sure you want to remove the primary names ${names}?`, options);
|
|
693
693
|
return writeANTFromOptions(options).removePrimaryNames({
|
|
694
694
|
names,
|
|
695
|
-
|
|
695
|
+
arioProcessId: arioProcessIdFromOptions(options),
|
|
696
696
|
}, writeActionTagsFromOptions(options));
|
|
697
697
|
},
|
|
698
698
|
});
|