@ar.io/sdk 2.7.0-alpha.6 → 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 +155 -239
- package/bundles/web.bundle.min.js +74 -74
- package/lib/cjs/cli/cli.js +32 -38
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +39 -39
- package/lib/cjs/cli/commands/readCommands.js +28 -45
- package/lib/cjs/cli/commands/transfer.js +7 -7
- package/lib/cjs/cli/options.js +4 -11
- package/lib/cjs/cli/utils.js +22 -22
- package/lib/cjs/common/ant.js +18 -14
- package/lib/cjs/common/io.js +15 -68
- 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 +36 -42
- package/lib/esm/cli/commands/gatewayWriteCommands.js +41 -41
- package/lib/esm/cli/commands/readCommands.js +27 -43
- package/lib/esm/cli/commands/transfer.js +8 -8
- package/lib/esm/cli/options.js +3 -10
- package/lib/esm/cli/utils.js +18 -18
- package/lib/esm/common/ant.js +18 -14
- package/lib/esm/common/io.js +12 -65
- 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/commands/readCommands.d.ts +3 -4
- package/lib/types/cli/options.d.ts +1 -5
- package/lib/types/cli/types.d.ts +2 -4
- 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 +20 -45
- package/lib/types/constants.d.ts +4 -4
- package/lib/types/types/ant.d.ts +8 -8
- package/lib/types/types/io.d.ts +14 -49
- 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
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { assertEnoughBalance, confirmationPrompt,
|
|
1
|
+
import { assertEnoughBalance, confirmationPrompt, formatARIOWithCommas, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
2
2
|
export async function transfer(options) {
|
|
3
|
-
const { target,
|
|
4
|
-
const {
|
|
3
|
+
const { target, arioQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
4
|
+
const { ario, signerAddress } = writeARIOFromOptions(options);
|
|
5
5
|
if (!options.skipConfirmation) {
|
|
6
|
-
await assertEnoughBalance(
|
|
7
|
-
const confirm = await confirmationPrompt(`Are you sure you want to transfer ${
|
|
6
|
+
await assertEnoughBalance(ario, signerAddress, arioQuantity);
|
|
7
|
+
const confirm = await confirmationPrompt(`Are you sure you want to transfer ${formatARIOWithCommas(arioQuantity)} ARIO to ${target}?`);
|
|
8
8
|
if (!confirm) {
|
|
9
9
|
return { message: 'Transfer aborted by user' };
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
const result = await
|
|
12
|
+
const result = await ario.transfer({
|
|
13
13
|
target,
|
|
14
|
-
qty:
|
|
14
|
+
qty: arioQuantity.toMARIO().valueOf(),
|
|
15
15
|
}, writeActionTagsFromOptions(options));
|
|
16
16
|
const output = {
|
|
17
17
|
senderAddress: signerAddress,
|
|
18
18
|
transferResult: result,
|
|
19
|
-
message: `Successfully transferred ${
|
|
19
|
+
message: `Successfully transferred ${formatARIOWithCommas(arioQuantity)} ARIO to ${target}`,
|
|
20
20
|
};
|
|
21
21
|
return output;
|
|
22
22
|
}
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -31,8 +31,8 @@ export const optionMap = {
|
|
|
31
31
|
description: 'Run against the AR.IO devnet process',
|
|
32
32
|
type: 'boolean',
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
alias: '--
|
|
34
|
+
arioProcessId: {
|
|
35
|
+
alias: '--ario-process-id <arioProcessId>',
|
|
36
36
|
description: 'Run against a custom AR.IO process id',
|
|
37
37
|
},
|
|
38
38
|
cuUrl: {
|
|
@@ -244,7 +244,7 @@ export const globalOptions = [
|
|
|
244
244
|
...walletOptions,
|
|
245
245
|
optionMap.dev,
|
|
246
246
|
optionMap.debug,
|
|
247
|
-
optionMap.
|
|
247
|
+
optionMap.arioProcessId,
|
|
248
248
|
optionMap.cuUrl,
|
|
249
249
|
];
|
|
250
250
|
export const writeActionOptions = [optionMap.skipConfirmation, optionMap.tags];
|
|
@@ -272,13 +272,6 @@ export const tokenCostOptions = [
|
|
|
272
272
|
optionMap.years,
|
|
273
273
|
optionMap.quantity,
|
|
274
274
|
];
|
|
275
|
-
export const arNSAuctionPricesOptions = [
|
|
276
|
-
optionMap.name,
|
|
277
|
-
optionMap.type,
|
|
278
|
-
optionMap.years,
|
|
279
|
-
optionMap.timestamp,
|
|
280
|
-
optionMap.intervalMs,
|
|
281
|
-
];
|
|
282
275
|
export const transferOptions = [
|
|
283
276
|
...writeActionOptions,
|
|
284
277
|
optionMap.quantity,
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -17,7 +17,7 @@ import { connect } from '@permaweb/aoconnect';
|
|
|
17
17
|
import { program } from 'commander';
|
|
18
18
|
import { readFileSync } from 'fs';
|
|
19
19
|
import prompts from 'prompts';
|
|
20
|
-
import { ANT, AOProcess,
|
|
20
|
+
import { ANT, AOProcess, ARIO, ARIOToken, ARIO_DEVNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, ArweaveSigner, Logger, createAoSigner, fromB64Url, initANTStateForAddress, mARIOToken, sha256B64Url, } from '../node/index.js';
|
|
21
21
|
import { globalOptions } from './options.js';
|
|
22
22
|
export function stringifyJsonForCLIDisplay(json) {
|
|
23
23
|
return JSON.stringify(json, null, 2);
|
|
@@ -64,12 +64,12 @@ export function makeCommand({ description, name, options = [], action, }) {
|
|
|
64
64
|
}
|
|
65
65
|
return appliedCommand;
|
|
66
66
|
}
|
|
67
|
-
export function
|
|
68
|
-
return
|
|
69
|
-
?
|
|
67
|
+
export function arioProcessIdFromOptions({ arioProcessId, dev, }) {
|
|
68
|
+
return arioProcessId !== undefined
|
|
69
|
+
? arioProcessId
|
|
70
70
|
: dev
|
|
71
|
-
?
|
|
72
|
-
:
|
|
71
|
+
? ARIO_DEVNET_PROCESS_ID
|
|
72
|
+
: ARIO_TESTNET_PROCESS_ID;
|
|
73
73
|
}
|
|
74
74
|
function jwkFromOptions({ privateKey, walletFile, }) {
|
|
75
75
|
if (privateKey !== undefined) {
|
|
@@ -101,15 +101,15 @@ export function getLoggerFromOptions(options) {
|
|
|
101
101
|
}
|
|
102
102
|
function aoProcessFromOptions(options) {
|
|
103
103
|
return new AOProcess({
|
|
104
|
-
processId:
|
|
104
|
+
processId: arioProcessIdFromOptions(options),
|
|
105
105
|
ao: connect({
|
|
106
106
|
CU_URL: options.cuUrl,
|
|
107
107
|
}),
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
export function
|
|
110
|
+
export function readARIOFromOptions(options) {
|
|
111
111
|
setLoggerIfDebug(options);
|
|
112
|
-
return
|
|
112
|
+
return ARIO.init({
|
|
113
113
|
process: aoProcessFromOptions(options),
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -122,18 +122,18 @@ export function requiredContractSignerFromOptions(options) {
|
|
|
122
122
|
export function requiredAoSignerFromOptions(options) {
|
|
123
123
|
return createAoSigner(requiredContractSignerFromOptions(options).signer);
|
|
124
124
|
}
|
|
125
|
-
export function
|
|
125
|
+
export function writeARIOFromOptions(options) {
|
|
126
126
|
const { signer, signerAddress } = requiredContractSignerFromOptions(options);
|
|
127
127
|
setLoggerIfDebug(options);
|
|
128
128
|
return {
|
|
129
|
-
|
|
129
|
+
ario: ARIO.init({
|
|
130
130
|
process: aoProcessFromOptions(options),
|
|
131
131
|
signer,
|
|
132
132
|
}),
|
|
133
133
|
signerAddress,
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
export function
|
|
136
|
+
export function formatARIOWithCommas(value) {
|
|
137
137
|
const [integerPart, decimalPart] = value.toString().split('.');
|
|
138
138
|
const integerWithCommas = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
139
139
|
if (decimalPart === undefined) {
|
|
@@ -242,11 +242,11 @@ export function requiredTargetAndQuantityFromOptions(options) {
|
|
|
242
242
|
}
|
|
243
243
|
return {
|
|
244
244
|
target: options.target,
|
|
245
|
-
|
|
245
|
+
arioQuantity: new ARIOToken(+options.quantity),
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
export function redelegateParamsFromOptions(options) {
|
|
249
|
-
const { target,
|
|
249
|
+
const { target, arioQuantity: aRIOQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
250
250
|
const source = options.source;
|
|
251
251
|
if (source === undefined) {
|
|
252
252
|
throw new Error('No source provided. Use --source');
|
|
@@ -255,7 +255,7 @@ export function redelegateParamsFromOptions(options) {
|
|
|
255
255
|
target,
|
|
256
256
|
source,
|
|
257
257
|
vaultId: options.vaultId,
|
|
258
|
-
stakeQty:
|
|
258
|
+
stakeQty: aRIOQuantity.toMARIO(),
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
export function recordTypeFromOptions(options) {
|
|
@@ -269,12 +269,12 @@ export function requiredMIOFromOptions(options, key) {
|
|
|
269
269
|
if (options[key] === undefined) {
|
|
270
270
|
throw new Error(`No ${key} provided. Use --${key} denominated in IO`);
|
|
271
271
|
}
|
|
272
|
-
return new
|
|
272
|
+
return new ARIOToken(+options[key]).toMARIO();
|
|
273
273
|
}
|
|
274
274
|
export async function assertEnoughBalance(io, address, ioQuantity) {
|
|
275
275
|
const balance = await io.getBalance({ address });
|
|
276
|
-
if (balance < ioQuantity.
|
|
277
|
-
throw new Error(`Insufficient IO balance for action. Balance available: ${new
|
|
276
|
+
if (balance < ioQuantity.toMARIO().valueOf()) {
|
|
277
|
+
throw new Error(`Insufficient IO balance for action. Balance available: ${new mARIOToken(balance).toARIO()} IO`);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
export async function confirmationPrompt(message) {
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -407,43 +407,45 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
407
407
|
});
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
410
|
-
* @param name @type {string} The name you want to release. The name will be put up for
|
|
411
|
-
* @param
|
|
410
|
+
* @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.
|
|
411
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
|
|
412
412
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
413
413
|
* @example
|
|
414
414
|
* ```ts
|
|
415
|
-
* ant.releaseName({ name: "ardrive",
|
|
415
|
+
* ant.releaseName({ name: "ardrive", arioProcessId: AR_TESTNET_PROCESS_ID });
|
|
416
416
|
* ```
|
|
417
417
|
*/
|
|
418
|
-
async releaseName({ name,
|
|
418
|
+
async releaseName({ name, arioProcessId }, options) {
|
|
419
419
|
return this.process.send({
|
|
420
420
|
tags: [
|
|
421
421
|
...(options?.tags ?? []),
|
|
422
422
|
{ name: 'Action', value: 'Release-Name' },
|
|
423
423
|
{ name: 'Name', value: name },
|
|
424
|
-
{ name: 'IO-Process-Id', value:
|
|
424
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
425
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
425
426
|
],
|
|
426
427
|
signer: this.signer,
|
|
427
428
|
});
|
|
428
429
|
}
|
|
429
430
|
/**
|
|
430
|
-
* Sends a message to the
|
|
431
|
+
* 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.
|
|
431
432
|
* @param name @type {string} The name you want to reassign.
|
|
432
|
-
* @param
|
|
433
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
433
434
|
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
434
435
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
435
436
|
* @example
|
|
436
437
|
* ```ts
|
|
437
|
-
* ant.reassignName({ name: "ardrive",
|
|
438
|
+
* ant.reassignName({ name: "ardrive", arioProcessId: ARIO_TESTNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID });
|
|
438
439
|
* ```
|
|
439
440
|
*/
|
|
440
|
-
async reassignName({ name,
|
|
441
|
+
async reassignName({ name, arioProcessId, antProcessId, }, options) {
|
|
441
442
|
return this.process.send({
|
|
442
443
|
tags: [
|
|
443
444
|
...(options?.tags ?? []),
|
|
444
445
|
{ name: 'Action', value: 'Reassign-Name' },
|
|
445
446
|
{ name: 'Name', value: name },
|
|
446
|
-
{ name: 'IO-Process-Id', value:
|
|
447
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
448
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
447
449
|
{ name: 'Process-Id', value: antProcessId },
|
|
448
450
|
],
|
|
449
451
|
signer: this.signer,
|
|
@@ -452,25 +454,27 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
452
454
|
/**
|
|
453
455
|
* Approves a primary name request for a given name or address.
|
|
454
456
|
*/
|
|
455
|
-
async approvePrimaryNameRequest({ name, address,
|
|
457
|
+
async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
|
|
456
458
|
return this.process.send({
|
|
457
459
|
tags: [
|
|
458
460
|
...(options?.tags ?? []),
|
|
459
461
|
{ name: 'Action', value: 'Approve-Primary-Name' },
|
|
460
462
|
{ name: 'Name', value: name },
|
|
461
463
|
{ name: 'Recipient', value: address },
|
|
462
|
-
{ name: 'IO-Process-Id', value:
|
|
464
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
465
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
463
466
|
],
|
|
464
467
|
signer: this.signer,
|
|
465
468
|
});
|
|
466
469
|
}
|
|
467
|
-
async removePrimaryNames({ names,
|
|
470
|
+
async removePrimaryNames({ names, arioProcessId }, options) {
|
|
468
471
|
return this.process.send({
|
|
469
472
|
tags: [
|
|
470
473
|
...(options?.tags ?? []),
|
|
471
474
|
{ name: 'Action', value: 'Remove-Primary-Names' },
|
|
472
475
|
{ name: 'Names', value: names.join(',') },
|
|
473
|
-
{ name: 'IO-Process-Id', value:
|
|
476
|
+
{ name: 'IO-Process-Id', value: arioProcessId },
|
|
477
|
+
{ name: 'ARIO-Process-Id', value: arioProcessId },
|
|
474
478
|
],
|
|
475
479
|
signer: this.signer,
|
|
476
480
|
});
|
package/lib/esm/common/io.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
2
2
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
3
3
|
import { createAoSigner } from '../utils/ao.js';
|
|
4
4
|
import { getCurrentBlockUnixTimestampMs, paginationParamsToTags, pruneTags, } from '../utils/arweave.js';
|
|
5
5
|
import { defaultArweave } from './arweave.js';
|
|
6
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
7
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
8
|
-
export class
|
|
8
|
+
export class ARIO {
|
|
9
9
|
static init(config) {
|
|
10
10
|
if (config && config.signer) {
|
|
11
11
|
const { signer, ...rest } = config;
|
|
12
|
-
return new
|
|
12
|
+
return new ARIOWriteable({
|
|
13
13
|
...rest,
|
|
14
14
|
signer,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
return new
|
|
17
|
+
return new ARIOReadable(config);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export class
|
|
20
|
+
export class ARIOReadable {
|
|
21
21
|
process;
|
|
22
22
|
arweave;
|
|
23
23
|
constructor(config, arweave = defaultArweave) {
|
|
24
24
|
if (!config) {
|
|
25
25
|
this.process = new AOProcess({
|
|
26
|
-
processId:
|
|
26
|
+
processId: ARIO_TESTNET_PROCESS_ID,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
else if (isProcessConfiguration(config)) {
|
|
@@ -315,60 +315,23 @@ export class IOReadable {
|
|
|
315
315
|
tags: [{ name: 'Action', value: 'Demand-Factor-Settings' }],
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
async getArNSAuctions(params) {
|
|
318
|
+
async getArNSReturnedNames(params) {
|
|
320
319
|
return this.process.read({
|
|
321
320
|
tags: [
|
|
322
|
-
{ name: 'Action', value: '
|
|
321
|
+
{ name: 'Action', value: 'Returned-Names' },
|
|
323
322
|
...paginationParamsToTags(params),
|
|
324
323
|
],
|
|
325
324
|
});
|
|
326
325
|
}
|
|
327
|
-
async
|
|
326
|
+
async getArNSReturnedName({ name, }) {
|
|
328
327
|
const allTags = [
|
|
329
|
-
{ name: 'Action', value: '
|
|
328
|
+
{ name: 'Action', value: 'Returned-Name' },
|
|
330
329
|
{ name: 'Name', value: name },
|
|
331
330
|
];
|
|
332
331
|
return this.process.read({
|
|
333
332
|
tags: allTags,
|
|
334
333
|
});
|
|
335
334
|
}
|
|
336
|
-
/**
|
|
337
|
-
* Get auction prices for a given auction at the provided intervals
|
|
338
|
-
*
|
|
339
|
-
* @param {Object} params - The parameters for fetching auction prices
|
|
340
|
-
* @param {string} params.name - The name of the auction
|
|
341
|
-
* @param {('permabuy'|'lease')} [params.type='lease'] - The type of purchase
|
|
342
|
-
* @param {number} [params.years=1] - The number of years for lease (only applicable if type is 'lease')
|
|
343
|
-
* @param {number} [params.timestamp=Date.now()] - The timestamp to fetch prices for
|
|
344
|
-
* @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
|
|
345
|
-
* @returns {Promise<AoAuctionPriceData>} The auction price data
|
|
346
|
-
*/
|
|
347
|
-
async getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
|
|
348
|
-
const prunedPriceTags = [
|
|
349
|
-
{ name: 'Action', value: 'Auction-Prices' },
|
|
350
|
-
{ name: 'Name', value: name },
|
|
351
|
-
{
|
|
352
|
-
name: 'Timestamp',
|
|
353
|
-
value: timestamp?.toString() ??
|
|
354
|
-
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
355
|
-
},
|
|
356
|
-
{ name: 'Purchase-Type', value: type ?? 'lease' },
|
|
357
|
-
{
|
|
358
|
-
name: 'Years',
|
|
359
|
-
value: type == undefined || type === 'lease'
|
|
360
|
-
? years?.toString() ?? '1'
|
|
361
|
-
: undefined,
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
name: 'Price-Interval-Ms',
|
|
365
|
-
value: intervalMs?.toString() ?? '900000',
|
|
366
|
-
},
|
|
367
|
-
].filter((tag) => tag.value !== undefined);
|
|
368
|
-
return this.process.read({
|
|
369
|
-
tags: prunedPriceTags,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
335
|
async getDelegations(params) {
|
|
373
336
|
const allTags = [
|
|
374
337
|
{ name: 'Action', value: 'Paginated-Delegations' },
|
|
@@ -453,13 +416,13 @@ export class IOReadable {
|
|
|
453
416
|
});
|
|
454
417
|
}
|
|
455
418
|
}
|
|
456
|
-
export class
|
|
419
|
+
export class ARIOWriteable extends ARIOReadable {
|
|
457
420
|
signer;
|
|
458
421
|
constructor({ signer, ...config }) {
|
|
459
422
|
if (Object.keys(config).length === 0) {
|
|
460
423
|
super({
|
|
461
424
|
process: new AOProcess({
|
|
462
|
-
processId:
|
|
425
|
+
processId: ARIO_TESTNET_PROCESS_ID,
|
|
463
426
|
}),
|
|
464
427
|
});
|
|
465
428
|
this.signer = createAoSigner(signer);
|
|
@@ -779,22 +742,6 @@ export class IOWriteable extends IOReadable {
|
|
|
779
742
|
tags: pruneTags(allTags),
|
|
780
743
|
});
|
|
781
744
|
}
|
|
782
|
-
async submitAuctionBid(params, options) {
|
|
783
|
-
const { tags = [] } = options || {};
|
|
784
|
-
const allTags = [
|
|
785
|
-
...tags,
|
|
786
|
-
{ name: 'Action', value: 'Auction-Bid' },
|
|
787
|
-
{ name: 'Name', value: params.name },
|
|
788
|
-
{ name: 'Process-Id', value: params.processId },
|
|
789
|
-
{ name: 'Quantity', value: params.quantity?.toString() ?? undefined },
|
|
790
|
-
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
791
|
-
{ name: 'Years', value: params.years?.toString() ?? undefined },
|
|
792
|
-
];
|
|
793
|
-
return this.process.send({
|
|
794
|
-
signer: this.signer,
|
|
795
|
-
tags: pruneTags(allTags),
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
745
|
async requestPrimaryName(params) {
|
|
799
746
|
return this.process.send({
|
|
800
747
|
signer: this.signer,
|
package/lib/esm/constants.js
CHANGED
|
@@ -20,12 +20,12 @@ export const FQDN_REGEX = new RegExp('^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Z
|
|
|
20
20
|
export const SORT_KEY_REGEX = new RegExp('^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$');
|
|
21
21
|
export const ARNS_TESTNET_REGISTRY_TX = process.env.ARNS_REGISTRY_TX ?? 'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U';
|
|
22
22
|
export const ARNS_DEVNET_REGISTRY_TX = '_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8';
|
|
23
|
-
export const
|
|
23
|
+
export const ARIO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
|
|
24
24
|
// backwards compatibility - TODO: remove in v2.0.0
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
25
|
+
export const arioDevnetProcessId = ARIO_DEVNET_PROCESS_ID;
|
|
26
|
+
export const ARIO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
|
|
27
27
|
export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
|
|
28
|
-
export const
|
|
28
|
+
export const MARIO_PER_ARIO = 1_000_000;
|
|
29
29
|
export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
|
|
30
30
|
export const ANT_LUA_ID = '16_FyX-V2QU0RPSh1GIaEETSaUjNb0oVjCFpVbAfQq4';
|
|
31
31
|
export const DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
|
package/lib/esm/types/token.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { MARIO_PER_ARIO } from '../constants.js';
|
|
17
17
|
class PositiveFiniteInteger {
|
|
18
18
|
positiveFiniteInteger;
|
|
19
19
|
constructor(positiveFiniteInteger) {
|
|
@@ -61,32 +61,32 @@ class PositiveFiniteInteger {
|
|
|
61
61
|
return this.positiveFiniteInteger === other.positiveFiniteInteger;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
export class
|
|
64
|
+
export class ARIOToken {
|
|
65
65
|
value;
|
|
66
66
|
constructor(value) {
|
|
67
67
|
if (!Number.isFinite(value) || value < 0) {
|
|
68
|
-
throw new Error('
|
|
68
|
+
throw new Error('ARIOToken must be a non-negative finite number');
|
|
69
69
|
}
|
|
70
70
|
this.value = +value.toFixed(6);
|
|
71
71
|
}
|
|
72
72
|
valueOf() {
|
|
73
73
|
return this.value;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
return new
|
|
75
|
+
toMARIO() {
|
|
76
|
+
return new mARIOToken(Math.floor(this.value * MARIO_PER_ARIO));
|
|
77
77
|
}
|
|
78
78
|
toString() {
|
|
79
79
|
return `${this.value}`;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
export class
|
|
82
|
+
export class mARIOToken extends PositiveFiniteInteger {
|
|
83
83
|
constructor(value) {
|
|
84
84
|
super(value);
|
|
85
85
|
}
|
|
86
86
|
multiply(multiplier) {
|
|
87
87
|
// always round down on multiplication and division
|
|
88
88
|
const result = Math.floor(this.valueOf() * multiplier.valueOf());
|
|
89
|
-
return new
|
|
89
|
+
return new mARIOToken(result);
|
|
90
90
|
}
|
|
91
91
|
divide(divisor) {
|
|
92
92
|
if (divisor.valueOf() === 0) {
|
|
@@ -95,17 +95,17 @@ export class mIOToken extends PositiveFiniteInteger {
|
|
|
95
95
|
}
|
|
96
96
|
// always round down on multiplication and division
|
|
97
97
|
const result = Math.floor(this.valueOf() / divisor.valueOf());
|
|
98
|
-
return new
|
|
98
|
+
return new mARIOToken(result);
|
|
99
99
|
}
|
|
100
100
|
plus(addend) {
|
|
101
101
|
const result = super.plus(addend);
|
|
102
|
-
return new
|
|
102
|
+
return new mARIOToken(result.valueOf());
|
|
103
103
|
}
|
|
104
104
|
minus(subtractHend) {
|
|
105
105
|
const result = super.minus(subtractHend);
|
|
106
|
-
return new
|
|
106
|
+
return new mARIOToken(result.valueOf());
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
return new
|
|
108
|
+
toARIO() {
|
|
109
|
+
return new ARIOToken(this.valueOf() / MARIO_PER_ARIO);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -17,9 +17,9 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
17
17
|
import { pLimit } from 'plimit-lit';
|
|
18
18
|
import { ANTRegistry } from '../common/ant-registry.js';
|
|
19
19
|
import { ANT } from '../common/ant.js';
|
|
20
|
-
import {
|
|
20
|
+
import { ARIO } from '../common/io.js';
|
|
21
21
|
import { Logger } from '../common/logger.js';
|
|
22
|
-
import {
|
|
22
|
+
import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
23
23
|
/**
|
|
24
24
|
* @beta This API is in beta and may change in the future.
|
|
25
25
|
*/
|
|
@@ -49,8 +49,8 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
49
49
|
throttle;
|
|
50
50
|
logger;
|
|
51
51
|
strict;
|
|
52
|
-
constructor({ contract =
|
|
53
|
-
processId:
|
|
52
|
+
constructor({ contract = ARIO.init({
|
|
53
|
+
processId: ARIO_TESTNET_PROCESS_ID,
|
|
54
54
|
}), timeoutMs = 60_000, concurrency = 30, logger = Logger.default, strict = false, } = {}) {
|
|
55
55
|
super();
|
|
56
56
|
this.contract = contract;
|
|
@@ -112,8 +112,8 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
112
112
|
this.emit('end', uniqueContractProcessIds);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
export const fetchAllArNSRecords = async ({ contract =
|
|
116
|
-
processId:
|
|
115
|
+
export const fetchAllArNSRecords = async ({ contract = ARIO.init({
|
|
116
|
+
processId: ARIO_TESTNET_PROCESS_ID,
|
|
117
117
|
}), emitter, logger = Logger.default, pageSize = 50_000, }) => {
|
|
118
118
|
let cursor;
|
|
119
119
|
const startTimestamp = Date.now();
|
package/lib/esm/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions,
|
|
1
|
+
import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, NameCLIOptions, PaginationAddressCLIOptions, PaginationCLIOptions } from '../types.js';
|
|
2
2
|
export declare function getGateway(o: AddressCLIOptions): Promise<import("../../types/io.js").AoGateway | {
|
|
3
3
|
message: string;
|
|
4
4
|
}>;
|
|
@@ -26,13 +26,12 @@ export declare function getArNSReservedName(o: NameCLIOptions): Promise<import("
|
|
|
26
26
|
export declare function listArNSReservedNames(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoArNSReservedNameDataWithName> | {
|
|
27
27
|
message: string;
|
|
28
28
|
}>;
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function getArNSReturnedName(o: NameCLIOptions): Promise<import("../../types/io.js").AoReturnedName | {
|
|
30
30
|
message: string;
|
|
31
31
|
}>;
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function listArNSReturnedNames(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoReturnedName> | {
|
|
33
33
|
message: string;
|
|
34
34
|
}>;
|
|
35
|
-
export declare function getArNSAuctionPrices(o: AuctionPricesCLIOptions): Promise<import("../../types/io.js").AoAuctionPriceData>;
|
|
36
35
|
export declare function getEpoch(o: EpochCLIOptions): Promise<import("../../types/io.js").AoEpochData | {
|
|
37
36
|
message: string;
|
|
38
37
|
}>;
|
|
@@ -27,7 +27,7 @@ export declare const optionMap: {
|
|
|
27
27
|
description: string;
|
|
28
28
|
type: string;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
arioProcessId: {
|
|
31
31
|
alias: string;
|
|
32
32
|
description: string;
|
|
33
33
|
};
|
|
@@ -284,10 +284,6 @@ export declare const tokenCostOptions: {
|
|
|
284
284
|
alias: string;
|
|
285
285
|
description: string;
|
|
286
286
|
}[];
|
|
287
|
-
export declare const arNSAuctionPricesOptions: {
|
|
288
|
-
alias: string;
|
|
289
|
-
description: string;
|
|
290
|
-
}[];
|
|
291
287
|
export declare const transferOptions: {
|
|
292
288
|
alias: string;
|
|
293
289
|
description: string;
|
package/lib/types/cli/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { AoAddressParams,
|
|
16
|
+
import { AoAddressParams, AoArNSNameParams, AoBuyRecordParams, AoExtendLeaseParams, AoGetVaultParams, AoIncreaseUndernameLimitParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
|
|
17
17
|
export type WalletCLIOptions = {
|
|
18
18
|
walletFile?: string;
|
|
19
19
|
privateKey?: string;
|
|
@@ -21,7 +21,7 @@ export type WalletCLIOptions = {
|
|
|
21
21
|
export type GlobalCLIOptions = WalletCLIOptions & {
|
|
22
22
|
dev: boolean;
|
|
23
23
|
debug: boolean;
|
|
24
|
-
|
|
24
|
+
arioProcessId?: string;
|
|
25
25
|
cuUrl?: string;
|
|
26
26
|
};
|
|
27
27
|
export type WriteActionCLIOptions = GlobalCLIOptions & {
|
|
@@ -64,7 +64,6 @@ export type EpochCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<{
|
|
|
64
64
|
timestamp: number;
|
|
65
65
|
}>;
|
|
66
66
|
export type GetTokenCostCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoTokenCostParams>;
|
|
67
|
-
export type AuctionPricesCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoArNSAuctionPricesParams>;
|
|
68
67
|
export type PaginationAddressCLIOptions = AddressCLIOptions & PaginationCLIOptions;
|
|
69
68
|
export type NameCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoArNSNameParams>;
|
|
70
69
|
export type NameWriteCLIOptions = WriteActionCLIOptions & NameCLIOptions;
|
|
@@ -91,7 +90,6 @@ export type BuyRecordCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams
|
|
|
91
90
|
export type UpgradeRecordCLIOptions = NameWriteCLIOptions;
|
|
92
91
|
export type ExtendLeaseCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoExtendLeaseParams>;
|
|
93
92
|
export type IncreaseUndernameLimitCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoIncreaseUndernameLimitParams>;
|
|
94
|
-
export type SubmitAuctionBidCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoSubmitAuctionBidParams>;
|
|
95
93
|
export type ANTStateCLIOptions = WriteActionCLIOptions & {
|
|
96
94
|
target?: string;
|
|
97
95
|
keywords?: string[];
|