@ar.io/sdk 2.5.0-alpha.4 → 2.5.0-alpha.6
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/bundles/web.bundle.min.js +64 -64
- package/lib/cjs/common/io.js +88 -72
- package/lib/cjs/utils/ao.js +4 -0
- package/lib/cjs/utils/arweave.js +11 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +89 -73
- package/lib/esm/utils/ao.js +4 -0
- package/lib/esm/utils/arweave.js +9 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/io.d.ts +18 -3
- package/lib/types/types/common.d.ts +10 -0
- package/lib/types/types/io.d.ts +22 -15
- package/lib/types/utils/arweave.d.ts +5 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
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() {
|
|
@@ -265,14 +244,7 @@ class IOReadable {
|
|
|
265
244
|
{
|
|
266
245
|
name: 'Timestamp',
|
|
267
246
|
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(),
|
|
247
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
276
248
|
},
|
|
277
249
|
{
|
|
278
250
|
name: 'Epoch-Index',
|
|
@@ -351,15 +323,11 @@ class IOReadable {
|
|
|
351
323
|
}
|
|
352
324
|
// Auctions
|
|
353
325
|
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
326
|
return this.process.read({
|
|
362
|
-
tags:
|
|
327
|
+
tags: [
|
|
328
|
+
{ name: 'Action', value: 'Auctions' },
|
|
329
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
330
|
+
],
|
|
363
331
|
});
|
|
364
332
|
}
|
|
365
333
|
async getArNSAuction({ name, }) {
|
|
@@ -409,16 +377,55 @@ class IOReadable {
|
|
|
409
377
|
async getDelegations(params) {
|
|
410
378
|
const allTags = [
|
|
411
379
|
{ 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
380
|
{ name: 'Address', value: params.address },
|
|
381
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
382
|
+
];
|
|
383
|
+
return this.process.read({
|
|
384
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async getPrimaryNameRequest(params) {
|
|
388
|
+
const allTags = [
|
|
389
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
390
|
+
{ name: 'Name', value: params.name },
|
|
391
|
+
{
|
|
392
|
+
name: 'Initiator',
|
|
393
|
+
value: params.initiator,
|
|
394
|
+
},
|
|
395
|
+
];
|
|
396
|
+
return this.process.read({
|
|
397
|
+
tags: allTags,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
async getPrimaryNameRequests(params) {
|
|
401
|
+
return this.process.read({
|
|
402
|
+
tags: [
|
|
403
|
+
{ name: 'Action', value: 'Primary-Name-Requests' },
|
|
404
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
405
|
+
],
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
async getPrimaryName(params) {
|
|
409
|
+
const allTags = [
|
|
410
|
+
{ name: 'Action', value: 'Primary-Name' },
|
|
411
|
+
{
|
|
412
|
+
name: 'Address',
|
|
413
|
+
value: params?.address,
|
|
414
|
+
},
|
|
415
|
+
{ name: 'Name', value: params?.name },
|
|
417
416
|
];
|
|
418
417
|
return this.process.read({
|
|
419
418
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
420
419
|
});
|
|
421
420
|
}
|
|
421
|
+
async getPrimaryNames(params) {
|
|
422
|
+
return this.process.read({
|
|
423
|
+
tags: [
|
|
424
|
+
{ name: 'Action', value: 'Primary-Names' },
|
|
425
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
426
|
+
],
|
|
427
|
+
});
|
|
428
|
+
}
|
|
422
429
|
}
|
|
423
430
|
exports.IOReadable = IOReadable;
|
|
424
431
|
class IOWriteable extends IOReadable {
|
|
@@ -762,5 +769,14 @@ class IOWriteable extends IOReadable {
|
|
|
762
769
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
763
770
|
});
|
|
764
771
|
}
|
|
772
|
+
async requestPrimaryName(params) {
|
|
773
|
+
return this.process.send({
|
|
774
|
+
signer: this.signer,
|
|
775
|
+
tags: [
|
|
776
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
777
|
+
{ name: 'Name', value: params.name },
|
|
778
|
+
],
|
|
779
|
+
});
|
|
780
|
+
}
|
|
765
781
|
}
|
|
766
782
|
exports.IOWriteable = IOWriteable;
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -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({
|
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/version.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
2
2
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
3
3
|
import { createAoSigner } from '../utils/ao.js';
|
|
4
|
-
import { getCurrentBlockUnixTimestampMs, pruneTags } from '../utils/arweave.js';
|
|
4
|
+
import { getCurrentBlockUnixTimestampMs, paginationParamsToTags, pruneTags, } from '../utils/arweave.js';
|
|
5
5
|
import { defaultArweave } from './arweave.js';
|
|
6
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
7
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
@@ -92,20 +92,19 @@ export class IOReadable {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
async getArNSRecords(params) {
|
|
95
|
-
const allTags = [
|
|
96
|
-
{ name: 'Action', value: 'Paginated-Records' },
|
|
97
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
98
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
99
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
100
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
101
|
-
];
|
|
102
95
|
return this.process.read({
|
|
103
|
-
tags:
|
|
96
|
+
tags: [
|
|
97
|
+
{ name: 'Action', value: 'Paginated-Records' },
|
|
98
|
+
...paginationParamsToTags(params),
|
|
99
|
+
],
|
|
104
100
|
});
|
|
105
101
|
}
|
|
106
|
-
async getArNSReservedNames() {
|
|
102
|
+
async getArNSReservedNames(params) {
|
|
107
103
|
return this.process.read({
|
|
108
|
-
tags: [
|
|
104
|
+
tags: [
|
|
105
|
+
{ name: 'Action', value: 'Reserved-Names' },
|
|
106
|
+
...paginationParamsToTags(params),
|
|
107
|
+
],
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
async getArNSReservedName({ name, }) {
|
|
@@ -125,15 +124,11 @@ export class IOReadable {
|
|
|
125
124
|
});
|
|
126
125
|
}
|
|
127
126
|
async getBalances(params) {
|
|
128
|
-
const allTags = [
|
|
129
|
-
{ name: 'Action', value: 'Paginated-Balances' },
|
|
130
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
131
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
132
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
133
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
134
|
-
];
|
|
135
127
|
return this.process.read({
|
|
136
|
-
tags:
|
|
128
|
+
tags: [
|
|
129
|
+
{ name: 'Action', value: 'Paginated-Balances' },
|
|
130
|
+
...paginationParamsToTags(params),
|
|
131
|
+
],
|
|
137
132
|
});
|
|
138
133
|
}
|
|
139
134
|
async getVault({ address, vaultId, }) {
|
|
@@ -146,15 +141,11 @@ export class IOReadable {
|
|
|
146
141
|
});
|
|
147
142
|
}
|
|
148
143
|
async getVaults(params) {
|
|
149
|
-
const allTags = [
|
|
150
|
-
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
151
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
152
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
153
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
154
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
155
|
-
];
|
|
156
144
|
return this.process.read({
|
|
157
|
-
tags:
|
|
145
|
+
tags: [
|
|
146
|
+
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
147
|
+
...paginationParamsToTags(params),
|
|
148
|
+
],
|
|
158
149
|
});
|
|
159
150
|
}
|
|
160
151
|
async getGateway({ address, }) {
|
|
@@ -166,41 +157,29 @@ export class IOReadable {
|
|
|
166
157
|
});
|
|
167
158
|
}
|
|
168
159
|
async getGatewayDelegates({ address, ...pageParams }) {
|
|
169
|
-
const allTags = [
|
|
170
|
-
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
171
|
-
{ name: 'Address', value: address },
|
|
172
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
173
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
174
|
-
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
175
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
176
|
-
];
|
|
177
160
|
return this.process.read({
|
|
178
|
-
tags:
|
|
161
|
+
tags: [
|
|
162
|
+
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
163
|
+
{ name: 'Address', value: address },
|
|
164
|
+
...paginationParamsToTags(pageParams),
|
|
165
|
+
],
|
|
179
166
|
});
|
|
180
167
|
}
|
|
181
168
|
async getGatewayDelegateAllowList({ address, ...pageParams }) {
|
|
182
|
-
const allTags = [
|
|
183
|
-
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
184
|
-
{ name: 'Address', value: address },
|
|
185
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
186
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
187
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
188
|
-
// note: sortBy is omitted because it's not supported for this action as table is an of addresses
|
|
189
|
-
];
|
|
190
169
|
return this.process.read({
|
|
191
|
-
tags:
|
|
170
|
+
tags: [
|
|
171
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
172
|
+
{ name: 'Address', value: address },
|
|
173
|
+
...paginationParamsToTags(pageParams),
|
|
174
|
+
],
|
|
192
175
|
});
|
|
193
176
|
}
|
|
194
177
|
async getGateways(pageParams) {
|
|
195
|
-
const allTags = [
|
|
196
|
-
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
197
|
-
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
198
|
-
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
199
|
-
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
200
|
-
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
201
|
-
];
|
|
202
178
|
return this.process.read({
|
|
203
|
-
tags:
|
|
179
|
+
tags: [
|
|
180
|
+
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
181
|
+
...paginationParamsToTags(pageParams),
|
|
182
|
+
],
|
|
204
183
|
});
|
|
205
184
|
}
|
|
206
185
|
async getCurrentEpoch() {
|
|
@@ -261,14 +240,7 @@ export class IOReadable {
|
|
|
261
240
|
{
|
|
262
241
|
name: 'Timestamp',
|
|
263
242
|
value: epoch?.timestamp?.toString() ??
|
|
264
|
-
(await this.arweave.
|
|
265
|
-
.getCurrent()
|
|
266
|
-
.then((block) => {
|
|
267
|
-
return { timestamp: block.timestamp * 1000 };
|
|
268
|
-
})
|
|
269
|
-
.catch(() => {
|
|
270
|
-
return { timestamp: `${Date.now()}` }; // fallback to current time
|
|
271
|
-
})).timestamp.toString(),
|
|
243
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
272
244
|
},
|
|
273
245
|
{
|
|
274
246
|
name: 'Epoch-Index',
|
|
@@ -347,15 +319,11 @@ export class IOReadable {
|
|
|
347
319
|
}
|
|
348
320
|
// Auctions
|
|
349
321
|
async getArNSAuctions(params) {
|
|
350
|
-
const allTags = [
|
|
351
|
-
{ name: 'Action', value: 'Auctions' },
|
|
352
|
-
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
353
|
-
{ name: 'Limit', value: params?.limit?.toString() },
|
|
354
|
-
{ name: 'Sort-By', value: params?.sortBy },
|
|
355
|
-
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
356
|
-
];
|
|
357
322
|
return this.process.read({
|
|
358
|
-
tags:
|
|
323
|
+
tags: [
|
|
324
|
+
{ name: 'Action', value: 'Auctions' },
|
|
325
|
+
...paginationParamsToTags(params),
|
|
326
|
+
],
|
|
359
327
|
});
|
|
360
328
|
}
|
|
361
329
|
async getArNSAuction({ name, }) {
|
|
@@ -405,16 +373,55 @@ export class IOReadable {
|
|
|
405
373
|
async getDelegations(params) {
|
|
406
374
|
const allTags = [
|
|
407
375
|
{ name: 'Action', value: 'Paginated-Delegations' },
|
|
408
|
-
{ name: 'Cursor', value: params.cursor?.toString() },
|
|
409
|
-
{ name: 'Limit', value: params.limit?.toString() },
|
|
410
|
-
{ name: 'Sort-By', value: params.sortBy },
|
|
411
|
-
{ name: 'Sort-Order', value: params.sortOrder },
|
|
412
376
|
{ name: 'Address', value: params.address },
|
|
377
|
+
...paginationParamsToTags(params),
|
|
378
|
+
];
|
|
379
|
+
return this.process.read({
|
|
380
|
+
tags: pruneTags(allTags),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async getPrimaryNameRequest(params) {
|
|
384
|
+
const allTags = [
|
|
385
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
386
|
+
{ name: 'Name', value: params.name },
|
|
387
|
+
{
|
|
388
|
+
name: 'Initiator',
|
|
389
|
+
value: params.initiator,
|
|
390
|
+
},
|
|
391
|
+
];
|
|
392
|
+
return this.process.read({
|
|
393
|
+
tags: allTags,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
async getPrimaryNameRequests(params) {
|
|
397
|
+
return this.process.read({
|
|
398
|
+
tags: [
|
|
399
|
+
{ name: 'Action', value: 'Primary-Name-Requests' },
|
|
400
|
+
...paginationParamsToTags(params),
|
|
401
|
+
],
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
async getPrimaryName(params) {
|
|
405
|
+
const allTags = [
|
|
406
|
+
{ name: 'Action', value: 'Primary-Name' },
|
|
407
|
+
{
|
|
408
|
+
name: 'Address',
|
|
409
|
+
value: params?.address,
|
|
410
|
+
},
|
|
411
|
+
{ name: 'Name', value: params?.name },
|
|
413
412
|
];
|
|
414
413
|
return this.process.read({
|
|
415
414
|
tags: pruneTags(allTags),
|
|
416
415
|
});
|
|
417
416
|
}
|
|
417
|
+
async getPrimaryNames(params) {
|
|
418
|
+
return this.process.read({
|
|
419
|
+
tags: [
|
|
420
|
+
{ name: 'Action', value: 'Primary-Names' },
|
|
421
|
+
...paginationParamsToTags(params),
|
|
422
|
+
],
|
|
423
|
+
});
|
|
424
|
+
}
|
|
418
425
|
}
|
|
419
426
|
export class IOWriteable extends IOReadable {
|
|
420
427
|
signer;
|
|
@@ -757,4 +764,13 @@ export class IOWriteable extends IOReadable {
|
|
|
757
764
|
tags: pruneTags(allTags),
|
|
758
765
|
});
|
|
759
766
|
}
|
|
767
|
+
async requestPrimaryName(params) {
|
|
768
|
+
return this.process.send({
|
|
769
|
+
signer: this.signer,
|
|
770
|
+
tags: [
|
|
771
|
+
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
772
|
+
{ name: 'Name', value: params.name },
|
|
773
|
+
],
|
|
774
|
+
});
|
|
775
|
+
}
|
|
760
776
|
}
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -42,6 +42,10 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, luaCodeTxId = A
|
|
|
42
42
|
name: 'ANT-Registry-Id',
|
|
43
43
|
value: antRegistryId,
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Source-Code-TX-ID', // utility for understanding what the original source id of the lua code was
|
|
47
|
+
value: luaCodeTxId,
|
|
48
|
+
},
|
|
45
49
|
],
|
|
46
50
|
});
|
|
47
51
|
const aosClient = new AOProcess({
|
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -18,3 +18,12 @@ export const getCurrentBlockUnixTimestampMs = async (arweave) => {
|
|
|
18
18
|
return Date.now(); // fallback to current time
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
export const paginationParamsToTags = (params) => {
|
|
22
|
+
const tags = [
|
|
23
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
24
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
25
|
+
{ name: 'Sort-By', value: params?.sortBy?.toString() },
|
|
26
|
+
{ name: 'Sort-Order', value: params?.sortOrder?.toString() },
|
|
27
|
+
];
|
|
28
|
+
return pruneTags(tags);
|
|
29
|
+
};
|
package/lib/esm/version.js
CHANGED
package/lib/types/common/io.d.ts
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
|
-
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
-
import { AoArNSNameData, AoAuctionPriceData, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoIORead, AoIOWrite, AoRegistrationFees, AoVaultData, AoWalletVault, EpochInput } from '../types/io.js';
|
|
17
|
+
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
+
import { AoArNSNameData, AoArNSReservedNameDataWithName, AoAuctionPriceData, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoIORead, AoIOWrite, AoRegistrationFees, AoVaultData, AoWalletVault, EpochInput } from '../types/io.js';
|
|
19
19
|
import { mIOToken } from '../types/token.js';
|
|
20
20
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
21
|
export declare class IO {
|
|
@@ -56,7 +56,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
56
56
|
name: string;
|
|
57
57
|
}): Promise<AoArNSNameData | undefined>;
|
|
58
58
|
getArNSRecords(params?: PaginationParams<AoArNSNameDataWithName>): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
59
|
-
getArNSReservedNames(): Promise<
|
|
59
|
+
getArNSReservedNames(params?: PaginationParams<AoArNSReservedNameDataWithName>): Promise<PaginationResult<AoArNSReservedNameDataWithName>>;
|
|
60
60
|
getArNSReservedName({ name, }: {
|
|
61
61
|
name: string;
|
|
62
62
|
}): Promise<AoArNSReservedNameData | undefined>;
|
|
@@ -128,6 +128,18 @@ export declare class IOReadable implements AoIORead {
|
|
|
128
128
|
getDelegations(params: PaginationParams<AoDelegation> & {
|
|
129
129
|
address: WalletAddress;
|
|
130
130
|
}): Promise<PaginationResult<AoDelegation>>;
|
|
131
|
+
getPrimaryNameRequest(params: {
|
|
132
|
+
initiator: WalletAddress;
|
|
133
|
+
} | {
|
|
134
|
+
name: string;
|
|
135
|
+
}): Promise<AoMessageResult>;
|
|
136
|
+
getPrimaryNameRequests(params: PaginationParams<AoPrimaryNameRequest>): Promise<PaginationResult<AoPrimaryNameRequest>>;
|
|
137
|
+
getPrimaryName(params: {
|
|
138
|
+
address: WalletAddress;
|
|
139
|
+
} | {
|
|
140
|
+
name: string;
|
|
141
|
+
}): Promise<AoPrimaryName>;
|
|
142
|
+
getPrimaryNames(params: PaginationParams<AoPrimaryName>): Promise<PaginationResult<AoPrimaryName>>;
|
|
131
143
|
}
|
|
132
144
|
export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
133
145
|
protected process: AOProcess;
|
|
@@ -229,4 +241,7 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
229
241
|
type?: 'lease' | 'permabuy';
|
|
230
242
|
years?: number;
|
|
231
243
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
244
|
+
requestPrimaryName(params: {
|
|
245
|
+
name: string;
|
|
246
|
+
}): Promise<AoMessageResult>;
|
|
232
247
|
}
|
|
@@ -44,6 +44,16 @@ export type WriteParameters<Input> = WithSigner<Required<ReadParameters<Input>>>
|
|
|
44
44
|
export type AoMessageResult = {
|
|
45
45
|
id: string;
|
|
46
46
|
};
|
|
47
|
+
export type AoPrimaryNameRequest = {
|
|
48
|
+
name: string;
|
|
49
|
+
startTimestamp: Timestamp;
|
|
50
|
+
endTimestamp: Timestamp;
|
|
51
|
+
};
|
|
52
|
+
export type AoPrimaryName = {
|
|
53
|
+
owner: WalletAddress;
|
|
54
|
+
name: string;
|
|
55
|
+
startTimestamp: Timestamp;
|
|
56
|
+
};
|
|
47
57
|
export type AtLeastOne<T, U = {
|
|
48
58
|
[K in keyof T]-?: Record<K, T[K]>;
|
|
49
59
|
}> = Partial<T> & U[keyof U];
|