@ar.io/sdk 3.9.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.
Files changed (51) hide show
  1. package/README.md +124 -140
  2. package/bundles/web.bundle.min.js +107 -99
  3. package/lib/cjs/cli/options.js +12 -0
  4. package/lib/cjs/cli/utils.js +33 -11
  5. package/lib/cjs/common/ant-versions.js +5 -5
  6. package/lib/cjs/common/faucet.js +150 -0
  7. package/lib/cjs/common/index.js +1 -0
  8. package/lib/cjs/common/io.js +107 -4
  9. package/lib/cjs/common/turbo.js +134 -0
  10. package/lib/cjs/types/faucet.js +2 -0
  11. package/lib/cjs/types/index.js +1 -0
  12. package/lib/cjs/types/io.js +4 -3
  13. package/lib/cjs/utils/ao.js +2 -0
  14. package/lib/cjs/utils/url.js +28 -0
  15. package/lib/cjs/utils/url.test.js +24 -0
  16. package/lib/cjs/version.js +1 -1
  17. package/lib/esm/cli/options.js +12 -0
  18. package/lib/esm/cli/utils.js +31 -10
  19. package/lib/esm/common/ant-versions.js +5 -5
  20. package/lib/esm/common/faucet.js +145 -0
  21. package/lib/esm/common/index.js +1 -0
  22. package/lib/esm/common/io.js +106 -3
  23. package/lib/esm/common/turbo.js +129 -0
  24. package/lib/esm/types/faucet.js +1 -0
  25. package/lib/esm/types/index.js +1 -0
  26. package/lib/esm/types/io.js +4 -3
  27. package/lib/esm/utils/ao.js +2 -0
  28. package/lib/esm/utils/url.js +24 -0
  29. package/lib/esm/utils/url.test.js +19 -0
  30. package/lib/esm/version.js +1 -1
  31. package/lib/types/cli/commands/antCommands.d.ts +3 -3
  32. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
  33. package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
  34. package/lib/types/cli/commands/readCommands.d.ts +1 -0
  35. package/lib/types/cli/commands/transfer.d.ts +3 -3
  36. package/lib/types/cli/options.d.ts +9 -0
  37. package/lib/types/cli/types.d.ts +3 -0
  38. package/lib/types/cli/utils.d.ts +4 -0
  39. package/lib/types/common/ant-versions.d.ts +3 -6
  40. package/lib/types/common/faucet.d.ts +96 -0
  41. package/lib/types/common/index.d.ts +1 -0
  42. package/lib/types/common/io.d.ts +25 -25
  43. package/lib/types/common/turbo.d.ts +47 -0
  44. package/lib/types/types/common.d.ts +6 -1
  45. package/lib/types/types/faucet.d.ts +82 -0
  46. package/lib/types/types/index.d.ts +1 -0
  47. package/lib/types/types/io.d.ts +9 -8
  48. package/lib/types/utils/url.d.ts +19 -0
  49. package/lib/types/utils/url.test.d.ts +1 -0
  50. package/lib/types/version.d.ts +1 -1
  51. package/package.json +7 -7
@@ -27,6 +27,10 @@ export type ProcessId = string;
27
27
  export type OptionalArweave<T = NonNullable<unknown>> = {
28
28
  arweave?: Arweave;
29
29
  } & T;
30
+ export type OptionalPaymentUrl<T = NonNullable<unknown>> = {
31
+ paymentUrl?: string;
32
+ } & T;
33
+ export type TurboArNSSigner = Signer;
30
34
  export type ContractSigner = Signer | Window['arweaveWallet'] | AoSigner;
31
35
  export type WithSigner<T = NonNullable<unknown>> = {
32
36
  signer: ContractSigner;
@@ -45,8 +49,9 @@ export type WriteOptions = {
45
49
  }[];
46
50
  };
47
51
  export type WriteParameters<Input> = WithSigner<Required<ReadParameters<Input>>>;
