@ar.io/sdk 3.10.2 → 3.11.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.
Files changed (114) hide show
  1. package/README.md +52 -0
  2. package/bundles/web.bundle.min.js +140 -132
  3. package/lib/cjs/cli/cli.js +137 -122
  4. package/lib/cjs/cli/commands/readCommands.js +6 -0
  5. package/lib/cjs/cli/options.js +12 -0
  6. package/lib/cjs/cli/utils.js +40 -11
  7. package/lib/cjs/common/ant-versions.js +5 -5
  8. package/lib/cjs/common/ant.js +5 -5
  9. package/lib/cjs/common/index.js +2 -0
  10. package/lib/cjs/common/io.js +106 -1
  11. package/lib/cjs/common/turbo.js +208 -0
  12. package/lib/cjs/common/wayfinder/gateways/trusted-gateways.js +106 -0
  13. package/lib/cjs/common/wayfinder/gateways.js +86 -0
  14. package/lib/cjs/common/wayfinder/index.js +44 -0
  15. package/lib/cjs/common/wayfinder/routers/priority.js +29 -0
  16. package/lib/cjs/common/wayfinder/routers/priority.test.js +155 -0
  17. package/lib/cjs/common/wayfinder/routers/random.js +23 -0
  18. package/lib/cjs/common/wayfinder/routers/random.test.js +25 -0
  19. package/lib/cjs/common/wayfinder/routers/simple-cache.js +25 -0
  20. package/lib/cjs/common/wayfinder/routers/simple-cache.test.js +41 -0
  21. package/lib/cjs/common/wayfinder/routers/static.js +14 -0
  22. package/lib/cjs/common/wayfinder/routers/static.test.js +14 -0
  23. package/lib/cjs/common/wayfinder/verification/data-root-verifier.js +139 -0
  24. package/lib/cjs/common/wayfinder/verification/hash-verifier.js +50 -0
  25. package/lib/cjs/common/wayfinder/wayfinder.js +596 -0
  26. package/lib/cjs/common/wayfinder/wayfinder.test.js +500 -0
  27. package/lib/cjs/types/ant.js +12 -1
  28. package/lib/cjs/types/index.js +1 -0
  29. package/lib/cjs/types/io.js +1 -1
  30. package/lib/cjs/types/wayfinder.js +3 -0
  31. package/lib/cjs/utils/ao.js +42 -0
  32. package/lib/cjs/utils/hash.js +56 -0
  33. package/lib/cjs/utils/random.js +30 -0
  34. package/lib/cjs/utils/url.js +28 -0
  35. package/lib/cjs/utils/url.test.js +24 -0
  36. package/lib/cjs/utils/utils.test.js +8 -8
  37. package/lib/cjs/version.js +1 -1
  38. package/lib/cjs/web/index.js +3 -1
  39. package/lib/esm/cli/cli.js +138 -123
  40. package/lib/esm/cli/commands/readCommands.js +5 -0
  41. package/lib/esm/cli/options.js +12 -0
  42. package/lib/esm/cli/utils.js +39 -11
  43. package/lib/esm/common/ant-versions.js +5 -5
  44. package/lib/esm/common/ant.js +5 -5
  45. package/lib/esm/common/index.js +2 -0
  46. package/lib/esm/common/io.js +106 -1
  47. package/lib/esm/common/turbo.js +200 -0
  48. package/lib/esm/common/wayfinder/gateways/trusted-gateways.js +102 -0
  49. package/lib/esm/common/wayfinder/gateways.js +80 -0
  50. package/lib/esm/common/wayfinder/index.js +28 -0
  51. package/lib/esm/common/wayfinder/routers/priority.js +25 -0
  52. package/lib/esm/common/wayfinder/routers/priority.test.js +153 -0
  53. package/lib/esm/common/wayfinder/routers/random.js +19 -0
  54. package/lib/esm/common/wayfinder/routers/random.test.js +23 -0
  55. package/lib/esm/common/wayfinder/routers/simple-cache.js +21 -0
  56. package/lib/esm/common/wayfinder/routers/simple-cache.test.js +39 -0
  57. package/lib/esm/common/wayfinder/routers/static.js +10 -0
  58. package/lib/esm/common/wayfinder/routers/static.test.js +12 -0
  59. package/lib/esm/common/wayfinder/verification/data-root-verifier.js +130 -0
  60. package/lib/esm/common/wayfinder/verification/hash-verifier.js +46 -0
  61. package/lib/esm/common/wayfinder/wayfinder.js +584 -0
  62. package/lib/esm/common/wayfinder/wayfinder.test.js +495 -0
  63. package/lib/esm/types/ant.js +11 -0
  64. package/lib/esm/types/index.js +1 -0
  65. package/lib/esm/types/io.js +1 -1
  66. package/lib/esm/types/wayfinder.js +2 -0
  67. package/lib/esm/utils/ao.js +42 -0
  68. package/lib/esm/utils/hash.js +50 -0
  69. package/lib/esm/utils/random.js +26 -0
  70. package/lib/esm/utils/url.js +24 -0
  71. package/lib/esm/utils/url.test.js +19 -0
  72. package/lib/esm/utils/utils.test.js +1 -1
  73. package/lib/esm/version.js +1 -1
  74. package/lib/esm/web/index.js +1 -1
  75. package/lib/types/cli/commands/antCommands.d.ts +3 -3
  76. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
  77. package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
  78. package/lib/types/cli/commands/readCommands.d.ts +2 -0
  79. package/lib/types/cli/commands/transfer.d.ts +3 -3
  80. package/lib/types/cli/options.d.ts +9 -0
  81. package/lib/types/cli/types.d.ts +3 -0
  82. package/lib/types/cli/utils.d.ts +4 -0
  83. package/lib/types/common/ant-versions.d.ts +3 -6
  84. package/lib/types/common/index.d.ts +1 -0
  85. package/lib/types/common/io.d.ts +13 -8
  86. package/lib/types/common/turbo.d.ts +62 -0
  87. package/lib/types/common/wayfinder/gateways/trusted-gateways.d.ts +51 -0
  88. package/lib/types/common/wayfinder/gateways.d.ts +53 -0
  89. package/lib/types/common/wayfinder/index.d.ts +23 -0
  90. package/lib/types/common/wayfinder/routers/priority.d.ts +29 -0
  91. package/lib/types/common/wayfinder/routers/priority.test.d.ts +1 -0
  92. package/lib/types/common/wayfinder/routers/random.d.ts +27 -0
  93. package/lib/types/common/wayfinder/routers/random.test.d.ts +1 -0
  94. package/lib/types/common/wayfinder/routers/simple-cache.d.ts +28 -0
  95. package/lib/types/common/wayfinder/routers/simple-cache.test.d.ts +1 -0
  96. package/lib/types/common/wayfinder/routers/static.d.ts +24 -0
  97. package/lib/types/common/wayfinder/routers/static.test.d.ts +1 -0
  98. package/lib/types/common/wayfinder/verification/data-root-verifier.d.ts +31 -0
  99. package/lib/types/common/wayfinder/verification/hash-verifier.d.ts +27 -0
  100. package/lib/types/common/wayfinder/wayfinder.d.ts +265 -0
  101. package/lib/types/common/wayfinder/wayfinder.test.d.ts +1 -0
  102. package/lib/types/types/ant.d.ts +53 -1
  103. package/lib/types/types/common.d.ts +7 -2
  104. package/lib/types/types/index.d.ts +1 -0
  105. package/lib/types/types/io.d.ts +23 -6
  106. package/lib/types/types/wayfinder.d.ts +62 -0
  107. package/lib/types/utils/ao.d.ts +1 -12
  108. package/lib/types/utils/hash.d.ts +4 -0
  109. package/lib/types/utils/random.d.ts +7 -0
  110. package/lib/types/utils/url.d.ts +19 -0
  111. package/lib/types/utils/url.test.d.ts +1 -0
  112. package/lib/types/version.d.ts +1 -1
  113. package/lib/types/web/index.d.ts +1 -1
  114. package/package.json +5 -3
