@ar.io/sdk 3.4.0-alpha.2 → 3.4.0-alpha.4
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 +42 -0
- package/bundles/web.bundle.min.js +65 -65
- package/lib/cjs/cli/cli.js +34 -19
- package/lib/cjs/cli/commands/antCommands.js +48 -0
- package/lib/cjs/cli/commands/transfer.js +83 -1
- package/lib/cjs/cli/options.js +16 -2
- package/lib/cjs/cli/utils.js +19 -2
- package/lib/cjs/common/ant.js +11 -17
- package/lib/cjs/common/io.js +36 -0
- package/lib/cjs/types/io.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +36 -21
- package/lib/esm/cli/commands/antCommands.js +42 -0
- package/lib/esm/cli/commands/transfer.js +80 -1
- package/lib/esm/cli/options.js +15 -1
- package/lib/esm/cli/utils.js +17 -1
- package/lib/esm/common/ant.js +11 -17
- package/lib/esm/common/io.js +36 -0
- package/lib/esm/types/io.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +21 -0
- package/lib/types/cli/commands/transfer.d.ts +16 -1
- package/lib/types/cli/options.d.ts +12 -0
- package/lib/types/cli/types.d.ts +3 -0
- package/lib/types/cli/utils.d.ts +2 -0
- package/lib/types/common/ant.d.ts +5 -19
- package/lib/types/common/io.d.ts +4 -1
- package/lib/types/types/ant.d.ts +42 -44
- package/lib/types/types/common.d.ts +2 -0
- package/lib/types/types/io.d.ts +43 -31
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertEnoughMARIOBalance, confirmationPrompt, formatARIOWithCommas, formatMARIOToARIOWithCommas, requiredMARIOFromOptions, requiredPositiveIntegerFromOptions, requiredStringFromOptions, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
1
|
+
import { assertEnoughMARIOBalance, assertLockLengthInRange, confirmationPrompt, formatARIOWithCommas, formatMARIOToARIOWithCommas, requiredMARIOFromOptions, requiredPositiveIntegerFromOptions, requiredStringFromOptions, requiredTargetAndQuantityFromOptions, writeARIOFromOptions, writeActionTagsFromOptions, } from '../utils.js';
|
|
2
2
|
export async function transferCLICommand(options) {
|
|
3
3
|
const { target, arioQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
4
4
|
const { ario, signerAddress } = writeARIOFromOptions(options);
|
|
@@ -29,6 +29,7 @@ export async function vaultedTransferCLICommand(o) {
|
|
|
29
29
|
const recipient = requiredStringFromOptions(o, 'recipient');
|
|
30
30
|
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
31
31
|
const lockLengthMs = requiredPositiveIntegerFromOptions(o, 'lockLengthMs');
|
|
32
|
+
assertLockLengthInRange(lockLengthMs);
|
|
32
33
|
if (!o.skipConfirmation) {
|
|
33
34
|
await assertEnoughMARIOBalance({
|
|
34
35
|
ario,
|
|
@@ -78,3 +79,81 @@ export async function revokeVaultCLICommand(o) {
|
|
|
78
79
|
};
|
|
79
80
|
return output;
|
|
80
81
|
}
|
|
82
|
+
export async function createVaultCLICommand(o) {
|
|
83
|
+
const mARIOQuantity = requiredMARIOFromOptions(o, 'quantity');
|
|
84
|
+
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
85
|
+
const lockLengthMs = requiredPositiveIntegerFromOptions(o, 'lockLengthMs');
|
|
86
|
+
assertLockLengthInRange(lockLengthMs);
|
|
87
|
+
if (!o.skipConfirmation) {
|
|
88
|
+
await assertEnoughMARIOBalance({
|
|
89
|
+
ario,
|
|
90
|
+
address: signerAddress,
|
|
91
|
+
mARIOQuantity,
|
|
92
|
+
});
|
|
93
|
+
const confirm = await confirmationPrompt(`Are you sure you want to create a vault with ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO, locked for ${lockLengthMs}ms?`);
|
|
94
|
+
if (!confirm) {
|
|
95
|
+
return { message: 'Vault creation aborted by user' };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const result = await ario.createVault({
|
|
99
|
+
quantity: mARIOQuantity,
|
|
100
|
+
lockLengthMs,
|
|
101
|
+
}, writeActionTagsFromOptions(o));
|
|
102
|
+
const output = {
|
|
103
|
+
senderAddress: signerAddress,
|
|
104
|
+
transferResult: result,
|
|
105
|
+
message: `Successfully created vault with ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO`,
|
|
106
|
+
};
|
|
107
|
+
return output;
|
|
108
|
+
}
|
|
109
|
+
export async function extendVaultCLICommand(o) {
|
|
110
|
+
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
111
|
+
const vaultId = requiredStringFromOptions(o, 'vaultId');
|
|
112
|
+
const extendLengthMs = requiredPositiveIntegerFromOptions(o, 'extendLengthMs');
|
|
113
|
+
assertLockLengthInRange(extendLengthMs, false);
|
|
114
|
+
if (!o.skipConfirmation) {
|
|
115
|
+
const vault = await ario.getVault({ vaultId, address: signerAddress });
|
|
116
|
+
if (!vault) {
|
|
117
|
+
throw new Error(`Vault for signer '${signerAddress}' with vault id '${vaultId}' not found`);
|
|
118
|
+
}
|
|
119
|
+
const confirm = await confirmationPrompt(`Are you sure you want to extend vault with id ${vaultId} for ${extendLengthMs}ms?`);
|
|
120
|
+
if (!confirm) {
|
|
121
|
+
return { message: 'Vault extension aborted by user' };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const result = await ario.extendVault({
|
|
125
|
+
vaultId,
|
|
126
|
+
extendLengthMs,
|
|
127
|
+
}, writeActionTagsFromOptions(o));
|
|
128
|
+
const output = {
|
|
129
|
+
senderAddress: signerAddress,
|
|
130
|
+
transferResult: result,
|
|
131
|
+
message: `Successfully extended vault with id ${vaultId}`,
|
|
132
|
+
};
|
|
133
|
+
return output;
|
|
134
|
+
}
|
|
135
|
+
export async function increaseVaultCLICommand(o) {
|
|
136
|
+
const mARIOQuantity = requiredMARIOFromOptions(o, 'quantity');
|
|
137
|
+
const { ario, signerAddress } = writeARIOFromOptions(o);
|
|
138
|
+
const vaultId = requiredStringFromOptions(o, 'vaultId');
|
|
139
|
+
if (!o.skipConfirmation) {
|
|
140
|
+
const vault = await ario.getVault({ vaultId, address: signerAddress });
|
|
141
|
+
if (!vault) {
|
|
142
|
+
throw new Error(`Vault for signer '${signerAddress}' with vault id '${vaultId}' not found`);
|
|
143
|
+
}
|
|
144
|
+
const confirm = await confirmationPrompt(`Are you sure you want to increase vault with id ${vaultId} by ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO?`);
|
|
145
|
+
if (!confirm) {
|
|
146
|
+
return { message: 'Vault increase aborted by user' };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const result = await ario.increaseVault({
|
|
150
|
+
vaultId,
|
|
151
|
+
quantity: mARIOQuantity,
|
|
152
|
+
}, writeActionTagsFromOptions(o));
|
|
153
|
+
const output = {
|
|
154
|
+
senderAddress: signerAddress,
|
|
155
|
+
transferResult: result,
|
|
156
|
+
message: `Successfully increased vault with id ${vaultId} by ${formatMARIOToARIOWithCommas(mARIOQuantity)} ARIO`,
|
|
157
|
+
};
|
|
158
|
+
return output;
|
|
159
|
+
}
|
package/lib/esm/cli/options.js
CHANGED
|
@@ -245,7 +245,11 @@ export const optionMap = {
|
|
|
245
245
|
},
|
|
246
246
|
lockLengthMs: {
|
|
247
247
|
alias: '--lock-length-ms <lockLengthMs>',
|
|
248
|
-
description: 'The length of time in milliseconds to lock the
|
|
248
|
+
description: 'The length of time in milliseconds to lock the vault for',
|
|
249
|
+
},
|
|
250
|
+
extendLengthMs: {
|
|
251
|
+
alias: '--extend-length-ms <extendLengthMs>',
|
|
252
|
+
description: 'The length of time in milliseconds to extend the vault for',
|
|
249
253
|
},
|
|
250
254
|
recipient: {
|
|
251
255
|
alias: '--recipient <recipient>',
|
|
@@ -351,3 +355,13 @@ export const antStateOptions = [
|
|
|
351
355
|
optionMap.controllers,
|
|
352
356
|
optionMap.ttlSeconds,
|
|
353
357
|
];
|
|
358
|
+
export const setAntBaseNameOptions = [
|
|
359
|
+
optionMap.processId,
|
|
360
|
+
optionMap.transactionId,
|
|
361
|
+
optionMap.ttlSeconds,
|
|
362
|
+
...writeActionOptions,
|
|
363
|
+
];
|
|
364
|
+
export const setAntUndernameOptions = [
|
|
365
|
+
...setAntBaseNameOptions,
|
|
366
|
+
optionMap.undername,
|
|
367
|
+
];
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ import { readFileSync } from 'fs';
|
|
|
19
19
|
import prompts from 'prompts';
|
|
20
20
|
import { ANT, AOProcess, ARIO, ARIOToken, ARIO_DEVNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, ArweaveSigner, Logger, createAoSigner, fromB64Url, fundFromOptions, initANTStateForAddress, isValidFundFrom, isValidIntent, mARIOToken, sha256B64Url, validIntents, } from '../node/index.js';
|
|
21
21
|
import { globalOptions } from './options.js';
|
|
22
|
+
export const defaultTtlSecondsCLI = 3600;
|
|
22
23
|
export function stringifyJsonForCLIDisplay(json) {
|
|
23
24
|
return JSON.stringify(json, null, 2);
|
|
24
25
|
}
|
|
@@ -385,7 +386,9 @@ export function getANTStateFromOptions(options) {
|
|
|
385
386
|
ticker: options.ticker,
|
|
386
387
|
name: options.name,
|
|
387
388
|
keywords: options.keywords,
|
|
388
|
-
ttlSeconds: options.ttlSeconds !== undefined
|
|
389
|
+
ttlSeconds: options.ttlSeconds !== undefined
|
|
390
|
+
? +options.ttlSeconds
|
|
391
|
+
: defaultTtlSecondsCLI,
|
|
389
392
|
});
|
|
390
393
|
}
|
|
391
394
|
export function getTokenCostParamsFromOptions(o) {
|
|
@@ -415,3 +418,16 @@ export function fundFromFromOptions(o) {
|
|
|
415
418
|
}
|
|
416
419
|
return o.fundFrom ?? 'balance';
|
|
417
420
|
}
|
|
421
|
+
export function assertLockLengthInRange(lockLengthMs, assertMin = true) {
|
|
422
|
+
const minLockLengthMs = 1209600000; // 14 days
|
|
423
|
+
const maxLockLengthMs = 378432000000; // ~12 years
|
|
424
|
+
if (lockLengthMs > maxLockLengthMs) {
|
|
425
|
+
throw new Error(`Lock length must be at most 12 years (378432000000 ms). Provided lock length: ${lockLengthMs} ms`);
|
|
426
|
+
}
|
|
427
|
+
if (!assertMin) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (lockLengthMs < minLockLengthMs) {
|
|
431
|
+
throw new Error(`Lock length must be at least 14 days (1209600000 ms). Provided lock length: ${lockLengthMs} ms`);
|
|
432
|
+
}
|
|
433
|
+
}
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -30,6 +30,7 @@ export class ANT {
|
|
|
30
30
|
}
|
|
31
31
|
export class AoANTReadable {
|
|
32
32
|
process;
|
|
33
|
+
processId;
|
|
33
34
|
strict;
|
|
34
35
|
constructor(config) {
|
|
35
36
|
this.strict = config.strict || false;
|
|
@@ -44,6 +45,7 @@ export class AoANTReadable {
|
|
|
44
45
|
else {
|
|
45
46
|
throw new InvalidContractConfigurationError();
|
|
46
47
|
}
|
|
48
|
+
this.processId = this.process.processId;
|
|
47
49
|
}
|
|
48
50
|
async getState({ strict } = { strict: this.strict }) {
|
|
49
51
|
const tags = [{ name: 'Action', value: 'State' }];
|
|
@@ -287,12 +289,8 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
287
289
|
* @param transactionId @type {string} The transactionId of the record.
|
|
288
290
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
289
291
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
290
|
-
* @example
|
|
291
|
-
* ```ts
|
|
292
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
293
|
-
* ```
|
|
294
292
|
*/
|
|
295
|
-
async setRecord({ undername, transactionId, ttlSeconds
|
|
293
|
+
async setRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
296
294
|
return this.process.send({
|
|
297
295
|
tags: [
|
|
298
296
|
...(options?.tags ?? []),
|
|
@@ -315,16 +313,12 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
315
313
|
* ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
316
314
|
* ```
|
|
317
315
|
*/
|
|
318
|
-
async setBaseNameRecord({ transactionId, ttlSeconds,
|
|
319
|
-
return this.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
325
|
-
],
|
|
326
|
-
signer: this.signer,
|
|
327
|
-
});
|
|
316
|
+
async setBaseNameRecord({ transactionId, ttlSeconds }, options) {
|
|
317
|
+
return this.setRecord({
|
|
318
|
+
transactionId,
|
|
319
|
+
ttlSeconds,
|
|
320
|
+
undername: '@',
|
|
321
|
+
}, options);
|
|
328
322
|
}
|
|
329
323
|
/**
|
|
330
324
|
* Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
|
|
@@ -338,12 +332,12 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
338
332
|
* ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
339
333
|
* ```
|
|
340
334
|
*/
|
|
341
|
-
async setUndernameRecord({ undername, transactionId, ttlSeconds,
|
|
335
|
+
async setUndernameRecord({ undername, transactionId, ttlSeconds }, options) {
|
|
342
336
|
return this.setRecord({
|
|
343
337
|
undername,
|
|
344
338
|
transactionId,
|
|
345
339
|
ttlSeconds,
|
|
346
|
-
});
|
|
340
|
+
}, options);
|
|
347
341
|
}
|
|
348
342
|
/**
|
|
349
343
|
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
package/lib/esm/common/io.js
CHANGED
|
@@ -513,6 +513,42 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
513
513
|
signer: this.signer,
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
|
+
async createVault({ lockLengthMs, quantity }, options) {
|
|
517
|
+
const { tags = [] } = options || {};
|
|
518
|
+
return this.process.send({
|
|
519
|
+
tags: [
|
|
520
|
+
...tags,
|
|
521
|
+
{ name: 'Action', value: 'Create-Vault' },
|
|
522
|
+
{ name: 'Lock-Length', value: lockLengthMs.toString() },
|
|
523
|
+
{ name: 'Quantity', value: quantity.toString() },
|
|
524
|
+
],
|
|
525
|
+
signer: this.signer,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
async extendVault({ vaultId, extendLengthMs }, options) {
|
|
529
|
+
const { tags = [] } = options || {};
|
|
530
|
+
return this.process.send({
|
|
531
|
+
tags: [
|
|
532
|
+
...tags,
|
|
533
|
+
{ name: 'Action', value: 'Extend-Vault' },
|
|
534
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
535
|
+
{ name: 'Extend-Length', value: extendLengthMs.toString() },
|
|
536
|
+
],
|
|
537
|
+
signer: this.signer,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
async increaseVault({ vaultId, quantity }, options) {
|
|
541
|
+
const { tags = [] } = options || {};
|
|
542
|
+
return this.process.send({
|
|
543
|
+
tags: [
|
|
544
|
+
...tags,
|
|
545
|
+
{ name: 'Action', value: 'Increase-Vault' },
|
|
546
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
547
|
+
{ name: 'Quantity', value: quantity.toString() },
|
|
548
|
+
],
|
|
549
|
+
signer: this.signer,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
516
552
|
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
517
553
|
const { tags = [] } = options || {};
|
|
518
554
|
const allTags = [
|
package/lib/esm/types/io.js
CHANGED
|
@@ -19,7 +19,7 @@ export const fundFromOptions = ['balance', 'stakes', 'any'];
|
|
|
19
19
|
export const isValidFundFrom = (fundFrom) => {
|
|
20
20
|
return fundFromOptions.indexOf(fundFrom) !== -1;
|
|
21
21
|
};
|
|
22
|
-
//
|
|
22
|
+
// Type-guard functions
|
|
23
23
|
export function isProcessConfiguration(config) {
|
|
24
24
|
return 'process' in config;
|
|
25
25
|
}
|
package/lib/esm/version.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams } from '../../types/ant.js';
|
|
17
|
+
import { CLIWriteOptionsFromAoAntParams } from '../types.js';
|
|
18
|
+
/** @deprecated -- use set-ant-base-name and set-ant-undername */
|
|
19
|
+
export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
|
+
export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
|
+
export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -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 { AoRevokeVaultParams, AoVaultedTransferParams } from '../../types/io.js';
|
|
16
|
+
import { AoCreateVaultParams, AoExtendVaultParams, AoIncreaseVaultParams, AoRevokeVaultParams, AoVaultedTransferParams } from '../../types/io.js';
|
|
17
17
|
import { CLIWriteOptionsFromAoParams, JsonSerializable, TransferCLIOptions } from '../types.js';
|
|
18
18
|
export declare function transferCLICommand(options: TransferCLIOptions): Promise<{
|
|
19
19
|
senderAddress: string;
|
|
@@ -24,3 +24,18 @@ export declare function transferCLICommand(options: TransferCLIOptions): Promise
|
|
|
24
24
|
}>;
|
|
25
25
|
export declare function vaultedTransferCLICommand(o: CLIWriteOptionsFromAoParams<AoVaultedTransferParams>): Promise<JsonSerializable>;
|
|
26
26
|
export declare function revokeVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoRevokeVaultParams>): Promise<JsonSerializable>;
|
|
27
|
+
export declare function createVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoCreateVaultParams>): Promise<JsonSerializable>;
|
|
28
|
+
export declare function extendVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendVaultParams>): Promise<{
|
|
29
|
+
senderAddress: string;
|
|
30
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
31
|
+
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function increaseVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseVaultParams>): Promise<{
|
|
36
|
+
senderAddress: string;
|
|
37
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
38
|
+
message: string;
|
|
39
|
+
} | {
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
@@ -243,6 +243,10 @@ export declare const optionMap: {
|
|
|
243
243
|
alias: string;
|
|
244
244
|
description: string;
|
|
245
245
|
};
|
|
246
|
+
extendLengthMs: {
|
|
247
|
+
alias: string;
|
|
248
|
+
description: string;
|
|
249
|
+
};
|
|
246
250
|
recipient: {
|
|
247
251
|
alias: string;
|
|
248
252
|
description: string;
|
|
@@ -333,3 +337,11 @@ export declare const antStateOptions: {
|
|
|
333
337
|
alias: string;
|
|
334
338
|
description: string;
|
|
335
339
|
}[];
|
|
340
|
+
export declare const setAntBaseNameOptions: {
|
|
341
|
+
alias: string;
|
|
342
|
+
description: string;
|
|
343
|
+
}[];
|
|
344
|
+
export declare const setAntUndernameOptions: {
|
|
345
|
+
alias: string;
|
|
346
|
+
description: string;
|
|
347
|
+
}[];
|
package/lib/types/cli/types.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ export type CLIOptionsFromAoParams<T> = {
|
|
|
49
49
|
};
|
|
50
50
|
export type CLIReadOptionsFromAoParams<T> = CLIOptionsFromAoParams<T> & GlobalCLIOptions;
|
|
51
51
|
export type CLIWriteOptionsFromAoParams<T> = WriteActionCLIOptions & CLIOptionsFromAoParams<T>;
|
|
52
|
+
export type CLIWriteOptionsFromAoAntParams<T> = CLIWriteOptionsFromAoParams<T & {
|
|
53
|
+
processId: string;
|
|
54
|
+
}>;
|
|
52
55
|
export type PaginationCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<PaginationParams>;
|
|
53
56
|
export type AddressCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoAddressParams>;
|
|
54
57
|
export type ProcessIdCLIOptions = GlobalCLIOptions & {
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { JWKInterface } from 'arweave/node/lib/wallet.js';
|
|
|
2
2
|
import { Command, OptionValues } from 'commander';
|
|
3
3
|
import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
|
|
4
4
|
import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
|
|
5
|
+
export declare const defaultTtlSecondsCLI = 3600;
|
|
5
6
|
export declare function stringifyJsonForCLIDisplay(json: JsonSerializable | unknown): string;
|
|
6
7
|
export declare function runCommand<O extends OptionValues>(command: Command, action: (options: O) => Promise<JsonSerializable>): Promise<void>;
|
|
7
8
|
export interface CommanderOption {
|
|
@@ -85,3 +86,4 @@ export declare function getTokenCostParamsFromOptions(o: GetTokenCostCLIOptions)
|
|
|
85
86
|
export declare function fundFromFromOptions<O extends {
|
|
86
87
|
fundFrom?: string;
|
|
87
88
|
}>(o: O): FundFrom;
|
|
89
|
+
export declare function assertLockLengthInRange(lockLengthMs: number, assertMin?: boolean): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTState, AoANTWrite } from '../types/ant.js';
|
|
1
|
+
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTWrite } from '../types/ant.js';
|
|
2
2
|
import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './index.js';
|
|
4
4
|
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
@@ -12,6 +12,7 @@ export declare class ANT {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class AoANTReadable implements AoANTRead {
|
|
14
14
|
protected process: AOProcess;
|
|
15
|
+
readonly processId: string;
|
|
15
16
|
private strict;
|
|
16
17
|
constructor(config: ANTConfigOptionalStrict);
|
|
17
18
|
getState({ strict }?: AntReadOptions): Promise<AoANTState>;
|
|
@@ -154,16 +155,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
154
155
|
* @param transactionId @type {string} The transactionId of the record.
|
|
155
156
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
156
157
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
160
|
-
* ```
|
|
161
158
|
*/
|
|
162
|
-
setRecord({ undername, transactionId, ttlSeconds
|
|
163
|
-
undername: string;
|
|
164
|
-
transactionId: string;
|
|
165
|
-
ttlSeconds: number;
|
|
166
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
159
|
+
setRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
167
160
|
/**
|
|
168
161
|
* Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
|
|
169
162
|
*
|
|
@@ -175,10 +168,7 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
175
168
|
* ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
176
169
|
* ```
|
|
177
170
|
*/
|
|
178
|
-
setBaseNameRecord({ transactionId, ttlSeconds
|
|
179
|
-
transactionId: string;
|
|
180
|
-
ttlSeconds: number;
|
|
181
|
-
}): Promise<AoMessageResult>;
|
|
171
|
+
setBaseNameRecord({ transactionId, ttlSeconds }: AoANTSetBaseNameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
182
172
|
/**
|
|
183
173
|
* Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
|
|
184
174
|
*
|
|
@@ -191,11 +181,7 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
191
181
|
* ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
|
|
192
182
|
* ```
|
|
193
183
|
*/
|
|
194
|
-
setUndernameRecord({ undername, transactionId, ttlSeconds
|
|
195
|
-
undername: string;
|
|
196
|
-
transactionId: string;
|
|
197
|
-
ttlSeconds: number;
|
|
198
|
-
}): Promise<AoMessageResult>;
|
|
184
|
+
setUndernameRecord({ undername, transactionId, ttlSeconds }: AoANTSetUndernameRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
199
185
|
/**
|
|
200
186
|
* Removes an undername from the ANT. This will remove the undername from the ANT.
|
|
201
187
|
*
|
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, OptionalArweave, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
-
import { AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoRevokeVaultParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
18
|
+
import { AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoPaginatedAddressParams, AoRegistrationFees, AoRevokeVaultParams, AoVaultData, AoVaultedTransferParams, 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
|
type ARIOConfigNoSigner = OptionalArweave<ProcessConfiguration>;
|
|
@@ -149,6 +149,9 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
149
149
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
150
150
|
vaultedTransfer({ recipient, quantity, lockLengthMs, revokable, }: AoVaultedTransferParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
151
151
|
revokeVault({ vaultId, recipient }: AoRevokeVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
152
|
+
createVault({ lockLengthMs, quantity }: AoCreateVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
153
|
+
extendVault({ vaultId, extendLengthMs }: AoExtendVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
154
|
+
increaseVault({ vaultId, quantity }: AoIncreaseVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
152
155
|
joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
153
156
|
leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
|
|
154
157
|
updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
package/lib/types/types/ant.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { z } from 'zod';
|
|
17
|
-
import {
|
|
17
|
+
import { AoWriteAction, WalletAddress } from './common.js';
|
|
18
18
|
/**
|
|
19
19
|
* example error:
|
|
20
20
|
* {
|
|
@@ -161,6 +161,7 @@ export type AntReadOptions = {
|
|
|
161
161
|
strict?: boolean;
|
|
162
162
|
};
|
|
163
163
|
export interface AoANTRead {
|
|
164
|
+
processId: string;
|
|
164
165
|
getState(opts?: AntReadOptions): Promise<AoANTState>;
|
|
165
166
|
getInfo(opts?: AntReadOptions): Promise<AoANTInfo>;
|
|
166
167
|
getRecord({ undername }: {
|
|
@@ -179,67 +180,64 @@ export interface AoANTRead {
|
|
|
179
180
|
getHandlers(): Promise<AoANTHandler[]>;
|
|
180
181
|
}
|
|
181
182
|
export interface AoANTWrite extends AoANTRead {
|
|
182
|
-
transfer
|
|
183
|
+
transfer: AoWriteAction<{
|
|
183
184
|
target: WalletAddress;
|
|
184
|
-
}
|
|
185
|
-
addController
|
|
185
|
+
}>;
|
|
186
|
+
addController: AoWriteAction<{
|
|
186
187
|
controller: WalletAddress;
|
|
187
|
-
}
|
|
188
|
-
removeController
|
|
188
|
+
}>;
|
|
189
|
+
removeController: AoWriteAction<{
|
|
189
190
|
controller: WalletAddress;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
ttlSeconds: number;
|
|
195
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
196
|
-
removeRecord({ undername }: {
|
|
197
|
-
undername: string;
|
|
198
|
-
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
199
|
-
setBaseNameRecord({ transactionId, ttlSeconds, }: {
|
|
200
|
-
transactionId: string;
|
|
201
|
-
ttlSeconds: number;
|
|
202
|
-
}): Promise<AoMessageResult>;
|
|
203
|
-
setUndernameRecord({ undername, transactionId, ttlSeconds, }: {
|
|
191
|
+
}>;
|
|
192
|
+
/** @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@") */
|
|
193
|
+
setRecord: AoWriteAction<AoANTSetUndernameRecordParams>;
|
|
194
|
+
removeRecord: AoWriteAction<{
|
|
204
195
|
undername: string;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
removeUndernameRecord
|
|
196
|
+
}>;
|
|
197
|
+
setBaseNameRecord: AoWriteAction<AoANTSetBaseNameRecordParams>;
|
|
198
|
+
setUndernameRecord: AoWriteAction<AoANTSetUndernameRecordParams>;
|
|
199
|
+
removeUndernameRecord: AoWriteAction<{
|
|
209
200
|
undername: string;
|
|
210
|
-
}
|
|
211
|
-
setTicker
|
|
201
|
+
}>;
|
|
202
|
+
setTicker: AoWriteAction<{
|
|
212
203
|
ticker: string;
|
|
213
|
-
}
|
|
214
|
-
setDescription
|
|
204
|
+
}>;
|
|
205
|
+
setDescription: AoWriteAction<{
|
|
215
206
|
description: string;
|
|
216
|
-
}
|
|
217
|
-
setKeywords
|
|
207
|
+
}>;
|
|
208
|
+
setKeywords: AoWriteAction<{
|
|
218
209
|
keywords: string[];
|
|
219
|
-
}
|
|
220
|
-
setName
|
|
210
|
+
}>;
|
|
211
|
+
setName: AoWriteAction<{
|
|
221
212
|
name: string;
|
|
222
|
-
}
|
|
223
|
-
setLogo
|
|
213
|
+
}>;
|
|
214
|
+
setLogo: AoWriteAction<{
|
|
224
215
|
txId: string;
|
|
225
|
-
}
|
|
226
|
-
releaseName
|
|
216
|
+
}>;
|
|
217
|
+
releaseName: AoWriteAction<{
|
|
227
218
|
name: string;
|
|
228
219
|
arioProcessId: string;
|
|
229
|
-
}
|
|
230
|
-
reassignName
|
|
220
|
+
}>;
|
|
221
|
+
reassignName: AoWriteAction<{
|
|
231
222
|
name: string;
|
|
232
223
|
arioProcessId: string;
|
|
233
224
|
antProcessId: string;
|
|
234
|
-
}
|
|
235
|
-
approvePrimaryNameRequest
|
|
225
|
+
}>;
|
|
226
|
+
approvePrimaryNameRequest: AoWriteAction<{
|
|
236
227
|
name: string;
|
|
237
|
-
address:
|
|
228
|
+
address: string;
|
|
238
229
|
arioProcessId: string;
|
|
239
|
-
}
|
|
240
|
-
removePrimaryNames
|
|
230
|
+
}>;
|
|
231
|
+
removePrimaryNames: AoWriteAction<{
|
|
241
232
|
names: string[];
|
|
242
233
|
arioProcessId: string;
|
|
243
234
|
notifyOwners?: boolean;
|
|
244
|
-
}
|
|
235
|
+
}>;
|
|
245
236
|
}
|
|
237
|
+
export type AoANTSetBaseNameRecordParams = {
|
|
238
|
+
transactionId: string;
|
|
239
|
+
ttlSeconds: number;
|
|
240
|
+
};
|
|
241
|
+
export type AoANTSetUndernameRecordParams = AoANTSetBaseNameRecordParams & {
|
|
242
|
+
undername: string;
|
|
243
|
+
};
|