@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.
- package/README.md +38 -0
- package/bundles/web.bundle.min.js +69 -69
- package/lib/cjs/cli/cli.js +8 -2
- package/lib/cjs/cli/commands/readCommands.js +22 -22
- package/lib/cjs/cli/options.js +6 -0
- package/lib/cjs/cli/utils.js +21 -1
- package/lib/cjs/common/contracts/ao-process.js +12 -3
- package/lib/cjs/common/io.js +47 -1
- package/lib/cjs/types/io.js +6 -1
- package/lib/cjs/utils/base64.js +10 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +9 -3
- package/lib/esm/cli/commands/readCommands.js +21 -22
- package/lib/esm/cli/options.js +6 -0
- package/lib/esm/cli/utils.js +20 -1
- package/lib/esm/common/contracts/ao-process.js +12 -3
- package/lib/esm/common/io.js +47 -1
- package/lib/esm/types/io.js +4 -0
- package/lib/esm/utils/base64.js +9 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/readCommands.d.ts +24 -2
- package/lib/types/cli/options.d.ts +4 -0
- package/lib/types/cli/utils.d.ts +9 -1
- package/lib/types/common/contracts/ao-process.d.ts +2 -1
- package/lib/types/common/io.d.ts +2 -1
- package/lib/types/types/io.d.ts +31 -3
- package/lib/types/utils/base64.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,20 @@
|
|
|
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 { 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
|
-
|
|
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
|
}>;
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -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<{
|
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, 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>;
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -252,16 +252,43 @@ export type AoRedelegateStakeParams = {
|
|
|
252
252
|
stakeQty: number | mARIOToken;
|
|
253
253
|
vaultId?: string;
|
|
254
254
|
};
|
|
255
|
-
export declare const validIntents:
|
|
256
|
-
export declare const intentsUsingYears:
|
|
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
|
|
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>;
|
package/lib/types/version.d.ts
CHANGED