@ar.io/sdk 3.1.0-alpha.1 → 3.1.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 (34) hide show
  1. package/bundles/web.bundle.min.js +68 -68
  2. package/lib/cjs/cli/cli.js +19 -69
  3. package/lib/cjs/cli/commands/arnsPurchaseCommands.js +167 -0
  4. package/lib/cjs/cli/commands/gatewayWriteCommands.js +8 -4
  5. package/lib/cjs/cli/commands/readCommands.js +1 -22
  6. package/lib/cjs/cli/commands/transfer.js +5 -1
  7. package/lib/cjs/cli/options.js +8 -7
  8. package/lib/cjs/cli/utils.js +39 -7
  9. package/lib/cjs/common/contracts/ao-process.js +34 -16
  10. package/lib/cjs/common/io.js +76 -116
  11. package/lib/cjs/utils/arweave.js +22 -13
  12. package/lib/cjs/version.js +1 -1
  13. package/lib/esm/cli/cli.js +21 -71
  14. package/lib/esm/cli/commands/arnsPurchaseCommands.js +159 -0
  15. package/lib/esm/cli/commands/gatewayWriteCommands.js +6 -2
  16. package/lib/esm/cli/commands/readCommands.js +2 -23
  17. package/lib/esm/cli/commands/transfer.js +6 -2
  18. package/lib/esm/cli/options.js +7 -6
  19. package/lib/esm/cli/utils.js +34 -5
  20. package/lib/esm/common/contracts/ao-process.js +34 -16
  21. package/lib/esm/common/io.js +77 -117
  22. package/lib/esm/utils/arweave.js +21 -11
  23. package/lib/esm/version.js +1 -1
  24. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +22 -0
  25. package/lib/types/cli/options.d.ts +1 -9
  26. package/lib/types/cli/types.d.ts +3 -5
  27. package/lib/types/cli/utils.d.ts +16 -3
  28. package/lib/types/common/contracts/ao-process.d.ts +1 -0
  29. package/lib/types/common/io.d.ts +14 -43
  30. package/lib/types/types/common.d.ts +1 -0
  31. package/lib/types/types/io.d.ts +15 -9
  32. package/lib/types/utils/arweave.d.ts +6 -18
  33. package/lib/types/version.d.ts +1 -1
  34. package/package.json +2 -2
@@ -1,8 +1,22 @@
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
+ */
1
16
  import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
2
17
  import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
3
18
  import { createAoSigner } from '../utils/ao.js';
4
- import { getCurrentBlockUnixTimestampMs, paginationParamsToTags, pruneTags, } from '../utils/arweave.js';
5
- import { defaultArweave } from './arweave.js';
19
+ import { paginationParamsToTags, pruneTags } from '../utils/arweave.js';
6
20
  import { AOProcess } from './contracts/ao-process.js';
7
21
  import { InvalidContractConfigurationError } from './error.js';
