@ar.io/sdk 3.0.0 → 3.1.0-alpha.1

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,4 +1,20 @@
1
- import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, NameCLIOptions, PaginationAddressCLIOptions, PaginationCLIOptions } from '../types.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 { AoGetCostDetailsParams } from '../../types/io.js';
17
+ import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions, CLIOptionsFromAoParams, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, NameCLIOptions, PaginationAddressCLIOptions, PaginationCLIOptions } from '../types.js';
2
18
  export declare function getGateway(o: AddressCLIOptions): Promise<import("../../types/io.js").AoGateway | {
3
19
  message: string;
4
20
  }>;
@@ -42,9 +58,15 @@ export declare function getPrescribedNames(o: EpochCLIOptions): Promise<string[]
42
58
  message: string;
43
59
  }>;
44
60
  export declare function getTokenCost(o: GetTokenCostCLIOptions): Promise<{
45
- mIOTokenCost: number;
61
+ mARIOTokenCost: number;
46
62
  message: string;
47
63
  }>;
64
+ export declare function getCostDetails(o: GlobalCLIOptions & CLIOptionsFromAoParams<AoGetCostDetailsParams>): Promise<{
65
+ message: string;
66
+ tokenCost: number;
67
+ discounts: import("../../types/io.js").CostDiscount[];
68
+ fundingPlan?: import("../../types/io.js").AoFundingPlan | undefined;
69
+ }>;
48
70
  export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<import("../../types/common.js").AoPrimaryName | {
49
71
  message: string;
50
72
  }>;
@@ -230,6 +230,10 @@ export declare const optionMap: {
230
230
  description: string;
231
231
  type: string;
232
232
  };
233
+ fundFrom: {
234
+ alias: string;
235
+ description: string;
236
+ };
233
237
  };
234
238
  export declare const walletOptions: {
235
239
  alias: string;
@@ -1,7 +1,7 @@
1
1
  import { JWKInterface } from 'arweave/node/lib/wallet.js';
2
2
  import { Command, OptionValues } from 'commander';
3
3
  import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
4
- import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
4
+ import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
5
5
  export declare function stringifyJsonForCLIDisplay(json: JsonSerializable | unknown): string;
6
6
  export declare function runCommand<O extends OptionValues>(command: Command, action: (options: O) => Promise<JsonSerializable>): Promise<void>;
7
7
  export interface CommanderOption {
@@ -65,3 +65,11 @@ export declare function requiredStringArrayFromOptions<O extends GlobalCLIOption
65
65
  export declare function positiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number | undefined;
66
66
  export declare function requiredPositiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number;
67
67
  export declare function getANTStateFromOptions(options: ANTStateCLIOptions): SpawnANTState;
68
+ export declare function getTokenCostParamsFromOptions(o: GetTokenCostCLIOptions): {
69
+ type: "lease" | "permabuy";
70
+ quantity: number | undefined;
71
+ years: number;
72
+ intent: "Buy-Record" | "Extend-Lease" | "Increase-Undername-Limit" | "Upgrade-Name" | "Primary-Name-Request";
73
+ name: string;
74
+ fromAddress: string | undefined;
75
+ };
@@ -9,12 +9,13 @@ export declare class AOProcess implements AOContract {
9
9
  ao?: AoClient;
10
10
  logger?: ILogger;
11
11
  });
12
- read<K>({ tags, retries, }: {
12
+ read<K>({ tags, retries, fromAddress, }: {
13
13
  tags?: Array<{
14
14
  name: string;
15
15
  value: string;
16
16
  }>;
17
17
  retries?: number;
18
+ fromAddress?: string;
18
19
  }): Promise<K>;
19
20
  send<K>({ tags, data, signer, retries, }: {
20
21
  tags: Array<{
@@ -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, AoArNSReservedNameDataWithName, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, DemandFactorSettings, EpochInput } from '../types/io.js';
18
+ import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSReservedNameDataWithName, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, 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 {
@@ -107,6 +107,7 @@ export declare class ARIOReadable implements AoARIORead {
107
107
  intent: 'Primary-Name-Request';
108
108
  name: string;
109
109
  }): Promise<number>;
110
+ getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
110
111
  getRegistrationFees(): Promise<AoRegistrationFees>;
111
112
  getDemandFactor(): Promise<number>;
112
113
  getDemandFactorSettings(): Promise<DemandFactorSettings>;
@@ -252,16 +252,43 @@ export type AoRedelegateStakeParams = {
252
252
  stakeQty: number | mARIOToken;
253
253
  vaultId?: string;
254
254
  };
255
- export declare const validIntents: string[];
256
- export declare const intentsUsingYears: string[];
255
+ export declare const validIntents: readonly ["Buy-Record", "Extend-Lease", "Increase-Undername-Limit", "Upgrade-Name", "Primary-Name-Request"];
256
+ export declare const intentsUsingYears: readonly ["Buy-Record", "Extend-Lease"];
257
257
  export type Intent = (typeof validIntents)[number];
258
- export declare const isValidIntent: (intent: string) => intent is string;
258
+ export declare const isValidIntent: (intent: string) => intent is "Buy-Record" | "Extend-Lease" | "Increase-Undername-Limit" | "Upgrade-Name" | "Primary-Name-Request";
259
259
  export type AoTokenCostParams = {
260
260
  intent: Intent;
261
261
  type?: 'permabuy' | 'lease';
262
262
  years?: number;
263
263
  name: string;
264
264
  quantity?: number;
265
+ fromAddress?: WalletAddress;
266
+ };
267
+ export declare const fundFromOptions: readonly ["balance", "stakes", "any"];
268
+ export type FundFrom = (typeof fundFromOptions)[number];
269
+ export declare const isValidFundFrom: (fundFrom: string) => fundFrom is "balance" | "stakes" | "any";
270
+ export type AoGetCostDetailsParams = AoTokenCostParams & {
271
+ fundFrom?: FundFrom;
272
+ };
273
+ export type AoFundingPlan = {
274
+ address: WalletAddress;
275
+ balance: number;
276
+ stakes: Record<WalletAddress, {
277
+ vaults: string[];
278
+ delegatedStake: number;
279
+ }>;
280
+ /** Any remaining shortfall will indicate an insufficient balance for the action */
281
+ shortfall: number;
282
+ };
283
+ export type CostDiscount = {
284
+ name: string;
285
+ discountTotal: number;
286
+ multiplier: number;
287
+ };
288
+ export type CostDetailsResult = {
289
+ tokenCost: number;
290
+ discounts: CostDiscount[];
291
+ fundingPlan?: AoFundingPlan;
265
292
  };
266
293
  export type AoGetVaultParams = {
267
294
  address: WalletAddress;
@@ -353,6 +380,7 @@ export interface AoARIORead {
353
380
  getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
354
381
  getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
355
382
  getTokenCost({ intent, type, years, name, quantity, }: AoTokenCostParams): Promise<number>;
383
+ getCostDetails({ intent, type, years, name, quantity, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
356
384
  getRegistrationFees(): Promise<AoRegistrationFees>;
357
385
  getDemandFactor(): Promise<number>;
358
386
  getDemandFactorSettings(): Promise<DemandFactorSettings>;
@@ -2,3 +2,4 @@
2
2
  export declare function fromB64Url(str: string): Buffer;
3
3
  export declare function toB64Url(buffer: Buffer): string;
4
4
  export declare function sha256B64Url(input: Buffer): string;
5
+ export declare function getRandomText(length?: number): 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.0.0-alpha.1";
16
+ export declare const version = "3.0.1-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.0.0",
3
+ "version": "3.1.0-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"