@ar.io/sdk 2.3.3-alpha.1 → 2.4.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 +282 -9
- package/bundles/web.bundle.min.js +63 -63
- package/lib/cjs/common/ant.js +80 -1
- package/lib/cjs/common/io.js +204 -49
- package/lib/cjs/types/ant.js +11 -1
- package/lib/cjs/utils/arweave.js +5 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +80 -1
- package/lib/esm/common/io.js +202 -47
- package/lib/esm/types/ant.js +10 -0
- package/lib/esm/utils/arweave.js +3 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +52 -1
- package/lib/types/common/io.d.ts +87 -10
- package/lib/types/types/ant.d.ts +29 -0
- package/lib/types/types/io.d.ts +69 -14
- package/lib/types/utils/arweave.d.ts +7 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +8 -6
package/lib/cjs/common/ant.js
CHANGED
|
@@ -331,7 +331,7 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
331
331
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
332
332
|
* @example
|
|
333
333
|
* ```ts
|
|
334
|
-
* ant.setName({ name: "
|
|
334
|
+
* ant.setName({ name: "test" }); // results in the resolution of `test_<apexName>.ar.io`
|
|
335
335
|
* ```
|
|
336
336
|
*/
|
|
337
337
|
async setName({ name }, options) {
|
|
@@ -344,5 +344,84 @@ class AoANTWriteable extends AoANTReadable {
|
|
|
344
344
|
signer: this.signer,
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* @param description @type {string} Sets the ANT Description.
|
|
349
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* ant.setDescription({ description: "This name is used for the ArDrive" });
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
async setDescription({ description }, options) {
|
|
356
|
+
return this.process.send({
|
|
357
|
+
tags: [
|
|
358
|
+
...(options?.tags ?? []),
|
|
359
|
+
{ name: 'Action', value: 'Set-Description' },
|
|
360
|
+
{ name: 'Description', value: description },
|
|
361
|
+
],
|
|
362
|
+
signer: this.signer,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* @param keywords @type {string[]} Sets the ANT Keywords.
|
|
367
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* ant.setKeywords({ keywords: ['keyword1', 'keyword2', 'keyword3']});
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
async setKeywords({ keywords }, options) {
|
|
374
|
+
return this.process.send({
|
|
375
|
+
tags: [
|
|
376
|
+
...(options?.tags ?? []),
|
|
377
|
+
{ name: 'Action', value: 'Set-Keywords' },
|
|
378
|
+
{ name: 'Description', value: JSON.stringify(keywords) },
|
|
379
|
+
],
|
|
380
|
+
signer: this.signer,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* @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
|
+
* @param ioProcessId @type {string} The processId of the IO contract. This is where the ANT will send the message to release the name.
|
|
386
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* ant.releaseName({ name: "ardrive", ioProcessId: IO_TESTNET_PROCESS_ID });
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
async releaseName({ name, ioProcessId }, options) {
|
|
393
|
+
return this.process.send({
|
|
394
|
+
tags: [
|
|
395
|
+
...(options?.tags ?? []),
|
|
396
|
+
{ name: 'Action', value: 'Release-Name' },
|
|
397
|
+
{ name: 'Name', value: name },
|
|
398
|
+
{ name: 'IO-Process-Id', value: ioProcessId },
|
|
399
|
+
],
|
|
400
|
+
signer: this.signer,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Sends a message to the IO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
|
|
405
|
+
* @param name @type {string} The name you want to reassign.
|
|
406
|
+
* @param ioProcessId @type {string} The processId of the IO contract.
|
|
407
|
+
* @param antProcessId @type {string} The processId of the ANT contract.
|
|
408
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* ant.reassignName({ name: "ardrive", ioProcessId: IO_TESTNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID });
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
async reassignName({ name, ioProcessId, antProcessId, }, options) {
|
|
415
|
+
return this.process.send({
|
|
416
|
+
tags: [
|
|
417
|
+
...(options?.tags ?? []),
|
|
418
|
+
{ name: 'Action', value: 'Reassign-Name' },
|
|
419
|
+
{ name: 'Name', value: name },
|
|
420
|
+
{ name: 'IO-Process-Id', value: ioProcessId },
|
|
421
|
+
{ name: 'Process-Id', value: antProcessId },
|
|
422
|
+
],
|
|
423
|
+
signer: this.signer,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
347
426
|
}
|
|
348
427
|
exports.AoANTWriteable = AoANTWriteable;
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.IOWriteable = exports.IOReadable = exports.IO = void 0;
|
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const io_js_1 = require("../types/io.js");
|
|
6
6
|
const ao_js_1 = require("../utils/ao.js");
|
|
7
|
-
const arweave_js_1 = require("
|
|
7
|
+
const arweave_js_1 = require("../utils/arweave.js");
|
|
8
|
+
const arweave_js_2 = require("./arweave.js");
|
|
8
9
|
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
9
10
|
const error_js_1 = require("./error.js");
|
|
10
11
|
class IO {
|
|
@@ -23,7 +24,7 @@ exports.IO = IO;
|
|
|
23
24
|
class IOReadable {
|
|
24
25
|
process;
|
|
25
26
|
arweave;
|
|
26
|
-
constructor(config, arweave =
|
|
27
|
+
constructor(config, arweave = arweave_js_2.defaultArweave) {
|
|
27
28
|
if (!config) {
|
|
28
29
|
this.process = new ao_process_js_1.AOProcess({
|
|
29
30
|
processId: constants_js_1.IO_TESTNET_PROCESS_ID,
|
|
@@ -72,9 +73,8 @@ class IOReadable {
|
|
|
72
73
|
value: params?.epochIndex?.toString(),
|
|
73
74
|
},
|
|
74
75
|
];
|
|
75
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
76
76
|
return this.process.read({
|
|
77
|
-
tags:
|
|
77
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
async getEpoch(epoch) {
|
|
@@ -97,9 +97,8 @@ class IOReadable {
|
|
|
97
97
|
value: epoch?.epochIndex?.toString(),
|
|
98
98
|
},
|
|
99
99
|
];
|
|
100
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
101
100
|
return this.process.read({
|
|
102
|
-
tags:
|
|
101
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
async getArNSRecord({ name, }) {
|
|
@@ -110,17 +109,16 @@ class IOReadable {
|
|
|
110
109
|
],
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
|
-
async getArNSRecords(
|
|
112
|
+
async getArNSRecords(params) {
|
|
114
113
|
const allTags = [
|
|
115
114
|
{ name: 'Action', value: 'Paginated-Records' },
|
|
116
|
-
{ name: 'Cursor', value:
|
|
117
|
-
{ name: 'Limit', value:
|
|
118
|
-
{ name: 'Sort-By', value:
|
|
119
|
-
{ name: 'Sort-Order', value:
|
|
115
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
116
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
117
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
118
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
120
119
|
];
|
|
121
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
122
120
|
return this.process.read({
|
|
123
|
-
tags:
|
|
121
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
124
122
|
});
|
|
125
123
|
}
|
|
126
124
|
async getArNSReservedNames() {
|
|
@@ -144,17 +142,16 @@ class IOReadable {
|
|
|
144
142
|
],
|
|
145
143
|
});
|
|
146
144
|
}
|
|
147
|
-
async getBalances(
|
|
145
|
+
async getBalances(params) {
|
|
148
146
|
const allTags = [
|
|
149
147
|
{ name: 'Action', value: 'Paginated-Balances' },
|
|
150
|
-
{ name: 'Cursor', value:
|
|
151
|
-
{ name: 'Limit', value:
|
|
152
|
-
{ name: 'Sort-By', value:
|
|
153
|
-
{ name: 'Sort-Order', value:
|
|
148
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
149
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
150
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
151
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
154
152
|
];
|
|
155
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
156
153
|
return this.process.read({
|
|
157
|
-
tags:
|
|
154
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
158
155
|
});
|
|
159
156
|
}
|
|
160
157
|
async getGateway({ address, }) {
|
|
@@ -165,6 +162,32 @@ class IOReadable {
|
|
|
165
162
|
],
|
|
166
163
|
});
|
|
167
164
|
}
|
|
165
|
+
async getGatewayDelegates({ address, ...pageParams }) {
|
|
166
|
+
const allTags = [
|
|
167
|
+
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
168
|
+
{ name: 'Address', value: address },
|
|
169
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
170
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
171
|
+
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
172
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
173
|
+
];
|
|
174
|
+
return this.process.read({
|
|
175
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async getGatewayDelegateAllowList({ address, ...pageParams }) {
|
|
179
|
+
const allTags = [
|
|
180
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
181
|
+
{ name: 'Address', value: address },
|
|
182
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
183
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
184
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
185
|
+
// note: sortBy is omitted because it's not supported for this action as table is an of addresses
|
|
186
|
+
];
|
|
187
|
+
return this.process.read({
|
|
188
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
168
191
|
async getGateways(pageParams) {
|
|
169
192
|
const allTags = [
|
|
170
193
|
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
@@ -173,9 +196,8 @@ class IOReadable {
|
|
|
173
196
|
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
174
197
|
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
175
198
|
];
|
|
176
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
177
199
|
return this.process.read({
|
|
178
|
-
tags:
|
|
200
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
179
201
|
});
|
|
180
202
|
}
|
|
181
203
|
async getCurrentEpoch() {
|
|
@@ -216,9 +238,8 @@ class IOReadable {
|
|
|
216
238
|
value: epoch?.epochIndex?.toString(),
|
|
217
239
|
},
|
|
218
240
|
];
|
|
219
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
220
241
|
return this.process.read({
|
|
221
|
-
tags:
|
|
242
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
222
243
|
});
|
|
223
244
|
}
|
|
224
245
|
async getPrescribedNames(epoch) {
|
|
@@ -241,9 +262,8 @@ class IOReadable {
|
|
|
241
262
|
value: epoch?.epochIndex?.toString(),
|
|
242
263
|
},
|
|
243
264
|
];
|
|
244
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
245
265
|
return this.process.read({
|
|
246
|
-
tags:
|
|
266
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
247
267
|
});
|
|
248
268
|
}
|
|
249
269
|
async getObservations(epoch) {
|
|
@@ -266,9 +286,8 @@ class IOReadable {
|
|
|
266
286
|
value: epoch?.epochIndex?.toString(),
|
|
267
287
|
},
|
|
268
288
|
];
|
|
269
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
270
289
|
return this.process.read({
|
|
271
|
-
tags:
|
|
290
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
272
291
|
});
|
|
273
292
|
}
|
|
274
293
|
async getDistributions(epoch) {
|
|
@@ -291,12 +310,11 @@ class IOReadable {
|
|
|
291
310
|
value: epoch?.epochIndex?.toString(),
|
|
292
311
|
},
|
|
293
312
|
];
|
|
294
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
295
313
|
return this.process.read({
|
|
296
|
-
tags:
|
|
314
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
297
315
|
});
|
|
298
316
|
}
|
|
299
|
-
async getTokenCost({ intent,
|
|
317
|
+
async getTokenCost({ intent, type, years, name, quantity, }) {
|
|
300
318
|
const allTags = [
|
|
301
319
|
{ name: 'Action', value: 'Token-Cost' },
|
|
302
320
|
{
|
|
@@ -317,7 +335,7 @@ class IOReadable {
|
|
|
317
335
|
},
|
|
318
336
|
{
|
|
319
337
|
name: 'Purchase-Type',
|
|
320
|
-
value:
|
|
338
|
+
value: type,
|
|
321
339
|
},
|
|
322
340
|
{
|
|
323
341
|
name: 'Timestamp',
|
|
@@ -331,9 +349,8 @@ class IOReadable {
|
|
|
331
349
|
})).timestamp.toString(),
|
|
332
350
|
},
|
|
333
351
|
];
|
|
334
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
335
352
|
return this.process.read({
|
|
336
|
-
tags:
|
|
353
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
337
354
|
});
|
|
338
355
|
}
|
|
339
356
|
async getRegistrationFees() {
|
|
@@ -346,6 +363,63 @@ class IOReadable {
|
|
|
346
363
|
tags: [{ name: 'Action', value: 'Demand-Factor' }],
|
|
347
364
|
});
|
|
348
365
|
}
|
|
366
|
+
// Auctions
|
|
367
|
+
async getArNSAuctions(params) {
|
|
368
|
+
const allTags = [
|
|
369
|
+
{ name: 'Action', value: 'Auctions' },
|
|
370
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
371
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
372
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
373
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
374
|
+
];
|
|
375
|
+
return this.process.read({
|
|
376
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
async getArNSAuction({ name, }) {
|
|
380
|
+
const allTags = [
|
|
381
|
+
{ name: 'Action', value: 'Auction-Info' },
|
|
382
|
+
{ name: 'Name', value: name },
|
|
383
|
+
];
|
|
384
|
+
return this.process.read({
|
|
385
|
+
tags: allTags,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Get auction prices for a given auction at the provided intervals
|
|
390
|
+
*
|
|
391
|
+
* @param {Object} params - The parameters for fetching auction prices
|
|
392
|
+
* @param {string} params.name - The name of the auction
|
|
393
|
+
* @param {('permabuy'|'lease')} [params.type='lease'] - The type of purchase
|
|
394
|
+
* @param {number} [params.years=1] - The number of years for lease (only applicable if type is 'lease')
|
|
395
|
+
* @param {number} [params.timestamp=Date.now()] - The timestamp to fetch prices for
|
|
396
|
+
* @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
|
|
397
|
+
* @returns {Promise<AoAuctionPriceData>} The auction price data
|
|
398
|
+
*/
|
|
399
|
+
async getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
|
|
400
|
+
const prunedPriceTags = [
|
|
401
|
+
{ name: 'Action', value: 'Auction-Prices' },
|
|
402
|
+
{ name: 'Name', value: name },
|
|
403
|
+
{
|
|
404
|
+
name: 'Timestamp',
|
|
405
|
+
value: timestamp?.toString() ?? Date.now().toString(),
|
|
406
|
+
},
|
|
407
|
+
{ name: 'Purchase-Type', value: type ?? 'lease' },
|
|
408
|
+
{
|
|
409
|
+
name: 'Years',
|
|
410
|
+
value: type == undefined || type === 'lease'
|
|
411
|
+
? years?.toString() ?? '1'
|
|
412
|
+
: undefined,
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: 'Price-Interval-Ms',
|
|
416
|
+
value: intervalMs?.toString() ?? '900000',
|
|
417
|
+
},
|
|
418
|
+
].filter((tag) => tag.value !== undefined);
|
|
419
|
+
return this.process.read({
|
|
420
|
+
tags: prunedPriceTags,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
349
423
|
}
|
|
350
424
|
exports.IOReadable = IOReadable;
|
|
351
425
|
class IOWriteable extends IOReadable {
|
|
@@ -393,7 +467,7 @@ class IOWriteable extends IOReadable {
|
|
|
393
467
|
signer: this.signer,
|
|
394
468
|
});
|
|
395
469
|
}
|
|
396
|
-
async joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
470
|
+
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
397
471
|
const { tags = [] } = options || {};
|
|
398
472
|
const allTags = [
|
|
399
473
|
...tags,
|
|
@@ -406,6 +480,10 @@ class IOWriteable extends IOReadable {
|
|
|
406
480
|
name: 'Allow-Delegated-Staking',
|
|
407
481
|
value: allowDelegatedStaking?.toString(),
|
|
408
482
|
},
|
|
483
|
+
{
|
|
484
|
+
name: 'Allowed-Delegates',
|
|
485
|
+
value: allowedDelegates?.join(','),
|
|
486
|
+
},
|
|
409
487
|
{
|
|
410
488
|
name: 'Delegate-Reward-Share-Ratio',
|
|
411
489
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -447,10 +525,9 @@ class IOWriteable extends IOReadable {
|
|
|
447
525
|
value: observerAddress,
|
|
448
526
|
},
|
|
449
527
|
];
|
|
450
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
451
528
|
return this.process.send({
|
|
452
529
|
signer: this.signer,
|
|
453
|
-
tags:
|
|
530
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
454
531
|
});
|
|
455
532
|
}
|
|
456
533
|
async leaveNetwork(options) {
|
|
@@ -460,7 +537,7 @@ class IOWriteable extends IOReadable {
|
|
|
460
537
|
tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
|
|
461
538
|
});
|
|
462
539
|
}
|
|
463
|
-
async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
540
|
+
async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
464
541
|
const { tags = [] } = options || {};
|
|
465
542
|
const allTags = [
|
|
466
543
|
...tags,
|
|
@@ -476,6 +553,10 @@ class IOWriteable extends IOReadable {
|
|
|
476
553
|
name: 'Allow-Delegated-Staking',
|
|
477
554
|
value: allowDelegatedStaking?.toString(),
|
|
478
555
|
},
|
|
556
|
+
{
|
|
557
|
+
name: 'Allowed-Delegates',
|
|
558
|
+
value: allowedDelegates?.join(','),
|
|
559
|
+
},
|
|
479
560
|
{
|
|
480
561
|
name: 'Delegate-Reward-Share-Ratio',
|
|
481
562
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -486,10 +567,9 @@ class IOWriteable extends IOReadable {
|
|
|
486
567
|
},
|
|
487
568
|
{ name: 'Auto-Stake', value: autoStake?.toString() },
|
|
488
569
|
];
|
|
489
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
490
570
|
return this.process.send({
|
|
491
571
|
signer: this.signer,
|
|
492
|
-
tags:
|
|
572
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
493
573
|
});
|
|
494
574
|
}
|
|
495
575
|
async delegateStake(params, options) {
|
|
@@ -513,9 +593,31 @@ class IOWriteable extends IOReadable {
|
|
|
513
593
|
{ name: 'Action', value: 'Decrease-Delegate-Stake' },
|
|
514
594
|
{ name: 'Target', value: params.target },
|
|
515
595
|
{ name: 'Quantity', value: params.decreaseQty.valueOf().toString() },
|
|
596
|
+
{ name: 'Instant', value: `${params.instant || false}` },
|
|
516
597
|
],
|
|
517
598
|
});
|
|
518
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Initiates an instant withdrawal from a gateway.
|
|
602
|
+
*
|
|
603
|
+
* @param {Object} params - The parameters for initiating an instant withdrawal
|
|
604
|
+
* @param {string} params.address - The gateway address of the withdrawal, if not provided, the signer's address will be used
|
|
605
|
+
* @param {string} params.vaultId - The vault ID of the withdrawal
|
|
606
|
+
* @returns {Promise<AoMessageResult>} The result of the withdrawal
|
|
607
|
+
*/
|
|
608
|
+
async instantWithdrawal(params, options) {
|
|
609
|
+
const { tags = [] } = options || {};
|
|
610
|
+
const allTags = [
|
|
611
|
+
...tags,
|
|
612
|
+
{ name: 'Action', value: 'Instant-Withdrawal' },
|
|
613
|
+
{ name: 'Vault-Id', value: params.vaultId },
|
|
614
|
+
{ name: 'Address', value: params.gatewayAddress },
|
|
615
|
+
];
|
|
616
|
+
return this.process.send({
|
|
617
|
+
signer: this.signer,
|
|
618
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
619
|
+
});
|
|
620
|
+
}
|
|
519
621
|
async increaseOperatorStake(params, options) {
|
|
520
622
|
const { tags = [] } = options || {};
|
|
521
623
|
return this.process.send({
|
|
@@ -566,12 +668,39 @@ class IOWriteable extends IOReadable {
|
|
|
566
668
|
{ name: 'Process-Id', value: params.processId },
|
|
567
669
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
568
670
|
];
|
|
569
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
570
671
|
return this.process.send({
|
|
571
672
|
signer: this.signer,
|
|
572
|
-
tags:
|
|
673
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Upgrades an existing leased record to a permabuy.
|
|
678
|
+
*
|
|
679
|
+
* @param {Object} params - The parameters for upgrading a record
|
|
680
|
+
* @param {string} params.name - The name of the record to upgrade
|
|
681
|
+
* @param {Object} [options] - The options for the upgrade
|
|
682
|
+
* @returns {Promise<AoMessageResult>} The result of the upgrade
|
|
683
|
+
*/
|
|
684
|
+
async upgradeRecord(params, options) {
|
|
685
|
+
const { tags = [] } = options || {};
|
|
686
|
+
return this.process.send({
|
|
687
|
+
signer: this.signer,
|
|
688
|
+
tags: [
|
|
689
|
+
...tags,
|
|
690
|
+
{ name: 'Action', value: 'Upgrade-Name' }, // TODO: align on Update-Record vs. Upgrade-Name (contract currently uses Upgrade-Name)
|
|
691
|
+
{ name: 'Name', value: params.name },
|
|
692
|
+
],
|
|
573
693
|
});
|
|
574
694
|
}
|
|
695
|
+
/**
|
|
696
|
+
* Extends the lease of an existing leased record.
|
|
697
|
+
*
|
|
698
|
+
* @param {Object} params - The parameters for extending a lease
|
|
699
|
+
* @param {string} params.name - The name of the record to extend
|
|
700
|
+
* @param {number} params.years - The number of years to extend the lease
|
|
701
|
+
* @param {Object} [options] - The options for the extension
|
|
702
|
+
* @returns {Promise<AoMessageResult>} The result of the extension
|
|
703
|
+
*/
|
|
575
704
|
async extendLease(params, options) {
|
|
576
705
|
const { tags = [] } = options || {};
|
|
577
706
|
return this.process.send({
|
|
@@ -596,16 +725,42 @@ class IOWriteable extends IOReadable {
|
|
|
596
725
|
],
|
|
597
726
|
});
|
|
598
727
|
}
|
|
599
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Cancel a withdrawal from a gateway.
|
|
730
|
+
*
|
|
731
|
+
* @param {Object} params - The parameters for cancelling a withdrawal
|
|
732
|
+
* @param {string} [params.address] - The address of the withdrawal (optional). If not provided, the signer's address will be used.
|
|
733
|
+
* @param {string} params.vaultId - The vault ID of the withdrawal.
|
|
734
|
+
* @param {Object} [options] - The options for the cancellation
|
|
735
|
+
* @returns {Promise<AoMessageResult>} The result of the cancellation
|
|
736
|
+
*/
|
|
737
|
+
async cancelWithdrawal(params, options) {
|
|
600
738
|
const { tags = [] } = options || {};
|
|
739
|
+
const allTags = [
|
|
740
|
+
...tags,
|
|
741
|
+
{ name: 'Action', value: 'Cancel-Withdrawal' },
|
|
742
|
+
{ name: 'Vault-Id', value: params.vaultId },
|
|
743
|
+
{ name: 'Address', value: params.gatewayAddress },
|
|
744
|
+
];
|
|
601
745
|
return this.process.send({
|
|
602
746
|
signer: this.signer,
|
|
603
|
-
tags:
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
747
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
async submitAuctionBid(params, options) {
|
|
751
|
+
const { tags = [] } = options || {};
|
|
752
|
+
const allTags = [
|
|
753
|
+
...tags,
|
|
754
|
+
{ name: 'Action', value: 'Auction-Bid' },
|
|
755
|
+
{ name: 'Name', value: params.name },
|
|
756
|
+
{ name: 'Process-Id', value: params.processId },
|
|
757
|
+
{ name: 'Quantity', value: params.quantity?.toString() ?? undefined },
|
|
758
|
+
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
759
|
+
{ name: 'Years', value: params.years?.toString() ?? undefined },
|
|
760
|
+
];
|
|
761
|
+
return this.process.send({
|
|
762
|
+
signer: this.signer,
|
|
763
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
609
764
|
});
|
|
610
765
|
}
|
|
611
766
|
}
|
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.IntegerStringSchema = exports.ArweaveTxIdSchema = void 0;
|
|
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;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -45,6 +45,8 @@ exports.IntegerStringSchema = zod_1.z
|
|
|
45
45
|
const num = parseInt(val);
|
|
46
46
|
return Number.isInteger(num) && num >= 0;
|
|
47
47
|
}, { message: 'Must be a non negative integer string' });
|
|
48
|
+
exports.AntDescriptionSchema = zod_1.z.string(); // TODO: add specific limits for description ie max length
|
|
49
|
+
exports.AntKeywordsSchema = zod_1.z.array(zod_1.z.string()); // TODO: add specific limits for keywords ie max amount and max length
|
|
48
50
|
exports.AntRecordSchema = zod_1.z.object({
|
|
49
51
|
transactionId: exports.ArweaveTxIdSchema.describe('The Target ID of the undername'),
|
|
50
52
|
ttlSeconds: zod_1.z.number(),
|
|
@@ -55,6 +57,8 @@ exports.AntBalancesSchema = zod_1.z.record(exports.ArweaveTxIdSchema.describe('H
|
|
|
55
57
|
exports.AntStateSchema = zod_1.z.object({
|
|
56
58
|
Name: zod_1.z.string().describe('The name of the ANT.'),
|
|
57
59
|
Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
|
|
60
|
+
Description: zod_1.z.string().describe('The description for the ANT.'),
|
|
61
|
+
Keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
|
|
58
62
|
Denomination: zod_1.z
|
|
59
63
|
.number()
|
|
60
64
|
.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.')
|
|
@@ -91,8 +95,12 @@ exports.AntHandlerNames = [
|
|
|
91
95
|
'records',
|
|
92
96
|
'setName',
|
|
93
97
|
'setTicker',
|
|
98
|
+
'setDescription',
|
|
99
|
+
'setKeywords',
|
|
94
100
|
'initializeState',
|
|
95
101
|
'state',
|
|
102
|
+
'releaseName',
|
|
103
|
+
'reassignName',
|
|
96
104
|
];
|
|
97
105
|
exports.AntHandlersSchema = zod_1.z
|
|
98
106
|
.array(zod_1.z.string({ description: 'Handler Name' }))
|
|
@@ -107,6 +115,8 @@ exports.AntInfoSchema = zod_1.z.object({
|
|
|
107
115
|
['Source-Code-TX-ID']: exports.ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
|
|
108
116
|
Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
|
|
109
117
|
['Total-Supply']: exports.IntegerStringSchema.describe('Total supply of the ANT in circulation.'),
|
|
118
|
+
Description: exports.AntDescriptionSchema.describe('The description for the ANT.'),
|
|
119
|
+
Keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
|
|
110
120
|
Logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
|
|
111
121
|
Denomination: exports.IntegerStringSchema.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.'),
|
|
112
122
|
Handlers: exports.AntHandlersSchema.optional().describe('List of handlers for the ANT.'),
|
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.isBlockHeight = exports.validateArweaveId = void 0;
|
|
3
|
+
exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -25,3 +25,7 @@ function isBlockHeight(height) {
|
|
|
25
25
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
26
26
|
}
|
|
27
27
|
exports.isBlockHeight = isBlockHeight;
|
|
28
|
+
const pruneTags = (tags) => {
|
|
29
|
+
return tags.filter((tag) => tag.value !== undefined);
|
|
30
|
+
};
|
|
31
|
+
exports.pruneTags = pruneTags;
|
package/lib/cjs/version.js
CHANGED