8
22
  export class ARIO {
@@ -19,8 +33,8 @@ export class ARIO {
19
33
  }
20
34
  export class ARIOReadable {
21
35
  process;
22
- arweave;
23
- constructor(config, arweave = defaultArweave) {
36
+ epochSettings;
37
+ constructor(config) {
24
38
  if (!config) {
25
39
  this.process = new AOProcess({
26
40
  processId: ARIO_TESTNET_PROCESS_ID,
@@ -37,7 +51,6 @@ export class ARIOReadable {
37
51
  else {
38
52
  throw new InvalidContractConfigurationError();
39
53
  }
40
- this.arweave = arweave;
41
54
  }
42
55
  async getInfo() {
43
56
  return this.process.read({
@@ -49,35 +62,32 @@ export class ARIOReadable {
49
62
  tags: [{ name: 'Action', value: 'Total-Token-Supply' }],
50
63
  });
51
64
  }
52
- async getEpochSettings(params) {
53
- const allTags = [
54
- { name: 'Action', value: 'Epoch-Settings' },
55
- {
56
- name: 'Timestamp',
57
- value: params?.timestamp?.toString() ??
58
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
59
- },
60
- {
61
- name: 'Epoch-Index',
62
- value: params?.epochIndex?.toString(),
63
- },
64
- ];
65
- return this.process.read({
66
- tags: pruneTags(allTags),
67
- });
65
+ async computeEpochIndexForTimestamp(timestamp) {
66
+ const epochSettings = await this.getEpochSettings();
67
+ const epochZeroStartTimestamp = epochSettings.epochZeroStartTimestamp;
68
+ const epochLengthMs = epochSettings.durationMs;
69
+ return Math.floor((timestamp - epochZeroStartTimestamp) / epochLengthMs);
70
+ }
71
+ async computeEpochIndex(params) {
72
+ const epochIndex = params?.epochIndex;
73
+ if (epochIndex !== undefined) {
74
+ return epochIndex.toString();
75
+ }
76
+ const timestamp = params?.timestamp;
77
+ if (timestamp !== undefined) {
78
+ return (await this.computeEpochIndexForTimestamp(timestamp)).toString();
79
+ }
80
+ return undefined;
81
+ }
82
+ async getEpochSettings() {
83
+ return (this.epochSettings ??= await this.process.read({
84
+ tags: [{ name: 'Action', value: 'Epoch-Settings' }],
85
+ }));
68
86
  }
69
87
  async getEpoch(epoch) {
70
88
  const allTags = [
71
89
  { name: 'Action', value: 'Epoch' },
72
- {
73
- name: 'Timestamp',
74
- value: epoch?.timestamp?.toString() ??
75
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
76
- },
77
- {
78
- name: 'Epoch-Index',
79
- value: epoch?.epochIndex?.toString(),
80
- },
90
+ { name: 'Epoch-Index', value: await this.computeEpochIndex(epoch) },
81
91
  ];
82
92
  return this.process.read({
83
93
  tags: pruneTags(allTags),
@@ -184,27 +194,13 @@ export class ARIOReadable {
184
194
  }
185
195
  async getCurrentEpoch() {
186
196
  return this.process.read({
187
- tags: [
188
- { name: 'Action', value: 'Epoch' },
189
- {
190
- name: 'Timestamp',
191
- value: (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
192
- },
193
- ],
197
+ tags: [{ name: 'Action', value: 'Epoch' }],
194
198
  });
195
199
  }
196
200
  async getPrescribedObservers(epoch) {
197
201
  const allTags = [
198
202
  { name: 'Action', value: 'Epoch-Prescribed-Observers' },
199
- {
200
- name: 'Timestamp',
201
- value: epoch?.timestamp?.toString() ??
202
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
203
- },
204
- {
205
- name: 'Epoch-Index',
206
- value: epoch?.epochIndex?.toString(),
207
- },
203
+ { name: 'Epoch-Index', value: await this.computeEpochIndex(epoch) },
208
204
  ];
209
205
  return this.process.read({
210
206
  tags: pruneTags(allTags),
@@ -213,15 +209,7 @@ export class ARIOReadable {
213
209
  async getPrescribedNames(epoch) {
214
210
  const allTags = [
215
211
  { name: 'Action', value: 'Epoch-Prescribed-Names' },
216
- {
217
- name: 'Timestamp',
218
- value: epoch?.timestamp?.toString() ??
219
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
220
- },
221
- {
222
- name: 'Epoch-Index',
223
- value: epoch?.epochIndex?.toString(),
224
- },
212
+ { name: 'Epoch-Index', value: await this.computeEpochIndex(epoch) },
225
213
  ];
226
214
  return this.process.read({
227
215
  tags: pruneTags(allTags),
@@ -230,15 +218,7 @@ export class ARIOReadable {
230
218
  async getObservations(epoch) {
231
219
  const allTags = [
232
220
  { name: 'Action', value: 'Epoch-Observations' },
233
- {
234
- name: 'Timestamp',
235
- value: epoch?.timestamp?.toString() ??
236
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
237
- },
238
- {
239
- name: 'Epoch-Index',
240
- value: epoch?.epochIndex?.toString(),
241
- },
221
+ { name: 'Epoch-Index', value: await this.computeEpochIndex(epoch) },
242
222
  ];
243
223
  return this.process.read({
244
224
  tags: pruneTags(allTags),
@@ -247,15 +227,7 @@ export class ARIOReadable {
247
227
  async getDistributions(epoch) {
248
228
  const allTags = [
249
229
  { name: 'Action', value: 'Epoch-Distributions' },
250
- {
251
- name: 'Timestamp',
252
- value: epoch?.timestamp?.toString() ??
253
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
254
- },
255
- {
256
- name: 'Epoch-Index',
257
- value: epoch?.epochIndex?.toString(),
258
- },
230
+ { name: 'Epoch-Index', value: await this.computeEpochIndex(epoch) },
259
231
  ];
260
232
  return this.process.read({
261
233
  tags: pruneTags(allTags),
@@ -284,17 +256,6 @@ export class ARIOReadable {
284
256
  name: 'Purchase-Type',
285
257
  value: type,
286
258
  },
287
- {
288
- name: 'Timestamp',
289
- value: (await this.arweave.blocks
290
- .getCurrent()
291
- .then((block) => {
292
- return { timestamp: block.timestamp * 1000 };
293
- })
294
- .catch(() => {
295
- return { timestamp: Date.now() }; // fallback to current time
296
- })).timestamp.toString(),
297
- },
298
259
  ];
299
260
  return this.process.read({
300
261
  tags: pruneTags(allTags),
@@ -329,17 +290,6 @@ export class ARIOReadable {
329
290
  name: 'Fund-From',
330
291
  value: fundFrom,
331
292
  },
332
- {
333
- name: 'Timestamp',
334
- value: (await this.arweave.blocks
335
- .getCurrent()
336
- .then((block) => {
337
- return { timestamp: block.timestamp * 1000 };
338
- })
339
- .catch(() => {
340
- return { timestamp: Date.now() }; // fallback to current time
341
- })).timestamp.toString(),
342
- },
343
293
  ];
344
294
  return this.process.read({
345
295
  tags: pruneTags(allTags),
@@ -708,6 +658,7 @@ export class ARIOWriteable extends ARIOReadable {
708
658
  { name: 'Years', value: params.years?.toString() ?? '1' },
709
659
  { name: 'Process-Id', value: params.processId },
710
660
  { name: 'Purchase-Type', value: params.type || 'lease' },
661
+ { name: 'Fund-From', value: params.fundFrom },
711
662
  ];
712
663
  return this.process.send({
713
664
  signer: this.signer,
@@ -724,13 +675,15 @@ export class ARIOWriteable extends ARIOReadable {
724
675
  */
725
676
  async upgradeRecord(params, options) {
726
677
  const { tags = [] } = options || {};
678
+ const allTags = [
679
+ ...tags,
680
+ { name: 'Action', value: 'Upgrade-Name' }, // TODO: align on Update-Record vs. Upgrade-Name (contract currently uses Upgrade-Name)
681
+ { name: 'Name', value: params.name },
682
+ { name: 'Fund-From', value: params.fundFrom },
683
+ ];
727
684
  return this.process.send({
728
685
  signer: this.signer,
729
- tags: [
730
- ...tags,
731
- { name: 'Action', value: 'Upgrade-Name' }, // TODO: align on Update-Record vs. Upgrade-Name (contract currently uses Upgrade-Name)
732
- { name: 'Name', value: params.name },
733
- ],
686
+ tags: pruneTags(allTags),
734
687
  });
735
688
  }
736
689
  /**
@@ -744,26 +697,30 @@ export class ARIOWriteable extends ARIOReadable {
744
697
  */
745
698
  async extendLease(params, options) {
746
699
  const { tags = [] } = options || {};
700
+ const allTags = [
701
+ ...tags,
702
+ { name: 'Action', value: 'Extend-Lease' },
703
+ { name: 'Name', value: params.name },
704
+ { name: 'Years', value: params.years.toString() },
705
+ { name: 'Fund-From', value: params.fundFrom },
706
+ ];
747
707
  return this.process.send({
748
708
  signer: this.signer,
749
- tags: [
750
- ...tags,
751
- { name: 'Action', value: 'Extend-Lease' },
752
- { name: 'Name', value: params.name },
753
- { name: 'Years', value: params.years.toString() },
754
- ],
709
+ tags: pruneTags(allTags),
755
710
  });
756
711
  }
757
712
  async increaseUndernameLimit(params, options) {
758
713
  const { tags = [] } = options || {};
714
+ const allTags = [
715
+ ...tags,
716
+ { name: 'Action', value: 'Increase-Undername-Limit' },
717
+ { name: 'Name', value: params.name },
718
+ { name: 'Quantity', value: params.increaseCount.toString() },
719
+ { name: 'Fund-From', value: params.fundFrom },
720
+ ];
759
721
  return this.process.send({
760
722
  signer: this.signer,
761
- tags: [
762
- ...tags,
763
- { name: 'Action', value: 'Increase-Undername-Limit' },
764
- { name: 'Name', value: params.name },
765
- { name: 'Quantity', value: params.increaseCount.toString() },
766
- ],
723
+ tags: pruneTags(allTags),
767
724
  });
768
725
  }
769
726
  /**
@@ -788,13 +745,16 @@ export class ARIOWriteable extends ARIOReadable {
788
745
  tags: pruneTags(allTags),
789
746
  });
790
747
  }
791
- async requestPrimaryName(params) {
748
+ async requestPrimaryName(params, options) {
749
+ const { tags = [] } = options || {};
750
+ const allTags = [
751
+ ...tags,
752
+ { name: 'Action', value: 'Request-Primary-Name' },
753
+ { name: 'Name', value: params.name },
754
+ ];
792
755
  return this.process.send({
793
756
  signer: this.signer,
794
- tags: [
795
- { name: 'Action', value: 'Request-Primary-Name' },
796
- { name: 'Name', value: params.name },
797
- ],
757
+ tags: pruneTags(allTags),
798
758
  });
799
759
  }
800
760
  /**
@@ -1,3 +1,18 @@
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
+ */
1
16
  import { ARWEAVE_TX_REGEX } from '../constants.js';
2
17
  export const validateArweaveId = (id) => {
3
18
  return ARWEAVE_TX_REGEX.test(id);
@@ -5,18 +20,13 @@ export const validateArweaveId = (id) => {
5
20
  export function isBlockHeight(height) {
6
21
  return height !== undefined && !isNaN(parseInt(height.toString()));
7
22
  }
23
+ /**
24
+ * Prune tags that are undefined or empty.
25
+ * @param tags - The tags to prune.
26
+ * @returns The pruned tags.
27
+ */
8
28
  export const pruneTags = (tags) => {
9
- return tags.filter((tag) => tag.value !== undefined);
10
- };
11
- export const getCurrentBlockUnixTimestampMs = async (arweave) => {
12
- return await arweave.blocks
13
- .getCurrent()
14
- .then((block) => {
15
- return block.timestamp * 1000;
16
- })
17
- .catch(() => {
18
- return Date.now(); // fallback to current time
19
- });
29
+ return tags.filter((tag) => tag.value !== undefined && tag.value !== '');
20
30
  };
21
31
  export const paginationParamsToTags = (params) => {
22
32
  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.1.0-alpha.1';
17
+ export const version = '3.1.0-alpha.10';
@@ -0,0 +1,22 @@
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 { AoArNSPurchaseParams, AoBuyRecordParams, AoExtendLeaseParams, AoIncreaseUndernameLimitParams } from '../../types/io.js';
17
+ import { CLIWriteOptionsFromAoParams } from '../types.js';
18
+ export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuyRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
19
+ export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
20
+ export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendLeaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
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>;
@@ -248,15 +248,7 @@ export declare const writeActionOptions: {
248
248
  description: string;
249
249
  type: string;
250
250
  }[];
251
- export declare const addressOptions: {
252
- alias: string;
253
- description: string;
254
- }[];
255
- export declare const nameOptions: {
256
- alias: string;
257
- description: string;
258
- }[];
259
- export declare const initiatorOptions: {
251
+ export declare const arnsPurchaseOptions: {
260
252
  alias: string;
261
253
  description: string;
262
254
  }[];
@@ -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
- import { AoAddressParams, AoArNSNameParams, AoBuyRecordParams, AoExtendLeaseParams, AoGetVaultParams, AoIncreaseUndernameLimitParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
16
+ import { AoAddressParams, AoArNSNameParams, AoGetVaultParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
17
17
  export type WalletCLIOptions = {
18
18
  walletFile?: string;
19
19
  privateKey?: string;
@@ -47,6 +47,8 @@ export type ProcessIdWriteActionCLIOptions = WriteActionCLIOptions & {
47
47
  export type CLIOptionsFromAoParams<T> = {
48
48
  [K in keyof T]?: T[K] extends number | undefined ? string | undefined : T[K] extends string | boolean | symbol ? string : T[K] extends ReadonlyArray<infer U> ? ReadonlyArray<U> : T[K] extends object ? CLIOptionsFromAoParams<T[K]> : T[K];
49
49
  };
50
+ export type CLIReadOptionsFromAoParams<T> = CLIOptionsFromAoParams<T> & GlobalCLIOptions;
51
+ export type CLIWriteOptionsFromAoParams<T> = WriteActionCLIOptions & CLIOptionsFromAoParams<T>;
50
52
  export type PaginationCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<PaginationParams>;
51
53
  export type AddressCLIOptions = GlobalCLIOptions & CLIOptionsFromAoParams<AoAddressParams>;
52
54
  export type ProcessIdCLIOptions = GlobalCLIOptions & {
@@ -86,10 +88,6 @@ export type OperatorStakeCLIOptions = WriteActionCLIOptions & {
86
88
  export type DecreaseDelegateStakeCLIOptions = DelegateStakeCLIOptions & {
87
89
  instant: boolean;
88
90
  };
89
- export type BuyRecordCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoBuyRecordParams>;
90
- export type UpgradeRecordCLIOptions = NameWriteCLIOptions;
91
- export type ExtendLeaseCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoExtendLeaseParams>;
92
- export type IncreaseUndernameLimitCLIOptions = WriteActionCLIOptions & CLIOptionsFromAoParams<AoIncreaseUndernameLimitParams>;
93
91
  export type ANTStateCLIOptions = WriteActionCLIOptions & {
94
92
  target?: string;
95
93
  keywords?: string[];
@@ -1,6 +1,6 @@
1
1
  import { JWKInterface } from 'arweave/node/lib/wallet.js';
2
2
  import { Command, OptionValues } from 'commander';
3
- import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
3
+ import { ARIOToken, AoANTRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
4
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>;
@@ -31,6 +31,7 @@ export declare function writeARIOFromOptions(options: GlobalCLIOptions): {
31
31
  signerAddress: string;
32
32
  };
33
33
  export declare function formatARIOWithCommas(value: ARIOToken): string;
34
+ export declare function formatMARIOToARIOWithCommas(value: mARIOToken): string;
34
35
  /** helper to get address from --address option first, then check wallet options */
35
36
  export declare function addressFromOptions<O extends AddressCLIOptions>(options: O): string | undefined;
36
37
  export declare function requiredAddressFromOptions<O extends AddressCLIOptions>(options: O): string;
@@ -51,8 +52,17 @@ export declare function redelegateParamsFromOptions(options: RedelegateStakeCLIO
51
52
  export declare function recordTypeFromOptions<O extends {
52
53
  type?: string;
53
54
  }>(options: O): 'lease' | 'permabuy';
54
- export declare function requiredMIOFromOptions<O extends GlobalCLIOptions>(options: O, key: string): mARIOToken;
55
- export declare function assertEnoughBalance(ario: AoARIORead, address: string, arioQuantity: ARIOToken): Promise<void>;
55
+ export declare function requiredMARIOFromOptions<O extends GlobalCLIOptions>(options: O, key: string): mARIOToken;
56
+ export declare function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }: {
57
+ ario: AoARIORead;
58
+ address: string;
59
+ costDetailsParams: AoGetCostDetailsParams;
60
+ }): Promise<void>;
61
+ export declare function assertEnoughMARIOBalance({ address, ario, mARIOQuantity, }: {
62
+ ario: AoARIORead;
63
+ address: string;
64
+ mARIOQuantity: mARIOToken | number;
65
+ }): Promise<void>;
56
66
  export declare function confirmationPrompt(message: string): Promise<boolean>;
57
67
  export declare function assertConfirmationPrompt<O extends {
58
68
  skipConfirmation?: boolean;
@@ -73,3 +83,6 @@ export declare function getTokenCostParamsFromOptions(o: GetTokenCostCLIOptions)
73
83
  name: string;
74
84
  fromAddress: string | undefined;
75
85
  };
86
+ export declare function fundFromFromOptions<O extends {
87
+ fundFrom?: string;
88
+ }>(o: O): FundFrom;
@@ -9,6 +9,7 @@ export declare class AOProcess implements AOContract {
9
9
  ao?: AoClient;
10
10
  logger?: ILogger;
11
11
  });
12
+ private isMessageDataEmpty;
12
13
  read<K>({ tags, retries, fromAddress, }: {
13
14
  tags?: Array<{
14
15
  name: string;
@@ -1,21 +1,5 @@
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 Arweave from 'arweave';
17
1
  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, AoGetCostDetailsParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
2
+ import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
19
3
  import { mARIOToken } from '../types/token.js';
20
4
  import { AOProcess } from './contracts/ao-process.js';
21
5
  export declare class ARIO {
@@ -27,7 +11,7 @@ export declare class ARIO {
27
11
  process: AOProcess;
28
12
  }>): AoARIOWrite;
29
13
  static init({ processId, signer, }: WithSigner<{
30
- processId: string;
14
+ processId?: string;
31
15
  }>): AoARIOWrite;
32
16
  static init({ processId, signer, }: {
33
17
  signer?: ContractSigner | undefined;
@@ -39,8 +23,8 @@ export declare class ARIO {
39
23
  }
40
24
  export declare class ARIOReadable implements AoARIORead {
41
25
  protected process: AOProcess;
42
- private arweave;
43
- constructor(config?: ProcessConfiguration, arweave?: Arweave);
26
+ protected epochSettings: AoEpochSettings | undefined;
27
+ constructor(config?: ProcessConfiguration);
44
28
  getInfo(): Promise<{
45
29
  Name: string;
46
30
  Ticker: string;
@@ -50,7 +34,9 @@ export declare class ARIOReadable implements AoARIORead {
50
34
  LastTickedEpochIndex: number;
51
35
  }>;
52
36
  getTokenSupply(): Promise<AoTokenSupplyData>;
53
- getEpochSettings(params?: EpochInput): Promise<AoEpochSettings>;
37
+ private computeEpochIndexForTimestamp;
38
+ private computeEpochIndex;
39
+ getEpochSettings(): Promise<AoEpochSettings>;
54
40
  getEpoch(epoch?: EpochInput): Promise<AoEpochData>;
55
41
  getArNSRecord({ name, }: {
56
42
  name: string;
@@ -67,7 +53,7 @@ export declare class ARIOReadable implements AoARIORead {
67
53
  getVault({ address, vaultId, }: {
68
54
  address: WalletAddress;
69
55
  vaultId: string;
70
- }): Promise<AoVaultData>;
56
+ }): Promise<AoVaultData | undefined>;
71
57
  getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
72
58
  getGateway({ address, }: {
73
59
  address: WalletAddress;
@@ -125,7 +111,7 @@ export declare class ARIOReadable implements AoARIORead {
125
111
  getPrimaryNameRequest(params: {
126
112
  initiator: WalletAddress;
127
113
  }): Promise<AoPrimaryNameRequest>;
128
- getPrimaryNameRequests(params: PaginationParams<AoPrimaryNameRequest>): Promise<PaginationResult<AoPrimaryNameRequest>>;
114
+ getPrimaryNameRequests(params?: PaginationParams<AoPrimaryNameRequest>): Promise<PaginationResult<AoPrimaryNameRequest>>;
129
115
  getPrimaryName(params: {
130
116
  address: WalletAddress;
131
117
  } | {
@@ -191,12 +177,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
191
177
  reportTxId: TransactionId;
192
178
  failedGateways: WalletAddress[];
193
179
  }, options?: WriteOptions): Promise<AoMessageResult>;
194
- buyRecord(params: {
195
- name: string;
196
- years?: number;
197
- type: 'lease' | 'permabuy';
198
- processId: string;
199
- }, options?: WriteOptions): Promise<AoMessageResult>;
180
+ buyRecord(params: AoBuyRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
200
181
  /**
201
182
  * Upgrades an existing leased record to a permabuy.
202
183
  *
@@ -205,9 +186,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
205
186
  * @param {Object} [options] - The options for the upgrade
206
187
  * @returns {Promise<AoMessageResult>} The result of the upgrade
207
188
  */
208
- upgradeRecord(params: {
209
- name: string;
210
- }, options?: WriteOptions): Promise<AoMessageResult>;
189
+ upgradeRecord(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
211
190
  /**
212
191
  * Extends the lease of an existing leased record.
213
192
  *
@@ -217,14 +196,8 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
217
196
  * @param {Object} [options] - The options for the extension
218
197
  * @returns {Promise<AoMessageResult>} The result of the extension
219
198
  */
220
- extendLease(params: {
221
- name: string;
222
- years: number;
223
- }, options?: WriteOptions): Promise<AoMessageResult>;
224
- increaseUndernameLimit(params: {
225
- name: string;
226
- increaseCount: number;
227
- }, options?: WriteOptions): Promise<AoMessageResult>;
199
+ extendLease(params: AoExtendLeaseParams, options?: WriteOptions): Promise<AoMessageResult>;
200
+ increaseUndernameLimit(params: AoIncreaseUndernameLimitParams, options?: WriteOptions): Promise<AoMessageResult>;
228
201
  /**
229
202
  * Cancel a withdrawal from a gateway.
230
203
  *
@@ -238,9 +211,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
238
211
  gatewayAddress?: WalletAddress;
239
212
  vaultId: string;
240
213
  }, options?: WriteOptions | undefined): Promise<AoMessageResult>;
241
- requestPrimaryName(params: {
242
- name: string;
243
- }): Promise<AoMessageResult>;
214
+ requestPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
244
215
  /**
245
216
  * Redelegate stake from one gateway to another gateway.
246
217
  *
@@ -52,6 +52,7 @@ export type AoPrimaryNameRequest = {
52
52
  };
53
53
  export type AoPrimaryName = {
54
54
  owner: WalletAddress;
55
+ processId: ProcessId;
55
56
  name: string;
56
57
  startTimestamp: Timestamp;
57
58
  };