@@ -0,0 +1,24 @@
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 const urlWithSearchParams = ({ baseUrl, params, }) => {
17
+ const urlObj = new URL(baseUrl);
18
+ Object.entries(params).forEach(([key, value]) => {
19
+ if (value === undefined || value === null)
20
+ return;
21
+ urlObj.searchParams.set(key, value.toString());
22
+ });
23
+ return urlObj.toString();
24
+ };
@@ -0,0 +1,19 @@
1
+ import assert from 'node:assert';
2
+ import { test } from 'node:test';
3
+ import { urlWithSearchParams } from './url.js';
4
+ test('urlWithSearchParams prunes undefined values but keeps other falsey values', () => {
5
+ const result = urlWithSearchParams({
6
+ baseUrl: 'https://example.com',
7
+ params: {
8
+ number: 1,
9
+ string: 'string',
10
+ boolean: true,
11
+ empty: '',
12
+ zero: 0,
13
+ false: false,
14
+ null: null,
15
+ undef: undefined,
16
+ },
17
+ });
18
+ assert.strictEqual(result, 'https://example.com/?number=1&string=string&boolean=true&empty=&zero=0&false=false');
19
+ });
@@ -1,7 +1,7 @@
1
1
  import { strict as assert } from 'node:assert';
2
2
  import { describe, it } from 'node:test';
