@ar.io/sdk 2.5.0-alpha.1 → 2.5.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.
@@ -96,7 +96,7 @@ class AoANTReadable {
96
96
  return record;
97
97
  }
98
98
  /**
99
- * @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
99
+ * @returns {Promise<AoANTRecordEntry[]>} All the undernames managed by the ANT.
100
100
  * @example
101
101
  * Get the current records
102
102
  * ```ts
@@ -108,9 +108,10 @@ class AoANTReadable {
108
108
  const records = await this.process.read({
109
109
  tags,
110
110
  });
111
+ const result = (0, ao_js_1.parseAntRecords)(records);
111
112
  if (strict)
112
- (0, schema_js_1.parseSchemaResult)(ant_js_1.AntRecordsSchema, records);
113
- return records;
113
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntEntriesSchema, result);
114
+ return result;
114
115
  }
115
116
  /**
116
117
  * @returns {Promise<string>} The owner of the ANT.
@@ -30,5 +30,5 @@ exports.IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
30
30
  exports.ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
31
31
  exports.MIO_PER_IO = 1_000_000;
32
32
  exports.AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
33
- exports.ANT_LUA_ID = 'pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30';
33
+ exports.ANT_LUA_ID = 'AWO2a2lVfQnjPFThjE4Uuw4ZFAd9EsCHBEgDYkJA-kk'; // v8 id test - remove comment when updated with actual v8 id.
34
34
  exports.DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAoANTState = exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = exports.AntRecordSchema = exports.AntKeywordsSchema = exports.AntDescriptionSchema = exports.IntegerStringSchema = exports.ArweaveTxIdSchema = void 0;
3
+ exports.isAoANTState = exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntEntriesSchema = exports.AntRecordsSchema = exports.AntEntrySchema = exports.AntRecordSchema = exports.AntKeywordsSchema = exports.AntDescriptionSchema = exports.IntegerStringSchema = exports.ArweaveTxIdSchema = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -51,7 +51,9 @@ exports.AntRecordSchema = zod_1.z.object({
51
51
  transactionId: exports.ArweaveTxIdSchema.describe('The Target ID of the undername'),
52
52
  ttlSeconds: zod_1.z.number(),
53
53
  });
54
+ exports.AntEntrySchema = zod_1.z.intersection(exports.AntRecordSchema, zod_1.z.object({ name: zod_1.z.string() }));
54
55
  exports.AntRecordsSchema = zod_1.z.record(zod_1.z.string(), exports.AntRecordSchema);
56
+ exports.AntEntriesSchema = zod_1.z.array(exports.AntEntrySchema);
55
57
  exports.AntControllersSchema = zod_1.z.array(exports.ArweaveTxIdSchema.describe('Controller address'));
56
58
  exports.AntBalancesSchema = zod_1.z.record(exports.ArweaveTxIdSchema.describe('Holder address'), zod_1.z.number());
57
59
  exports.AntStateSchema = zod_1.z.object({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
3
+ exports.parseAntRecords = exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -177,3 +177,29 @@ function createAoSigner(signer) {
177
177
  return aoSigner;
178
178
  }
179
179
  exports.createAoSigner = createAoSigner;
180
+ /**
181
+ * @param records @type {AoANTRecordEntry[] | Record<string, AoANTRecord>} - the records returned by an ANT
182
+ * @returns @type {AoANTRecordEntry[]} - the alphabetically sorted records
183
+ */
184
+ function parseAntRecords(records) {
185
+ const result = Array.isArray(records)
186
+ ? records // assumes if records is an array that its AoANTRecordEntry[]
187
+ : // backwards compatibility for when ANTs returned as Record<string, AoANTRecord>
188
+ Object.keys(records) // sort the keys since string indexed maps in lua do not retain order
189
+ .sort((a, b) => {
190
+ if (a == '@')
191
+ return -1;
192
+ if (b == '@')
193
+ return 1;
194
+ return a.localeCompare(b);
195
+ })
196
+ .reduce((acc, undername) => {
197
+ acc.push({
198
+ ...records[undername],
199
+ name: undername,
200
+ });
201
+ return acc;
202
+ }, []);
203
+ return result;
204
+ }
205
+ exports.parseAntRecords = parseAntRecords;
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '2.5.0-alpha.1';
20
+ exports.version = '2.5.0-alpha.2';
@@ -14,9 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { z } from 'zod';
17
- import { AntBalancesSchema, AntControllersSchema, AntInfoSchema, AntRecordSchema, AntRecordsSchema, AntStateSchema, } from '../types/ant.js';
17
+ import { AntBalancesSchema, AntControllersSchema, AntEntriesSchema, AntInfoSchema, AntRecordSchema, AntStateSchema, } from '../types/ant.js';
18
18
  import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
