@ar.io/sdk 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +24 -1
- package/bundles/web.bundle.min.js +131 -98
- package/lib/cjs/common/ant.js +294 -3
- package/lib/cjs/common/contracts/ao-process.js +1 -1
- package/lib/cjs/common/http.js +1 -2
- package/lib/cjs/common/index.js +0 -1
- package/lib/cjs/common/io.js +0 -4
- package/lib/cjs/common/logger.js +31 -19
- package/lib/cjs/utils/http-client.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +290 -1
- package/lib/esm/common/contracts/ao-process.js +2 -2
- package/lib/esm/common/http.js +2 -3
- package/lib/esm/common/index.js +0 -1
- package/lib/esm/common/io.js +0 -4
- package/lib/esm/common/logger.js +29 -14
- package/lib/esm/utils/http-client.js +2 -2
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +176 -1
- package/lib/types/common/contracts/ao-process.d.ts +2 -2
- package/lib/types/common/http.d.ts +3 -2
- package/lib/types/common/index.d.ts +0 -1
- package/lib/types/common/logger.d.ts +10 -3
- package/lib/types/common.d.ts +0 -7
- package/lib/types/utils/http-client.d.ts +2 -2
- package/lib/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/lib/cjs/common/ant-ao.js +0 -297
- package/lib/esm/common/ant-ao.js +0 -292
- package/lib/types/common/ant-ao.d.ts +0 -194
package/lib/esm/common/ant.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types.js';
|
|
18
|
-
import {
|
|
18
|
+
import { AOProcess, InvalidContractConfigurationError } from './index.js';
|
|
19
19
|
export class ANT {
|
|
20
20
|
static init({ signer, ...config }) {
|
|
21
21
|
// ao supported implementation
|
|
@@ -28,3 +28,292 @@ export class ANT {
|
|
|
28
28
|
throw new InvalidContractConfigurationError();
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
export class AoANTReadable {
|
|
32
|
+
process;
|
|
33
|
+
constructor(config) {
|
|
34
|
+
if (isProcessConfiguration(config)) {
|
|
35
|
+
this.process = config.process;
|
|
36
|
+
}
|
|
37
|
+
else if (isProcessIdConfiguration(config)) {
|
|
38
|
+
this.process = new AOProcess({
|
|
39
|
+
processId: config.processId,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new InvalidContractConfigurationError();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async getState() {
|
|
47
|
+
const tags = [{ name: 'Action', value: 'State' }];
|
|
48
|
+
const res = await this.process.read({
|
|
49
|
+
tags,
|
|
50
|
+
});
|
|
51
|
+
return res;
|
|
52
|
+
}
|
|
53
|
+
async getInfo() {
|
|
54
|
+
const tags = [{ name: 'Action', value: 'Info' }];
|
|
55
|
+
const info = await this.process.read({
|
|
56
|
+
tags,
|
|
57
|
+
});
|
|
58
|
+
return info;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @param undername @type {string} The domain name.
|
|
62
|
+
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
63
|
+
* @example
|
|
64
|
+
* Get the current record
|
|
65
|
+
* ```ts
|
|
66
|
+
* ant.getRecord({ undername: "john" });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
async getRecord({ undername }) {
|
|
70
|
+
const tags = [
|
|
71
|
+
{ name: 'Sub-Domain', value: undername },
|
|
72
|
+
{ name: 'Action', value: 'Record' },
|
|
73
|
+
];
|
|
74
|
+
const record = await this.process.read({
|
|
75
|
+
tags,
|
|
76
|
+
});
|
|
77
|
+
return record;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
|
|
81
|
+
* @example
|
|
82
|
+
* Get the current records
|
|
83
|
+
* ```ts
|
|
84
|
+
* ant.getRecords();
|
|
85
|
+
* ````
|
|
86
|
+
*/
|
|
87
|
+
async getRecords() {
|
|
88
|
+
const tags = [{ name: 'Action', value: 'Records' }];
|
|
89
|
+
const records = await this.process.read({
|
|
90
|
+
tags,
|
|
91
|
+
});
|
|
92
|
+
return records;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @returns {Promise<string>} The owner of the ANT.
|
|
96
|
+
* @example
|
|
97
|
+
* Get the current owner
|
|
98
|
+
* ```ts
|
|
99
|
+
* ant.getOwner();
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async getOwner() {
|
|
103
|
+
const info = await this.getInfo();
|
|
104
|
+
return info.Owner;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @returns {Promise<string[]>} The controllers of the ANT.
|
|
108
|
+
* @example
|
|
109
|
+
* Get the controllers of the ANT.
|
|
110
|
+
* ```ts
|
|
111
|
+
* ant.getControllers();
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
async getControllers() {
|
|
115
|
+
const tags = [{ name: 'Action', value: 'Controllers' }];
|
|
116
|
+
const controllers = await this.process.read({
|
|
117
|
+
tags,
|
|
118
|
+
});
|
|
119
|
+
return controllers;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
123
|
+
* @example
|
|
124
|
+
* Get the current name
|
|
125
|
+
* ```ts
|
|
126
|
+
* ant.getName();
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
async getName() {
|
|
130
|
+
const info = await this.getInfo();
|
|
131
|
+
return info.Name;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
135
|
+
* @example
|
|
136
|
+
* The current ticker of the ANT.
|
|
137
|
+
* ```ts
|
|
138
|
+
* ant.getTicker();
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
async getTicker() {
|
|
142
|
+
const info = await this.getInfo();
|
|
143
|
+
return info.Ticker;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
|
|
147
|
+
* @example
|
|
148
|
+
* The current balances of the ANT.
|
|
149
|
+
* ```ts
|
|
150
|
+
* ant.getBalances();
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async getBalances() {
|
|
154
|
+
const tags = [{ name: 'Action', value: 'Balances' }];
|
|
155
|
+
const balances = await this.process.read({
|
|
156
|
+
tags,
|
|
157
|
+
});
|
|
158
|
+
return balances;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @param address @type {string} The address of the account you want the balance of.
|
|
162
|
+
* @returns {Promise<number>} The balance of the provided address
|
|
163
|
+
* @example
|
|
164
|
+
* The current balance of the address.
|
|
165
|
+
* ```ts
|
|
166
|
+
* ant.getBalance({ address });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
async getBalance({ address }) {
|
|
170
|
+
const tags = [
|
|
171
|
+
{ name: 'Action', value: 'Balance' },
|
|
172
|
+
{ name: 'Recipient', value: address },
|
|
173
|
+
];
|
|
174
|
+
const balance = await this.process.read({
|
|
175
|
+
tags,
|
|
176
|
+
});
|
|
177
|
+
return balance;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export class AoANTWriteable extends AoANTReadable {
|
|
181
|
+
signer;
|
|
182
|
+
constructor({ signer, ...config }) {
|
|
183
|
+
super(config);
|
|
184
|
+
this.signer = signer;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @param target @type {string} The address of the account you want to transfer the ANT to.
|
|
188
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
async transfer({ target }) {
|
|
195
|
+
const tags = [
|
|
196
|
+
{ name: 'Action', value: 'Transfer' },
|
|
197
|
+
{ name: 'Recipient', value: target },
|
|
198
|
+
];
|
|
199
|
+
return this.process.send({
|
|
200
|
+
tags,
|
|
201
|
+
data: {},
|
|
202
|
+
signer: this.signer,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* @param controller @type {string} The address of the account you want to set as a controller.
|
|
207
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
async addController({ controller, }) {
|
|
214
|
+
const tags = [
|
|
215
|
+
{ name: 'Action', value: 'Add-Controller' },
|
|
216
|
+
{ name: 'Controller', value: controller },
|
|
217
|
+
];
|
|
218
|
+
return this.process.send({
|
|
219
|
+
tags,
|
|
220
|
+
data: {},
|
|
221
|
+
signer: this.signer,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @param controller @type {string} The address of the account you want to remove from the controllers list
|
|
226
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
async removeController({ controller, }) {
|
|
233
|
+
const tags = [
|
|
234
|
+
{ name: 'Action', value: 'Remove-Controller' },
|
|
235
|
+
{ name: 'Controller', value: controller },
|
|
236
|
+
];
|
|
237
|
+
return this.process.send({
|
|
238
|
+
tags,
|
|
239
|
+
data: {},
|
|
240
|
+
signer: this.signer,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
245
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
246
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
247
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
async setRecord({ undername, transactionId, ttlSeconds, }) {
|
|
254
|
+
return this.process.send({
|
|
255
|
+
tags: [
|
|
256
|
+
{ name: 'Action', value: 'Set-Record' },
|
|
257
|
+
{ name: 'Sub-Domain', value: undername },
|
|
258
|
+
{ name: 'Transaction-Id', value: transactionId },
|
|
259
|
+
{ name: 'TTL-Seconds', value: ttlSeconds.toString() },
|
|
260
|
+
],
|
|
261
|
+
data: { transactionId, ttlSeconds },
|
|
262
|
+
signer: this.signer,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @param undername @type {string} The record you want to remove.
|
|
267
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* ant.removeRecord({ subDomain: "shorts" });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
async removeRecord({ undername, }) {
|
|
274
|
+
return this.process.send({
|
|
275
|
+
tags: [
|
|
276
|
+
{ name: 'Action', value: 'Remove-Record' },
|
|
277
|
+
{ name: 'Sub-Domain', value: undername },
|
|
278
|
+
],
|
|
279
|
+
data: { undername },
|
|
280
|
+
signer: this.signer,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* @param ticker @type {string} Sets the ANT Ticker.
|
|
285
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* ant.setTicker({ ticker: "KAPOW" });
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
async setTicker({ ticker }) {
|
|
292
|
+
return this.process.send({
|
|
293
|
+
tags: [
|
|
294
|
+
{ name: 'Action', value: 'Set-Ticker' },
|
|
295
|
+
{ name: 'Ticker', value: ticker },
|
|
296
|
+
],
|
|
297
|
+
data: { ticker },
|
|
298
|
+
signer: this.signer,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @param name @type {string} Sets the Name of the ANT.
|
|
303
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* ant.setName({ name: "ships at sea" });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
async setName({ name }) {
|
|
310
|
+
return this.process.send({
|
|
311
|
+
tags: [
|
|
312
|
+
{ name: 'Action', value: 'Set-Name' },
|
|
313
|
+
{ name: 'Name', value: name },
|
|
314
|
+
],
|
|
315
|
+
data: { name },
|
|
316
|
+
signer: this.signer,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
@@ -19,12 +19,12 @@ import { createData } from 'arbundles';
|
|
|
19
19
|
import { safeDecode } from '../../utils/json.js';
|
|
20
20
|
import { version } from '../../version.js';
|
|
21
21
|
import { WriteInteractionError } from '../error.js';
|
|
22
|
-
import {
|
|
22
|
+
import { Logger } from '../logger.js';
|
|
23
23
|
export class AOProcess {
|
|
24
24
|
logger;
|
|
25
25
|
processId;
|
|
26
26
|
ao;
|
|
27
|
-
constructor({ processId, ao = connect(), logger =
|
|
27
|
+
constructor({ processId, ao = connect(), logger = Logger.default, }) {
|
|
28
28
|
this.processId = processId;
|
|
29
29
|
this.logger = logger;
|
|
30
30
|
this.ao = ao;
|
package/lib/esm/common/http.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createAxiosInstance } from '../utils/index.js';
|
|
2
2
|
import { FailedRequestError, NotFound, UnknownError } from './error.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Logger } from './logger.js';
|
|
4
4
|
export class AxiosHTTPService {
|
|
5
5
|
axios;
|
|
6
6
|
logger;
|
|
7
|
-
|
|
8
|
-
constructor({ url, logger = new DefaultLogger(), }) {
|
|
7
|
+
constructor({ url, logger = Logger.default, }) {
|
|
9
8
|
this.logger = logger;
|
|
10
9
|
this.axios = createAxiosInstance({
|
|
11
10
|
axiosConfig: {
|
package/lib/esm/common/index.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -19,7 +19,6 @@ import { IO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
|
19
19
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../io.js';
|
|
20
20
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
21
|
import { InvalidContractConfigurationError } from './error.js';
|
|
22
|
-
import { DefaultLogger } from './logger.js';
|
|
23
22
|
export class IO {
|
|
24
23
|
static init(config) {
|
|
25
24
|
if (config && config.signer) {
|
|
@@ -47,9 +46,6 @@ export class IOReadable {
|
|
|
47
46
|
else if (isProcessIdConfiguration(config)) {
|
|
48
47
|
this.process = new AOProcess({
|
|
49
48
|
processId: config.processId,
|
|
50
|
-
logger: new DefaultLogger({
|
|
51
|
-
level: 'info',
|
|
52
|
-
}),
|
|
53
49
|
});
|
|
54
50
|
}
|
|
55
51
|
else {
|
package/lib/esm/common/logger.js
CHANGED
|
@@ -14,48 +14,63 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import { createLogger, format, transports, } from 'winston';
|
|
18
18
|
import { version } from '../version.js';
|
|
19
|
-
export class
|
|
19
|
+
export class Logger {
|
|
20
20
|
logger;
|
|
21
21
|
silent = false;
|
|
22
|
+
static default = new Logger();
|
|
22
23
|
constructor({ level = 'info', } = {}) {
|
|
23
24
|
if (level === 'none') {
|
|
24
25
|
this.silent = true;
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
this.logger =
|
|
28
|
+
this.logger = createLogger({
|
|
28
29
|
level,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
silent: this.silent,
|
|
31
|
+
defaultMeta: {
|
|
32
|
+
name: 'ar-io-sdk',
|
|
33
|
+
version,
|
|
34
|
+
},
|
|
35
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
32
36
|
});
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
if (typeof window !== 'undefined') {
|
|
40
|
+
this.logger = console;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.logger.add(new transports.Console({
|
|
44
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
33
47
|
}
|
|
34
48
|
info(message, ...args) {
|
|
35
49
|
if (this.silent)
|
|
36
50
|
return;
|
|
37
|
-
this.logger.info(...args
|
|
51
|
+
this.logger.info(message, ...args);
|
|
38
52
|
}
|
|
39
53
|
warn(message, ...args) {
|
|
40
54
|
if (this.silent)
|
|
41
55
|
return;
|
|
42
|
-
this.logger.warn(...args
|
|
56
|
+
this.logger.warn(message, ...args);
|
|
43
57
|
}
|
|
44
58
|
error(message, ...args) {
|
|
45
59
|
if (this.silent)
|
|
46
60
|
return;
|
|
47
|
-
this.logger.error(...args
|
|
61
|
+
this.logger.error(message, ...args);
|
|
48
62
|
}
|
|
49
63
|
debug(message, ...args) {
|
|
50
64
|
if (this.silent)
|
|
51
65
|
return;
|
|
52
|
-
this.logger.debug(...args
|
|
66
|
+
this.logger.debug(message, ...args);
|
|
53
67
|
}
|
|
54
68
|
setLogLevel(level) {
|
|
55
|
-
if (
|
|
56
|
-
this.silent =
|
|
57
|
-
|
|
69
|
+
if ('silent' in this.logger) {
|
|
70
|
+
this.logger.silent = level === 'none';
|
|
71
|
+
}
|
|
72
|
+
if ('level' in this.logger) {
|
|
73
|
+
this.logger.level = level;
|
|
58
74
|
}
|
|
59
|
-
this.logger.level(level);
|
|
60
75
|
}
|
|
61
76
|
}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import axios from 'axios';
|
|
18
18
|
import axiosRetry from 'axios-retry';
|
|
19
|
-
import {
|
|
19
|
+
import { Logger } from '../common/logger.js';
|
|
20
20
|
import { version } from '../version.js';
|
|
21
|
-
export const createAxiosInstance = ({ axiosConfig = {}, logger =
|
|
21
|
+
export const createAxiosInstance = ({ axiosConfig = {}, logger = Logger.default, retryConfig = {
|
|
22
22
|
retries: 5,
|
|
23
23
|
retryDelay: axiosRetry.exponentialDelay,
|
|
24
24
|
retryCondition: (error) => axiosRetry.isRetryableError(error),
|
package/lib/esm/version.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
import { AoANTRead, AoANTWrite, ProcessConfiguration, WithSigner } from '../types.js';
|
|
17
|
+
import { ANTRecord, AoANTRead, AoANTState, AoANTWrite, AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner } from '../types.js';
|
|
18
|
+
import { AOProcess } from './index.js';
|
|
18
19
|
export declare class ANT {
|
|
19
20
|
/**
|
|
20
21
|
* Initializes an ANT instance.
|
|
@@ -45,3 +46,177 @@ export declare class ANT {
|
|
|
45
46
|
}): AoANTRead;
|
|
46
47
|
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>): AoANTWrite;
|
|
47
48
|
}
|
|
49
|
+
export declare class AoANTReadable implements AoANTRead {
|
|
50
|
+
protected process: AOProcess;
|
|
51
|
+
constructor(config: Required<ProcessConfiguration>);
|
|
52
|
+
getState(): Promise<AoANTState>;
|
|
53
|
+
getInfo(): Promise<{
|
|
54
|
+
Name: string;
|
|
55
|
+
Ticker: string;
|
|
56
|
+
Denomination: number;
|
|
57
|
+
Owner: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* @param undername @type {string} The domain name.
|
|
61
|
+
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
62
|
+
* @example
|
|
63
|
+
* Get the current record
|
|
64
|
+
* ```ts
|
|
65
|
+
* ant.getRecord({ undername: "john" });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
getRecord({ undername }: {
|
|
69
|
+
undername: string;
|
|
70
|
+
}): Promise<ANTRecord>;
|
|
71
|
+
/**
|
|
72
|
+
* @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
|
|
73
|
+
* @example
|
|
74
|
+
* Get the current records
|
|
75
|
+
* ```ts
|
|
76
|
+
* ant.getRecords();
|
|
77
|
+
* ````
|
|
78
|
+
*/
|
|
79
|
+
getRecords(): Promise<Record<string, ANTRecord>>;
|
|
80
|
+
/**
|
|
81
|
+
* @returns {Promise<string>} The owner of the ANT.
|
|
82
|
+
* @example
|
|
83
|
+
* Get the current owner
|
|
84
|
+
* ```ts
|
|
85
|
+
* ant.getOwner();
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
getOwner(): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* @returns {Promise<string[]>} The controllers of the ANT.
|
|
91
|
+
* @example
|
|
92
|
+
* Get the controllers of the ANT.
|
|
93
|
+
* ```ts
|
|
94
|
+
* ant.getControllers();
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getControllers(): Promise<WalletAddress[]>;
|
|
98
|
+
/**
|
|
99
|
+
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
100
|
+
* @example
|
|
101
|
+
* Get the current name
|
|
102
|
+
* ```ts
|
|
103
|
+
* ant.getName();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
getName(): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
109
|
+
* @example
|
|
110
|
+
* The current ticker of the ANT.
|
|
111
|
+
* ```ts
|
|
112
|
+
* ant.getTicker();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
getTicker(): Promise<string>;
|
|
116
|
+
/**
|
|
117
|
+
* @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
|
|
118
|
+
* @example
|
|
119
|
+
* The current balances of the ANT.
|
|
120
|
+
* ```ts
|
|
121
|
+
* ant.getBalances();
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
getBalances(): Promise<Record<string, number>>;
|
|
125
|
+
/**
|
|
126
|
+
* @param address @type {string} The address of the account you want the balance of.
|
|
127
|
+
* @returns {Promise<number>} The balance of the provided address
|
|
128
|
+
* @example
|
|
129
|
+
* The current balance of the address.
|
|
130
|
+
* ```ts
|
|
131
|
+
* ant.getBalance({ address });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
getBalance({ address }: {
|
|
135
|
+
address: string;
|
|
136
|
+
}): Promise<number>;
|
|
137
|
+
}
|
|
138
|
+
export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite {
|
|
139
|
+
private signer;
|
|
140
|
+
constructor({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>);
|
|
141
|
+
/**
|
|
142
|
+
* @param target @type {string} The address of the account you want to transfer the ANT to.
|
|
143
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
transfer({ target }: {
|
|
150
|
+
target: string;
|
|
151
|
+
}): Promise<AoMessageResult>;
|
|
152
|
+
/**
|
|
153
|
+
* @param controller @type {string} The address of the account you want to set as a controller.
|
|
154
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
addController({ controller, }: {
|
|
161
|
+
controller: string;
|
|
162
|
+
}): Promise<AoMessageResult>;
|
|
163
|
+
/**
|
|
164
|
+
* @param controller @type {string} The address of the account you want to remove from the controllers list
|
|
165
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
removeController({ controller, }: {
|
|
172
|
+
controller: string;
|
|
173
|
+
}): Promise<AoMessageResult>;
|
|
174
|
+
/**
|
|
175
|
+
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
176
|
+
* @param transactionId @type {string} The transactionId of the record.
|
|
177
|
+
* @param ttlSeconds @type {number} The time to live of the record.
|
|
178
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
setRecord({ undername, transactionId, ttlSeconds, }: {
|
|
185
|
+
undername: string;
|
|
186
|
+
transactionId: string;
|
|
187
|
+
ttlSeconds: number;
|
|
188
|
+
}): Promise<AoMessageResult>;
|
|
189
|
+
/**
|
|
190
|
+
* @param undername @type {string} The record you want to remove.
|
|
191
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* ant.removeRecord({ subDomain: "shorts" });
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
removeRecord({ undername, }: {
|
|
198
|
+
undername: string;
|
|
199
|
+
}): Promise<AoMessageResult>;
|
|
200
|
+
/**
|
|
201
|
+
* @param ticker @type {string} Sets the ANT Ticker.
|
|
202
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* ant.setTicker({ ticker: "KAPOW" });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
setTicker({ ticker }: {
|
|
209
|
+
ticker: string;
|
|
210
|
+
}): Promise<AoMessageResult>;
|
|
211
|
+
/**
|
|
212
|
+
* @param name @type {string} Sets the Name of the ANT.
|
|
213
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* ant.setName({ name: "ships at sea" });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
setName({ name }: {
|
|
220
|
+
name: string;
|
|
221
|
+
}): Promise<AoMessageResult>;
|
|
222
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AOContract, AoClient, ContractSigner } from '../../types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ILogger } from '../logger.js';
|
|
4
4
|
export declare class AOProcess implements AOContract {
|
|
5
5
|
private logger;
|
|
6
6
|
private processId;
|
|
@@ -8,7 +8,7 @@ export declare class AOProcess implements AOContract {
|
|
|
8
8
|
constructor({ processId, ao, logger, }: {
|
|
9
9
|
processId: string;
|
|
10
10
|
ao?: AoClient;
|
|
11
|
-
logger?:
|
|
11
|
+
logger?: ILogger;
|
|
12
12
|
});
|
|
13
13
|
static createAoSigner(signer: ContractSigner): Promise<(args: {
|
|
14
14
|
data: string | Buffer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { HTTPClient
|
|
2
|
+
import { HTTPClient } from '../types.js';
|
|
3
|
+
import { ILogger } from './logger.js';
|
|
3
4
|
export declare class AxiosHTTPService implements HTTPClient {
|
|
4
5
|
private axios;
|
|
5
6
|
private logger;
|
|
6
7
|
constructor({ url, logger, }: {
|
|
7
8
|
url: string;
|
|
8
|
-
logger?:
|
|
9
|
+
logger?: ILogger;
|
|
9
10
|
});
|
|
10
11
|
get<I, K>({ endpoint, signal, allowedStatuses, headers, params, }: {
|
|
11
12
|
endpoint: string;
|