3
+ import { errorMessageFromOutput } from './ao.js';
3
4
  import { pruneTags, sortAndPaginateEpochDataIntoEligibleDistributions, } from './arweave.js';
4
- import { errorMessageFromOutput } from './index.js';
5
5
  describe('pruneTags', () => {
6
6
  it('should remove tags with undefined values', () => {
7
7
  const tags = [
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.10.2';
17
+ export const version = '3.11.0-alpha.10';
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { ArweaveSigner, ArconnectSigner } from '@dha-team/arbundles';
16
+ export { ArweaveSigner, ArconnectSigner, InjectedEthereumSigner, EthereumSigner, } from '@dha-team/arbundles';
17
17
  export * from '../types/index.js';
18
18
  export * from '../common/index.js';
19
19
  export * from '../constants.js';
@@ -16,6 +16,6 @@
16
16
  import { AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams } from '../../types/ant.js';
17
17
  import { CLIWriteOptionsFromAoAntParams } from '../types.js';
18
18
  /** @deprecated -- use set-ant-base-name and set-ant-undername */
19
- export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
20
- export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
21
- export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
19
+ export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
20
+ export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
21
+ export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
@@ -19,4 +19,4 @@ export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuy
19
19
  export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
20
20
  export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendLeaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
21
21
  export declare function increaseUndernameLimitCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseUndernameLimitParams>): Promise<import("../../types/common.js").AoMessageResult>;
22
- export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
22
+ export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
@@ -1,11 +1,11 @@
1
1
  import { AddressAndVaultIdCLIWriteOptions, DecreaseDelegateStakeCLIOptions, JoinNetworkCLIOptions, OperatorStakeCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WriteActionCLIOptions } from '../types.js';
2
2
  export declare function joinNetwork(options: JoinNetworkCLIOptions): Promise<{
3
- joinNetworkResult: import("../../types/common.js").AoMessageResult;
3
+ joinNetworkResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
4
4
  joinedAddress: string;
5
5
  message: string;
6
6
  }>;
7
7
  export declare function updateGatewaySettings(options: UpdateGatewaySettingsCLIOptions): Promise<{
8
- updateGatewaySettingsResult: import("../../types/common.js").AoMessageResult;
8
+ updateGatewaySettingsResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
9
9
  updatedGatewayAddress: string;
10
10
  message: string;
11
11
  }>;
@@ -13,26 +13,26 @@ export declare function leaveNetwork(options: WriteActionCLIOptions): Promise<im
13
13
  export declare function saveObservations(o: WriteActionCLIOptions & {
14
14
  failedGateways?: string[];
15
15
  transactionId?: string;
16
- }): Promise<import("../../types/common.js").AoMessageResult>;
16
+ }): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
17
17
  export declare function increaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").WriteOptions>;
18
- export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult>;
19
- export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult>;
20
- export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult>;
18
+ export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
19
+ export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
20
+ export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
21
21
  export declare function delegateStake(options: TransferCLIOptions): Promise<{
22
22
  senderAddress: string;
23
- transferResult: import("../../types/common.js").AoMessageResult;
23
+ transferResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
24
24
  message: string;
25
25
  } | {
26
26
  message: string;
27
27
  }>;
28
28
  export declare function decreaseDelegateStake(options: DecreaseDelegateStakeCLIOptions): Promise<{
29
29
  targetGateway: string;
30
- decreaseDelegateStakeResult: import("../../types/common.js").AoMessageResult;
30
+ decreaseDelegateStakeResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
31
31
  message: string;
32
32
  }>;
33
33
  export declare function redelegateStake(options: RedelegateStakeCLIOptions): Promise<{
34
34
  sourceGateway: string;
35
35
  targetGateway: string;
36
- redelegateStakeResult: import("../../types/common.js").AoMessageResult;
36
+ redelegateStakeResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
37
37
  message: string;
38
38
  }>;
@@ -58,6 +58,7 @@ export declare function getCostDetails(o: GlobalCLIOptions & CLIOptionsFromAoPar
58
58
  basePrice: number;
59
59
  };
60
60
  fundingPlan?: import("../../types/io.js").AoFundingPlan;
61
+ wincQty?: string;
61
62
  }>;
62
63
  export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<import("../../types/common.js").AoPrimaryName>;
63
64
  export declare function getGatewayVaults(o: PaginationAddressCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoGatewayVault> | {
@@ -67,3 +68,4 @@ export declare function getAllGatewayVaults(o: PaginationCLIOptions): Promise<im
67
68
  message: string;
68
69
  }>;
69
70
  export declare function getVault(o: AddressAndVaultIdCLIOptions): Promise<import("../../types/io.js").AoVaultData>;
71
+ export declare function resolveArNSName(o: NameCLIOptions): Promise<import("../../types/io.js").ArNSNameResolutionData>;
@@ -17,7 +17,7 @@ import { AoCreateVaultParams, AoExtendVaultParams, AoIncreaseVaultParams, AoRevo
17
17
  import { CLIWriteOptionsFromAoParams, JsonSerializable, TransferCLIOptions } from '../types.js';
18
18
  export declare function transferCLICommand(options: TransferCLIOptions): Promise<{
19
19
  senderAddress: string;
20
- transferResult: import("../../types/common.js").AoMessageResult;
20
+ transferResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
21
21
  message: string;
22
22
  } | {
23
23
  message: string;
@@ -27,14 +27,14 @@ export declare function revokeVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoR
27
27
  export declare function createVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoCreateVaultParams>): Promise<JsonSerializable>;
28
28
  export declare function extendVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendVaultParams>): Promise<{
29
29
  senderAddress: string;
30
- transferResult: import("../../types/common.js").AoMessageResult;
30
+ transferResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
31
31
  message: string;
32
32
  } | {
33
33
  message: string;
34
34
  }>;
35
35
  export declare function increaseVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseVaultParams>): Promise<{
36
36
  senderAddress: string;
37
- transferResult: import("../../types/common.js").AoMessageResult;
37
+ transferResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
38
38
  message: string;
39
39
  } | {
40
40
  message: string;
@@ -45,6 +45,10 @@ export declare const optionMap: {
45
45
  alias: string;
46
46
  description: string;
47
47
  };
48
+ paymentUrl: {
49
+ alias: string;
50
+ description: string;
51
+ };
48
52
  processId: {
49
53
  alias: string;
50
54
  description: string;
@@ -265,6 +269,11 @@ export declare const optionMap: {
265
269
  alias: string;
266
270
  description: string;
267
271
  };
272
+ token: {
273
+ alias: string;
274
+ description: string;
275
+ default: string;
276
+ };
268
277
  };
269
278
  export declare const walletOptions: {
270
279
  alias: string;
@@ -14,8 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { AoAddressParams, AoArNSNameParams, AoGetVaultParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
17
+ export type SupportedCLITokenType = 'ethereum' | 'arweave';
17
18
  export type WalletCLIOptions = {
18
19
  walletFile?: string;
20
+ token?: SupportedCLITokenType;
19
21
  privateKey?: string;
20
22
  };
21
23
  export type GlobalCLIOptions = WalletCLIOptions & {
@@ -25,6 +27,7 @@ export type GlobalCLIOptions = WalletCLIOptions & {
25
27
  debug: boolean;
26
28
  arioProcessId?: string;
27
29
  cuUrl?: string;
30
+ paymentUrl?: string;
28
31
  };
29
32
  export type WriteActionCLIOptions = GlobalCLIOptions & {
30
33
  tags?: string[];
@@ -22,6 +22,10 @@ export declare function requiredJwkFromOptions(options: WalletCLIOptions): JWKIn
22
22
  export declare function jwkToAddress(jwk: JWKInterface): string;
23
23
  export declare function getLoggerFromOptions(options: GlobalCLIOptions): Logger;
24
24
  export declare function readARIOFromOptions(options: GlobalCLIOptions): AoARIORead;
25
+ export declare function contractSignerFromOptions(options: WalletCLIOptions): {
26
+ signer: ContractSigner;
27
+ signerAddress: string;
28
+ } | undefined;
25
29
  export declare function requiredContractSignerFromOptions(options: WalletCLIOptions): {
26
30
  signer: ContractSigner;
27
31
  signerAddress: string;
@@ -1,5 +1,5 @@
1
1
  import { AoANTVersionsRead, AoANTVersionsWrite } from '../types/ant.js';
2
- import { WithSigner } from '../types/common.js';
2
+ import { AoMessageResult, WithSigner } from '../types/common.js';
3
3
  import { ProcessConfiguration } from '../types/io.js';
4
4
  import { AOProcess } from './contracts/ao-process.js';
5
5
  type ANTVersionsNoSigner = ProcessConfiguration;
@@ -27,16 +27,13 @@ export declare class ANTVersionsReadable implements AoANTVersionsRead {
27
27
  export declare class ANTVersionsWritable extends ANTVersionsReadable implements AoANTVersionsWrite {
28
28
  private signer;
29
29
  constructor({ signer, ...config }: WithSigner<ProcessConfiguration>);
30
- addVersion(params: {
30
+ addVersion({ version, moduleId, luaSourceId, notes, }: {
31
31
  version: string;
32
32
  moduleId: string;
33
33
  luaSourceId?: string;
34
34
  notes?: string;
35
35
  }, { tags }: {
36
36
  tags: any;
37
- }): Promise<{
38
- id: string;
39
- result?: unknown;
40
- }>;
37
+ }): Promise<AoMessageResult>;
41
38
  }
42
39
  export {};
@@ -21,3 +21,4 @@ export * from './ant-versions.js';
21
21
  export * from './faucet.js';
22
22
  export * from './io.js';
23
23
  export * from './contracts/ao-process.js';
24
+ export * from './wayfinder/index.js';
@@ -1,8 +1,9 @@
1
1
  import Arweave from 'arweave';
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, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.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, ArNSNameResolutionData, ArNSNameResolver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
3
3
  import { AOProcess } from './contracts/ao-process.js';
4
- type ARIOConfigNoSigner = OptionalArweave<ProcessConfiguration>;
5
- type ARIOConfigWithSigner = WithSigner<OptionalArweave<ProcessConfiguration>>;
4
+ import { TurboArNSPaymentProviderAuthenticated, TurboArNSPaymentProviderUnauthenticated } from './turbo.js';
5
+ type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
6
+ type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>>;
6
7
  export declare class ARIO {
7
8
  static init(): AoARIORead;
8
9
  static init(config: ARIOConfigWithSigner): AoARIOWrite;
@@ -18,11 +19,12 @@ export declare class ARIO {
18
19
  faucetUrl?: string;
19
20
  }): ARIOWithFaucet<AoARIOWrite>;
20
21
  }
21
- export declare class ARIOReadable implements AoARIORead {
22
+ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
22
23
  readonly process: AOProcess;
23
24
  protected epochSettings: AoEpochSettings | undefined;
24
25
  protected arweave: Arweave;
25
- constructor(config?: OptionalArweave<ProcessConfiguration>);
26
+ protected paymentProvider: TurboArNSPaymentProviderUnauthenticated;
27
+ constructor(config?: ARIOConfigNoSigner);
26
28
  getInfo(): Promise<{
27
29
  Name: string;
28
30
  Ticker: string;
@@ -37,8 +39,8 @@ export declare class ARIOReadable implements AoARIORead {
37
39
  private computeCurrentEpochIndex;
38
40
  private computeEpochIndex;
39
41
  getEpochSettings(): Promise<AoEpochSettings>;
40
- getEpoch(epoch: EpochInput): Promise<AoEpochData<AoEpochDistributed>>;
41
42
  getEpoch(): Promise<AoEpochData<AoEpochDistributionTotalsData>>;
43
+ getEpoch(epoch: EpochInput): Promise<AoEpochData<AoEpochDistributed>>;
42
44
  getArNSRecord({ name }: {
43
45
  name: string;
44
46
  }): Promise<AoArNSNameData>;
@@ -133,11 +135,14 @@ export declare class ARIOReadable implements AoARIORead {
133
135
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
134
136
  getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
135
137
  getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
138
+ resolveArNSName({ name, }: {
139
+ name: string;
140
+ }): Promise<ArNSNameResolutionData>;
136
141
  }
137
142
  export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
138
- readonly process: AOProcess;
139
143
  private signer;
140
- constructor({ signer, ...config }: ARIOConfigWithSigner);
144
+ protected paymentProvider: TurboArNSPaymentProviderAuthenticated | TurboArNSPaymentProviderUnauthenticated;
145
+ constructor({ signer, paymentUrl, ...config }: ARIOConfigWithSigner);
141
146
  transfer({ target, qty, }: {
142
147
  target: string;
143
148
  qty: number | mARIOToken;
@@ -0,0 +1,62 @@
1
+ import { AxiosInstance, RawAxiosRequestHeaders } from 'axios';
2
+ import { AoMessageResult, TransactionId, TurboArNSSigner } from '../types/common.js';
3
+ import { AoTokenCostParams } from '../types/io.js';
4
+ import { mARIOToken } from '../types/token.js';
5
+ import { ILogger } from './logger.js';
6
+ export interface TurboUnauthenticatedConfig {
7
+ paymentUrl?: string;
8
+ logger?: ILogger;
9
+ axios?: AxiosInstance;
10
+ }
11
+ export interface TurboAuthenticatedConfig extends TurboUnauthenticatedConfig {
12
+ signer: TurboArNSSigner;
13
+ }
14
+ export declare function signedRequestHeadersFromSigner({ signer, nonce, }: {
15
+ signer: TurboArNSSigner;
16
+ nonce?: string;
17
+ }): Promise<RawAxiosRequestHeaders>;
18
+ export type ArNSPurchaseReceipt = AoTokenCostParams & {
19
+ wincQty: string;
20
+ mARIOQty: string;
21
+ usdArRate: number;
22
+ createdDate: string;
23
+ };
24
+ export interface ArNSPaymentProvider {
25
+ /** Returns the cost of the action in the Payment Provider's native currency (winc for Turbo) */
26
+ getPrice(params: AoTokenCostParams): Promise<number>;
27
+ getArNSPriceDetails(params: AoTokenCostParams): Promise<{
28
+ winc: string;
29
+ mARIO: mARIOToken;
30
+ }>;
31
+ }
32
+ export interface ArNSAuthenticatedPaymentProvider extends ArNSPaymentProvider {
33
+ initiateArNSPurchase(params: AoTokenCostParams & {
34
+ processId?: TransactionId;
35
+ }): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
36
+ }
37
+ export declare class TurboArNSPaymentFactory {
38
+ static init(): TurboArNSPaymentProviderUnauthenticated;
39
+ static init({ paymentUrl, axios, logger, }: TurboUnauthenticatedConfig & {
40
+ signer?: TurboArNSSigner;
41
+ }): TurboArNSPaymentProviderUnauthenticated;
42
+ static init({ signer, paymentUrl, axios, logger, }: TurboAuthenticatedConfig): TurboArNSPaymentProviderAuthenticated;
43
+ }
44
+ export declare class TurboArNSPaymentProviderUnauthenticated implements ArNSPaymentProvider {
45
+ protected readonly paymentUrl: string;
46
+ protected readonly axios: AxiosInstance;
47
+ protected readonly logger: ILogger;
48
+ constructor({ paymentUrl, axios, logger, }: TurboUnauthenticatedConfig);
49
+ getArNSPriceDetails({ intent, name, quantity, type, years, }: AoTokenCostParams): Promise<{
50
+ winc: string;
51
+ mARIO: mARIOToken;
52
+ }>;
53
+ getPrice(params: AoTokenCostParams): Promise<number>;
54
+ }
55
+ export declare class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnauthenticated implements ArNSAuthenticatedPaymentProvider {
56
+ private readonly signer;
57
+ constructor({ signer, ...restConfig }: TurboAuthenticatedConfig);
58
+ initiateArNSPurchase({ intent, name, quantity, type, processId, years, }: AoTokenCostParams & {
59
+ processId?: TransactionId;
60
+ }): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
61
+ }
62
+ export declare function isTurboArNSSigner(signer: unknown): signer is TurboArNSSigner;
@@ -0,0 +1,51 @@
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 { DataHashProvider, DataRootProvider } from '../../../types/wayfinder.js';
17
+ import { GatewaysProvider } from '../gateways.js';
18
+ export declare class TrustedGatewaysHashProvider implements DataHashProvider, DataRootProvider {
19
+ private gatewaysProvider;
20
+ constructor({ gatewaysProvider, }: {
21
+ gatewaysProvider: GatewaysProvider;
22
+ });
23
+ /**
24
+ * Gets the digest for a given txId from all trusted gateways and ensures they all match.
25
+ * @param txId - The txId to get the digest for.
26
+ * @returns The digest for the given txId.
27
+ */
28
+ getHash({ txId, }: {
29
+ txId: string;
30
+ }): Promise<{
31
+ hash: string;
32
+ algorithm: 'sha256';
33
+ }>;
34
+ /**
35
+ * Get the data root for a given txId from all trusted gateways and ensure they all match.
36
+ * @param txId - The txId to get the data root for.
37
+ * @returns The data root for the given txId.
38
+ */
39
+ getDataRoot({ txId }: {
40
+ txId: string;
41
+ }): Promise<string>;
42
+ }
43
+ /**
44
+ * Note from @djwhitt
45
+ *
46
+ * Calculating data roots this way is fine, but it may not reproduce the original data root.
47
+ * We could also implement a data root verifier that pulls all the chunks, checks that they
48
+ * reproduce the expected data root, and then compares the concatenated chunk data to the
49
+ * original data retrieved. That would take a while, but it should be able to verify any L1
50
+ * data where we can find the chunks.
51
+ */
@@ -0,0 +1,53 @@
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, AoGatewayWithAddress } from '../../types/io.js';
17
+ export interface GatewaysProvider {
18
+ getGateways(): Promise<URL[]>;
19
+ }
20
+ export declare class NetworkGatewaysProvider implements GatewaysProvider {
21
+ private ario;
22
+ private sortBy;
23
+ private sortOrder;
24
+ private limit;
25
+ private filter;
26
+ constructor({ ario, sortBy, sortOrder, limit, filter, }: {
27
+ ario: AoARIORead;
28
+ sortBy?: 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp';
29
+ sortOrder?: 'asc' | 'desc';
30
+ limit?: number;
31
+ blocklist?: string[];
32
+ filter?: (gateway: AoGatewayWithAddress) => boolean;
33
+ });
34
+ getGateways(): Promise<URL[]>;
35
+ }
36
+ export declare class StaticGatewaysProvider implements GatewaysProvider {
37
+ private gateways;
38
+ constructor({ gateways }: {
39
+ gateways: string[];
40
+ });
41
+ getGateways(): Promise<URL[]>;
42
+ }
43
+ export declare class SimpleCacheGatewaysProvider implements GatewaysProvider {
44
+ private gatewaysProvider;
45
+ private ttlSeconds;
46
+ private lastUpdated;
47
+ private gatewaysCache;
48
+ constructor({ gatewaysProvider, ttlSeconds, }: {
49
+ gatewaysProvider: GatewaysProvider;
50
+ ttlSeconds?: number;
51
+ });
52
+ getGateways(): Promise<URL[]>;
53
+ }
@@ -0,0 +1,23 @@
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 * from './wayfinder.js';
17
+ export * from './routers/random.js';
18
+ export * from './routers/priority.js';
19
+ export * from './routers/static.js';
20
+ export * from './gateways.js';
21
+ export * from './gateways/trusted-gateways.js';
22
+ export * from './verification/data-root-verifier.js';
23
+ export * from './verification/hash-verifier.js';
@@ -0,0 +1,29 @@
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 { WayfinderRouter } from '../../../types/wayfinder.js';
17
+ import { AoARIORead } from '../../../web/index.js';
18
+ import { NetworkGatewaysProvider } from '../gateways.js';
19
+ export declare class PriorityGatewayRouter implements WayfinderRouter {
20
+ readonly name = "priority";
21
+ readonly gatewaysProvider: NetworkGatewaysProvider;
22
+ constructor({ ario, sortBy, sortOrder, limit, }: {
23
+ ario: AoARIORead;
24
+ sortBy: 'operatorStake' | 'totalDelegatedStake' | 'startTimestamp';
25
+ sortOrder: 'asc' | 'desc';
26
+ limit: number;
27
+ });
28
+ getTargetGateway(): Promise<URL>;
29
+ }
@@ -0,0 +1,27 @@
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 { WayfinderRouter } from '../../../types/wayfinder.js';
17
+ import { GatewaysProvider } from '../gateways.js';
18
+ export declare class RandomGatewayRouter implements WayfinderRouter {
19
+ readonly name = "random";
20
+ private gatewaysProvider;
21
+ private blocklist;
22
+ constructor({ gatewaysProvider, blocklist, }: {
23
+ gatewaysProvider: GatewaysProvider;
24
+ blocklist?: string[];
25
+ });
26
+ getTargetGateway(): Promise<URL>;
27
+ }
@@ -0,0 +1,28 @@
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 { WayfinderRouter } from '../../../types/wayfinder.js';
17
+ export declare class SimpleCacheRouter implements WayfinderRouter {
18
+ readonly name: 'simple-cache';
19
+ private lastUpdatedTimestamp;
20
+ private ttlSeconds;
21
+ private targetGateway;
22
+ private router;
23
+ constructor({ router, ttlSeconds, }: {
24
+ router: WayfinderRouter;
25
+ ttlSeconds?: number;
26
+ });
27
+ getTargetGateway(): Promise<URL>;
28
+ }
@@ -0,0 +1,24 @@
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 { WayfinderRouter } from '../../../types/wayfinder.js';
17
+ export declare class StaticGatewayRouter implements WayfinderRouter {
18
+ readonly name = "static";
19
+ private gateway;
20
+ constructor({ gateway }: {
21
+ gateway: string;
22
+ });
23
+ getTargetGateway(): Promise<URL>;
24
+ }