19
- import { createAoSigner } from '../utils/ao.js';
19
+ import { createAoSigner, parseAntRecords } from '../utils/ao.js';
20
20
  import { parseSchemaResult } from '../utils/schema.js';
21
21
  import { AOProcess, InvalidContractConfigurationError } from './index.js';
22
22
  export class ANT {
@@ -92,7 +92,7 @@ export class AoANTReadable {
92
92
  return record;
93
93
  }
94
94
  /**
95
- * @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
95
+ * @returns {Promise<AoANTRecordEntry[]>} All the undernames managed by the ANT.
96
96
  * @example
97
97
  * Get the current records
98
98
  * ```ts
@@ -104,9 +104,10 @@ export class AoANTReadable {
104
104
  const records = await this.process.read({
105
105
  tags,
106
106
  });
107
+ const result = parseAntRecords(records);
107
108
  if (strict)
108
- parseSchemaResult(AntRecordsSchema, records);
109
- return records;
109
+ parseSchemaResult(AntEntriesSchema, result);
110
+ return result;
110
111
  }
111
112
  /**
112
113
  * @returns {Promise<string>} The owner of the ANT.
@@ -27,5 +27,5 @@ export const IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdi
27
27
  export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
28
28
  export const MIO_PER_IO = 1_000_000;
29
29
  export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
30
- export const ANT_LUA_ID = 'pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30';
30
+ export const ANT_LUA_ID = 'AWO2a2lVfQnjPFThjE4Uuw4ZFAd9EsCHBEgDYkJA-kk'; // v8 id test - remove comment when updated with actual v8 id.
31
31
  export const DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
@@ -48,7 +48,9 @@ export const AntRecordSchema = z.object({
48
48
  transactionId: ArweaveTxIdSchema.describe('The Target ID of the undername'),
49
49
  ttlSeconds: z.number(),
50
50
  });
51
+ export const AntEntrySchema = z.intersection(AntRecordSchema, z.object({ name: z.string() }));
51
52
  export const AntRecordsSchema = z.record(z.string(), AntRecordSchema);
53
+ export const AntEntriesSchema = z.array(AntEntrySchema);
52
54
  export const AntControllersSchema = z.array(ArweaveTxIdSchema.describe('Controller address'));
53
55
  export const AntBalancesSchema = z.record(ArweaveTxIdSchema.describe('Holder address'), z.number());
54
56
  export const AntStateSchema = z.object({
@@ -170,3 +170,28 @@ export function createAoSigner(signer) {
170
170
  };
171
171
  return aoSigner;
172
172
  }
173
+ /**
174
+ * @param records @type {AoANTRecordEntry[] | Record<string, AoANTRecord>} - the records returned by an ANT
175
+ * @returns @type {AoANTRecordEntry[]} - the alphabetically sorted records
176
+ */
177
+ export function parseAntRecords(records) {
178
+ const result = Array.isArray(records)
179
+ ? records // assumes if records is an array that its AoANTRecordEntry[]
180
+ : // backwards compatibility for when ANTs returned as Record<string, AoANTRecord>
181
+ Object.keys(records) // sort the keys since string indexed maps in lua do not retain order
182
+ .sort((a, b) => {
183
+ if (a == '@')
184
+ return -1;
185
+ if (b == '@')
186
+ return 1;
187
+ return a.localeCompare(b);
188
+ })
189
+ .reduce((acc, undername) => {
190
+ acc.push({
191
+ ...records[undername],
192
+ name: undername,
193
+ });
194
+ return acc;
195
+ }, []);
196
+ return result;
197
+ }
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '2.5.0-alpha.1';
17
+ export const version = '2.5.0-alpha.2';
@@ -1,4 +1,4 @@
1
- import { AntReadOptions, AoANTInfo, AoANTRead, AoANTRecord, AoANTState, AoANTWrite } from '../types/ant.js';
1
+ import { AntReadOptions, AoANTInfo, AoANTRead, AoANTRecord, AoANTRecordEntry, AoANTState, AoANTWrite } from '../types/ant.js';
2
2
  import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
3
3
  import { AOProcess } from './index.js';
4
4
  export declare class ANT {
@@ -31,14 +31,14 @@ export declare class AoANTReadable implements AoANTRead {
31
31
  undername: string;
32
32
  }, { strict }?: AntReadOptions): Promise<AoANTRecord>;
33
33
  /**
34
- * @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
34
+ * @returns {Promise<AoANTRecordEntry[]>} All the undernames managed by the ANT.
35
35
  * @example
36
36
  * Get the current records
37
37
  * ```ts
38
38
  * ant.getRecords();
39
39
  * ````
40
40
  */
41
- getRecords({ strict }?: AntReadOptions): Promise<Record<string, AoANTRecord>>;
41
+ getRecords({ strict }?: AntReadOptions): Promise<AoANTRecordEntry[]>;
42
42
  /**
43
43
  * @returns {Promise<string>} The owner of the ANT.
44
44
  * @example
@@ -25,5 +25,5 @@ export declare const IO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmt
25
25
  export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
26
26
  export declare const MIO_PER_IO = 1000000;
27
27
  export declare const AOS_MODULE_ID = "cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk";
28
- export declare const ANT_LUA_ID = "pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30";
28
+ export declare const ANT_LUA_ID = "AWO2a2lVfQnjPFThjE4Uuw4ZFAd9EsCHBEgDYkJA-kk";
29
29
  export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
@@ -41,7 +41,24 @@ export declare const AntRecordSchema: z.ZodObject<{
41
41
  transactionId: string;
42
42
  ttlSeconds: number;
43
43
  }>;
44
+ export declare const AntEntrySchema: z.ZodIntersection<z.ZodObject<{
45
+ transactionId: z.ZodEffects<z.ZodString, string, string>;
46
+ ttlSeconds: z.ZodNumber;
47
+ }, "strip", z.ZodTypeAny, {
48
+ transactionId: string;
49
+ ttlSeconds: number;
50
+ }, {
51
+ transactionId: string;
52
+ ttlSeconds: number;
53
+ }>, z.ZodObject<{
54
+ name: z.ZodString;
55
+ }, "strip", z.ZodTypeAny, {
56
+ name: string;
57
+ }, {
58
+ name: string;
59
+ }>>;
44
60
  export type AoANTRecord = z.infer<typeof AntRecordSchema>;
61
+ export type AoANTRecordEntry = z.infer<typeof AntEntrySchema>;
45
62
  export declare const AntRecordsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
46
63
  transactionId: z.ZodEffects<z.ZodString, string, string>;
47
64
  ttlSeconds: z.ZodNumber;
@@ -52,6 +69,22 @@ export declare const AntRecordsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
52
69
  transactionId: string;
53
70
  ttlSeconds: number;
54
71
  }>>;
72
+ export declare const AntEntriesSchema: z.ZodArray<z.ZodIntersection<z.ZodObject<{
73
+ transactionId: z.ZodEffects<z.ZodString, string, string>;
74
+ ttlSeconds: z.ZodNumber;
75
+ }, "strip", z.ZodTypeAny, {
76
+ transactionId: string;
77
+ ttlSeconds: number;
78
+ }, {
79
+ transactionId: string;
80
+ ttlSeconds: number;
81
+ }>, z.ZodObject<{
82
+ name: z.ZodString;
83
+ }, "strip", z.ZodTypeAny, {
84
+ name: string;
85
+ }, {
86
+ name: string;
87
+ }>>, "many">;
55
88
  export declare const AntControllersSchema: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
56
89
  export declare const AntBalancesSchema: z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodNumber>;
57
90
  export declare const AntStateSchema: z.ZodObject<{
@@ -167,7 +200,7 @@ export interface AoANTRead {
167
200
  getRecord({ undername }: {
168
201
  undername: string;
169
202
  }, opts?: AntReadOptions): Promise<AoANTRecord | undefined>;
170
- getRecords(opts?: AntReadOptions): Promise<Record<string, AoANTRecord>>;
203
+ getRecords(opts?: AntReadOptions): Promise<AoANTRecordEntry[]>;
171
204
  getOwner(opts?: AntReadOptions): Promise<WalletAddress>;
172
205
  getControllers(): Promise<WalletAddress[]>;
173
206
  getTicker(opts?: AntReadOptions): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  import Arweave from 'arweave';
2
2
  import { Logger } from '../common/index.js';
3
- import { AoANTRecord } from '../types/ant.js';
3
+ import { AoANTRecord, AoANTRecordEntry } from '../types/ant.js';
4
4
  import { AoClient, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
5
5
  export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, state, stateContractTxId, antRegistryId, logger, arweave, }: {
6
6
  signer: AoSigner;
@@ -31,3 +31,8 @@ export declare function evolveANT({ signer, processId, luaCodeTxId, ao, logger,
31
31
  }): Promise<string>;
32
32
  export declare function isAoSigner(value: unknown): value is AoSigner;
33
33
  export declare function createAoSigner(signer: ContractSigner): AoSigner;
34
+ /**
35
+ * @param records @type {AoANTRecordEntry[] | Record<string, AoANTRecord>} - the records returned by an ANT
36
+ * @returns @type {AoANTRecordEntry[]} - the alphabetically sorted records
37
+ */
38
+ export declare function parseAntRecords(records: AoANTRecordEntry[] | Record<string, AoANTRecord>): AoANTRecordEntry[];
@@ -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 = "2.4.0";
16
+ export declare const version = "2.5.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.5.0-alpha.1",
3
+ "version": "2.5.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"