@ar.io/sdk 2.4.0-alpha.8 → 2.4.0
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 +98 -10
- package/bundles/web.bundle.min.js +85 -90
- package/lib/cjs/common/contracts/ao-process.js +7 -5
- package/lib/cjs/common/http.js +2 -2
- package/lib/cjs/common/io.js +95 -91
- package/lib/cjs/types/index.js +3 -1
- package/lib/cjs/utils/arweave.js +16 -16
- package/lib/cjs/utils/index.js +2 -2
- package/lib/cjs/utils/processes.js +4 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/contracts/ao-process.js +7 -5
- package/lib/esm/common/http.js +1 -1
- package/lib/esm/common/io.js +93 -89
- package/lib/esm/types/index.js +3 -1
- package/lib/esm/utils/arweave.js +13 -15
- package/lib/esm/utils/index.js +2 -2
- package/lib/esm/utils/processes.js +4 -2
- package/lib/esm/version.js +1 -1
- package/lib/types/common/io.d.ts +21 -9
- package/lib/types/types/index.d.ts +3 -1
- package/lib/types/types/io.d.ts +41 -22
- package/lib/types/utils/arweave.d.ts +25 -1
- package/lib/types/utils/index.d.ts +2 -2
- package/lib/types/utils/processes.d.ts +3 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +8 -6
package/lib/types/types/io.d.ts
CHANGED
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
import { AOProcess } from '../common/index.js';
|
|
17
17
|
import { AoMessageResult, AtLeastOne, BlockHeight, ProcessId, Timestamp, TransactionId, WalletAddress, WriteOptions } from './index.js';
|
|
18
18
|
import { mIOToken } from './token.js';
|
|
19
|
-
export type PaginationParams = {
|
|
19
|
+
export type PaginationParams<T = Record<string, never>> = {
|
|
20
20
|
cursor?: string;
|
|
21
21
|
limit?: number;
|
|
22
|
-
sortBy?: string;
|
|
22
|
+
sortBy?: keyof T extends never ? string : keyof T;
|
|
23
23
|
sortOrder?: 'asc' | 'desc';
|
|
24
24
|
};
|
|
25
25
|
export type PaginationResult<T> = {
|
|
26
26
|
items: T[];
|
|
27
27
|
nextCursor: string | undefined;
|
|
28
28
|
totalItems: number;
|
|
29
|
-
sortBy
|
|
29
|
+
sortBy?: keyof T;
|
|
30
30
|
sortOrder: 'asc' | 'desc';
|
|
31
31
|
hasMore: boolean;
|
|
32
32
|
};
|
|
@@ -65,7 +65,7 @@ export type AoEpochObservationData = {
|
|
|
65
65
|
};
|
|
66
66
|
export type AoVaultData = {
|
|
67
67
|
balance: number;
|
|
68
|
-
|
|
68
|
+
startTimestamp: Timestamp;
|
|
69
69
|
endTimestamp: Timestamp;
|
|
70
70
|
};
|
|
71
71
|
export type AoEpochDistributionRewards = {
|
|
@@ -142,10 +142,16 @@ export type AoGatewayService = {
|
|
|
142
142
|
export type AoGatewayServices = {
|
|
143
143
|
bundlers: AoGatewayService[];
|
|
144
144
|
} | undefined;
|
|
145
|
+
export type AoGatewayDelegates = Record<WalletAddress, AoGatewayDelegate>;
|
|
146
|
+
export type AoGatewayDelegateAllowList = WalletAddress[];
|
|
147
|
+
export type AoWalletVault = AoVaultData & {
|
|
148
|
+
address: WalletAddress;
|
|
149
|
+
vaultId: string;
|
|
150
|
+
};
|
|
145
151
|
export type AoGateway = {
|
|
146
152
|
settings: AoGatewaySettings;
|
|
153
|
+
delegates: AoGatewayDelegates;
|
|
147
154
|
stats: AoGatewayStats;
|
|
148
|
-
delegates: Record<WalletAddress, AoGatewayDelegate>;
|
|
149
155
|
totalDelegatedStake: number;
|
|
150
156
|
vaults: Record<WalletAddress, AoVaultData>;
|
|
151
157
|
startTimestamp: Timestamp;
|
|
@@ -187,9 +193,13 @@ export type AoGatewayDelegate = {
|
|
|
187
193
|
startTimestamp: Timestamp;
|
|
188
194
|
vaults: Record<WalletAddress, AoVaultData>;
|
|
189
195
|
};
|
|
196
|
+
export type AoGatewayDelegateWithAddress = AoGatewayDelegate & {
|
|
197
|
+
address: WalletAddress;
|
|
198
|
+
};
|
|
190
199
|
export type AoGatewaySettings = {
|
|
191
|
-
allowDelegatedStaking: boolean;
|
|
200
|
+
allowDelegatedStaking: boolean | 'allowlist';
|
|
192
201
|
delegateRewardShareRatio: number;
|
|
202
|
+
allowedDelegates: WalletAddress[];
|
|
193
203
|
minDelegatedStake: number;
|
|
194
204
|
autoStake: boolean;
|
|
195
205
|
label: string;
|
|
@@ -240,19 +250,34 @@ export interface AoIORead {
|
|
|
240
250
|
getGateway({ address, }: {
|
|
241
251
|
address: WalletAddress;
|
|
242
252
|
}): Promise<AoGateway | undefined>;
|
|
243
|
-
|
|
253
|
+
getGatewayDelegates({ address, ...pageParams }: {
|
|
254
|
+
address: WalletAddress;
|
|
255
|
+
} & PaginationParams<AoGatewayDelegateWithAddress>): Promise<PaginationResult<AoGatewayDelegateWithAddress>>;
|
|
256
|
+
getGatewayDelegateAllowList(params?: PaginationParams<WalletAddress>): Promise<PaginationResult<WalletAddress>>;
|
|
257
|
+
getGateways(params?: PaginationParams<AoGatewayWithAddress>): Promise<PaginationResult<AoGatewayWithAddress>>;
|
|
244
258
|
getBalance(params: {
|
|
245
259
|
address: WalletAddress;
|
|
246
260
|
}): Promise<number>;
|
|
247
|
-
getBalances(params?: PaginationParams): Promise<PaginationResult<AoBalanceWithAddress>>;
|
|
261
|
+
getBalances(params?: PaginationParams<AoBalanceWithAddress>): Promise<PaginationResult<AoBalanceWithAddress>>;
|
|
248
262
|
getArNSRecord({ name, }: {
|
|
249
263
|
name: string;
|
|
250
264
|
}): Promise<AoArNSNameData | undefined>;
|
|
251
|
-
getArNSRecords(params?: PaginationParams): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
265
|
+
getArNSRecords(params?: PaginationParams<AoArNSNameDataWithName>): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
252
266
|
getArNSReservedNames(): Promise<Record<string, AoArNSReservedNameData> | Record<string, never>>;
|
|
253
267
|
getArNSReservedName({ name, }: {
|
|
254
268
|
name: string;
|
|
255
269
|
}): Promise<AoArNSReservedNameData | undefined>;
|
|
270
|
+
getArNSAuctions(params?: PaginationParams<AoAuction>): Promise<PaginationResult<AoAuction>>;
|
|
271
|
+
getArNSAuction({ name }: {
|
|
272
|
+
name: string;
|
|
273
|
+
}): Promise<AoAuction | undefined>;
|
|
274
|
+
getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }: {
|
|
275
|
+
name: string;
|
|
276
|
+
type: 'lease' | 'permabuy';
|
|
277
|
+
years?: number;
|
|
278
|
+
timestamp?: number;
|
|
279
|
+
intervalMs?: number;
|
|
280
|
+
}): Promise<AoAuctionPriceData>;
|
|
256
281
|
getEpoch(epoch?: EpochInput): Promise<AoEpochData>;
|
|
257
282
|
getCurrentEpoch(): Promise<AoEpochData>;
|
|
258
283
|
getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
|
|
@@ -268,26 +293,20 @@ export interface AoIORead {
|
|
|
268
293
|
}): Promise<number>;
|
|
269
294
|
getRegistrationFees(): Promise<AoRegistrationFees>;
|
|
270
295
|
getDemandFactor(): Promise<number>;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
name: string;
|
|
277
|
-
type: 'lease' | 'permabuy';
|
|
278
|
-
years?: number;
|
|
279
|
-
timestamp?: number;
|
|
280
|
-
intervalMs?: number;
|
|
281
|
-
}): Promise<AoAuctionPriceData>;
|
|
296
|
+
getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
|
|
297
|
+
getVault({ address, vaultId, }: {
|
|
298
|
+
address: WalletAddress;
|
|
299
|
+
vaultId: string;
|
|
300
|
+
}): Promise<AoVaultData>;
|
|
282
301
|
}
|
|
283
302
|
export interface AoIOWrite extends AoIORead {
|
|
284
303
|
transfer({ target, qty, }: {
|
|
285
304
|
target: WalletAddress;
|
|
286
305
|
qty: number;
|
|
287
306
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
288
|
-
joinNetwork(
|
|
307
|
+
joinNetwork(params: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
289
308
|
leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
|
|
290
|
-
updateGatewaySettings(
|
|
309
|
+
updateGatewaySettings(params: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
291
310
|
increaseOperatorStake(params: {
|
|
292
311
|
increaseQty: number | mIOToken;
|
|
293
312
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
@@ -1,3 +1,27 @@
|
|
|
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 Arweave from 'arweave';
|
|
17
|
+
import { BlockHeight, Timestamp } from '../types/common.js';
|
|
2
18
|
export declare const validateArweaveId: (id: string) => boolean;
|
|
3
19
|
export declare function isBlockHeight(height: string | number): height is BlockHeight;
|
|
20
|
+
export declare const pruneTags: (tags: {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string | undefined;
|
|
23
|
+
}[]) => {
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
export declare const getCurrentBlockUnixTimestampMs: (arweave: Arweave) => Promise<Timestamp>;
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export * from './arweave.js';
|
|
17
|
-
export * from './http-client.js';
|
|
18
16
|
export * from './ao.js';
|
|
17
|
+
export * from './arweave.js';
|
|
18
|
+
export * from './base64.js';
|
|
19
19
|
export * from './json.js';
|
|
20
20
|
export * from './processes.js';
|
|
21
21
|
export * from './schema.js';
|
|
@@ -29,11 +29,13 @@ export declare class ArNSEventEmitter extends EventEmitter {
|
|
|
29
29
|
private timeoutMs;
|
|
30
30
|
private throttle;
|
|
31
31
|
private logger;
|
|
32
|
-
|
|
32
|
+
private strict;
|
|
33
|
+
constructor({ contract, timeoutMs, concurrency, logger, strict, }?: {
|
|
33
34
|
contract?: AoIORead;
|
|
34
35
|
timeoutMs?: number;
|
|
35
36
|
concurrency?: number;
|
|
36
37
|
logger?: ILogger;
|
|
38
|
+
strict?: boolean;
|
|
37
39
|
});
|
|
38
40
|
fetchProcessesOwnedByWallet({ address, pageSize, antRegistry, }: {
|
|
39
41
|
address: WalletAddress;
|
package/lib/types/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ar.io/sdk",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ar-io/ar-io-sdk.git"
|
|
@@ -66,17 +66,18 @@
|
|
|
66
66
|
"format": "prettier --check .",
|
|
67
67
|
"format:fix": "prettier --write .",
|
|
68
68
|
"test": "yarn test:unit && yarn test:e2e",
|
|
69
|
-
"test:cjs": "yarn
|
|
70
|
-
"test:esm": "yarn
|
|
71
|
-
"test:web": "yarn
|
|
69
|
+
"test:cjs": "yarn build:cjs && yarn link && cd ./tests/e2e/cjs && yarn && yarn test",
|
|
70
|
+
"test:esm": "yarn build:esm && yarn link && cd ./tests/e2e/esm && yarn && yarn test",
|
|
71
|
+
"test:web": "yarn build:esm && yarn link && cd ./tests/e2e/web && yarn && yarn test",
|
|
72
72
|
"test:unit": "NODE_OPTIONS=\"--import=./register.mjs\" node --test tests/unit/**.test.ts",
|
|
73
73
|
"test:link": "yarn build && yarn link",
|
|
74
74
|
"test:e2e": "yarn test:cjs && yarn test:esm && yarn test:web",
|
|
75
75
|
"prepare": "husky install",
|
|
76
76
|
"docs:update": "markdown-toc-gen insert README.md",
|
|
77
77
|
"example:esm": "cd examples/esm && yarn && node index.mjs",
|
|
78
|
-
"example:cjs": "yarn
|
|
79
|
-
"example:web": "yarn
|
|
78
|
+
"example:cjs": "yarn build:cjs && yarn link && cd examples/cjs && yarn && node index.cjs",
|
|
79
|
+
"example:web": "yarn build:web && http-server --port 8080 --host -o examples/web",
|
|
80
|
+
"example:vite": "yarn build:esm && yarn link && cd examples/vite && yarn && yarn start"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@commitlint/cli": "^17.1.2",
|
|
@@ -108,6 +109,7 @@
|
|
|
108
109
|
"husky": "^8.0.3",
|
|
109
110
|
"lint-staged": "^15.2.2",
|
|
110
111
|
"markdown-toc-gen": "^1.0.1",
|
|
112
|
+
"nock": "^13.5.5",
|
|
111
113
|
"prettier": "^3.0.2",
|
|
112
114
|
"rimraf": "^5.0.1",
|
|
113
115
|
"semantic-release": "^21.0.7",
|