@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.
@@ -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: keyof T;
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
- locked: number;
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
- getGateways(params?: PaginationParams): Promise<PaginationResult<AoGatewayWithAddress>>;
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
- getAuctions(params?: PaginationParams): Promise<PaginationResult<AoAuction>>;
272
- getAuction({ name }: {
273
- name: string;
274
- }): Promise<AoAuction | undefined>;
275
- getAuctionPrices({ name, type, years, timestamp, intervalMs, }: {
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({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
307
+ joinNetwork(params: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
289
308
  leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
290
- updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
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
- import { BlockHeight } from '../types/common.js';
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
- constructor({ contract, timeoutMs, concurrency, logger, }?: {
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;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "2.4.0-alpha.7";
16
+ export declare const version = "2.4.0-alpha.16";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.4.0-alpha.8",
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 test:link && cd ./tests/e2e/cjs && yarn && yarn test",
70
- "test:esm": "yarn test:link && cd ./tests/e2e/esm && yarn && yarn test",
71
- "test:web": "yarn test:link && cd ./tests/e2e/web && yarn && yarn test",
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 test:link && cd examples/cjs && yarn && node index.cjs",
79
- "example:web": "yarn test:link && build:web && http-server --port 8080 --host -o examples/web"
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",