@ar.io/sdk 3.3.0-alpha.3 → 3.3.0-alpha.5
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 +46 -0
- package/bundles/web.bundle.min.js +64 -64
- package/lib/cjs/cli/cli.js +6 -0
- package/lib/cjs/cli/commands/readCommands.js +6 -1
- package/lib/cjs/common/contracts/ao-process.js +18 -9
- package/lib/cjs/common/io.js +8 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +7 -1
- package/lib/esm/cli/commands/readCommands.js +4 -0
- package/lib/esm/common/contracts/ao-process.js +18 -9
- package/lib/esm/common/io.js +8 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/readCommands.d.ts +3 -0
- package/lib/types/common/io.d.ts +2 -1
- package/lib/types/types/io.d.ts +9 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/cli/cli.js
CHANGED
|
@@ -64,6 +64,12 @@ const utils_js_1 = require("./utils.js");
|
|
|
64
64
|
options: options_js_1.paginationOptions,
|
|
65
65
|
action: readCommands_js_1.listGateways,
|
|
66
66
|
});
|
|
67
|
+
(0, utils_js_1.makeCommand)({
|
|
68
|
+
name: 'list-all-delegates',
|
|
69
|
+
description: 'List all paginated delegates from all gateways',
|
|
70
|
+
options: options_js_1.paginationOptions,
|
|
71
|
+
action: readCommands_js_1.listAllDelegatesCLICommand,
|
|
72
|
+
});
|
|
67
73
|
(0, utils_js_1.makeCommand)({
|
|
68
74
|
name: 'get-gateway-delegates',
|
|
69
75
|
description: 'Get the delegates of a gateway',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVault = exports.getGatewayVaults = exports.getPrimaryName = exports.getCostDetails = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.listArNSReturnedNames = exports.getArNSReturnedName = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listGateways = exports.getGateway = void 0;
|
|
3
|
+
exports.getVault = exports.getGatewayVaults = exports.getPrimaryName = exports.getCostDetails = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.listArNSReturnedNames = exports.getArNSReturnedName = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listAllDelegatesCLICommand = exports.listGateways = exports.getGateway = void 0;
|
|
4
4
|
const token_js_1 = require("../../types/token.js");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
async function getGateway(o) {
|
|
@@ -16,6 +16,11 @@ async function listGateways(o) {
|
|
|
16
16
|
return gateways.items.length ? gateways : { message: 'No gateways found' };
|
|
17
17
|
}
|
|
18
18
|
exports.listGateways = listGateways;
|
|
19
|
+
async function listAllDelegatesCLICommand(o) {
|
|
20
|
+
const delegates = await (0, utils_js_1.readARIOFromOptions)(o).getAllDelegates((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
21
|
+
return delegates.items.length ? delegates : { message: 'No delegates found' };
|
|
22
|
+
}
|
|
23
|
+
exports.listAllDelegatesCLICommand = listAllDelegatesCLICommand;
|
|
19
24
|
async function getGatewayDelegates(o) {
|
|
20
25
|
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
21
26
|
const result = await (0, utils_js_1.readARIOFromOptions)(o).getGatewayDelegates({
|
|
@@ -42,8 +42,9 @@ class AOProcess {
|
|
|
42
42
|
let lastError;
|
|
43
43
|
while (attempts < retries) {
|
|
44
44
|
try {
|
|
45
|
-
this.logger.debug(`Evaluating read interaction on
|
|
45
|
+
this.logger.debug(`Evaluating read interaction on process`, {
|
|
46
46
|
tags,
|
|
47
|
+
processId: this.processId,
|
|
47
48
|
});
|
|
48
49
|
// map tags to inputs
|
|
49
50
|
const dryRunInput = {
|
|
@@ -56,13 +57,18 @@ class AOProcess {
|
|
|
56
57
|
const result = await this.ao.dryrun(dryRunInput);
|
|
57
58
|
this.logger.debug(`Read interaction result`, {
|
|
58
59
|
result,
|
|
60
|
+
processId: this.processId,
|
|
59
61
|
});
|
|
60
62
|
const error = errorMessageFromOutput(result);
|
|
61
63
|
if (error !== undefined) {
|
|
62
64
|
throw new Error(error);
|
|
63
65
|
}
|
|
64
66
|
if (result.Messages === undefined || result.Messages.length === 0) {
|
|
65
|
-
this.logger.debug(`Process ${this.processId} does not support provided action.`,
|
|
67
|
+
this.logger.debug(`Process ${this.processId} does not support provided action.`, {
|
|
68
|
+
result,
|
|
69
|
+
tags,
|
|
70
|
+
processId: this.processId,
|
|
71
|
+
});
|
|
66
72
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
67
73
|
}
|
|
68
74
|
const messageData = result.Messages?.[0]?.Data;
|
|
@@ -70,16 +76,18 @@ class AOProcess {
|
|
|
70
76
|
if (this.isMessageDataEmpty(messageData)) {
|
|
71
77
|
return undefined;
|
|
72
78
|
}
|
|
73
|
-
const response = (0, json_js_1.safeDecode)(
|
|
79
|
+
const response = (0, json_js_1.safeDecode)(messageData);
|
|
74
80
|
return response;
|
|
75
81
|
}
|
|
76
|
-
catch (
|
|
82
|
+
catch (error) {
|
|
77
83
|
attempts++;
|
|
78
84
|
this.logger.debug(`Read attempt ${attempts} failed`, {
|
|
79
|
-
error:
|
|
85
|
+
error: error?.message,
|
|
86
|
+
stack: error?.stack,
|
|
80
87
|
tags,
|
|
88
|
+
processId: this.processId,
|
|
81
89
|
});
|
|
82
|
-
lastError =
|
|
90
|
+
lastError = error;
|
|
83
91
|
// exponential backoff
|
|
84
92
|
await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
|
|
85
93
|
}
|
|
@@ -147,16 +155,17 @@ class AOProcess {
|
|
|
147
155
|
}
|
|
148
156
|
catch (error) {
|
|
149
157
|
this.logger.error('Error sending message to process', {
|
|
150
|
-
error: error
|
|
158
|
+
error: error?.message,
|
|
159
|
+
stack: error?.stack,
|
|
151
160
|
processId: this.processId,
|
|
152
161
|
tags,
|
|
153
162
|
});
|
|
154
163
|
// throw on write interaction errors. No point retrying wr ite interactions, waste of gas.
|
|
155
|
-
if (error
|
|
164
|
+
if (!error?.message?.includes('500')) {
|
|
156
165
|
this.logger.debug('Retrying send interaction', {
|
|
157
166
|
attempts,
|
|
158
167
|
retries,
|
|
159
|
-
error: error
|
|
168
|
+
error: error?.message,
|
|
160
169
|
processId: this.processId,
|
|
161
170
|
});
|
|
162
171
|
// exponential backoff
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -448,6 +448,14 @@ class ARIOReadable {
|
|
|
448
448
|
tags: [{ name: 'Action', value: 'Gateway-Registry-Settings' }],
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
|
+
async getAllDelegates(params) {
|
|
452
|
+
return this.process.read({
|
|
453
|
+
tags: [
|
|
454
|
+
{ name: 'Action', value: 'All-Paginated-Delegates' },
|
|
455
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
456
|
+
],
|
|
457
|
+
});
|
|
458
|
+
}
|
|
451
459
|
}
|
|
452
460
|
exports.ARIOReadable = ARIOReadable;
|
|
453
461
|
class ARIOWriteable extends ARIOReadable {
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ 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';
|
|
23
23
|
import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
|
|
24
|
-
import { getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
|
|
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
27
|
import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
|
|
@@ -62,6 +62,12 @@ makeCommand({
|
|
|
62
62
|
options: paginationOptions,
|
|
63
63
|
action: listGateways,
|
|
64
64
|
});
|
|
65
|
+
makeCommand({
|
|
66
|
+
name: 'list-all-delegates',
|
|
67
|
+
description: 'List all paginated delegates from all gateways',
|
|
68
|
+
options: paginationOptions,
|
|
69
|
+
action: listAllDelegatesCLICommand,
|
|
70
|
+
});
|
|
65
71
|
makeCommand({
|
|
66
72
|
name: 'get-gateway-delegates',
|
|
67
73
|
description: 'Get the delegates of a gateway',
|
|
@@ -11,6 +11,10 @@ export async function listGateways(o) {
|
|
|
11
11
|
const gateways = await readARIOFromOptions(o).getGateways(paginationParamsFromOptions(o));
|
|
12
12
|
return gateways.items.length ? gateways : { message: 'No gateways found' };
|
|
13
13
|
}
|
|
14
|
+
export async function listAllDelegatesCLICommand(o) {
|
|
15
|
+
const delegates = await readARIOFromOptions(o).getAllDelegates(paginationParamsFromOptions(o));
|
|
16
|
+
return delegates.items.length ? delegates : { message: 'No delegates found' };
|
|
17
|
+
}
|
|
14
18
|
export async function getGatewayDelegates(o) {
|
|
15
19
|
const address = requiredAddressFromOptions(o);
|
|
16
20
|
const result = await readARIOFromOptions(o).getGatewayDelegates({
|
|
@@ -39,8 +39,9 @@ export class AOProcess {
|
|
|
39
39
|
let lastError;
|
|
40
40
|
while (attempts < retries) {
|
|
41
41
|
try {
|
|
42
|
-
this.logger.debug(`Evaluating read interaction on
|
|
42
|
+
this.logger.debug(`Evaluating read interaction on process`, {
|
|
43
43
|
tags,
|
|
44
|
+
processId: this.processId,
|
|
44
45
|
});
|
|
45
46
|
// map tags to inputs
|
|
46
47
|
const dryRunInput = {
|
|
@@ -53,13 +54,18 @@ export class AOProcess {
|
|
|
53
54
|
const result = await this.ao.dryrun(dryRunInput);
|
|
54
55
|
this.logger.debug(`Read interaction result`, {
|
|
55
56
|
result,
|
|
57
|
+
processId: this.processId,
|
|
56
58
|
});
|
|
57
59
|
const error = errorMessageFromOutput(result);
|
|
58
60
|
if (error !== undefined) {
|
|
59
61
|
throw new Error(error);
|
|
60
62
|
}
|
|
61
63
|
if (result.Messages === undefined || result.Messages.length === 0) {
|
|
62
|
-
this.logger.debug(`Process ${this.processId} does not support provided action.`,
|
|
64
|
+
this.logger.debug(`Process ${this.processId} does not support provided action.`, {
|
|
65
|
+
result,
|
|
66
|
+
tags,
|
|
67
|
+
processId: this.processId,
|
|
68
|
+
});
|
|
63
69
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
64
70
|
}
|
|
65
71
|
const messageData = result.Messages?.[0]?.Data;
|
|
@@ -67,16 +73,18 @@ export class AOProcess {
|
|
|
67
73
|
if (this.isMessageDataEmpty(messageData)) {
|
|
68
74
|
return undefined;
|
|
69
75
|
}
|
|
70
|
-
const response = safeDecode(
|
|
76
|
+
const response = safeDecode(messageData);
|
|
71
77
|
return response;
|
|
72
78
|
}
|
|
73
|
-
catch (
|
|
79
|
+
catch (error) {
|
|
74
80
|
attempts++;
|
|
75
81
|
this.logger.debug(`Read attempt ${attempts} failed`, {
|
|
76
|
-
error:
|
|
82
|
+
error: error?.message,
|
|
83
|
+
stack: error?.stack,
|
|
77
84
|
tags,
|
|
85
|
+
processId: this.processId,
|
|
78
86
|
});
|
|
79
|
-
lastError =
|
|
87
|
+
lastError = error;
|
|
80
88
|
// exponential backoff
|
|
81
89
|
await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
|
|
82
90
|
}
|
|
@@ -144,16 +152,17 @@ export class AOProcess {
|
|
|
144
152
|
}
|
|
145
153
|
catch (error) {
|
|
146
154
|
this.logger.error('Error sending message to process', {
|
|
147
|
-
error: error
|
|
155
|
+
error: error?.message,
|
|
156
|
+
stack: error?.stack,
|
|
148
157
|
processId: this.processId,
|
|
149
158
|
tags,
|
|
150
159
|
});
|
|
151
160
|
// throw on write interaction errors. No point retrying wr ite interactions, waste of gas.
|
|
152
|
-
if (error
|
|
161
|
+
if (!error?.message?.includes('500')) {
|
|
153
162
|
this.logger.debug('Retrying send interaction', {
|
|
154
163
|
attempts,
|
|
155
164
|
retries,
|
|
156
|
-
error: error
|
|
165
|
+
error: error?.message,
|
|
157
166
|
processId: this.processId,
|
|
158
167
|
});
|
|
159
168
|
// exponential backoff
|
package/lib/esm/common/io.js
CHANGED
|
@@ -444,6 +444,14 @@ export class ARIOReadable {
|
|
|
444
444
|
tags: [{ name: 'Action', value: 'Gateway-Registry-Settings' }],
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
|
+
async getAllDelegates(params) {
|
|
448
|
+
return this.process.read({
|
|
449
|
+
tags: [
|
|
450
|
+
{ name: 'Action', value: 'All-Paginated-Delegates' },
|
|
451
|
+
...paginationParamsToTags(params),
|
|
452
|
+
],
|
|
453
|
+
});
|
|
454
|
+
}
|
|
447
455
|
}
|
|
448
456
|
export class ARIOWriteable extends ARIOReadable {
|
|
449
457
|
signer;
|
package/lib/esm/version.js
CHANGED
|
@@ -21,6 +21,9 @@ export declare function getGateway(o: AddressCLIOptions): Promise<import("../../
|
|
|
21
21
|
export declare function listGateways(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoGatewayWithAddress> | {
|
|
22
22
|
message: string;
|
|
23
23
|
}>;
|
|
24
|
+
export declare function listAllDelegatesCLICommand(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoAllDelegates> | {
|
|
25
|
+
message: string;
|
|
26
|
+
}>;
|
|
24
27
|
export declare function getGatewayDelegates(o: AddressCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoGatewayDelegateWithAddress> | {
|
|
25
28
|
message: string;
|
|
26
29
|
}>;
|
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, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
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
21
|
export declare class ARIO {
|
|
@@ -150,6 +150,7 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
150
150
|
address: WalletAddress;
|
|
151
151
|
}): Promise<AoRedelegationFeeInfo>;
|
|
152
152
|
getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
|
|
153
|
+
getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
|
|
153
154
|
}
|
|
154
155
|
export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
155
156
|
protected process: AOProcess;
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -412,7 +412,16 @@ export interface AoARIORead {
|
|
|
412
412
|
address: WalletAddress;
|
|
413
413
|
}): Promise<AoRedelegationFeeInfo>;
|
|
414
414
|
getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
|
|
415
|
+
getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
|
|
415
416
|
}
|
|
417
|
+
export type AoAllDelegates = {
|
|
418
|
+
address: WalletAddress;
|
|
419
|
+
gatewayAddress: WalletAddress;
|
|
420
|
+
delegatedStake: number;
|
|
421
|
+
startTimestamp: Timestamp;
|
|
422
|
+
vaultedStake: number;
|
|
423
|
+
cursorId: string;
|
|
424
|
+
};
|
|
416
425
|
export interface AoARIOWrite extends AoARIORead {
|
|
417
426
|
transfer({ target, qty, }: {
|
|
418
427
|
target: WalletAddress;
|
package/lib/types/version.d.ts
CHANGED