@ar.io/sdk 2.5.0-alpha.1 → 2.5.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.
- package/README.md +214 -9
- package/bundles/web.bundle.min.js +69 -69
- package/lib/cjs/common/ant.js +61 -3
- package/lib/cjs/common/contracts/ao-process.js +12 -11
- package/lib/cjs/common/io.js +100 -81
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/types/ant.js +16 -12
- package/lib/cjs/utils/ao.js +31 -1
- package/lib/cjs/utils/arweave.js +11 -1
- package/lib/cjs/utils/schema.js +0 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +63 -5
- package/lib/esm/common/contracts/ao-process.js +12 -11
- package/lib/esm/common/io.js +101 -82
- package/lib/esm/constants.js +1 -1
- package/lib/esm/types/ant.js +15 -11
- package/lib/esm/utils/ao.js +29 -0
- package/lib/esm/utils/arweave.js +9 -0
- package/lib/esm/utils/schema.js +0 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +36 -3
- package/lib/types/common/io.d.ts +21 -3
- package/lib/types/constants.d.ts +1 -1
- package/lib/types/types/ant.d.ts +53 -8
- package/lib/types/types/common.d.ts +10 -0
- package/lib/types/types/io.d.ts +38 -18
- package/lib/types/utils/ao.d.ts +6 -1
- package/lib/types/utils/arweave.d.ts +5 -0
- package/lib/types/utils/schema.d.ts +0 -1
- 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<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.
|
|
113
|
-
return
|
|
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.
|
|
@@ -203,6 +204,18 @@ class AoANTReadable {
|
|
|
203
204
|
(0, schema_js_1.parseSchemaResult)(zod_1.z.number(), balance);
|
|
204
205
|
return balance;
|
|
205
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* @returns {Promise<AoANTHandler[]>} The handlers of the ANT.
|
|
209
|
+
* @example
|
|
210
|
+
* Get the handlers of the ANT.
|
|
211
|
+
* ```ts
|
|
212
|
+
* const handlers = await ant.getHandlers();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
async getHandlers() {
|
|
216
|
+
const info = await this.getInfo();
|
|
217
|
+
return (info.Handlers ?? info.HandlerNames);
|
|
218
|
+
}
|
|
206
219
|
}
|
|
207
220
|
exports.AoANTReadable = AoANTReadable;
|
|
208
221
|
class AoANTWriteable extends AoANTReadable {
|
|
@@ -380,6 +393,25 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
380
393
|
signer: this.signer,
|
|
381
394
|
});
|
|
382
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* @param txId @type {string} - Arweave transaction id of the logo we want to set
|
|
398
|
+
* @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
|
|
399
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* ant.setLogo({ logo: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f" });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
async setLogo({ txId }, options) {
|
|
406
|
+
return this.process.send({
|
|
407
|
+
tags: [
|
|
408
|
+
...(options?.tags ?? []),
|
|
409
|
+
{ name: 'Action', value: 'Set-Logo' },
|
|
410
|
+
{ name: 'Logo', value: txId },
|
|
411
|
+
],
|
|
412
|
+
signer: this.signer,
|
|
413
|
+
});
|
|
414
|
+
}
|
|
383
415
|
/**
|
|
384
416
|
* @param name @type {string} The name you want to release. The name will be put up for auction on the IO contract. 50% of the winning bid will be distributed to the ANT owner at the time of release. If no bids, the name will be released and can be reregistered by anyone.
|
|
385
417
|
* @param ioProcessId @type {string} The processId of the IO contract. This is where the ANT will send the message to release the name.
|
|
@@ -423,5 +455,31 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
423
455
|
signer: this.signer,
|
|
424
456
|
});
|
|
425
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Approves a primary name request for a given name or address.
|
|
460
|
+
*/
|
|
461
|
+
async approvePrimaryNameRequest({ name, address, ioProcessId, }, options) {
|
|
462
|
+
return this.process.send({
|
|
463
|
+
tags: [
|
|
464
|
+
...(options?.tags ?? []),
|
|
465
|
+
{ name: 'Action', value: 'Approve-Primary-Name' },
|
|
466
|
+
{ name: 'Name', value: name },
|
|
467
|
+
{ name: 'Recipient', value: address },
|
|
468
|
+
{ name: 'IO-Process-Id', value: ioProcessId },
|
|
469
|
+
],
|
|
470
|
+
signer: this.signer,
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
async removePrimaryNames({ names, ioProcessId }, options) {
|
|
474
|
+
return this.process.send({
|
|
475
|
+
tags: [
|
|
476
|
+
...(options?.tags ?? []),
|
|
477
|
+
{ name: 'Action', value: 'Remove-Primary-Names' },
|
|
478
|
+
{ name: 'Names', value: names.join(',') },
|
|
479
|
+
{ name: 'IO-Process-Id', value: ioProcessId },
|
|
480
|
+
],
|
|
481
|
+
signer: this.signer,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
426
484
|
}
|
|
427
485
|
exports.AoANTWriteable = AoANTWriteable;
|
|
@@ -50,11 +50,12 @@ class AOProcess {
|
|
|
50
50
|
this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
|
|
51
51
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
52
52
|
}
|
|
53
|
-
const tagsOutput = result.Messages[0]
|
|
54
|
-
const messageData = result.Messages[0]
|
|
55
|
-
const
|
|
53
|
+
const tagsOutput = result.Messages?.[0]?.Tags;
|
|
54
|
+
const messageData = result.Messages?.[0]?.Data;
|
|
55
|
+
const errorData = result.Error;
|
|
56
|
+
const error = errorData || tagsOutput?.find((tag) => tag.name === 'Error')?.value;
|
|
56
57
|
if (error) {
|
|
57
|
-
throw new Error(`${error
|
|
58
|
+
throw new Error(`${error}${messageData ? `: ${messageData}` : ''}`);
|
|
58
59
|
}
|
|
59
60
|
// return empty object if no data is returned
|
|
60
61
|
if (messageData === undefined) {
|
|
@@ -109,17 +110,17 @@ class AOProcess {
|
|
|
109
110
|
messageId,
|
|
110
111
|
processId: this.processId,
|
|
111
112
|
});
|
|
113
|
+
const errorData = output.Error;
|
|
114
|
+
const error = errorData ||
|
|
115
|
+
output.Messages?.[0]?.Tags?.find((tag) => tag.name === 'Error')
|
|
116
|
+
?.value;
|
|
117
|
+
if (error) {
|
|
118
|
+
throw new error_js_1.WriteInteractionError(error);
|
|
119
|
+
}
|
|
112
120
|
// check if there are any Messages in the output
|
|
113
121
|
if (output.Messages?.length === 0 || output.Messages === undefined) {
|
|
114
122
|
return { id: messageId };
|
|
115
123
|
}
|
|
116
|
-
const tagsOutput = output.Messages[0].Tags;
|
|
117
|
-
const error = tagsOutput.find((tag) => tag.name === 'Error');
|
|
118
|
-
// if there's an Error tag, throw an error related to it
|
|
119
|
-
if (error) {
|
|
120
|
-
const result = output.Messages[0].Data;
|
|
121
|
-
throw new error_js_1.WriteInteractionError(`${error.Value}: ${result}`);
|
|
122
|
-
}
|
|
123
124
|
if (output.Messages.length === 0) {
|
|
124
125
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
125
126
|
}
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -96,20 +96,19 @@ class IOReadable {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
async getArNSRecords(params) {
|
|
99
|
-
const allTags = [
|
|
100
|
-
{ name: 'Action', value: 'Paginated-Records' },
|
|
101
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
102
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
103
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
104
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
105
|
-
];
|
|
106
99
|
return this.process.read({
|
|
107
|
-
tags:
|
|
100
|
+
tags: [
|
|
101
|
+
{ name: 'Action', value: 'Paginated-Records' },
|
|
102
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
103
|
+
],
|
|
108
104
|
});
|
|
109
105
|
}
|
|
110
|
-
async getArNSReservedNames() {
|
|
106
|
+
async getArNSReservedNames(params) {
|
|
111
107
|
return this.process.read({
|
|
112
|
-
tags: [
|
|
108
|
+
tags: [
|
|
109
|
+
{ name: 'Action', value: 'Reserved-Names' },
|
|
110
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
111
|
+
],
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
async getArNSReservedName({ name, }) {
|
|
@@ -129,15 +128,11 @@ class IOReadable {
|
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
130
|
async getBalances(params) {
|
|
132
|
-
const allTags = [
|
|
133
|
-
{ name: 'Action', value: 'Paginated-Balances' },
|
|
134
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
135
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
136
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
137
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
138
|
-
];
|
|
139
131
|
return this.process.read({
|
|
140
|
-
tags:
|
|
132
|
+
tags: [
|
|
133
|
+
{ name: 'Action', value: 'Paginated-Balances' },
|
|
134
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
135
|
+
],
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
138
|
async getVault({ address, vaultId, }) {
|
|
@@ -150,15 +145,11 @@ class IOReadable {
|
|
|
150
145
|
});
|
|
151
146
|
}
|
|
152
147
|
async getVaults(params) {
|
|
153
|
-
const allTags = [
|
|
154
|
-
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
155
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
156
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
157
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
158
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
159
|
-
];
|
|
160
148
|
return this.process.read({
|
|
161
|
-
tags:
|
|
149
|
+
tags: [
|
|
150
|
+
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
151
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
152
|
+
],
|
|
162
153
|
});
|
|
163
154
|
}
|
|
164
155
|
async getGateway({ address, }) {
|
|
@@ -170,41 +161,29 @@ class IOReadable {
|
|
|
170
161
|
});
|
|
171
162
|
}
|
|
172
163
|
async getGatewayDelegates({ address, ...pageParams }) {
|
|
173
|
-
const allTags = [
|
|
174
|
-
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
175
|
-
{ name: 'Address', value: address },
|
|
176
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
177
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
178
|
-
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
179
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
180
|
-
];
|
|
181
164
|
return this.process.read({
|
|
182
|
-
tags:
|
|
165
|
+
tags: [
|
|
166
|
+
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
167
|
+
{ name: 'Address', value: address },
|
|
168
|
+
...(0, arweave_js_1.paginationParamsToTags)(pageParams),
|
|
169
|
+
],
|
|
183
170
|
});
|
|
184
171
|
}
|
|
185
172
|
async getGatewayDelegateAllowList({ address, ...pageParams }) {
|
|
186
|
-
const allTags = [
|
|
187
|
-
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
188
|
-
{ name: 'Address', value: address },
|
|
189
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
190
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
191
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
192
|
-
// note: sortBy is omitted because it's not supported for this action as table is an of addresses
|
|
193
|
-
];
|
|
194
173
|
return this.process.read({
|
|
195
|
-
tags:
|
|
174
|
+
tags: [
|
|
175
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
176
|
+
{ name: 'Address', value: address },
|
|
177
|
+
...(0, arweave_js_1.paginationParamsToTags)(pageParams),
|
|
178
|
+
],
|
|
196
179
|
});
|
|
197
180
|
}
|
|
198
181
|
async getGateways(pageParams) {
|
|
199
|
-
const allTags = [
|
|
200
|
-
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
201
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
202
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
203
|
-
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
204
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
205
|
-
];
|
|
206
182
|
return this.process.read({
|
|
207
|
-
tags:
|
|
183
|
+
tags: [
|
|
184
|
+
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
185
|
+
...(0, arweave_js_1.paginationParamsToTags)(pageParams),
|
|
186
|
+
],
|
|
208
187
|
});
|
|
209
188
|
}
|
|
210
189
|
async getCurrentEpoch() {
|
|
@@ -213,14 +192,7 @@ class IOReadable {
|
|
|
213
192
|
{ name: 'Action', value: 'Epoch' },
|
|
214
193
|
{
|
|
215
194
|
name: 'Timestamp',
|
|
216
|
-
value: (await this.arweave.
|
|
217
|
-
.getCurrent()
|
|
218
|
-
.then((block) => {
|
|
219
|
-
return { timestamp: block.timestamp * 1000 };
|
|
220
|
-
})
|
|
221
|
-
.catch(() => {
|
|
222
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
223
|
-
})).timestamp.toString(),
|
|
195
|
+
value: (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
224
196
|
},
|
|
225
197
|
],
|
|
226
198
|
});
|
|
@@ -265,14 +237,7 @@ class IOReadable {
|
|
|
265
237
|
{
|
|
266
238
|
name: 'Timestamp',
|
|
267
239
|
value: epoch?.timestamp?.toString() ??
|
|
268
|
-
(await this.arweave.
|
|
269
|
-
.getCurrent()
|
|
270
|
-
.then((block) => {
|
|
271
|
-
return { timestamp: block.timestamp * 1000 };
|
|
272
|
-
})
|
|
273
|
-
.catch(() => {
|
|
274
|
-
return { timestamp: `${Date.now()}` }; // fallback to current time
|
|
275
|
-
})).timestamp.toString(),
|
|
240
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
276
241
|
},
|
|
277
242
|
{
|
|
278
243
|
name: 'Epoch-Index',
|
|
@@ -351,15 +316,11 @@ class IOReadable {
|
|
|
351
316
|
}
|
|
352
317
|
// Auctions
|
|
353
318
|
async getArNSAuctions(params) {
|
|
354
|
-
const allTags = [
|
|
355
|
-
{ name: 'Action', value: 'Auctions' },
|
|
356
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
357
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
358
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
359
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
360
|
-
];
|
|
361
319
|
return this.process.read({
|
|
362
|
-
tags:
|
|
320
|
+
tags: [
|
|
321
|
+
{ name: 'Action', value: 'Auctions' },
|
|
322
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
323
|
+
],
|
|
363
324
|
});
|
|
364
325
|
}
|
|
365
326
|
async getArNSAuction({ name, }) {
|
|
@@ -388,7 +349,8 @@ class IOReadable {
|
|
|
388
349
|
{ name: 'Name', value: name },
|
|
389
350
|
{
|
|
390
351
|
name: 'Timestamp',
|
|
391
|
-
value: timestamp?.toString() ??
|
|
352
|
+
value: timestamp?.toString() ??
|
|
353
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
392
354
|
},
|
|
393
355
|
{ name: 'Purchase-Type', value: type ?? 'lease' },
|
|
394
356
|
{
|
|
@@ -409,16 +371,64 @@ class IOReadable {
|
|
|
409
371
|
async getDelegations(params) {
|
|
410
372
|
const allTags = [
|
|
411
373
|
{ name: 'Action', value: 'Paginated-Delegations' },
|
|
412
|
-
{ name: 'Cursor', value: params.cursor?.toString() },
|
|
413
|
-
{ name: 'Limit', value: params.limit?.toString() },
|
|
414
|
-
{ name: 'Sort-By', value: params.sortBy },
|
|
415
|
-
{ name: 'Sort-Order', value: params.sortOrder },
|
|
416
374
|
{ name: 'Address', value: params.address },
|
|
375
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
376
|
+
];
|
|
377
|
+
return this.process.read({
|
|
378
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async getGatewayVaults(params) {
|
|
382
|
+
return this.process.read({
|
|
383
|
+
tags: [
|
|
384
|
+
{ name: 'Action', value: 'Paginated-Gateway-Vaults' },
|
|
385
|
+
{ name: 'Address', value: params.address },
|
|
386
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
387
|
+
],
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async getPrimaryNameRequest(params) {
|
|
391
|
+
const allTags = [
|
|
392
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
393
|
+
{ name: 'Name', value: params.name },
|
|
394
|
+
{
|
|
395
|
+
name: 'Initiator',
|
|
396
|
+
value: params.initiator,
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
return this.process.read({
|
|
400
|
+
tags: allTags,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
async getPrimaryNameRequests(params) {
|
|
404
|
+
return this.process.read({
|
|
405
|
+
tags: [
|
|
406
|
+
{ name: 'Action', value: 'Primary-Name-Requests' },
|
|
407
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
408
|
+
],
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
async getPrimaryName(params) {
|
|
412
|
+
const allTags = [
|
|
413
|
+
{ name: 'Action', value: 'Primary-Name' },
|
|
414
|
+
{
|
|
415
|
+
name: 'Address',
|
|
416
|
+
value: params?.address,
|
|
417
|
+
},
|
|
418
|
+
{ name: 'Name', value: params?.name },
|
|
417
419
|
];
|
|
418
420
|
return this.process.read({
|
|
419
421
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
420
422
|
});
|
|
421
423
|
}
|
|
424
|
+
async getPrimaryNames(params) {
|
|
425
|
+
return this.process.read({
|
|
426
|
+
tags: [
|
|
427
|
+
{ name: 'Action', value: 'Primary-Names' },
|
|
428
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
429
|
+
],
|
|
430
|
+
});
|
|
431
|
+
}
|
|
422
432
|
}
|
|
423
433
|
exports.IOReadable = IOReadable;
|
|
424
434
|
class IOWriteable extends IOReadable {
|
|
@@ -762,5 +772,14 @@ class IOWriteable extends IOReadable {
|
|
|
762
772
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
763
773
|
});
|
|
764
774
|
}
|
|
775
|
+
async requestPrimaryName(params) {
|
|
776
|
+
return this.process.send({
|
|
777
|
+
signer: this.signer,
|
|
778
|
+
tags: [
|
|
779
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
780
|
+
{ name: 'Name', value: params.name },
|
|
781
|
+
],
|
|
782
|
+
});
|
|
783
|
+
}
|
|
765
784
|
}
|
|
766
785
|
exports.IOWriteable = IOWriteable;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -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 = '
|
|
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';
|
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.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.AntWriteHandlers = exports.AntReadHandlers = 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({
|
|
@@ -75,33 +77,36 @@ exports.AntStateSchema = zod_1.z.object({
|
|
|
75
77
|
Initialized: zod_1.z
|
|
76
78
|
.boolean()
|
|
77
79
|
.describe('Flag indicating whether the ANT has been initialized.'),
|
|
78
|
-
['Source-Code-TX-ID']: exports.ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
|
|
79
80
|
});
|
|
80
|
-
exports.
|
|
81
|
-
'evolve',
|
|
82
|
-
'_eval',
|
|
83
|
-
'_default',
|
|
84
|
-
'transfer',
|
|
81
|
+
exports.AntReadHandlers = [
|
|
85
82
|
'balance',
|
|
86
83
|
'balances',
|
|
87
84
|
'totalSupply',
|
|
88
85
|
'info',
|
|
86
|
+
'controllers',
|
|
87
|
+
'record',
|
|
88
|
+
'records',
|
|
89
|
+
'state',
|
|
90
|
+
];
|
|
91
|
+
exports.AntWriteHandlers = [
|
|
92
|
+
'evolve',
|
|
93
|
+
'_eval',
|
|
94
|
+
'_default',
|
|
95
|
+
'transfer',
|
|
89
96
|
'addController',
|
|
90
97
|
'removeController',
|
|
91
|
-
'controllers',
|
|
92
98
|
'setRecord',
|
|
93
99
|
'removeRecord',
|
|
94
|
-
'record',
|
|
95
|
-
'records',
|
|
96
100
|
'setName',
|
|
97
101
|
'setTicker',
|
|
98
102
|
'setDescription',
|
|
99
103
|
'setKeywords',
|
|
104
|
+
'setLogo',
|
|
100
105
|
'initializeState',
|
|
101
|
-
'state',
|
|
102
106
|
'releaseName',
|
|
103
107
|
'reassignName',
|
|
104
108
|
];
|
|
109
|
+
exports.AntHandlerNames = [...exports.AntReadHandlers, ...exports.AntWriteHandlers];
|
|
105
110
|
exports.AntHandlersSchema = zod_1.z
|
|
106
111
|
.array(zod_1.z.string({ description: 'Handler Name' }))
|
|
107
112
|
.refine((antHandlers) => {
|
|
@@ -112,7 +117,6 @@ exports.AntHandlersSchema = zod_1.z
|
|
|
112
117
|
exports.AntInfoSchema = zod_1.z.object({
|
|
113
118
|
Name: zod_1.z.string().describe('The name of the ANT.'),
|
|
114
119
|
Owner: exports.ArweaveTxIdSchema.describe('The Owners address.'),
|
|
115
|
-
['Source-Code-TX-ID']: exports.ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
|
|
116
120
|
Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
|
|
117
121
|
['Total-Supply']: exports.IntegerStringSchema.describe('Total supply of the ANT in circulation.'),
|
|
118
122
|
Description: exports.AntDescriptionSchema.describe('The description for the ANT.'),
|
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.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
|
*
|
|
@@ -45,6 +45,10 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, luaCode
|
|
|
45
45
|
name: 'ANT-Registry-Id',
|
|
46
46
|
value: antRegistryId,
|
|
47
47
|
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Source-Code-TX-ID', // utility for understanding what the original source id of the lua code was
|
|
50
|
+
value: luaCodeTxId,
|
|
51
|
+
},
|
|
48
52
|
],
|
|
49
53
|
});
|
|
50
54
|
const aosClient = new index_js_1.AOProcess({
|
|
@@ -177,3 +181,29 @@ function createAoSigner(signer) {
|
|
|
177
181
|
return aoSigner;
|
|
178
182
|
}
|
|
179
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/utils/arweave.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentBlockUnixTimestampMs = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
3
|
+
exports.paginationParamsToTags = exports.getCurrentBlockUnixTimestampMs = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const validateArweaveId = (id) => {
|
|
6
6
|
return constants_js_1.ARWEAVE_TX_REGEX.test(id);
|
|
@@ -25,3 +25,13 @@ const getCurrentBlockUnixTimestampMs = async (arweave) => {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
exports.getCurrentBlockUnixTimestampMs = getCurrentBlockUnixTimestampMs;
|
|
28
|
+
const paginationParamsToTags = (params) => {
|
|
29
|
+
const tags = [
|
|
30
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
31
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
32
|
+
{ name: 'Sort-By', value: params?.sortBy?.toString() },
|
|
33
|
+
{ name: 'Sort-Order', value: params?.sortOrder?.toString() },
|
|
34
|
+
];
|
|
35
|
+
return (0, exports.pruneTags)(tags);
|
|
36
|
+
};
|
|
37
|
+
exports.paginationParamsToTags = paginationParamsToTags;
|
package/lib/cjs/utils/schema.js
CHANGED
package/lib/cjs/version.js
CHANGED