@ar.io/sdk 3.0.1-alpha.1 → 3.1.0-alpha.2
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 +38 -0
- package/bundles/web.bundle.min.js +76 -76
- package/lib/cjs/cli/cli.js +27 -71
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +167 -0
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +8 -4
- package/lib/cjs/cli/commands/readCommands.js +17 -38
- package/lib/cjs/cli/commands/transfer.js +5 -1
- package/lib/cjs/cli/options.js +14 -7
- package/lib/cjs/cli/utils.js +59 -7
- package/lib/cjs/common/contracts/ao-process.js +7 -3
- package/lib/cjs/common/io.js +79 -23
- package/lib/cjs/types/io.js +6 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +30 -74
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +159 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +6 -2
- package/lib/esm/cli/commands/readCommands.js +16 -38
- package/lib/esm/cli/commands/transfer.js +6 -2
- package/lib/esm/cli/options.js +13 -6
- package/lib/esm/cli/utils.js +53 -5
- package/lib/esm/common/contracts/ao-process.js +7 -3
- package/lib/esm/common/io.js +79 -23
- package/lib/esm/types/io.js +4 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +22 -0
- package/lib/types/cli/commands/readCommands.d.ts +24 -2
- package/lib/types/cli/options.d.ts +5 -9
- package/lib/types/cli/types.d.ts +3 -5
- package/lib/types/cli/utils.d.ts +25 -4
- package/lib/types/common/contracts/ao-process.d.ts +2 -1
- package/lib/types/common/io.d.ts +7 -21
- package/lib/types/types/io.d.ts +39 -10
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertEnoughMARIOBalance, confirmationPrompt, formatARIOWithCommas, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
2
2
|
export async function transfer(options) {
|
|
3
3
|
const { target, arioQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
4
4
|
const { ario, signerAddress } = writeARIOFromOptions(options);
|
|
5
5
|
if (!options.skipConfirmation) {
|
|
6
|
-
await
|
|
6
|
+
await assertEnoughMARIOBalance({
|
|
7
|
+
ario,
|
|
8
|
+
address: signerAddress,
|
|
9
|
+
mARIOQuantity: arioQuantity.toMARIO(),
|
|
10
|
+
});
|
|
7
11
|
const confirm = await confirmationPrompt(`Are you sure you want to transfer ${formatARIOWithCommas(arioQuantity)} ARIO to ${target}?`);
|
|
8
12
|
if (!confirm) {
|
|
9
13
|
return { message: 'Transfer aborted by user' };
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -234,6 +234,10 @@ export const optionMap = {
|
|
|
234
234
|
description: 'Include failed gateways in the list',
|
|
235
235
|
type: 'array',
|
|
236
236
|
},
|
|
237
|
+
fundFrom: {
|
|
238
|
+
alias: '--fund-from <fundFrom>',
|
|
239
|
+
description: 'Where to fund the action from. e.g. "balance", "stakes", or "any',
|
|
240
|
+
},
|
|
237
241
|
};
|
|
238
242
|
export const walletOptions = [
|
|
239
243
|
optionMap.walletFile,
|
|
@@ -248,11 +252,13 @@ export const globalOptions = [
|
|
|
248
252
|
optionMap.cuUrl,
|
|
249
253
|
];
|
|
250
254
|
export const writeActionOptions = [optionMap.skipConfirmation, optionMap.tags];
|
|
251
|
-
export const
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
export const arnsPurchaseOptions = [
|
|
256
|
+
...writeActionOptions,
|
|
257
|
+
optionMap.name,
|
|
258
|
+
optionMap.fundFrom,
|
|
259
|
+
];
|
|
254
260
|
export const epochOptions = [optionMap.epochIndex, optionMap.timestamp];
|
|
255
|
-
export const addressAndVaultIdOptions = [
|
|
261
|
+
export const addressAndVaultIdOptions = [optionMap.address, optionMap.vaultId];
|
|
256
262
|
export const nameWriteOptions = [...writeActionOptions, optionMap.name];
|
|
257
263
|
export const paginationOptions = [
|
|
258
264
|
optionMap.cursor,
|
|
@@ -271,6 +277,8 @@ export const tokenCostOptions = [
|
|
|
271
277
|
optionMap.type,
|
|
272
278
|
optionMap.years,
|
|
273
279
|
optionMap.quantity,
|
|
280
|
+
optionMap.address,
|
|
281
|
+
optionMap.fundFrom,
|
|
274
282
|
];
|
|
275
283
|
export const transferOptions = [
|
|
276
284
|
...writeActionOptions,
|
|
@@ -307,8 +315,7 @@ export const joinNetworkOptions = [
|
|
|
307
315
|
optionMap.operatorStake,
|
|
308
316
|
];
|
|
309
317
|
export const buyRecordOptions = [
|
|
310
|
-
...
|
|
311
|
-
optionMap.name,
|
|
318
|
+
...arnsPurchaseOptions,
|
|
312
319
|
optionMap.quantity,
|
|
313
320
|
optionMap.type,
|
|
314
321
|
optionMap.years,
|
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, ARIO, ARIOToken, ARIO_DEVNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, ArweaveSigner, Logger, createAoSigner, fromB64Url, initANTStateForAddress, mARIOToken, sha256B64Url, } from '../node/index.js';
|
|
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
22
|
export function stringifyJsonForCLIDisplay(json) {
|
|
23
23
|
return JSON.stringify(json, null, 2);
|
|
@@ -141,6 +141,9 @@ export function formatARIOWithCommas(value) {
|
|
|
141
141
|
}
|
|
142
142
|
return integerWithCommas + '.' + decimalPart;
|
|
143
143
|
}
|
|
144
|
+
export function formatMARIOToARIOWithCommas(value) {
|
|
145
|
+
return formatARIOWithCommas(value.toARIO());
|
|
146
|
+
}
|
|
144
147
|
/** helper to get address from --address option first, then check wallet options */
|
|
145
148
|
export function addressFromOptions(options) {
|
|
146
149
|
if (options.address !== undefined) {
|
|
@@ -265,16 +268,34 @@ export function recordTypeFromOptions(options) {
|
|
|
265
268
|
}
|
|
266
269
|
return options.type;
|
|
267
270
|
}
|
|
268
|
-
export function
|
|
271
|
+
export function requiredMARIOFromOptions(options, key) {
|
|
269
272
|
if (options[key] === undefined) {
|
|
270
273
|
throw new Error(`No ${key} provided. Use --${key} denominated in ARIO`);
|
|
271
274
|
}
|
|
272
275
|
return new ARIOToken(+options[key]).toMARIO();
|
|
273
276
|
}
|
|
274
|
-
export async function
|
|
277
|
+
export async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
|
|
278
|
+
const costDetails = await ario.getCostDetails(costDetailsParams);
|
|
279
|
+
if (costDetails.fundingPlan) {
|
|
280
|
+
if (costDetails.fundingPlan.shortfall > 0) {
|
|
281
|
+
throw new Error(`Insufficient balance for action. Shortfall: ${formatMARIOToARIOWithCommas(new mARIOToken(costDetails.fundingPlan.shortfall))}\n${JSON.stringify(costDetails, null, 2)}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
await assertEnoughMARIOBalance({
|
|
286
|
+
ario,
|
|
287
|
+
address,
|
|
288
|
+
mARIOQuantity: costDetails.tokenCost,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
export async function assertEnoughMARIOBalance({ address, ario, mARIOQuantity, }) {
|
|
293
|
+
if (typeof mARIOQuantity === 'number') {
|
|
294
|
+
mARIOQuantity = new mARIOToken(mARIOQuantity);
|
|
295
|
+
}
|
|
275
296
|
const balance = await ario.getBalance({ address });
|
|
276
|
-
if (balance <
|
|
277
|
-
throw new Error(`Insufficient ARIO balance for action. Balance available: ${new mARIOToken(balance)
|
|
297
|
+
if (balance < mARIOQuantity.valueOf()) {
|
|
298
|
+
throw new Error(`Insufficient ARIO balance for action. Balance available: ${formatMARIOToARIOWithCommas(new mARIOToken(balance))} ARIO`);
|
|
278
299
|
}
|
|
279
300
|
}
|
|
280
301
|
export async function confirmationPrompt(message) {
|
|
@@ -364,3 +385,30 @@ export function getANTStateFromOptions(options) {
|
|
|
364
385
|
ttlSeconds: options.ttlSeconds !== undefined ? +options.ttlSeconds : 3600,
|
|
365
386
|
});
|
|
366
387
|
}
|
|
388
|
+
export function getTokenCostParamsFromOptions(o) {
|
|
389
|
+
o.intent ??= 'Buy-Record';
|
|
390
|
+
o.type ??= 'lease';
|
|
391
|
+
o.years ??= '1';
|
|
392
|
+
if (!isValidIntent(o.intent)) {
|
|
393
|
+
throw new Error(`Invalid intent. Valid intents are: ${validIntents.join(', ')}`);
|
|
394
|
+
}
|
|
395
|
+
if (o.type !== 'lease' && o.type !== 'permabuy') {
|
|
396
|
+
throw new Error(`Invalid type. Valid types are: lease, permabuy`);
|
|
397
|
+
}
|
|
398
|
+
return {
|
|
399
|
+
type: o.type,
|
|
400
|
+
quantity: o.quantity !== undefined ? +o.quantity : undefined,
|
|
401
|
+
years: +o.years,
|
|
402
|
+
intent: o.intent,
|
|
403
|
+
name: requiredStringFromOptions(o, 'name'),
|
|
404
|
+
fromAddress: addressFromOptions(o),
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
export function fundFromFromOptions(o) {
|
|
408
|
+
if (o.fundFrom !== undefined) {
|
|
409
|
+
if (!isValidFundFrom(o.fundFrom)) {
|
|
410
|
+
throw new Error(`Invalid fund from: ${o.fundFrom}. Please use one of ${fundFromOptions.join(', ')}`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return o.fundFrom ?? 'balance';
|
|
414
|
+
}
|
|
@@ -28,7 +28,7 @@ export class AOProcess {
|
|
|
28
28
|
this.logger = logger;
|
|
29
29
|
this.ao = ao;
|
|
30
30
|
}
|
|
31
|
-
async read({ tags, retries = 3, }) {
|
|
31
|
+
async read({ tags, retries = 3, fromAddress, }) {
|
|
32
32
|
let attempts = 0;
|
|
33
33
|
let lastError;
|
|
34
34
|
while (attempts < retries) {
|
|
@@ -37,10 +37,14 @@ export class AOProcess {
|
|
|
37
37
|
tags,
|
|
38
38
|
});
|
|
39
39
|
// map tags to inputs
|
|
40
|
-
const
|
|
40
|
+
const dryRunInput = {
|
|
41
41
|
process: this.processId,
|
|
42
42
|
tags,
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
|
+
if (fromAddress !== undefined) {
|
|
45
|
+
dryRunInput['Owner'] = fromAddress;
|
|
46
|
+
}
|
|
47
|
+
const result = await this.ao.dryrun(dryRunInput);
|
|
44
48
|
this.logger.debug(`Read interaction result`, {
|
|
45
49
|
result,
|
|
46
50
|
});
|
package/lib/esm/common/io.js
CHANGED
|
@@ -261,7 +261,7 @@ export class ARIOReadable {
|
|
|
261
261
|
tags: pruneTags(allTags),
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
|
-
async getTokenCost({ intent, type, years, name, quantity, }) {
|
|
264
|
+
async getTokenCost({ intent, type, years, name, quantity, fromAddress, }) {
|
|
265
265
|
const allTags = [
|
|
266
266
|
{ name: 'Action', value: 'Token-Cost' },
|
|
267
267
|
{
|
|
@@ -298,6 +298,52 @@ export class ARIOReadable {
|
|
|
298
298
|
];
|
|
299
299
|
return this.process.read({
|
|
300
300
|
tags: pruneTags(allTags),
|
|
301
|
+
fromAddress,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
// TODO: Can overload this function to refine different types of cost details params
|
|
305
|
+
async getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }) {
|
|
306
|
+
const allTags = [
|
|
307
|
+
{ name: 'Action', value: 'Get-Cost-Details-For-Action' },
|
|
308
|
+
{
|
|
309
|
+
name: 'Intent',
|
|
310
|
+
value: intent,
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'Name',
|
|
314
|
+
value: name,
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: 'Years',
|
|
318
|
+
value: years?.toString(),
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: 'Quantity',
|
|
322
|
+
value: quantity?.toString(),
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: 'Purchase-Type',
|
|
326
|
+
value: type,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'Fund-From',
|
|
330
|
+
value: fundFrom,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'Timestamp',
|
|
334
|
+
value: (await this.arweave.blocks
|
|
335
|
+
.getCurrent()
|
|
336
|
+
.then((block) => {
|
|
337
|
+
return { timestamp: block.timestamp * 1000 };
|
|
338
|
+
})
|
|
339
|
+
.catch(() => {
|
|
340
|
+
return { timestamp: Date.now() }; // fallback to current time
|
|
341
|
+
})).timestamp.toString(),
|
|
342
|
+
},
|
|
343
|
+
];
|
|
344
|
+
return this.process.read({
|
|
345
|
+
tags: pruneTags(allTags),
|
|
346
|
+
fromAddress,
|
|
301
347
|
});
|
|
302
348
|
}
|
|
303
349
|
async getRegistrationFees() {
|
|
@@ -662,6 +708,7 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
662
708
|
{ name: 'Years', value: params.years?.toString() ?? '1' },
|
|
663
709
|
{ name: 'Process-Id', value: params.processId },
|
|
664
710
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
711
|
+
{ name: 'Fund-From', value: params.fundFrom },
|
|
665
712
|
];
|
|
666
713
|
return this.process.send({
|
|
667
714
|
signer: this.signer,
|
|
@@ -678,13 +725,15 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
678
725
|
*/
|
|
679
726
|
async upgradeRecord(params, options) {
|
|
680
727
|
const { tags = [] } = options || {};
|
|
728
|
+
const allTags = [
|
|
729
|
+
...tags,
|
|
730
|
+
{ name: 'Action', value: 'Upgrade-Name' }, // TODO: align on Update-Record vs. Upgrade-Name (contract currently uses Upgrade-Name)
|
|
731
|
+
{ name: 'Name', value: params.name },
|
|
732
|
+
{ name: 'Fund-From', value: params.fundFrom },
|
|
733
|
+
];
|
|
681
734
|
return this.process.send({
|
|
682
735
|
signer: this.signer,
|
|
683
|
-
tags:
|
|
684
|
-
...tags,
|
|
685
|
-
{ name: 'Action', value: 'Upgrade-Name' }, // TODO: align on Update-Record vs. Upgrade-Name (contract currently uses Upgrade-Name)
|
|
686
|
-
{ name: 'Name', value: params.name },
|
|
687
|
-
],
|
|
736
|
+
tags: pruneTags(allTags),
|
|
688
737
|
});
|
|
689
738
|
}
|
|
690
739
|
/**
|
|
@@ -698,26 +747,30 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
698
747
|
*/
|
|
699
748
|
async extendLease(params, options) {
|
|
700
749
|
const { tags = [] } = options || {};
|
|
750
|
+
const allTags = [
|
|
751
|
+
...tags,
|
|
752
|
+
{ name: 'Action', value: 'Extend-Lease' },
|
|
753
|
+
{ name: 'Name', value: params.name },
|
|
754
|
+
{ name: 'Years', value: params.years.toString() },
|
|
755
|
+
{ name: 'Fund-From', value: params.fundFrom },
|
|
756
|
+
];
|
|
701
757
|
return this.process.send({
|
|
702
758
|
signer: this.signer,
|
|
703
|
-
tags:
|
|
704
|
-
...tags,
|
|
705
|
-
{ name: 'Action', value: 'Extend-Lease' },
|
|
706
|
-
{ name: 'Name', value: params.name },
|
|
707
|
-
{ name: 'Years', value: params.years.toString() },
|
|
708
|
-
],
|
|
759
|
+
tags: pruneTags(allTags),
|
|
709
760
|
});
|
|
710
761
|
}
|
|
711
762
|
async increaseUndernameLimit(params, options) {
|
|
712
763
|
const { tags = [] } = options || {};
|
|
764
|
+
const allTags = [
|
|
765
|
+
...tags,
|
|
766
|
+
{ name: 'Action', value: 'Increase-Undername-Limit' },
|
|
767
|
+
{ name: 'Name', value: params.name },
|
|
768
|
+
{ name: 'Quantity', value: params.increaseCount.toString() },
|
|
769
|
+
{ name: 'Fund-From', value: params.fundFrom },
|
|
770
|
+
];
|
|
713
771
|
return this.process.send({
|
|
714
772
|
signer: this.signer,
|
|
715
|
-
tags:
|
|
716
|
-
...tags,
|
|
717
|
-
{ name: 'Action', value: 'Increase-Undername-Limit' },
|
|
718
|
-
{ name: 'Name', value: params.name },
|
|
719
|
-
{ name: 'Quantity', value: params.increaseCount.toString() },
|
|
720
|
-
],
|
|
773
|
+
tags: pruneTags(allTags),
|
|
721
774
|
});
|
|
722
775
|
}
|
|
723
776
|
/**
|
|
@@ -742,13 +795,16 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
742
795
|
tags: pruneTags(allTags),
|
|
743
796
|
});
|
|
744
797
|
}
|
|
745
|
-
async requestPrimaryName(params) {
|
|
798
|
+
async requestPrimaryName(params, options) {
|
|
799
|
+
const { tags = [] } = options || {};
|
|
800
|
+
const allTags = [
|
|
801
|
+
...tags,
|
|
802
|
+
{ name: 'Action', value: 'Request-Primary-Name' },
|
|
803
|
+
{ name: 'Name', value: params.name },
|
|
804
|
+
];
|
|
746
805
|
return this.process.send({
|
|
747
806
|
signer: this.signer,
|
|
748
|
-
tags:
|
|
749
|
-
{ name: 'Action', value: 'Request-Primary-Name' },
|
|
750
|
-
{ name: 'Name', value: params.name },
|
|
751
|
-
],
|
|
807
|
+
tags: pruneTags(allTags),
|
|
752
808
|
});
|
|
753
809
|
}
|
|
754
810
|
/**
|
package/lib/esm/types/io.js
CHANGED
|
@@ -10,6 +10,10 @@ export const intentsUsingYears = ['Buy-Record', 'Extend-Lease'];
|
|
|
10
10
|
export const isValidIntent = (intent) => {
|
|
11
11
|
return validIntents.indexOf(intent) !== -1;
|
|
12
12
|
};
|
|
13
|
+
export const fundFromOptions = ['balance', 'stakes', 'any'];
|
|
14
|
+
export const isValidFundFrom = (fundFrom) => {
|
|
15
|
+
return fundFromOptions.indexOf(fundFrom) !== -1;
|
|
16
|
+
};
|
|
13
17
|
// Typeguard functions
|
|
14
18
|
export function isProcessConfiguration(config) {
|
|
15
19
|
return 'process' in config;
|
package/lib/esm/version.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
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 { AoArNSPurchaseParams, AoBuyRecordParams, AoExtendLeaseParams, AoIncreaseUndernameLimitParams } from '../../types/io.js';
|
|
17
|
+
import { CLIWriteOptionsFromAoParams } from '../types.js';
|
|
18
|
+
export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuyRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
19
|
+
export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
|
+
export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendLeaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
|
+
export declare function increaseUndernameLimitCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseUndernameLimitParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
22
|
+
export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
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 { AoGetCostDetailsParams } from '../../types/io.js';
|
|
17
|
+
import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions, CLIOptionsFromAoParams, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, NameCLIOptions, PaginationAddressCLIOptions, PaginationCLIOptions } from '../types.js';
|
|
2
18
|
export declare function getGateway(o: AddressCLIOptions): Promise<import("../../types/io.js").AoGateway | {
|
|
3
19
|
message: string;
|
|
4
20
|
}>;
|
|
@@ -42,9 +58,15 @@ export declare function getPrescribedNames(o: EpochCLIOptions): Promise<string[]
|
|
|
42
58
|
message: string;
|
|
43
59
|
}>;
|
|
44
60
|
export declare function getTokenCost(o: GetTokenCostCLIOptions): Promise<{
|
|
45
|
-
|
|
61
|
+
mARIOTokenCost: number;
|
|
46
62
|
message: string;
|
|
47
63
|
}>;
|
|
64
|
+
export declare function getCostDetails(o: GlobalCLIOptions & CLIOptionsFromAoParams<AoGetCostDetailsParams>): Promise<{
|
|
65
|
+
message: string;
|
|
66
|
+
tokenCost: number;
|
|
67
|
+
discounts: import("../../types/io.js").CostDiscount[];
|
|
68
|
+
fundingPlan?: import("../../types/io.js").AoFundingPlan | undefined;
|
|
69
|
+
}>;
|
|
48
70
|
export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<import("../../types/common.js").AoPrimaryName | {
|
|
49
71
|
message: string;
|
|
50
72
|
}>;
|
|
@@ -230,6 +230,10 @@ export declare const optionMap: {
|
|
|
230
230
|
description: string;
|
|
231
231
|
type: string;
|
|
232
232
|
};
|
|
233
|
+
fundFrom: {
|
|
234
|
+
alias: string;
|
|
235
|
+
description: string;
|
|
236
|
+
};
|
|
233
237
|
};
|
|
234
238
|
export declare const walletOptions: {
|
|
235
239
|
alias: string;
|
|
@@ -244,15 +248,7 @@ export declare const writeActionOptions: {
|
|
|
244
248
|
description: string;
|
|
245
249
|
type: string;
|
|
246
250
|
}[];
|
|
247
|
-
export declare const
|
|
248
|
-
alias: string;
|
|
249
|
-
description: string;
|
|
250
|
-
}[];
|
|
251
|
-
export declare const nameOptions: {
|
|
252
|
-
alias: string;
|
|
253
|
-
description: string;
|
|
254
|
-
}[];
|
|
255
|
-
export declare const initiatorOptions: {
|
|
251
|
+
export declare const arnsPurchaseOptions: {
|
|
256
252
|
alias: string;
|
|
257
253
|
description: string;
|
|
258
254
|
}[];
|
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, AoArNSNameParams,
|
|
16
|
+
import { AoAddressParams, AoArNSNameParams, AoGetVaultParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
|
|
17
17
|
export type WalletCLIOptions = {
|
|
18
18
|
walletFile?: string;
|
|
19
19
|
privateKey?: string;
|
|
@@ -47,6 +47,8 @@ export type ProcessIdWriteActionCLIOptions = WriteActionCLIOptions & {
|
|
|
47
47
|
export type CLIOptionsFromAoParams<T> = {
|
|
48
48
|
[K in keyof T]?: T[K] extends number | undefined ? string | undefined : T[K] extends string | boolean | symbol ? string : T[K] extends ReadonlyArray<infer U> ? ReadonlyArray<U> : T[K] extends object ? CLIOptionsFromAoParams<T[K]> : T[K];
|
|
49
49
|
};
|
|
50
|
+
export type CLIReadOptionsFromAoParams<T> = CLIOptionsFromAoParams<T> & GlobalCLIOptions;
|
|
51
|
+
export type CLIWriteOptionsFromAoParams<T> = WriteActionCLIOptions & CLIOptionsFromAoParams<T>;
|
|
50
52
|
export type PaginationCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<PaginationParams>;
|
|
51
53
|
export type AddressCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoAddressParams>;
|
|
52
54
|
export type ProcessIdCLIOptions = GlobalCLIOptions & {
|
|
@@ -86,10 +88,6 @@ export type OperatorStakeCLIOptions = WriteActionCLIOptions & {
|
|
|
86
88
|
export type DecreaseDelegateStakeCLIOptions = DelegateStakeCLIOptions & {
|
|
87
89
|
instant: boolean;
|
|
88
90
|
};
|
|
89
|
-
export type BuyRecordCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoBuyRecordParams>;
|
|
90
|
-
export type UpgradeRecordCLIOptions = NameWriteCLIOptions;
|
|
91
|
-
export type ExtendLeaseCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoExtendLeaseParams>;
|
|
92
|
-
export type IncreaseUndernameLimitCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoIncreaseUndernameLimitParams>;
|
|
93
91
|
export type ANTStateCLIOptions = WriteActionCLIOptions & {
|
|
94
92
|
target?: string;
|
|
95
93
|
keywords?: string[];
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JWKInterface } from 'arweave/node/lib/wallet.js';
|
|
2
2
|
import { Command, OptionValues } from 'commander';
|
|
3
|
-
import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
|
|
4
|
-
import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
|
|
3
|
+
import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
|
|
4
|
+
import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
|
|
5
5
|
export declare function stringifyJsonForCLIDisplay(json: JsonSerializable | unknown): string;
|
|
6
6
|
export declare function runCommand<O extends OptionValues>(command: Command, action: (options: O) => Promise<JsonSerializable>): Promise<void>;
|
|
7
7
|
export interface CommanderOption {
|
|
@@ -31,6 +31,7 @@ export declare function writeARIOFromOptions(options: GlobalCLIOptions): {
|
|
|
31
31
|
signerAddress: string;
|
|
32
32
|
};
|
|
33
33
|
export declare function formatARIOWithCommas(value: ARIOToken): string;
|
|
34
|
+
export declare function formatMARIOToARIOWithCommas(value: mARIOToken): string;
|
|
34
35
|
/** helper to get address from --address option first, then check wallet options */
|
|
35
36
|
export declare function addressFromOptions<O extends AddressCLIOptions>(options: O): string | undefined;
|
|
36
37
|
export declare function requiredAddressFromOptions<O extends AddressCLIOptions>(options: O): string;
|
|
@@ -51,8 +52,17 @@ export declare function redelegateParamsFromOptions(options: RedelegateStakeCLIO
|
|
|
51
52
|
export declare function recordTypeFromOptions<O extends {
|
|
52
53
|
type?: string;
|
|
53
54
|
}>(options: O): 'lease' | 'permabuy';
|
|
54
|
-
export declare function
|
|
55
|
-
export declare function
|
|
55
|
+
export declare function requiredMARIOFromOptions<O extends GlobalCLIOptions>(options: O, key: string): mARIOToken;
|
|
56
|
+
export declare function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }: {
|
|
57
|
+
ario: AoARIORead;
|
|
58
|
+
address: string;
|
|
59
|
+
costDetailsParams: AoGetCostDetailsParams;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
export declare function assertEnoughMARIOBalance({ address, ario, mARIOQuantity, }: {
|
|
62
|
+
ario: AoARIORead;
|
|
63
|
+
address: string;
|
|
64
|
+
mARIOQuantity: mARIOToken | number;
|
|
65
|
+
}): Promise<void>;
|
|
56
66
|
export declare function confirmationPrompt(message: string): Promise<boolean>;
|
|
57
67
|
export declare function assertConfirmationPrompt<O extends {
|
|
58
68
|
skipConfirmation?: boolean;
|
|
@@ -65,3 +75,14 @@ export declare function requiredStringArrayFromOptions<O extends GlobalCLIOption
|
|
|
65
75
|
export declare function positiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number | undefined;
|
|
66
76
|
export declare function requiredPositiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number;
|
|
67
77
|
export declare function getANTStateFromOptions(options: ANTStateCLIOptions): SpawnANTState;
|
|
78
|
+
export declare function getTokenCostParamsFromOptions(o: GetTokenCostCLIOptions): {
|
|
79
|
+
type: "lease" | "permabuy";
|
|
80
|
+
quantity: number | undefined;
|
|
81
|
+
years: number;
|
|
82
|
+
intent: "Buy-Record" | "Extend-Lease" | "Increase-Undername-Limit" | "Upgrade-Name" | "Primary-Name-Request";
|
|
83
|
+
name: string;
|
|
84
|
+
fromAddress: string | undefined;
|
|
85
|
+
};
|
|
86
|
+
export declare function fundFromFromOptions<O extends {
|
|
87
|
+
fundFrom?: string;
|
|
88
|
+
}>(o: O): FundFrom;
|
|
@@ -9,12 +9,13 @@ export declare class AOProcess implements AOContract {
|
|
|
9
9
|
ao?: AoClient;
|
|
10
10
|
logger?: ILogger;
|
|
11
11
|
});
|
|
12
|
-
read<K>({ tags, retries, }: {
|
|
12
|
+
read<K>({ tags, retries, fromAddress, }: {
|
|
13
13
|
tags?: Array<{
|
|
14
14
|
name: string;
|
|
15
15
|
value: string;
|
|
16
16
|
}>;
|
|
17
17
|
retries?: number;
|
|
18
|
+
fromAddress?: string;
|
|
18
19
|
}): Promise<K>;
|
|
19
20
|
send<K>({ tags, data, signer, retries, }: {
|
|
20
21
|
tags: Array<{
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
17
|
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
-
import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSReservedNameDataWithName, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
18
|
+
import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
19
19
|
import { mARIOToken } from '../types/token.js';
|
|
20
20
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
21
|
export declare class ARIO {
|
|
@@ -107,6 +107,7 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
107
107
|
intent: 'Primary-Name-Request';
|
|
108
108
|
name: string;
|
|
109
109
|
}): Promise<number>;
|
|
110
|
+
getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
|
|
110
111
|
getRegistrationFees(): Promise<AoRegistrationFees>;
|
|
111
112
|
getDemandFactor(): Promise<number>;
|
|
112
113
|
getDemandFactorSettings(): Promise<DemandFactorSettings>;
|
|
@@ -190,12 +191,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
190
191
|
reportTxId: TransactionId;
|
|
191
192
|
failedGateways: WalletAddress[];
|
|
192
193
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
193
|
-
buyRecord(params:
|
|
194
|
-
name: string;
|
|
195
|
-
years?: number;
|
|
196
|
-
type: 'lease' | 'permabuy';
|
|
197
|
-
processId: string;
|
|
198
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
194
|
+
buyRecord(params: AoBuyRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
199
195
|
/**
|
|
200
196
|
* Upgrades an existing leased record to a permabuy.
|
|
201
197
|
*
|
|
@@ -204,9 +200,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
204
200
|
* @param {Object} [options] - The options for the upgrade
|
|
205
201
|
* @returns {Promise<AoMessageResult>} The result of the upgrade
|
|
206
202
|
*/
|
|
207
|
-
upgradeRecord(params:
|
|
208
|
-
name: string;
|
|
209
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
203
|
+
upgradeRecord(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
210
204
|
/**
|
|
211
205
|
* Extends the lease of an existing leased record.
|
|
212
206
|
*
|
|
@@ -216,14 +210,8 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
216
210
|
* @param {Object} [options] - The options for the extension
|
|
217
211
|
* @returns {Promise<AoMessageResult>} The result of the extension
|
|
218
212
|
*/
|
|
219
|
-
extendLease(params:
|
|
220
|
-
|
|
221
|
-
years: number;
|
|
222
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
223
|
-
increaseUndernameLimit(params: {
|
|
224
|
-
name: string;
|
|
225
|
-
increaseCount: number;
|
|
226
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
213
|
+
extendLease(params: AoExtendLeaseParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
214
|
+
increaseUndernameLimit(params: AoIncreaseUndernameLimitParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
227
215
|
/**
|
|
228
216
|
* Cancel a withdrawal from a gateway.
|
|
229
217
|
*
|
|
@@ -237,9 +225,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
237
225
|
gatewayAddress?: WalletAddress;
|
|
238
226
|
vaultId: string;
|
|
239
227
|
}, options?: WriteOptions | undefined): Promise<AoMessageResult>;
|
|
240
|
-
requestPrimaryName(params:
|
|
241
|
-
name: string;
|
|
242
|
-
}): Promise<AoMessageResult>;
|
|
228
|
+
requestPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
243
229
|
/**
|
|
244
230
|
* Redelegate stake from one gateway to another gateway.
|
|
245
231
|
*
|