@ar.io/sdk 3.10.0-alpha.1 → 3.10.0-alpha.2

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,7 +1,5 @@
1
1
  import Arweave from 'arweave';
2
- import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
3
- import { AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionTotalsData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoPaginatedAddressParams, AoRegistrationFees, AoRevokeVaultParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
4
- import { mARIOToken } from '../types/token.js';
2
+ import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
5
3
  import { AOProcess } from './contracts/ao-process.js';
6
4
  import { TurboArNSPaymentProvider } from './turbo.js';
7
5
  type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
@@ -10,9 +8,23 @@ export declare class ARIO {
10
8
  static init(): AoARIORead;
11
9
  static init(config: ARIOConfigWithSigner): AoARIOWrite;
12
10
  static init(config: ARIOConfigNoSigner): AoARIORead;
11
+ static mainnet(): AoARIORead;
12
+ static mainnet(config: ARIOConfigNoSigner & {
13
+ faucetUrl?: string;
14
+ }): AoARIORead;
15
+ static mainnet(config: ARIOConfigWithSigner & {
16
+ faucetUrl?: string;
17
+ }): AoARIOWrite;
18
+ static testnet(): ARIOWithFaucet<AoARIORead>;
19
+ static testnet(config: ARIOConfigNoSigner & {
20
+ faucetUrl?: string;
21
+ }): ARIOWithFaucet<AoARIORead>;
22
+ static testnet(config: ARIOConfigWithSigner & {
23
+ faucetUrl?: string;
24
+ }): ARIOWithFaucet<AoARIOWrite>;
13
25
  }
14
26
  export declare class ARIOReadable implements AoARIORead {
15
- protected process: AOProcess;
27
+ readonly process: AOProcess;
16
28
  protected epochSettings: AoEpochSettings | undefined;
17
29
  protected arweave: Arweave;
18
30
  protected paymentProvider: TurboArNSPaymentProvider;
@@ -129,7 +141,7 @@ export declare class ARIOReadable implements AoARIORead {
129
141
  getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
130
142
  }
131
143
  export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
132
- protected process: AOProcess;
144
+ readonly process: AOProcess;
133
145
  private signer;
134
146
  protected paymentProvider: TurboArNSPaymentProvider;
135
147
  constructor({ signer, paymentUrl, ...config }: ARIOConfigWithSigner);
@@ -0,0 +1,82 @@
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 { AoARIORead, AoARIOWrite } from './io.js';
17
+ export type ARIOWithFaucet<T extends AoARIORead | AoARIOWrite> = T & {
18
+ faucet: TokenFaucet;
19
+ };
20
+ export interface TokenFaucet {
21
+ /**
22
+ * Claim tokens for a process using a captcha response. This method is used to synchronously claim tokens for a process using a captcha response.
23
+ * @param captchaResponse - The captcha response
24
+ * @param recipient - The recipient address
25
+ * @param quantity - The quantity of tokens to claim
26
+ * @returns The claim id and success status
27
+ */
28
+ claimWithCaptchaResponse({ captchaResponse, recipient, quantity, }: {
29
+ captchaResponse: string;
30
+ recipient: string;
31
+ quantity: number;
32
+ }): Promise<{
33
+ id: string;
34
+ success: boolean;
35
+ }>;
36
+ /**
37
+ * Returns the captcha URL for a process. The captcha is used to verify a human is solving the captcha. Once you have a captcha response, you can use it to request an authorization token via the requestAuthToken method.
38
+ * @returns The captcha URL for a process
39
+ */
40
+ captchaUrl(): Promise<{
41
+ processId: string;
42
+ captchaUrl: string;
43
+ }>;
44
+ /**
45
+ * Requests an authorization token for a process. The captcha response is used to verify a human is solving the captcha. Once you have an authorization token, you can use it to claim tokens from the faucet via the claimWithAuthToken method.
46
+ * @param captchaResponse - The captcha response
47
+ * @returns The status of the request, the authorization token, and the expiration time
48
+ */
49
+ requestAuthToken({ captchaResponse }: {
50
+ captchaResponse: string;
51
+ }): Promise<{
52
+ status: 'success' | 'error';
53
+ token: string;
54
+ expiresAt: number;
55
+ }>;
56
+ /**
57
+ * Transfers tokens from the faucet wallet to a recipient address using an authorization token. To request an authorization token, solve the captcha from the captchaUrl method.
58
+ * @param authToken - The authorization token
59
+ * @param recipient - The recipient address
60
+ * @param quantity - The quantity of tokens to claim
61
+ * @returns The message id of the transfer and success status
62
+ */
63
+ claimWithAuthToken({ authToken, recipient, quantity, }: {
64
+ authToken: string;
65
+ recipient: string;
66
+ quantity: number;
67
+ }): Promise<{
68
+ id: string;
69
+ success: boolean;
70
+ }>;
71
+ /**
72
+ * Verifies an authorization token is valid.
73
+ * @param authToken - The authorization token
74
+ * @returns The validity of the authorization token and the expiration time
75
+ */
76
+ verifyAuthToken({ authToken }: {
77
+ authToken: string;
78
+ }): Promise<{
79
+ valid: boolean;
80
+ expiresAt: number;
81
+ }>;
82
+ }
@@ -16,5 +16,6 @@
16
16
  export * from './ant-registry.js';
17
17
  export * from './ant.js';
18
18
  export * from './common.js';
19
+ export * from './faucet.js';
19
20
  export * from './io.js';
20
21
  export * from './token.js';
@@ -535,7 +535,7 @@ export interface AoARIOWrite extends AoARIORead {
535
535
  requestPrimaryName: AoWriteAction<AoArNSPurchaseParams>;
536
536
  redelegateStake: AoWriteAction<AoRedelegateStakeParams>;
537
537
  }
538
- export declare function isProcessConfiguration(config: object): config is Required<ProcessConfiguration> & Record<string, never>;
539
- export declare function isProcessIdConfiguration(config: object): config is Required<ProcessIdConfig> & Record<string, never>;
538
+ export declare function isProcessConfiguration(config: object | undefined): config is Required<ProcessConfiguration> & Record<string, never>;
539
+ export declare function isProcessIdConfiguration(config: object | undefined): config is Required<ProcessIdConfig> & Record<string, never>;
540
540
  export declare function isLeasedArNSRecord(record: AoArNSNameData): record is AoArNSLeaseData;
541
541
  export {};
@@ -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.9.1";
16
+ export declare const version = "3.10.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.10.0-alpha.1",
3
+ "version": "3.10.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"
@@ -67,7 +67,7 @@
67
67
  "lint": "eslint src",
68
68
  "lint:fix": "eslint src --fix",
69
69
  "format": "prettier --check .",
70
- "format:fix": "prettier --write .",
70
+ "format:fix": "prettier --write . && yarn docs:update",
71
71
  "test": "yarn test:unit && yarn test:e2e",
72
72
  "test:cjs": "yarn build:cjs && yarn link && cd ./tests/e2e/cjs && yarn && yarn test",
73
73
  "test:esm": "yarn build:esm && yarn link && cd ./tests/e2e/esm && yarn && yarn test",
@@ -77,7 +77,7 @@
77
77
  "test:e2e": "yarn test:cjs && yarn test:esm && yarn test:web",
78
78
  "test:integration": "yarn build:esm && yarn link && cd ./tests/integration && yarn && yarn test",
79
79
  "prepare": "husky install",
80
- "docs:update": "markdown-toc-gen insert README.md",
80
+ "docs:update": "markdown-toc-gen insert README.md --max-depth 2",
81
81
  "example:esm": "cd examples/esm && yarn && node index.mjs",
82
82
  "example:cjs": "yarn build:cjs && yarn link && cd examples/cjs && yarn && node index.cjs",
83
83
  "example:web": "yarn build:web && http-server --port 8080 --host -o examples/web",
@@ -121,8 +121,7 @@
121
121
  "sinon": "^15.2.0",
122
122
  "testcontainers": "^10.13.1",
123
123
  "ts-node": "^10.9.2",
124
- "typescript": "^5.1.6",
125
- "vite-plugin-node-polyfills": "^0.22.0"
124
+ "typescript": "^5.1.6"
126
125
  },
127
126
  "dependencies": {
128
127
  "@dha-team/arbundles": "^1.0.1",
@@ -143,7 +142,7 @@
143
142
  "prettier --write ."
144
143
  ],
145
144
  "**/README.md": [
146
- "markdown-toc-gen insert"
145
+ "markdown-toc-gen insert --max-depth 2"
147
146
  ]
148
147
  }
149
148
  }