@ar.io/sdk 2.5.0-alpha.9 → 2.5.1-alpha.1
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 +122 -33
- package/bundles/web.bundle.min.js +51 -51
- package/lib/cjs/common/ant.js +3 -4
- package/lib/cjs/common/io.js +59 -0
- package/lib/cjs/constants.js +1 -1
- 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/common/io.js +59 -0
- package/lib/esm/constants.js +1 -1
- 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/common/io.d.ts +36 -3
- package/lib/types/constants.d.ts +1 -1
- package/lib/types/types/ant.d.ts +1 -34
- package/lib/types/types/common.d.ts +10 -0
- package/lib/types/types/io.d.ts +24 -4
- 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/common/io.js
CHANGED
|
@@ -378,6 +378,24 @@ class IOReadable {
|
|
|
378
378
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
|
+
async getAllowedDelegates(params) {
|
|
382
|
+
return this.process.read({
|
|
383
|
+
tags: [
|
|
384
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
385
|
+
{ name: 'Address', value: params.address },
|
|
386
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
387
|
+
],
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async getGatewayVaults(params) {
|
|
391
|
+
return this.process.read({
|
|
392
|
+
tags: [
|
|
393
|
+
{ name: 'Action', value: 'Paginated-Gateway-Vaults' },
|
|
394
|
+
{ name: 'Address', value: params.address },
|
|
395
|
+
...(0, arweave_js_1.paginationParamsToTags)(params),
|
|
396
|
+
],
|
|
397
|
+
});
|
|
398
|
+
}
|
|
381
399
|
async getPrimaryNameRequest(params) {
|
|
382
400
|
const allTags = [
|
|
383
401
|
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
@@ -420,6 +438,21 @@ class IOReadable {
|
|
|
420
438
|
],
|
|
421
439
|
});
|
|
422
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Get current redelegation fee percentage for address
|
|
443
|
+
*
|
|
444
|
+
* @param {Object} params - The parameters for fetching redelegation fee
|
|
445
|
+
* @param {string} params.address - The address to fetch the fee for
|
|
446
|
+
* @returns {Promise<AoMessageResult>} The redelegation fee result
|
|
447
|
+
*/
|
|
448
|
+
async getRedelegationFee(params) {
|
|
449
|
+
return this.process.read({
|
|
450
|
+
tags: [
|
|
451
|
+
{ name: 'Action', value: 'Redelegation-Fee' },
|
|
452
|
+
{ name: 'Address', value: params.address },
|
|
453
|
+
],
|
|
454
|
+
});
|
|
455
|
+
}
|
|
423
456
|
}
|
|
424
457
|
exports.IOReadable = IOReadable;
|
|
425
458
|
class IOWriteable extends IOReadable {
|
|
@@ -772,5 +805,31 @@ class IOWriteable extends IOReadable {
|
|
|
772
805
|
],
|
|
773
806
|
});
|
|
774
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Redelegate stake from one gateway to another gateway.
|
|
810
|
+
*
|
|
811
|
+
* @param {Object} params - The parameters for redelegating stake
|
|
812
|
+
* @param {string} params.target - The target gateway address
|
|
813
|
+
* @param {string} params.source - The source gateway address
|
|
814
|
+
* @param {number} params.stakeQty - The quantity of stake to redelegate
|
|
815
|
+
* @param {string} params.vaultId - An optional vault ID to redelegate from
|
|
816
|
+
* @param {Object} [options] - The options for the redelegation
|
|
817
|
+
* @returns {Promise<AoMessageResult>} The result of the redelegation
|
|
818
|
+
*/
|
|
819
|
+
async redelegateStake(params, options) {
|
|
820
|
+
const { tags = [] } = options || {};
|
|
821
|
+
const allTags = [
|
|
822
|
+
...tags,
|
|
823
|
+
{ name: 'Action', value: 'Redelegate-Stake' },
|
|
824
|
+
{ name: 'Target', value: params.target },
|
|
825
|
+
{ name: 'Source', value: params.source },
|
|
826
|
+
{ name: 'Quantity', value: params.stakeQty.valueOf().toString() },
|
|
827
|
+
{ name: 'Vault-Id', value: params.vaultId },
|
|
828
|
+
];
|
|
829
|
+
return this.process.send({
|
|
830
|
+
signer: this.signer,
|
|
831
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
832
|
+
});
|
|
833
|
+
}
|
|
775
834
|
}
|
|
776
835
|
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 = 'pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30';
|
|
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.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/common/io.js
CHANGED
|
@@ -374,6 +374,24 @@ export class IOReadable {
|
|
|
374
374
|
tags: pruneTags(allTags),
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
|
+
async getAllowedDelegates(params) {
|
|
378
|
+
return this.process.read({
|
|
379
|
+
tags: [
|
|
380
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
381
|
+
{ name: 'Address', value: params.address },
|
|
382
|
+
...paginationParamsToTags(params),
|
|
383
|
+
],
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async getGatewayVaults(params) {
|
|
387
|
+
return this.process.read({
|
|
388
|
+
tags: [
|
|
389
|
+
{ name: 'Action', value: 'Paginated-Gateway-Vaults' },
|
|
390
|
+
{ name: 'Address', value: params.address },
|
|
391
|
+
...paginationParamsToTags(params),
|
|
392
|
+
],
|
|
393
|
+
});
|
|
394
|
+
}
|
|
377
395
|
async getPrimaryNameRequest(params) {
|
|
378
396
|
const allTags = [
|
|
379
397
|
{ name: 'Action', value: 'Primary-Name-Request' },
|
|
@@ -416,6 +434,21 @@ export class IOReadable {
|
|
|
416
434
|
],
|
|
417
435
|
});
|
|
418
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Get current redelegation fee percentage for address
|
|
439
|
+
*
|
|
440
|
+
* @param {Object} params - The parameters for fetching redelegation fee
|
|
441
|
+
* @param {string} params.address - The address to fetch the fee for
|
|
442
|
+
* @returns {Promise<AoMessageResult>} The redelegation fee result
|
|
443
|
+
*/
|
|
444
|
+
async getRedelegationFee(params) {
|
|
445
|
+
return this.process.read({
|
|
446
|
+
tags: [
|
|
447
|
+
{ name: 'Action', value: 'Redelegation-Fee' },
|
|
448
|
+
{ name: 'Address', value: params.address },
|
|
449
|
+
],
|
|
450
|
+
});
|
|
451
|
+
}
|
|
419
452
|
}
|
|
420
453
|
export class IOWriteable extends IOReadable {
|
|
421
454
|
signer;
|
|
@@ -767,4 +800,30 @@ export class IOWriteable extends IOReadable {
|
|
|
767
800
|
],
|
|
768
801
|
});
|
|
769
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Redelegate stake from one gateway to another gateway.
|
|
805
|
+
*
|
|
806
|
+
* @param {Object} params - The parameters for redelegating stake
|
|
807
|
+
* @param {string} params.target - The target gateway address
|
|
808
|
+
* @param {string} params.source - The source gateway address
|
|
809
|
+
* @param {number} params.stakeQty - The quantity of stake to redelegate
|
|
810
|
+
* @param {string} params.vaultId - An optional vault ID to redelegate from
|
|
811
|
+
* @param {Object} [options] - The options for the redelegation
|
|
812
|
+
* @returns {Promise<AoMessageResult>} The result of the redelegation
|
|
813
|
+
*/
|
|
814
|
+
async redelegateStake(params, options) {
|
|
815
|
+
const { tags = [] } = options || {};
|
|
816
|
+
const allTags = [
|
|
817
|
+
...tags,
|
|
818
|
+
{ name: 'Action', value: 'Redelegate-Stake' },
|
|
819
|
+
{ name: 'Target', value: params.target },
|
|
820
|
+
{ name: 'Source', value: params.source },
|
|
821
|
+
{ name: 'Quantity', value: params.stakeQty.valueOf().toString() },
|
|
822
|
+
{ name: 'Vault-Id', value: params.vaultId },
|
|
823
|
+
];
|
|
824
|
+
return this.process.send({
|
|
825
|
+
signer: this.signer,
|
|
826
|
+
tags: pruneTags(allTags),
|
|
827
|
+
});
|
|
828
|
+
}
|
|
770
829
|
}
|
package/lib/esm/constants.js
CHANGED
|
@@ -27,5 +27,5 @@ export const IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdi
|
|
|
27
27
|
export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
|
|
28
28
|
export const MIO_PER_IO = 1_000_000;
|
|
29
29
|
export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
|
|
30
|
-
export const ANT_LUA_ID = '
|
|
30
|
+
export const ANT_LUA_ID = 'pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30';
|
|
31
31
|
export const DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
|
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/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, 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';
|
|
17
|
+
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, 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, AoGatewayVault, 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 {
|
|
@@ -128,11 +128,17 @@ export declare class IOReadable implements AoIORead {
|
|
|
128
128
|
getDelegations(params: PaginationParams<AoDelegation> & {
|
|
129
129
|
address: WalletAddress;
|
|
130
130
|
}): Promise<PaginationResult<AoDelegation>>;
|
|
131
|
+
getAllowedDelegates(params: PaginationParams & {
|
|
132
|
+
address: WalletAddress;
|
|
133
|
+
}): Promise<PaginationResult<WalletAddress>>;
|
|
134
|
+
getGatewayVaults(params: PaginationParams<AoGatewayVault> & {
|
|
135
|
+
address: WalletAddress;
|
|
136
|
+
}): Promise<PaginationResult<AoGatewayVault>>;
|
|
131
137
|
getPrimaryNameRequest(params: {
|
|
132
138
|
initiator: WalletAddress;
|
|
133
139
|
} | {
|
|
134
140
|
name: string;
|
|
135
|
-
}): Promise<
|
|
141
|
+
}): Promise<AoPrimaryNameRequest>;
|
|
136
142
|
getPrimaryNameRequests(params: PaginationParams<AoPrimaryNameRequest>): Promise<PaginationResult<AoPrimaryNameRequest>>;
|
|
137
143
|
getPrimaryName(params: {
|
|
138
144
|
address: WalletAddress;
|
|
@@ -140,6 +146,16 @@ export declare class IOReadable implements AoIORead {
|
|
|
140
146
|
name: string;
|
|
141
147
|
}): Promise<AoPrimaryName>;
|
|
142
148
|
getPrimaryNames(params: PaginationParams<AoPrimaryName>): Promise<PaginationResult<AoPrimaryName>>;
|
|
149
|
+
/**
|
|
150
|
+
* Get current redelegation fee percentage for address
|
|
151
|
+
*
|
|
152
|
+
* @param {Object} params - The parameters for fetching redelegation fee
|
|
153
|
+
* @param {string} params.address - The address to fetch the fee for
|
|
154
|
+
* @returns {Promise<AoMessageResult>} The redelegation fee result
|
|
155
|
+
*/
|
|
156
|
+
getRedelegationFee(params: {
|
|
157
|
+
address: WalletAddress;
|
|
158
|
+
}): Promise<AoRedelegationFeeInfo>;
|
|
143
159
|
}
|
|
144
160
|
export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
145
161
|
protected process: AOProcess;
|
|
@@ -244,4 +260,21 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
244
260
|
requestPrimaryName(params: {
|
|
245
261
|
name: string;
|
|
246
262
|
}): Promise<AoMessageResult>;
|
|
263
|
+
/**
|
|
264
|
+
* Redelegate stake from one gateway to another gateway.
|
|
265
|
+
*
|
|
266
|
+
* @param {Object} params - The parameters for redelegating stake
|
|
267
|
+
* @param {string} params.target - The target gateway address
|
|
268
|
+
* @param {string} params.source - The source gateway address
|
|
269
|
+
* @param {number} params.stakeQty - The quantity of stake to redelegate
|
|
270
|
+
* @param {string} params.vaultId - An optional vault ID to redelegate from
|
|
271
|
+
* @param {Object} [options] - The options for the redelegation
|
|
272
|
+
* @returns {Promise<AoMessageResult>} The result of the redelegation
|
|
273
|
+
*/
|
|
274
|
+
redelegateStake(params: {
|
|
275
|
+
target: string;
|
|
276
|
+
source: string;
|
|
277
|
+
stakeQty: number | mIOToken;
|
|
278
|
+
vaultId?: string;
|
|
279
|
+
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
247
280
|
}
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export declare const IO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmt
|
|
|
25
25
|
export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
|
|
26
26
|
export declare const MIO_PER_IO = 1000000;
|
|
27
27
|
export declare const AOS_MODULE_ID = "cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk";
|
|
28
|
-
export declare const ANT_LUA_ID = "
|
|
28
|
+
export declare const ANT_LUA_ID = "pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30";
|
|
29
29
|
export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
|
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>;
|
|
@@ -54,6 +54,16 @@ export type AoPrimaryName = {
|
|
|
54
54
|
name: string;
|
|
55
55
|
startTimestamp: Timestamp;
|
|
56
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Users are allowed one free redelegation every seven epochs. Each additional
|
|
59
|
+
* redelegation increases the fee by 10%, capping at a 60% redelegation fee
|
|
60
|
+
*/
|
|
61
|
+
export type AoRedelegationFeeInfo = {
|
|
62
|
+
/** Percentage of redelegated stake that will be returned to the protocol on redelegation */
|
|
63
|
+
redelegationFeeRate: number;
|
|
64
|
+
/** Timestamp when the redelegation fee will reset to zero */
|
|
65
|
+
feeResetTimestamp: number;
|
|
66
|
+
};
|
|
57
67
|
export type AtLeastOne<T, U = {
|
|
58
68
|
[K in keyof T]-?: Record<K, T[K]>;
|
|
59
69
|
}> = Partial<T> & U[keyof U];
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { AOProcess } from '../common/index.js';
|
|
17
|
-
import { AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AtLeastOne, BlockHeight, ProcessId, Timestamp, TransactionId, WalletAddress, WriteOptions } from './index.js';
|
|
17
|
+
import { AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AtLeastOne, BlockHeight, ProcessId, Timestamp, TransactionId, WalletAddress, WriteOptions } from './index.js';
|
|
18
18
|
import { mIOToken } from './token.js';
|
|
19
19
|
export type PaginationParams<T = Record<string, never>> = {
|
|
20
20
|
cursor?: string;
|
|
@@ -140,10 +140,8 @@ export type AoWalletVault = AoVaultData & {
|
|
|
140
140
|
};
|
|
141
141
|
export type AoGateway = {
|
|
142
142
|
settings: AoGatewaySettings;
|
|
143
|
-
delegates: AoGatewayDelegates;
|
|
144
143
|
stats: AoGatewayStats;
|
|
145
144
|
totalDelegatedStake: number;
|
|
146
|
-
vaults: Record<WalletAddress, AoVaultData>;
|
|
147
145
|
startTimestamp: Timestamp;
|
|
148
146
|
endTimestamp: Timestamp;
|
|
149
147
|
observerAddress: WalletAddress;
|
|
@@ -239,6 +237,13 @@ export type AoStakeDelegation = AoDelegationBase & {
|
|
|
239
237
|
balance: number;
|
|
240
238
|
};
|
|
241
239
|
export type AoDelegation = AoStakeDelegation | AoVaultDelegation;
|
|
240
|
+
export type AoGatewayVault = {
|
|
241
|
+
cursorId: string;
|
|
242
|
+
vaultId: TransactionId;
|
|
243
|
+
balance: number;
|
|
244
|
+
endTimestamp: Timestamp;
|
|
245
|
+
startTimestamp: Timestamp;
|
|
246
|
+
};
|
|
242
247
|
export type AoJoinNetworkParams = Pick<AoGateway, 'operatorStake' | 'observerAddress'> & Partial<AoGatewaySettings>;
|
|
243
248
|
export type AoUpdateGatewaySettingsParams = AtLeastOne<AoJoinNetworkParams>;
|
|
244
249
|
export interface AoIORead {
|
|
@@ -263,6 +268,12 @@ export interface AoIORead {
|
|
|
263
268
|
getDelegations(params: PaginationParams<AoDelegation> & {
|
|
264
269
|
address: WalletAddress;
|
|
265
270
|
}): Promise<PaginationResult<AoDelegation>>;
|
|
271
|
+
getAllowedDelegates(params: PaginationParams & {
|
|
272
|
+
address: WalletAddress;
|
|
273
|
+
}): Promise<PaginationResult<WalletAddress>>;
|
|
274
|
+
getGatewayVaults(params: PaginationParams<AoGatewayVault> & {
|
|
275
|
+
address: WalletAddress;
|
|
276
|
+
}): Promise<PaginationResult<AoGatewayVault>>;
|
|
266
277
|
getBalance(params: {
|
|
267
278
|
address: WalletAddress;
|
|
268
279
|
}): Promise<number>;
|
|
@@ -310,7 +321,7 @@ export interface AoIORead {
|
|
|
310
321
|
initiator: WalletAddress;
|
|
311
322
|
} | {
|
|
312
323
|
name: string;
|
|
313
|
-
}): Promise<
|
|
324
|
+
}): Promise<AoPrimaryNameRequest>;
|
|
314
325
|
getPrimaryNameRequests(params: PaginationParams<AoPrimaryNameRequest> & {
|
|
315
326
|
initiator?: WalletAddress;
|
|
316
327
|
}): Promise<PaginationResult<AoPrimaryNameRequest>>;
|
|
@@ -320,6 +331,9 @@ export interface AoIORead {
|
|
|
320
331
|
name: string;
|
|
321
332
|
}): Promise<AoPrimaryName>;
|
|
322
333
|
getPrimaryNames(params?: PaginationParams<AoPrimaryName>): Promise<PaginationResult<AoPrimaryName>>;
|
|
334
|
+
getRedelegationFee(params: {
|
|
335
|
+
address: WalletAddress;
|
|
336
|
+
}): Promise<AoRedelegationFeeInfo>;
|
|
323
337
|
}
|
|
324
338
|
export interface AoIOWrite extends AoIORead {
|
|
325
339
|
transfer({ target, qty, }: {
|
|
@@ -383,6 +397,12 @@ export interface AoIOWrite extends AoIORead {
|
|
|
383
397
|
requestPrimaryName(params: {
|
|
384
398
|
name: string;
|
|
385
399
|
}): Promise<AoMessageResult>;
|
|
400
|
+
redelegateStake(params: {
|
|
401
|
+
target: string;
|
|
402
|
+
source: string;
|
|
403
|
+
stakeQty: number | mIOToken;
|
|
404
|
+
vaultId?: string;
|
|
405
|
+
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
386
406
|
}
|
|
387
407
|
export declare function isProcessConfiguration(config: object): config is {
|
|
388
408
|
process: AOProcess;
|
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