48
- export type AoMessageResult = {
52
+ export type AoMessageResult<T = Record<string, string | number | boolean | null>> = {
49
53
  id: string;
54
+ result?: T;
50
55
  };
51
56
  export type AoPrimaryNameRequest = {
52
57
  name: string;
@@ -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';
@@ -310,9 +310,9 @@ export type AoTokenCostParams = {
310
310
  quantity?: number;
311
311
  fromAddress?: WalletAddress;
312
312
  };
313
- export declare const fundFromOptions: readonly ["balance", "stakes", "any"];
313
+ export declare const fundFromOptions: readonly ["balance", "stakes", "any", "turbo"];
314
314
  export type FundFrom = (typeof fundFromOptions)[number];
315
- export declare const isValidFundFrom: (fundFrom: string) => fundFrom is "balance" | "stakes" | "any";
315
+ export declare const isValidFundFrom: (fundFrom: string) => fundFrom is "balance" | "stakes" | "any" | "turbo";
316
316
  export type AoGetCostDetailsParams = AoTokenCostParams & {
317
317
  fundFrom?: FundFrom;
318
318
  };
@@ -338,6 +338,7 @@ export type CostDetailsResult = {
338
338
  basePrice: number;
339
339
  };
340
340
  fundingPlan?: AoFundingPlan;
341
+ wincQty?: string;
341
342
  };
342
343
  export type AoGetVaultParams = {
343
344
  address: WalletAddress;
@@ -523,10 +524,10 @@ export interface AoARIOWrite extends AoARIORead {
523
524
  reportTxId: TransactionId;
524
525
  failedGateways: WalletAddress[];
525
526
  }>;
526
- buyRecord: AoWriteAction<AoBuyRecordParams>;
527
- upgradeRecord: AoWriteAction<AoArNSPurchaseParams>;
528
- extendLease: AoWriteAction<AoExtendLeaseParams>;
529
- increaseUndernameLimit: AoWriteAction<AoIncreaseUndernameLimitParams>;
527
+ buyRecord: AoWriteAction<AoBuyRecordParams, AoMessageResult>;
528
+ upgradeRecord: AoWriteAction<AoArNSPurchaseParams, AoMessageResult>;
529
+ extendLease: AoWriteAction<AoExtendLeaseParams, AoMessageResult>;
530
+ increaseUndernameLimit: AoWriteAction<AoIncreaseUndernameLimitParams, AoMessageResult>;
530
531
  cancelWithdrawal: AoWriteAction<{
531
532
  gatewayAddress?: WalletAddress;
532
533
  vaultId: string;
@@ -534,7 +535,7 @@ export interface AoARIOWrite extends AoARIORead {
534
535
  requestPrimaryName: AoWriteAction<AoArNSPurchaseParams>;
535
536
  redelegateStake: AoWriteAction<AoRedelegateStakeParams>;
536
537
  }
537
- export declare function isProcessConfiguration(config: object): config is Required<ProcessConfiguration> & Record<string, never>;
538
- 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>;
539
540
  export declare function isLeasedArNSRecord(record: AoArNSNameData): record is AoArNSLeaseData;
540
541
  export {};
@@ -0,0 +1,19 @@
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
+ export declare const urlWithSearchParams: ({ baseUrl, params, }: {
17
+ baseUrl: string;
18
+ params: Record<string, string | number | boolean | null | undefined>;
19
+ }) => string;
@@ -0,0 +1 @@
1
+ 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-alpha.2";
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.9.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",
@@ -100,7 +100,7 @@
100
100
  "arconnect": "^1.0.3",
101
101
  "dotenv": "^16.4.5",
102
102
  "dotenv-cli": "^7.4.2",
103
- "esbuild": "^0.25.1",
103
+ "esbuild": "^0.25.2",
104
104
  "esbuild-plugin-polyfill-node": "^0.3.0",
105
105
  "eslint": "^8.47.0",
106
106
  "eslint-config-prettier": "^9.0.0",
@@ -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",
@@ -134,6 +133,7 @@
134
133
  "eventemitter3": "^5.0.1",
135
134
  "plimit-lit": "^3.0.1",
136
135
  "prompts": "^2.4.2",
136
+ "uuid": "^11.1.0",
137
137
  "winston": "^3.13.0",
138
138
  "zod": "^3.23.8"
139
139
  },
@@ -142,7 +142,7 @@
142
142
  "prettier --write ."
143
143
  ],
144
144
  "**/README.md": [
145
- "markdown-toc-gen insert"
145
+ "markdown-toc-gen insert --max-depth 2"
146
146
  ]
147
147
  }
148
148
  }