@ar.io/sdk 3.3.0-alpha.5 → 3.3.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/web.bundle.min.js +58 -56
- package/lib/cjs/cli/cli.js +14 -0
- package/lib/cjs/common/ant-registry.js +14 -21
- package/lib/cjs/common/ant.js +5 -8
- package/lib/cjs/common/contracts/ao-process.js +11 -13
- package/lib/cjs/common/io.js +12 -33
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +16 -2
- package/lib/esm/common/ant-registry.js +14 -21
- package/lib/esm/common/ant.js +5 -8
- package/lib/esm/common/contracts/ao-process.js +11 -13
- package/lib/esm/common/io.js +12 -33
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant-registry.d.ts +5 -4
- package/lib/types/common/ant.d.ts +9 -10
- package/lib/types/common/io.d.ts +8 -27
- package/lib/types/types/common.d.ts +4 -0
- package/lib/types/types/io.d.ts +14 -13
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -2
package/lib/cjs/cli/cli.js
CHANGED
|
@@ -664,6 +664,20 @@ const utils_js_1 = require("./utils.js");
|
|
|
664
664
|
}, (0, utils_js_1.writeActionTagsFromOptions)(options));
|
|
665
665
|
},
|
|
666
666
|
});
|
|
667
|
+
(0, utils_js_1.makeCommand)({
|
|
668
|
+
name: 'write-action',
|
|
669
|
+
description: 'Send a write action to an AO Process',
|
|
670
|
+
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.processId],
|
|
671
|
+
action: async (options) => {
|
|
672
|
+
const process = new index_js_1.AOProcess({
|
|
673
|
+
processId: (0, utils_js_1.requiredProcessIdFromOptions)(options),
|
|
674
|
+
});
|
|
675
|
+
return process.send({
|
|
676
|
+
tags: (0, utils_js_1.writeActionTagsFromOptions)(options).tags ?? [],
|
|
677
|
+
signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
});
|
|
667
681
|
if (process.argv[1].includes('bin/ar.io') || // Running from global .bin
|
|
668
682
|
process.argv[1].includes('cli/cli') // Running from source
|
|
669
683
|
) {
|
|
@@ -22,12 +22,8 @@ const ao_js_1 = require("../utils/ao.js");
|
|
|
22
22
|
const index_js_2 = require("./index.js");
|
|
23
23
|
class ANTRegistry {
|
|
24
24
|
static init(config) {
|
|
25
|
-
if (config && config
|
|
26
|
-
|
|
27
|
-
return new AoANTRegistryWriteable({
|
|
28
|
-
...rest,
|
|
29
|
-
signer,
|
|
30
|
-
});
|
|
25
|
+
if (config !== undefined && 'signer' in config) {
|
|
26
|
+
return new AoANTRegistryWriteable(config);
|
|
31
27
|
}
|
|
32
28
|
return new AoANTRegistryReadable(config);
|
|
33
29
|
}
|
|
@@ -36,25 +32,22 @@ exports.ANTRegistry = ANTRegistry;
|
|
|
36
32
|
class AoANTRegistryReadable {
|
|
37
33
|
process;
|
|
38
34
|
constructor(config) {
|
|
39
|
-
if (config
|
|
40
|
-
((0, index_js_1.isProcessIdConfiguration)(config) || (0, index_js_1.isProcessConfiguration)(config))) {
|
|
41
|
-
if ((0, index_js_1.isProcessConfiguration)(config)) {
|
|
42
|
-
this.process = config.process;
|
|
43
|
-
}
|
|
44
|
-
else if ((0, index_js_1.isProcessIdConfiguration)(config)) {
|
|
45
|
-
this.process = new index_js_2.AOProcess({
|
|
46
|
-
processId: config.processId,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
throw new index_js_2.InvalidContractConfigurationError();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
35
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
54
36
|
this.process = new index_js_2.AOProcess({
|
|
55
37
|
processId: constants_js_1.ANT_REGISTRY_ID,
|
|
56
38
|
});
|
|
57
39
|
}
|
|
40
|
+
else if ((0, index_js_1.isProcessConfiguration)(config)) {
|
|
41
|
+
this.process = config.process;
|
|
42
|
+
}
|
|
43
|
+
else if ((0, index_js_1.isProcessIdConfiguration)(config)) {
|
|
44
|
+
this.process = new index_js_2.AOProcess({
|
|
45
|
+
processId: config.processId,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new index_js_2.InvalidContractConfigurationError();
|
|
50
|
+
}
|
|
58
51
|
}
|
|
59
52
|
// Should we rename this to "getANTsByAddress"? seems more clear, though not same as handler name
|
|
60
53
|
async accessControlList({ address, }) {
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -23,15 +23,12 @@ const ao_js_1 = require("../utils/ao.js");
|
|
|
23
23
|
const schema_js_1 = require("../utils/schema.js");
|
|
24
24
|
const index_js_2 = require("./index.js");
|
|
25
25
|
class ANT {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
return new AoANTReadable({ strict, ...config });
|
|
31
|
-
}
|
|
32
|
-
return new AoANTWriteable({ signer, strict, ...config });
|
|
26
|
+
// implementation
|
|
27
|
+
static init(config) {
|
|
28
|
+
if (config !== undefined && 'signer' in config) {
|
|
29
|
+
return new AoANTWriteable(config);
|
|
33
30
|
}
|
|
34
|
-
|
|
31
|
+
return new AoANTReadable(config);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
exports.ANT = ANT;
|
|
@@ -160,8 +160,8 @@ class AOProcess {
|
|
|
160
160
|
processId: this.processId,
|
|
161
161
|
tags,
|
|
162
162
|
});
|
|
163
|
-
// throw on write interaction errors. No point retrying
|
|
164
|
-
if (
|
|
163
|
+
// throw on write interaction errors. No point retrying write interactions, waste of gas.
|
|
164
|
+
if (error.message.includes('500')) {
|
|
165
165
|
this.logger.debug('Retrying send interaction', {
|
|
166
166
|
attempts,
|
|
167
167
|
retries,
|
|
@@ -183,18 +183,16 @@ class AOProcess {
|
|
|
183
183
|
exports.AOProcess = AOProcess;
|
|
184
184
|
function errorMessageFromOutput(output) {
|
|
185
185
|
const errorData = output.Error;
|
|
186
|
-
if
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return errorData;
|
|
190
|
-
}
|
|
191
|
-
const error = output.Messages?.[0]?.Tags?.find((tag) => tag.name === 'Error')?.value;
|
|
186
|
+
// Attempt to extract error details from Messages.Tags if Error is undefined
|
|
187
|
+
const error = errorData ??
|
|
188
|
+
output.Messages?.[0]?.Tags?.find((tag) => tag.name === 'Error')?.value;
|
|
192
189
|
if (error !== undefined) {
|
|
193
|
-
//
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
// Consolidated regex to match and extract line number and AO error message or Error Tags
|
|
191
|
+
const match = error.match(/\[string "aos"]:(\d+):\s*(.+)/);
|
|
192
|
+
if (match) {
|
|
193
|
+
const [, lineNumber, errorMessage] = match;
|
|
194
|
+
return `${errorMessage.trim()} (line ${lineNumber.trim()})`.trim();
|
|
195
|
+
}
|
|
198
196
|
}
|
|
199
197
|
return undefined;
|
|
200
198
|
}
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -9,19 +9,12 @@ const arweave_js_2 = require("./arweave.js");
|
|
|
9
9
|
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
10
10
|
const error_js_1 = require("./error.js");
|
|
11
11
|
class ARIO {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return new ARIOWriteable(
|
|
16
|
-
...rest,
|
|
17
|
-
signer,
|
|
18
|
-
arweave,
|
|
19
|
-
});
|
|
12
|
+
// Implementation
|
|
13
|
+
static init(config) {
|
|
14
|
+
if (config !== undefined && 'signer' in config) {
|
|
15
|
+
return new ARIOWriteable(config);
|
|
20
16
|
}
|
|
21
|
-
return new ARIOReadable(
|
|
22
|
-
arweave,
|
|
23
|
-
...config,
|
|
24
|
-
});
|
|
17
|
+
return new ARIOReadable(config);
|
|
25
18
|
}
|
|
26
19
|
}
|
|
27
20
|
exports.ARIO = ARIO;
|
|
@@ -29,8 +22,9 @@ class ARIOReadable {
|
|
|
29
22
|
process;
|
|
30
23
|
epochSettings;
|
|
31
24
|
arweave;
|
|
32
|
-
constructor(
|
|
33
|
-
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.arweave = config?.arweave ?? arweave_js_2.defaultArweave;
|
|
27
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
34
28
|
this.process = new ao_process_js_1.AOProcess({
|
|
35
29
|
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
36
30
|
});
|
|
@@ -46,7 +40,6 @@ class ARIOReadable {
|
|
|
46
40
|
else {
|
|
47
41
|
throw new error_js_1.InvalidContractConfigurationError();
|
|
48
42
|
}
|
|
49
|
-
this.arweave = arweave;
|
|
50
43
|
}
|
|
51
44
|
async getInfo() {
|
|
52
45
|
return this.process.read({
|
|
@@ -460,32 +453,18 @@ class ARIOReadable {
|
|
|
460
453
|
exports.ARIOReadable = ARIOReadable;
|
|
461
454
|
class ARIOWriteable extends ARIOReadable {
|
|
462
455
|
signer;
|
|
463
|
-
constructor({ signer,
|
|
464
|
-
if (
|
|
456
|
+
constructor({ signer, ...config }) {
|
|
457
|
+
if (config === undefined) {
|
|
465
458
|
super({
|
|
466
459
|
process: new ao_process_js_1.AOProcess({
|
|
467
460
|
processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
|
|
468
461
|
}),
|
|
469
|
-
arweave: arweave,
|
|
470
462
|
});
|
|
471
|
-
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
472
|
-
}
|
|
473
|
-
else if ((0, io_js_1.isProcessConfiguration)(config)) {
|
|
474
|
-
super({ process: config.process });
|
|
475
|
-
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
476
|
-
}
|
|
477
|
-
else if ((0, io_js_1.isProcessIdConfiguration)(config)) {
|
|
478
|
-
super({
|
|
479
|
-
process: new ao_process_js_1.AOProcess({
|
|
480
|
-
processId: config.processId,
|
|
481
|
-
}),
|
|
482
|
-
arweave: arweave,
|
|
483
|
-
});
|
|
484
|
-
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
485
463
|
}
|
|
486
464
|
else {
|
|
487
|
-
|
|
465
|
+
super(config);
|
|
488
466
|
}
|
|
467
|
+
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
489
468
|
}
|
|
490
469
|
async transfer({ target, qty, }, options) {
|
|
491
470
|
const { tags = [] } = options || {};
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
// eslint-disable-next-line header/header -- This is a CLI file
|
|
18
18
|
import { program } from 'commander';
|
|
19
|
-
import { spawnANT } from '../node/index.js';
|
|
19
|
+
import { AOProcess, spawnANT } from '../node/index.js';
|
|
20
20
|
import { mARIOToken } from '../types/token.js';
|
|
21
21
|
import { version } from '../version.js';
|
|
22
22
|
import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
|
|
@@ -24,7 +24,7 @@ import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegat
|
|
|
24
24
|
import { getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
|
|
25
25
|
import { transfer } from './commands/transfer.js';
|
|
26
26
|
import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, writeActionOptions, } from './options.js';
|
|
27
|
-
import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
|
|
27
|
+
import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
|
|
28
28
|
applyOptions(program
|
|
29
29
|
.name('ar.io')
|
|
30
30
|
.version(version)
|
|
@@ -662,6 +662,20 @@ makeCommand({
|
|
|
662
662
|
}, writeActionTagsFromOptions(options));
|
|
663
663
|
},
|
|
664
664
|
});
|
|
665
|
+
makeCommand({
|
|
666
|
+
name: 'write-action',
|
|
667
|
+
description: 'Send a write action to an AO Process',
|
|
668
|
+
options: [...writeActionOptions, optionMap.processId],
|
|
669
|
+
action: async (options) => {
|
|
670
|
+
const process = new AOProcess({
|
|
671
|
+
processId: requiredProcessIdFromOptions(options),
|
|
672
|
+
});
|
|
673
|
+
return process.send({
|
|
674
|
+
tags: writeActionTagsFromOptions(options).tags ?? [],
|
|
675
|
+
signer: requiredAoSignerFromOptions(options),
|
|
676
|
+
});
|
|
677
|
+
},
|
|
678
|
+
});
|
|
665
679
|
if (process.argv[1].includes('bin/ar.io') || // Running from global .bin
|
|
666
680
|
process.argv[1].includes('cli/cli') // Running from source
|
|
667
681
|
) {
|
|
@@ -19,12 +19,8 @@ import { createAoSigner } from '../utils/ao.js';
|
|
|
19
19
|
import { AOProcess, InvalidContractConfigurationError } from './index.js';
|
|
20
20
|
export class ANTRegistry {
|
|
21
21
|
static init(config) {
|
|
22
|
-
if (config && config
|
|
23
|
-
|
|
24
|
-
return new AoANTRegistryWriteable({
|
|
25
|
-
...rest,
|
|
26
|
-
signer,
|
|
27
|
-
});
|
|
22
|
+
if (config !== undefined && 'signer' in config) {
|
|
23
|
+
return new AoANTRegistryWriteable(config);
|
|
28
24
|
}
|
|
29
25
|
return new AoANTRegistryReadable(config);
|
|
30
26
|
}
|
|
@@ -32,25 +28,22 @@ export class ANTRegistry {
|
|
|
32
28
|
export class AoANTRegistryReadable {
|
|
33
29
|
process;
|
|
34
30
|
constructor(config) {
|
|
35
|
-
if (config
|
|
36
|
-
(isProcessIdConfiguration(config) || isProcessConfiguration(config))) {
|
|
37
|
-
if (isProcessConfiguration(config)) {
|
|
38
|
-
this.process = config.process;
|
|
39
|
-
}
|
|
40
|
-
else if (isProcessIdConfiguration(config)) {
|
|
41
|
-
this.process = new AOProcess({
|
|
42
|
-
processId: config.processId,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new InvalidContractConfigurationError();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
31
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
50
32
|
this.process = new AOProcess({
|
|
51
33
|
processId: ANT_REGISTRY_ID,
|
|
52
34
|
});
|
|
53
35
|
}
|
|
36
|
+
else if (isProcessConfiguration(config)) {
|
|
37
|
+
this.process = config.process;
|
|
38
|
+
}
|
|
39
|
+
else if (isProcessIdConfiguration(config)) {
|
|
40
|
+
this.process = new AOProcess({
|
|
41
|
+
processId: config.processId,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new InvalidContractConfigurationError();
|
|
46
|
+
}
|
|
54
47
|
}
|
|
55
48
|
// Should we rename this to "getANTsByAddress"? seems more clear, though not same as handler name
|
|
56
49
|
async accessControlList({ address, }) {
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -20,15 +20,12 @@ import { createAoSigner } from '../utils/ao.js';
|
|
|
20
20
|
import { parseSchemaResult } from '../utils/schema.js';
|
|
21
21
|
import { AOProcess, InvalidContractConfigurationError } from './index.js';
|
|
22
22
|
export class ANT {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
return new AoANTReadable({ strict, ...config });
|
|
28
|
-
}
|
|
29
|
-
return new AoANTWriteable({ signer, strict, ...config });
|
|
23
|
+
// implementation
|
|
24
|
+
static init(config) {
|
|
25
|
+
if (config !== undefined && 'signer' in config) {
|
|
26
|
+
return new AoANTWriteable(config);
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
return new AoANTReadable(config);
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
export class AoANTReadable {
|
|
@@ -157,8 +157,8 @@ export class AOProcess {
|
|
|
157
157
|
processId: this.processId,
|
|
158
158
|
tags,
|
|
159
159
|
});
|
|
160
|
-
// throw on write interaction errors. No point retrying
|
|
161
|
-
if (
|
|
160
|
+
// throw on write interaction errors. No point retrying write interactions, waste of gas.
|
|
161
|
+
if (error.message.includes('500')) {
|
|
162
162
|
this.logger.debug('Retrying send interaction', {
|
|
163
163
|
attempts,
|
|
164
164
|
retries,
|
|
@@ -179,18 +179,16 @@ export class AOProcess {
|
|
|
179
179
|
}
|
|
180
180
|
function errorMessageFromOutput(output) {
|
|
181
181
|
const errorData = output.Error;
|
|
182
|
-
if
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return errorData;
|
|
186
|
-
}
|
|
187
|
-
const error = output.Messages?.[0]?.Tags?.find((tag) => tag.name === 'Error')?.value;
|
|
182
|
+
// Attempt to extract error details from Messages.Tags if Error is undefined
|
|
183
|
+
const error = errorData ??
|
|
184
|
+
output.Messages?.[0]?.Tags?.find((tag) => tag.name === 'Error')?.value;
|
|
188
185
|
if (error !== undefined) {
|
|
189
|
-
//
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
186
|
+
// Consolidated regex to match and extract line number and AO error message or Error Tags
|
|
187
|
+
const match = error.match(/\[string "aos"]:(\d+):\s*(.+)/);
|
|
188
|
+
if (match) {
|
|
189
|
+
const [, lineNumber, errorMessage] = match;
|
|
190
|
+
return `${errorMessage.trim()} (line ${lineNumber.trim()})`.trim();
|
|
191
|
+
}
|
|
194
192
|
}
|
|
195
193
|
return undefined;
|
|
196
194
|
}
|
package/lib/esm/common/io.js
CHANGED
|
@@ -6,27 +6,21 @@ import { defaultArweave } from './arweave.js';
|
|
|
6
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
7
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
8
8
|
export class ARIO {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return new ARIOWriteable(
|
|
13
|
-
...rest,
|
|
14
|
-
signer,
|
|
15
|
-
arweave,
|
|
16
|
-
});
|
|
9
|
+
// Implementation
|
|
10
|
+
static init(config) {
|
|
11
|
+
if (config !== undefined && 'signer' in config) {
|
|
12
|
+
return new ARIOWriteable(config);
|
|
17
13
|
}
|
|
18
|
-
return new ARIOReadable(
|
|
19
|
-
arweave,
|
|
20
|
-
...config,
|
|
21
|
-
});
|
|
14
|
+
return new ARIOReadable(config);
|
|
22
15
|
}
|
|
23
16
|
}
|
|
24
17
|
export class ARIOReadable {
|
|
25
18
|
process;
|
|
26
19
|
epochSettings;
|
|
27
20
|
arweave;
|
|
28
|
-
constructor(
|
|
29
|
-
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.arweave = config?.arweave ?? defaultArweave;
|
|
23
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
30
24
|
this.process = new AOProcess({
|
|
31
25
|
processId: ARIO_TESTNET_PROCESS_ID,
|
|
32
26
|
});
|
|
@@ -42,7 +36,6 @@ export class ARIOReadable {
|
|
|
42
36
|
else {
|
|
43
37
|
throw new InvalidContractConfigurationError();
|
|
44
38
|
}
|
|
45
|
-
this.arweave = arweave;
|
|
46
39
|
}
|
|
47
40
|
async getInfo() {
|
|
48
41
|
return this.process.read({
|
|
@@ -455,32 +448,18 @@ export class ARIOReadable {
|
|
|
455
448
|
}
|
|
456
449
|
export class ARIOWriteable extends ARIOReadable {
|
|
457
450
|
signer;
|
|
458
|
-
constructor({ signer,
|
|
459
|
-
if (
|
|
451
|
+
constructor({ signer, ...config }) {
|
|
452
|
+
if (config === undefined) {
|
|
460
453
|
super({
|
|
461
454
|
process: new AOProcess({
|
|
462
455
|
processId: ARIO_TESTNET_PROCESS_ID,
|
|
463
456
|
}),
|
|
464
|
-
arweave: arweave,
|
|
465
457
|
});
|
|
466
|
-
this.signer = createAoSigner(signer);
|
|
467
|
-
}
|
|
468
|
-
else if (isProcessConfiguration(config)) {
|
|
469
|
-
super({ process: config.process });
|
|
470
|
-
this.signer = createAoSigner(signer);
|
|
471
|
-
}
|
|
472
|
-
else if (isProcessIdConfiguration(config)) {
|
|
473
|
-
super({
|
|
474
|
-
process: new AOProcess({
|
|
475
|
-
processId: config.processId,
|
|
476
|
-
}),
|
|
477
|
-
arweave: arweave,
|
|
478
|
-
});
|
|
479
|
-
this.signer = createAoSigner(signer);
|
|
480
458
|
}
|
|
481
459
|
else {
|
|
482
|
-
|
|
460
|
+
super(config);
|
|
483
461
|
}
|
|
462
|
+
this.signer = createAoSigner(signer);
|
|
484
463
|
}
|
|
485
464
|
async transfer({ target, qty, }, options) {
|
|
486
465
|
const { tags = [] } = options || {};
|
package/lib/esm/version.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AoANTRegistryRead, AoANTRegistryWrite } from '../types/ant-registry.js';
|
|
2
2
|
import { AoMessageResult, ProcessConfiguration, WithSigner } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './index.js';
|
|
4
|
+
type ANTRegistryNoSigner = ProcessConfiguration;
|
|
5
|
+
type ANTRegistryWithSigner = WithSigner<ProcessConfiguration>;
|
|
4
6
|
export declare class ANTRegistry {
|
|
5
7
|
static init(): AoANTRegistryRead;
|
|
6
|
-
static init(config:
|
|
7
|
-
|
|
8
|
-
}): AoANTRegistryRead;
|
|
9
|
-
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>): AoANTRegistryWrite;
|
|
8
|
+
static init(config: ANTRegistryNoSigner): AoANTRegistryRead;
|
|
9
|
+
static init(config: ANTRegistryWithSigner): AoANTRegistryWrite;
|
|
10
10
|
}
|
|
11
11
|
export declare class AoANTRegistryReadable implements AoANTRegistryRead {
|
|
12
12
|
protected process: AOProcess;
|
|
@@ -25,3 +25,4 @@ export declare class AoANTRegistryWriteable extends AoANTRegistryReadable implem
|
|
|
25
25
|
processId: string;
|
|
26
26
|
}): Promise<AoMessageResult>;
|
|
27
27
|
}
|
|
28
|
+
export {};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, 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
|
+
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ANTConfigNoSigner = ANTConfigOptionalStrict;
|
|
8
|
+
type ANTConfigWithSigner = WithSigner<ANTConfigOptionalStrict>;
|
|
4
9
|
export declare class ANT {
|
|
5
|
-
static init(config:
|
|
6
|
-
|
|
7
|
-
strict?: boolean;
|
|
8
|
-
}): AoANTRead;
|
|
9
|
-
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>> & {
|
|
10
|
-
strict?: boolean;
|
|
11
|
-
}): AoANTWrite;
|
|
10
|
+
static init(config: ANTConfigNoSigner): AoANTRead;
|
|
11
|
+
static init(config: ANTConfigWithSigner): AoANTWrite;
|
|
12
12
|
}
|
|
13
13
|
export declare class AoANTReadable implements AoANTRead {
|
|
14
14
|
protected process: AOProcess;
|
|
15
15
|
private strict;
|
|
16
|
-
constructor(config:
|
|
17
|
-
strict?: boolean;
|
|
18
|
-
});
|
|
16
|
+
constructor(config: ANTConfigOptionalStrict);
|
|
19
17
|
getState({ strict }?: AntReadOptions): Promise<AoANTState>;
|
|
20
18
|
getInfo({ strict }?: AntReadOptions): Promise<AoANTInfo>;
|
|
21
19
|
/**
|
|
@@ -273,3 +271,4 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
273
271
|
notifyOwners?: boolean;
|
|
274
272
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
275
273
|
}
|
|
274
|
+
export {};
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -14,36 +14,22 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
|
-
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver,
|
|
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
18
|
import { AoARIORead, AoARIOWrite, AoAllDelegates, 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
|
+
type ARIOConfigNoSigner = OptionalArweave<ProcessConfiguration>;
|
|
22
|
+
type ARIOConfigWithSigner = WithSigner<OptionalArweave<ProcessConfiguration>>;
|
|
21
23
|
export declare class ARIO {
|
|
22
24
|
static init(): AoARIORead;
|
|
23
|
-
static init(
|
|
24
|
-
|
|
25
|
-
}): AoARIORead;
|
|
26
|
-
static init({ process, signer, }: WithSigner<{
|
|
27
|
-
process: AOProcess;
|
|
28
|
-
}>): AoARIOWrite;
|
|
29
|
-
static init({ processId, signer, }: WithSigner<{
|
|
30
|
-
processId?: string;
|
|
31
|
-
}>): AoARIOWrite;
|
|
32
|
-
static init({ processId, signer, }: {
|
|
33
|
-
signer?: ContractSigner | undefined;
|
|
34
|
-
processId: string;
|
|
35
|
-
}): any;
|
|
36
|
-
static init({ processId }: {
|
|
37
|
-
processId: string;
|
|
38
|
-
}): AoARIORead;
|
|
25
|
+
static init(config: ARIOConfigWithSigner): AoARIOWrite;
|
|
26
|
+
static init(config: ARIOConfigNoSigner): AoARIORead;
|
|
39
27
|
}
|
|
40
28
|
export declare class ARIOReadable implements AoARIORead {
|
|
41
29
|
protected process: AOProcess;
|
|
42
30
|
protected epochSettings: AoEpochSettings | undefined;
|
|
43
31
|
protected arweave: Arweave;
|
|
44
|
-
constructor(
|
|
45
|
-
arweave?: Arweave;
|
|
46
|
-
});
|
|
32
|
+
constructor(config?: OptionalArweave<ProcessConfiguration>);
|
|
47
33
|
getInfo(): Promise<{
|
|
48
34
|
Name: string;
|
|
49
35
|
Ticker: string;
|
|
@@ -155,13 +141,7 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
155
141
|
export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
156
142
|
protected process: AOProcess;
|
|
157
143
|
private signer;
|
|
158
|
-
constructor({ signer,
|
|
159
|
-
process?: AOProcess;
|
|
160
|
-
} | {
|
|
161
|
-
processId?: string;
|
|
162
|
-
}> & {
|
|
163
|
-
arweave?: Arweave;
|
|
164
|
-
});
|
|
144
|
+
constructor({ signer, ...config }: ARIOConfigWithSigner);
|
|
165
145
|
transfer({ target, qty, }: {
|
|
166
146
|
target: string;
|
|
167
147
|
qty: number | mARIOToken;
|
|
@@ -254,3 +234,4 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
254
234
|
vaultId?: string;
|
|
255
235
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
256
236
|
}
|
|
237
|
+
export {};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Signer } from '@dha-team/arbundles';
|
|
18
18
|
import { dryrun, message, monitor, result, results, spawn, unmonitor } from '@permaweb/aoconnect';
|
|
19
|
+
import Arweave from 'arweave';
|
|
19
20
|
import { AoSigner } from './token.js';
|
|
20
21
|
export type BlockHeight = number;
|
|
21
22
|
export type SortKey = string;
|
|
@@ -23,6 +24,9 @@ export type Timestamp = number;
|
|
|
23
24
|
export type WalletAddress = string;
|
|
24
25
|
export type TransactionId = string;
|
|
25
26
|
export type ProcessId = string;
|
|
27
|
+
export type OptionalArweave<T = NonNullable<unknown>> = {
|
|
28
|
+
arweave?: Arweave;
|
|
29
|
+
} & T;
|
|
26
30
|
export type ContractSigner = Signer | Window['arweaveWallet'] | AoSigner;
|
|
27
31
|
export type WithSigner<T = NonNullable<unknown>> = {
|
|
28
32
|
signer: ContractSigner;
|