@ar.io/sdk 2.5.0-alpha.13 → 2.5.0-alpha.14
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.
- package/README.md +11 -33
- package/bundles/web.bundle.min.js +51 -51
- package/lib/cjs/common/ant.js +3 -4
- package/lib/cjs/types/ant.js +1 -3
- package/lib/cjs/utils/ao.js +1 -27
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +5 -6
- package/lib/esm/types/ant.js +0 -2
- package/lib/esm/utils/ao.js +0 -25
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +3 -3
- package/lib/types/types/ant.d.ts +1 -34
- package/lib/types/utils/ao.d.ts +1 -6
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/common/ant.js
CHANGED
|
@@ -96,7 +96,7 @@ class AoANTReadable {
|
|
|
96
96
|
return record;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* @returns {Promise<
|
|
99
|
+
* @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
|
|
100
100
|
* @example
|
|
101
101
|
* Get the current records
|
|
102
102
|
* ```ts
|
|
@@ -108,10 +108,9 @@ class AoANTReadable {
|
|
|
108
108
|
const records = await this.process.read({
|
|
109
109
|
tags,
|
|
110
110
|
});
|
|
111
|
-
const result = (0, ao_js_1.parseAntRecords)(records);
|
|
112
111
|
if (strict)
|
|
113
|
-
(0, schema_js_1.parseSchemaResult)(ant_js_1.
|
|
114
|
-
return
|
|
112
|
+
(0, schema_js_1.parseSchemaResult)(ant_js_1.AntRecordsSchema, records);
|
|
113
|
+
return records;
|
|
115
114
|
}
|
|
116
115
|
/**
|
|
117
116
|
* @returns {Promise<string>} The owner of the ANT.
|
package/lib/cjs/types/ant.js
CHANGED
|
@@ -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.AntWriteHandlers = exports.AntReadHandlers = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.
|
|
3
|
+
exports.isAoANTState = exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntWriteHandlers = exports.AntReadHandlers = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = 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,9 +51,7 @@ 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() }));
|
|
55
54
|
exports.AntRecordsSchema = zod_1.z.record(zod_1.z.string(), exports.AntRecordSchema);
|
|
56
|
-
exports.AntEntriesSchema = zod_1.z.array(exports.AntEntrySchema);
|
|
57
55
|
exports.AntControllersSchema = zod_1.z.array(exports.ArweaveTxIdSchema.describe('Controller address'));
|
|
58
56
|
exports.AntBalancesSchema = zod_1.z.record(exports.ArweaveTxIdSchema.describe('Holder address'), zod_1.z.number());
|
|
59
57
|
exports.AntStateSchema = zod_1.z.object({
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -181,29 +181,3 @@ function createAoSigner(signer) {
|
|
|
181
181
|
return aoSigner;
|
|
182
182
|
}
|
|
183
183
|
exports.createAoSigner = createAoSigner;
|
|
184
|
-
/**
|
|
185
|
-
* @param records @type {AoANTRecordEntry[] | Record<string, AoANTRecord>} - the records returned by an ANT
|
|
186
|
-
* @returns @type {AoANTRecordEntry[]} - the alphabetically sorted records
|
|
187
|
-
*/
|
|
188
|
-
function parseAntRecords(records) {
|
|
189
|
-
const result = Array.isArray(records)
|
|
190
|
-
? records // assumes if records is an array that its AoANTRecordEntry[]
|
|
191
|
-
: // backwards compatibility for when ANTs returned as Record<string, AoANTRecord>
|
|
192
|
-
Object.keys(records) // sort the keys since string indexed maps in lua do not retain order
|
|
193
|
-
.sort((a, b) => {
|
|
194
|
-
if (a == '@')
|
|
195
|
-
return -1;
|
|
196
|
-
if (b == '@')
|
|
197
|
-
return 1;
|
|
198
|
-
return a.localeCompare(b);
|
|
199
|
-
})
|
|
200
|
-
.reduce((acc, undername) => {
|
|
201
|
-
acc.push({
|
|
202
|
-
...records[undername],
|
|
203
|
-
name: undername,
|
|
204
|
-
});
|
|
205
|
-
return acc;
|
|
206
|
-
}, []);
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
exports.parseAntRecords = parseAntRecords;
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/ant.js
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { z } from 'zod';
|
|
17
|
-
import { AntBalancesSchema, AntControllersSchema,
|
|
17
|
+
import { AntBalancesSchema, AntControllersSchema, AntInfoSchema, AntRecordSchema, AntRecordsSchema, AntStateSchema, } from '../types/ant.js';
|
|
18
18
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
|
|
19
|
-
import { createAoSigner
|
|
19
|
+
import { createAoSigner } 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<
|
|
95
|
+
* @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
|
|
96
96
|
* @example
|
|
97
97
|
* Get the current records
|
|
98
98
|
* ```ts
|
|
@@ -104,10 +104,9 @@ export class AoANTReadable {
|
|
|
104
104
|
const records = await this.process.read({
|
|
105
105
|
tags,
|
|
106
106
|
});
|
|
107
|
-
const result = parseAntRecords(records);
|
|
108
107
|
if (strict)
|
|
109
|
-
parseSchemaResult(
|
|
110
|
-
return
|
|
108
|
+
parseSchemaResult(AntRecordsSchema, records);
|
|
109
|
+
return records;
|
|
111
110
|
}
|
|
112
111
|
/**
|
|
113
112
|
* @returns {Promise<string>} The owner of the ANT.
|
package/lib/esm/types/ant.js
CHANGED
|
@@ -48,9 +48,7 @@ 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() }));
|
|
52
51
|
export const AntRecordsSchema = z.record(z.string(), AntRecordSchema);
|
|
53
|
-
export const AntEntriesSchema = z.array(AntEntrySchema);
|
|
54
52
|
export const AntControllersSchema = z.array(ArweaveTxIdSchema.describe('Controller address'));
|
|
55
53
|
export const AntBalancesSchema = z.record(ArweaveTxIdSchema.describe('Holder address'), z.number());
|
|
56
54
|
export const AntStateSchema = z.object({
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -174,28 +174,3 @@ export function createAoSigner(signer) {
|
|
|
174
174
|
};
|
|
175
175
|
return aoSigner;
|
|
176
176
|
}
|
|
177
|
-
/**
|
|
178
|
-
* @param records @type {AoANTRecordEntry[] | Record<string, AoANTRecord>} - the records returned by an ANT
|
|
179
|
-
* @returns @type {AoANTRecordEntry[]} - the alphabetically sorted records
|
|
180
|
-
*/
|
|
181
|
-
export function parseAntRecords(records) {
|
|
182
|
-
const result = Array.isArray(records)
|
|
183
|
-
? records // assumes if records is an array that its AoANTRecordEntry[]
|
|
184
|
-
: // backwards compatibility for when ANTs returned as Record<string, AoANTRecord>
|
|
185
|
-
Object.keys(records) // sort the keys since string indexed maps in lua do not retain order
|
|
186
|
-
.sort((a, b) => {
|
|
187
|
-
if (a == '@')
|
|
188
|
-
return -1;
|
|
189
|
-
if (b == '@')
|
|
190
|
-
return 1;
|
|
191
|
-
return a.localeCompare(b);
|
|
192
|
-
})
|
|
193
|
-
.reduce((acc, undername) => {
|
|
194
|
-
acc.push({
|
|
195
|
-
...records[undername],
|
|
196
|
-
name: undername,
|
|
197
|
-
});
|
|
198
|
-
return acc;
|
|
199
|
-
}, []);
|
|
200
|
-
return result;
|
|
201
|
-
}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord,
|
|
1
|
+
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, 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<
|
|
34
|
+
* @returns {Promise<Record<string, AoANTRecord>>} 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<
|
|
41
|
+
getRecords({ strict }?: AntReadOptions): Promise<Record<string, AoANTRecord>>;
|
|
42
42
|
/**
|
|
43
43
|
* @returns {Promise<string>} The owner of the ANT.
|
|
44
44
|
* @example
|
package/lib/types/types/ant.d.ts
CHANGED
|
@@ -41,24 +41,7 @@ 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
|
-
}>>;
|
|
60
44
|
export type AoANTRecord = z.infer<typeof AntRecordSchema>;
|
|
61
|
-
export type AoANTRecordEntry = z.infer<typeof AntEntrySchema>;
|
|
62
45
|
export declare const AntRecordsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
46
|
transactionId: z.ZodEffects<z.ZodString, string, string>;
|
|
64
47
|
ttlSeconds: z.ZodNumber;
|
|
@@ -69,22 +52,6 @@ export declare const AntRecordsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
|
69
52
|
transactionId: string;
|
|
70
53
|
ttlSeconds: number;
|
|
71
54
|
}>>;
|
|
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">;
|
|
88
55
|
export declare const AntControllersSchema: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
89
56
|
export declare const AntBalancesSchema: z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodNumber>;
|
|
90
57
|
export declare const AntStateSchema: z.ZodObject<{
|
|
@@ -199,7 +166,7 @@ export interface AoANTRead {
|
|
|
199
166
|
getRecord({ undername }: {
|
|
200
167
|
undername: string;
|
|
201
168
|
}, opts?: AntReadOptions): Promise<AoANTRecord | undefined>;
|
|
202
|
-
getRecords(opts?: AntReadOptions): Promise<
|
|
169
|
+
getRecords(opts?: AntReadOptions): Promise<Record<string, AoANTRecord>>;
|
|
203
170
|
getOwner(opts?: AntReadOptions): Promise<WalletAddress>;
|
|
204
171
|
getControllers(): Promise<WalletAddress[]>;
|
|
205
172
|
getTicker(opts?: AntReadOptions): Promise<string>;
|
package/lib/types/utils/ao.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
2
|
import { Logger } from '../common/index.js';
|
|
3
|
-
import { AoANTRecord
|
|
3
|
+
import { AoANTRecord } 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,8 +31,3 @@ 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[];
|
package/lib/types/version.d.ts
CHANGED