@ar.io/sdk 3.2.0 → 3.3.0-alpha.10

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.
@@ -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: Required<ProcessConfiguration> & {
6
- signer?: undefined;
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: Required<ProcessConfiguration> & {
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 {};
@@ -2,8 +2,8 @@ import { AOContract, AoClient, AoSigner } from '../../types/index.js';
2
2
  import { ILogger } from '../logger.js';
3
3
  export declare class AOProcess implements AOContract {
4
4
  private logger;
5
- private processId;
6
5
  private ao;
6
+ readonly processId: string;
7
7
  constructor({ processId, ao, logger, }: {
8
8
  processId: string;
9
9
  ao?: AoClient;
@@ -1,30 +1,35 @@
1
- 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';
2
- 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';
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 { 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, 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';
3
19
  import { mARIOToken } from '../types/token.js';
4
20
  import { AOProcess } from './contracts/ao-process.js';
21
+ type ARIOConfigNoSigner = OptionalArweave<ProcessConfiguration>;
22
+ type ARIOConfigWithSigner = WithSigner<OptionalArweave<ProcessConfiguration>>;
5
23
  export declare class ARIO {
6
24
  static init(): AoARIORead;
7
- static init({ process }: {
8
- process: AOProcess;
9
- }): AoARIORead;
10
- static init({ process, signer, }: WithSigner<{
11
- process: AOProcess;
12
- }>): AoARIOWrite;
13
- static init({ processId, signer, }: WithSigner<{
14
- processId?: string;
15
- }>): AoARIOWrite;
16
- static init({ processId, signer, }: {
17
- signer?: ContractSigner | undefined;
18
- processId: string;
19
- }): any;
20
- static init({ processId }: {
21
- processId: string;
22
- }): AoARIORead;
25
+ static init(config: ARIOConfigWithSigner): AoARIOWrite;
26
+ static init(config: ARIOConfigNoSigner): AoARIORead;
23
27
  }
24
28
  export declare class ARIOReadable implements AoARIORead {
25
29
  protected process: AOProcess;
26
30
  protected epochSettings: AoEpochSettings | undefined;
27
- constructor(config?: ProcessConfiguration);
31
+ protected arweave: Arweave;
32
+ constructor(config?: OptionalArweave<ProcessConfiguration>);
28
33
  getInfo(): Promise<{
29
34
  Name: string;
30
35
  Ticker: string;
@@ -36,9 +41,10 @@ export declare class ARIOReadable implements AoARIORead {
36
41
  }>;
37
42
  getTokenSupply(): Promise<AoTokenSupplyData>;
38
43
  private computeEpochIndexForTimestamp;
44
+ private computeCurrentEpochIndex;
39
45
  private computeEpochIndex;
40
46
  getEpochSettings(): Promise<AoEpochSettings>;
41
- getEpoch(epoch?: EpochInput): Promise<AoEpochData>;
47
+ getEpoch(epoch?: EpochInput): Promise<AoEpochData | undefined>;
42
48
  getArNSRecord({ name, }: {
43
49
  name: string;
44
50
  }): Promise<AoArNSNameData | undefined>;
@@ -68,8 +74,8 @@ export declare class ARIOReadable implements AoARIORead {
68
74
  getCurrentEpoch(): Promise<AoEpochData>;
69
75
  getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
70
76
  getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
71
- getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
72
- getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
77
+ getObservations(epoch?: EpochInput): Promise<AoEpochObservationData | undefined>;
78
+ getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData | undefined>;
73
79
  getTokenCost(params: {
74
80
  intent: 'Buy-Record';
75
81
  type: 'permabuy' | 'lease';
@@ -130,15 +136,12 @@ export declare class ARIOReadable implements AoARIORead {
130
136
  address: WalletAddress;
131
137
  }): Promise<AoRedelegationFeeInfo>;
132
138
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
139
+ getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
133
140
  }
134
141
  export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
135
142
  protected process: AOProcess;
136
143
  private signer;
137
- constructor({ signer, ...config }: WithSigner<{
138
- process?: AOProcess;
139
- } | {
140
- processId?: string;
141
- }>);
144
+ constructor({ signer, ...config }: ARIOConfigWithSigner);
142
145
  transfer({ target, qty, }: {
143
146
  target: string;
144
147
  qty: number | mARIOToken;
@@ -231,3 +234,4 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
231
234
  vaultId?: string;
232
235
  }, options?: WriteOptions): Promise<AoMessageResult>;
233
236
  }
237
+ export {};
@@ -24,6 +24,6 @@ export declare const arioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6
24
24
  export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
25
25
  export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
26
26
  export declare const MARIO_PER_ARIO = 1000000;
27
- export declare const AOS_MODULE_ID = "cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk";
28
- export declare const ANT_LUA_ID = "16_FyX-V2QU0RPSh1GIaEETSaUjNb0oVjCFpVbAfQq4";
27
+ export declare const AOS_MODULE_ID = "BRyNPIJWZaQ4IudfNnsfvMrZBO2YDPjgKqg_wCYT2U8";
28
+ export declare const ANT_LUA_ID = "k9tQkbnFYZOGp6ist1yFuaqk_wOkzM5KUSNDtWzCLtg";
29
29
  export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
@@ -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;
@@ -31,16 +31,20 @@ export type PaginationResult<T> = {
31
31
  sortOrder: 'asc' | 'desc';
32
32
  hasMore: boolean;
33
33
  };
34
- export type ProcessConfiguration = {
35
- process?: AOProcess;
36
- } | {
34
+ export type ProcessIdConfig = {
37
35
  processId?: string;
38
36
  };
39
- export type EpochInput = {
40
- epochIndex: AoEpochIndex;
41
- } | {
37
+ export type ProcessConfig = {
38
+ process?: AOProcess;
39
+ };
40
+ export type ProcessConfiguration = ProcessConfig | ProcessIdConfig;
41
+ export type EpochTimestampInput = {
42
42
  timestamp: Timestamp;
43
- } | undefined;
43
+ };
44
+ export type EpochIndexInput = {
45
+ epochIndex: AoEpochIndex;
46
+ };
47
+ export type EpochInput = EpochTimestampInput | EpochIndexInput | undefined;
44
48
  export type AoBalances = Record<WalletAddress, number>;
45
49
  export type AoRegistrationFees = Record<number, {
46
50
  lease: Record<number, number>;
@@ -117,6 +121,7 @@ export type AoEpochData = {
117
121
  startTimestamp: Timestamp;
118
122
  endTimestamp: Timestamp;
119
123
  distributionTimestamp: Timestamp;
124
+ /** @deprecated - use `getDistributions` to get distribution data for a given epoch **/
120
125
  distributions: AoEpochDistributionData;
121
126
  };
122
127
  export type AoTokenSupplyData = {
@@ -389,8 +394,8 @@ export interface AoARIORead {
389
394
  getCurrentEpoch(): Promise<AoEpochData>;
390
395
  getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
391
396
  getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
392
- getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
393
- getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
397
+ getObservations(epoch?: EpochInput): Promise<AoEpochObservationData | undefined>;
398
+ getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData | undefined>;
394
399
  getTokenCost({ intent, type, years, name, quantity, }: AoTokenCostParams): Promise<number>;
395
400
  getCostDetails({ intent, type, years, name, quantity, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
396
401
  getRegistrationFees(): Promise<AoRegistrationFees>;
@@ -412,7 +417,16 @@ export interface AoARIORead {
412
417
  address: WalletAddress;
413
418
  }): Promise<AoRedelegationFeeInfo>;
414
419
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
420
+ getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
415
421
  }
422
+ export type AoAllDelegates = {
423
+ address: WalletAddress;
424
+ gatewayAddress: WalletAddress;
425
+ delegatedStake: number;
426
+ startTimestamp: Timestamp;
427
+ vaultedStake: number;
428
+ cursorId: string;
429
+ };
416
430
  export interface AoARIOWrite extends AoARIORead {
417
431
  transfer({ target, qty, }: {
418
432
  target: WalletAddress;
@@ -456,10 +470,6 @@ export interface AoARIOWrite extends AoARIORead {
456
470
  requestPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
457
471
  redelegateStake(params: AoRedelegateStakeParams, options?: WriteOptions): Promise<AoMessageResult>;
458
472
  }
459
- export declare function isProcessConfiguration(config: object): config is {
460
- process: AOProcess;
461
- };
462
- export declare function isProcessIdConfiguration(config: object): config is {
463
- processId: string;
464
- };
473
+ export declare function isProcessConfiguration(config: object): config is Required<ProcessConfiguration> & Record<string, never>;
474
+ export declare function isProcessIdConfiguration(config: object): config is Required<ProcessIdConfig> & Record<string, never>;
465
475
  export declare function isLeasedArNSRecord(record: AoArNSNameData): record is AoArNSLeaseData;
@@ -1,7 +1,7 @@
1
1
  import Arweave from 'arweave';
2
2
  import { Logger } from '../common/index.js';
3
3
  import { AoANTRecord } from '../types/ant.js';
4
- import { AoClient, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
4
+ import { AoClient, AoEpochData, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
5
5
  export type SpawnANTState = {
6
6
  owner: WalletAddress;
7
7
  controllers: WalletAddress[];
@@ -15,16 +15,22 @@ export type SpawnANTState = {
15
15
  export type SpawnANTParams = {
16
16
  signer: AoSigner;
17
17
  module?: string;
18
- luaCodeTxId?: string;
19
18
  ao?: AoClient;
20
19
  scheduler?: string;
21
20
  state?: SpawnANTState;
22
21
  stateContractTxId?: string;
23
22
  antRegistryId?: string;
24
23
  logger?: Logger;
24
+ /**
25
+ * @deprecated Compiled modules are now being used instead of luaCodeTxId
26
+ */
27
+ luaCodeTxId?: string;
28
+ /**
29
+ * @deprecated no longer in use due to compiled modules being preferred
30
+ */
25
31
  arweave?: Arweave;
26
32
  };
27
- export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, state, stateContractTxId, antRegistryId, logger, arweave, }: SpawnANTParams): Promise<string>;
33
+ export declare function spawnANT({ signer, module, ao, scheduler, state, stateContractTxId, antRegistryId, logger, }: SpawnANTParams): Promise<string>;
28
34
  export declare function evolveANT({ signer, processId, luaCodeTxId, ao, logger, arweave, }: {
29
35
  signer: AoSigner;
30
36
  processId: string;
@@ -41,3 +47,7 @@ export declare function initANTStateForAddress({ owner, targetId, ttlSeconds, ke
41
47
  ttlSeconds?: number;
42
48
  owner: WalletAddress;
43
49
  }): SpawnANTState;
50
+ /**
51
+ * Uses zod schema to parse the epoch data
52
+ */
53
+ export declare function parseAoEpochData(value: unknown): AoEpochData;
@@ -1,5 +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 Arweave from 'arweave';
1
17
  import { BlockHeight } from '../types/common.js';
2
- import { PaginationParams } from '../types/io.js';
18
+ import { AoEpochData, PaginationParams } from '../types/io.js';
3
19
  export declare const validateArweaveId: (id: string) => boolean;
4
20
  export declare function isBlockHeight(height: string | number): height is BlockHeight;
5
21
  /**
@@ -18,3 +34,17 @@ export declare const paginationParamsToTags: <T>(params?: PaginationParams<T>) =
18
34
  name: string;
19
35
  value: string;
20
36
  }[];
37
+ /**
38
+ * Get the epoch with distribution data for the current epoch
39
+ * @param arweave - The Arweave instance
40
+ * @returns The epoch with distribution data
41
+ */
42
+ export declare const getEpochDataFromGql: ({ arweave, epochIndex, processId, }: {
43
+ arweave: Arweave;
44
+ epochIndex: number;
45
+ processId?: string;
46
+ }) => Promise<AoEpochData | undefined>;
47
+ export declare const epochDistributionNoticeGqlQuery: ({ epochIndex, processId, }: {
48
+ epochIndex: number;
49
+ processId?: string;
50
+ }) => string;
@@ -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 = "3.2.0-alpha.3";
16
+ export declare const version = "3.3.0-alpha.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.2.0",
3
+ "version": "3.3.0-alpha.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"
@@ -126,7 +126,7 @@
126
126
  "dependencies": {
127
127
  "@dha-team/arbundles": "^1.0.1",
128
128
  "@permaweb/aoconnect": "^0.0.57",
129
- "arweave": "1.14.4",
129
+ "arweave": "1.15.5",
130
130
  "axios": "1.7.9",
131
131
  "axios-retry": "^4.3.0",
132
132
  "commander": "^12.1.0",