@ar.io/sdk 1.2.2 → 2.0.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.
Files changed (68) hide show
  1. package/README.md +148 -60
  2. package/bundles/web.bundle.min.js +132 -331
  3. package/lib/cjs/common/ant.js +147 -206
  4. package/lib/cjs/common/contracts/ao-process.js +1 -1
  5. package/lib/cjs/common/http.js +1 -2
  6. package/lib/cjs/common/index.js +0 -5
  7. package/lib/cjs/common/io.js +39 -31
  8. package/lib/cjs/common/logger.js +31 -19
  9. package/lib/cjs/types.js +0 -1
  10. package/lib/cjs/utils/arweave.js +1 -15
  11. package/lib/cjs/utils/http-client.js +1 -1
  12. package/lib/cjs/utils/index.js +1 -2
  13. package/lib/cjs/utils/{graphql/processes.js → processes.js} +35 -10
  14. package/lib/cjs/version.js +1 -1
  15. package/lib/esm/common/ant.js +144 -203
  16. package/lib/esm/common/contracts/ao-process.js +2 -2
  17. package/lib/esm/common/http.js +2 -3
  18. package/lib/esm/common/index.js +0 -5
  19. package/lib/esm/common/io.js +39 -28
  20. package/lib/esm/common/logger.js +29 -14
  21. package/lib/esm/types.js +0 -1
  22. package/lib/esm/utils/arweave.js +0 -12
  23. package/lib/esm/utils/http-client.js +2 -2
  24. package/lib/esm/utils/index.js +1 -2
  25. package/lib/esm/utils/{graphql/processes.js → processes.js} +33 -9
  26. package/lib/esm/version.js +1 -1
  27. package/lib/types/common/ant.d.ts +53 -175
  28. package/lib/types/common/contracts/ao-process.d.ts +2 -2
  29. package/lib/types/common/http.d.ts +3 -2
  30. package/lib/types/common/index.d.ts +0 -4
  31. package/lib/types/common/io.d.ts +5 -4
  32. package/lib/types/common/logger.d.ts +10 -3
  33. package/lib/types/common.d.ts +1 -145
  34. package/lib/types/io.d.ts +28 -3
  35. package/lib/types/types.d.ts +0 -1
  36. package/lib/types/utils/arweave.d.ts +0 -5
  37. package/lib/types/utils/http-client.d.ts +2 -2
  38. package/lib/types/utils/index.d.ts +1 -2
  39. package/lib/types/utils/{graphql/processes.d.ts → processes.d.ts} +4 -1
  40. package/lib/types/version.d.ts +1 -1
  41. package/package.json +8 -13
  42. package/lib/cjs/arns-service.js +0 -2
  43. package/lib/cjs/common/ant-ao.js +0 -297
  44. package/lib/cjs/common/ar-io.js +0 -741
  45. package/lib/cjs/common/contracts/remote-contract.js +0 -55
  46. package/lib/cjs/common/contracts/warp-contract.js +0 -176
  47. package/lib/cjs/common/warp.js +0 -25
  48. package/lib/cjs/utils/graphql/index.js +0 -34
  49. package/lib/cjs/utils/graphql/smartweave.js +0 -309
  50. package/lib/cjs/utils/smartweave.js +0 -58
  51. package/lib/esm/arns-service.js +0 -1
  52. package/lib/esm/common/ant-ao.js +0 -292
  53. package/lib/esm/common/ar-io.js +0 -735
  54. package/lib/esm/common/contracts/remote-contract.js +0 -51
  55. package/lib/esm/common/contracts/warp-contract.js +0 -172
  56. package/lib/esm/common/warp.js +0 -22
  57. package/lib/esm/utils/graphql/index.js +0 -18
  58. package/lib/esm/utils/graphql/smartweave.js +0 -303
  59. package/lib/esm/utils/smartweave.js +0 -50
  60. package/lib/types/arns-service.d.ts +0 -23
  61. package/lib/types/common/ant-ao.d.ts +0 -194
  62. package/lib/types/common/ar-io.d.ts +0 -551
  63. package/lib/types/common/contracts/remote-contract.d.ts +0 -38
  64. package/lib/types/common/contracts/warp-contract.d.ts +0 -43
  65. package/lib/types/common/warp.d.ts +0 -1
  66. package/lib/types/utils/graphql/index.d.ts +0 -18
  67. package/lib/types/utils/graphql/smartweave.d.ts +0 -47
  68. package/lib/types/utils/smartweave.d.ts +0 -41
@@ -14,47 +14,10 @@
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 { ANT_CONTRACT_FUNCTIONS, isProcessConfiguration, isProcessIdConfiguration, } from '../types.js';
18
- import { isContractConfiguration, isContractTxIdConfiguration, } from '../utils/smartweave.js';
19
- import { RemoteContract } from './contracts/remote-contract.js';
20
- import { AoANTReadable, AoANTWriteable, InvalidContractConfigurationError, WarpContract, } from './index.js';
17
+ import { isProcessConfiguration, isProcessIdConfiguration, } from '../types.js';
18
+ import { AOProcess, InvalidContractConfigurationError } from './index.js';
21
19
  export class ANT {
22
- /**
23
- * @param config - @type {ContractConfiguration} The configuration object.
24
- * @returns {WarpContract<ANTState>} The contract object.
25
- * @example
26
- * Using the contract object
27
- * ```ts
28
- * ANT.createContract({ contract: new WarpContract<ANTState>({ contractTxId: 'myContractTxId' });
29
- * ```
30
- * Using the contractTxId
31
- * ```ts
32
- * ANT.createContract({ contractTxId: 'myContractTxId' });
33
- * ```
34
- */
35
- static createWriteableContract(config) {
36
- if (isContractConfiguration(config)) {
37
- return config.contract instanceof WarpContract
38
- ? config.contract
39
- : new WarpContract(config.contract.configuration());
40
- }
41
- else if (isContractTxIdConfiguration(config)) {
42
- return new WarpContract({ contractTxId: config.contractTxId });
43
- }
44
- else {
45
- throw new InvalidContractConfigurationError();
46
- }
47
- }
48
20
  static init({ signer, ...config }) {
49
- // TODO: these will be deprecated in the future
50
- if (isContractConfiguration(config) ||
51
- isContractTxIdConfiguration(config)) {
52
- if (!signer) {
53
- return new ANTReadable(config);
54
- }
55
- const contract = this.createWriteableContract(config);
56
- return new ANTWritable({ signer, contract });
57
- }
58
21
  // ao supported implementation
59
22
  if (isProcessConfiguration(config) || isProcessIdConfiguration(config)) {
60
23
  if (!signer) {
@@ -65,171 +28,136 @@ export class ANT {
65
28
  throw new InvalidContractConfigurationError();
66
29
  }
67
30
  }
68
- export class ANTReadable {
69
- contract;
31
+ export class AoANTReadable {
32
+ process;
70
33
  constructor(config) {
71
- if (isContractConfiguration(config)) {
72
- this.contract = config.contract;
34
+ if (isProcessConfiguration(config)) {
35
+ this.process = config.process;
73
36
  }
74
- else if (isContractTxIdConfiguration(config)) {
75
- this.contract = new RemoteContract({
76
- contractTxId: config.contractTxId,
37
+ else if (isProcessIdConfiguration(config)) {
38
+ this.process = new AOProcess({
39
+ processId: config.processId,
77
40
  });
78
41
  }
79
42
  else {
80
43
  throw new InvalidContractConfigurationError();
81
44
  }
82
45
  }
83
- /**
84
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
85
- * @returns {Promise<ANTState>} The state of the contract.
86
- * @example
87
- * Get the current state
88
- * ```ts
89
- * ant.getState();
90
- * ```
91
- * Get the state at a specific block height or sortkey
92
- * ```ts
93
- * ant.getState({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
94
- * ant.getState({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
95
- * ```
96
- */
97
- async getState({ evaluationOptions, } = {}) {
98
- const state = await this.contract.getState({ evaluationOptions });
99
- return state;
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;
100
59
  }
101
60
  /**
102
- * @param domain @type {string} The domain name.
103
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
61
+ * @param undername @type {string} The domain name.
104
62
  * @returns {Promise<ANTRecord>} The record of the undername domain.
105
63
  * @example
106
64
  * Get the current record
107
65
  * ```ts
108
- * ant.getRecord({ domain: "john" });
109
- * ```
110
- * Get the record at a specific block height or sortkey
111
- * ```ts
112
- * ant.getRecord({ domain: "john", evaluationOptions: { evalTo: { blockHeight: 1000 } } });
113
- * ant.getRecord({ domain: "john", evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
66
+ * ant.getRecord({ undername: "john" });
114
67
  * ```
115
68
  */
116
- async getRecord({ domain, evaluationOptions, }) {
117
- const records = await this.getRecords({ evaluationOptions });
118
- return records[domain];
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;
119
78
  }
120
79
  /**
121
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
122
80
  * @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
123
81
  * @example
124
82
  * Get the current records
125
83
  * ```ts
126
84
  * ant.getRecords();
127
- * ```
128
- * Get the records at a specific block height or sortkey
129
- * ```ts
130
- * ant.getRecords({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
131
- * ant.getRecords({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
132
- * ```
85
+ * ````
133
86
  */
134
- async getRecords({ evaluationOptions, } = {}) {
135
- const state = await this.contract.getState({ evaluationOptions });
136
- return state.records;
87
+ async getRecords() {
88
+ const tags = [{ name: 'Action', value: 'Records' }];
89
+ const records = await this.process.read({
90
+ tags,
91
+ });
92
+ return records;
137
93
  }
138
94
  /**
139
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
140
95
  * @returns {Promise<string>} The owner of the ANT.
141
96
  * @example
142
97
  * Get the current owner
143
98
  * ```ts
144
99
  * ant.getOwner();
145
100
  * ```
146
- * Get the owner at a specific block height or sortkey
147
- * ```ts
148
- * ant.getOwner({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
149
- * ant.getOwner({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
150
- * ```
151
101
  */
152
- async getOwner({ evaluationOptions, } = {}) {
153
- const state = await this.contract.getState({ evaluationOptions });
154
- return state.owner;
102
+ async getOwner() {
103
+ const info = await this.getInfo();
104
+ return info.Owner;
155
105
  }
156
106
  /**
157
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
158
107
  * @returns {Promise<string[]>} The controllers of the ANT.
159
108
  * @example
160
109
  * Get the controllers of the ANT.
161
110
  * ```ts
162
111
  * ant.getControllers();
163
112
  * ```
164
- * Get the controllers at a specific block height or sortkey
165
- * ```ts
166
- * ant.getControllers({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
167
- * ant.getControllers({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
168
- * ```
169
113
  */
170
- async getControllers({ evaluationOptions, } = {}) {
171
- const state = await this.contract.getState({ evaluationOptions });
172
- return state.controllers;
114
+ async getControllers() {
115
+ const tags = [{ name: 'Action', value: 'Controllers' }];
116
+ const controllers = await this.process.read({
117
+ tags,
118
+ });
119
+ return controllers;
173
120
  }
174
121
  /**
175
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
176
122
  * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
177
123
  * @example
178
124
  * Get the current name
179
125
  * ```ts
180
126
  * ant.getName();
181
127
  * ```
182
- * @example
183
- * Get the ticker at a specific block height or sortkey
184
- * ```ts
185
- * ant.getName({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
186
- * ant.getName({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
187
- * ```
188
128
  */
189
- async getName({ evaluationOptions, } = {}) {
190
- const state = await this.contract.getState({ evaluationOptions });
191
- return state.name;
129
+ async getName() {
130
+ const info = await this.getInfo();
131
+ return info.Name;
192
132
  }
193
133
  /**
194
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
195
134
  * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
196
135
  * @example
197
136
  * The current ticker of the ANT.
198
137
  * ```ts
199
138
  * ant.getTicker();
200
139
  * ```
201
- * @example
202
- * Get the ticker at a specific block height or sortkey
203
- * ```ts
204
- * ant.getTicker({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
205
- * ant.getTicker({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
206
- * ```
207
140
  */
208
- async getTicker({ evaluationOptions, } = {}) {
209
- const state = await this.contract.getState({ evaluationOptions });
210
- return state.ticker;
141
+ async getTicker() {
142
+ const info = await this.getInfo();
143
+ return info.Ticker;
211
144
  }
212
145
  /**
213
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
214
- * @returns {Promise<Record<string, number>>} The balances of the ANT
146
+ * @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
215
147
  * @example
216
148
  * The current balances of the ANT.
217
149
  * ```ts
218
150
  * ant.getBalances();
219
151
  * ```
220
- * @example
221
- * Get the balances at a specific block height or sortkey
222
- * ```ts
223
- * ant.getBalances({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
224
- * ant.getBalances({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
225
- * ```
226
152
  */
227
- async getBalances({ evaluationOptions, } = {}) {
228
- const state = await this.contract.getState({ evaluationOptions });
229
- return state.balances;
153
+ async getBalances() {
154
+ const tags = [{ name: 'Action', value: 'Balances' }];
155
+ const balances = await this.process.read({
156
+ tags,
157
+ });
158
+ return balances;
230
159
  }
231
160
  /**
232
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
233
161
  * @param address @type {string} The address of the account you want the balance of.
234
162
  * @returns {Promise<number>} The balance of the provided address
235
163
  * @example
@@ -237,142 +165,155 @@ export class ANTReadable {
237
165
  * ```ts
238
166
  * ant.getBalance({ address });
239
167
  * ```
240
- * @example
241
- * Get the balance at a specific block height or sortkey
242
- * ```ts
243
- * ant.getBalance({ address, evaluationOptions: { evalTo: { blockHeight: 1000 } } });
244
- * ant.getBalance({ address, evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
245
- * ```
246
168
  */
247
- async getBalance({ address, evaluationOptions, }) {
248
- const balances = await this.getBalances({ evaluationOptions });
249
- return balances[address] || 0;
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;
250
178
  }
251
179
  }
252
- export class ANTWritable extends ANTReadable {
180
+ export class AoANTWriteable extends AoANTReadable {
253
181
  signer;
254
182
  constructor({ signer, ...config }) {
255
- if (isContractConfiguration(config)) {
256
- super({ contract: config.contract });
257
- this.signer = signer;
258
- }
259
- else if (isContractTxIdConfiguration(config)) {
260
- super({
261
- contract: new WarpContract({
262
- contractTxId: config.contractTxId,
263
- }),
264
- });
265
- this.signer = signer;
266
- }
267
- else {
268
- throw new InvalidContractConfigurationError();
269
- }
183
+ super(config);
184
+ this.signer = signer;
270
185
  }
271
186
  /**
272
187
  * @param target @type {string} The address of the account you want to transfer the ANT to.
273
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
188
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
274
189
  * @example
275
190
  * ```ts
276
191
  * ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
277
192
  * ```
278
193
  */
279
- async transfer({ target, }, options) {
280
- return this.contract.writeInteraction({
281
- functionName: ANT_CONTRACT_FUNCTIONS.TRANSFER,
282
- inputs: { target },
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: {},
283
202
  signer: this.signer,
284
- }, options);
203
+ });
285
204
  }
286
205
  /**
287
206
  * @param controller @type {string} The address of the account you want to set as a controller.
288
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
207
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
289
208
  * @example
290
209
  * ```ts
291
210
  * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
292
211
  * ```
293
212
  */
294
- async setController({ controller, }, options) {
295
- return this.contract.writeInteraction({
296
- functionName: ANT_CONTRACT_FUNCTIONS.SET_CONTROLLER,
297
- inputs: { target: controller },
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: {},
298
221
  signer: this.signer,
299
- }, options);
222
+ });
300
223
  }
301
224
  /**
302
225
  * @param controller @type {string} The address of the account you want to remove from the controllers list
303
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
226
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
304
227
  * @example
305
228
  * ```ts
306
229
  * ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
307
230
  * ```
308
231
  */
309
- async removeController({ controller, }, options) {
310
- return this.contract.writeInteraction({
311
- functionName: ANT_CONTRACT_FUNCTIONS.REMOVE_CONTROLLER,
312
- inputs: { target: controller },
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: {},
313
240
  signer: this.signer,
314
- }, options);
241
+ });
315
242
  }
316
243
  /**
317
- * @param subDomain @type {string} The record you want to set the transactionId and ttlSeconds of.
244
+ * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
318
245
  * @param transactionId @type {string} The transactionId of the record.
319
246
  * @param ttlSeconds @type {number} The time to live of the record.
320
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
247
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
321
248
  * @example
322
249
  * ```ts
323
250
  * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
324
251
  * ```
325
252
  */
326
- async setRecord({ subDomain, transactionId, ttlSeconds, }, options) {
327
- return this.contract.writeInteraction({
328
- functionName: ANT_CONTRACT_FUNCTIONS.SET_RECORD,
329
- inputs: { subDomain, transactionId, ttlSeconds },
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 },
330
262
  signer: this.signer,
331
- }, options);
263
+ });
332
264
  }
333
265
  /**
334
- * @param subDomain @type {string} The record you want to remove.
335
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
266
+ * @param undername @type {string} The record you want to remove.
267
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
336
268
  * @example
337
269
  * ```ts
338
270
  * ant.removeRecord({ subDomain: "shorts" });
339
271
  * ```
340
272
  */
341
- async removeRecord({ subDomain, }, options) {
342
- return this.contract.writeInteraction({
343
- functionName: ANT_CONTRACT_FUNCTIONS.REMOVE_RECORD,
344
- inputs: { subDomain },
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 },
345
280
  signer: this.signer,
346
- }, options);
281
+ });
347
282
  }
348
283
  /**
349
284
  * @param ticker @type {string} Sets the ANT Ticker.
350
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
285
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
351
286
  * @example
352
287
  * ```ts
353
288
  * ant.setTicker({ ticker: "KAPOW" });
354
289
  * ```
355
290
  */
356
- async setTicker({ ticker, }, options) {
357
- return this.contract.writeInteraction({
358
- functionName: ANT_CONTRACT_FUNCTIONS.SET_TICKER,
359
- inputs: { ticker },
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 },
360
298
  signer: this.signer,
361
- }, options);
299
+ });
362
300
  }
363
301
  /**
364
302
  * @param name @type {string} Sets the Name of the ANT.
365
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
303
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
366
304
  * @example
367
305
  * ```ts
368
306
  * ant.setName({ name: "ships at sea" });
369
307
  * ```
370
308
  */
371
- async setName({ name }, options) {
372
- return this.contract.writeInteraction({
373
- functionName: ANT_CONTRACT_FUNCTIONS.SET_NAME,
374
- inputs: { name },
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 },
375
316
  signer: this.signer,
376
- }, options);
317
+ });
377
318
  }
378
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 { DefaultLogger } from '../logger.js';
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 = new DefaultLogger({ level: 'info' }), }) {
27
+ constructor({ processId, ao = connect(), logger = Logger.default, }) {
28
28
  this.processId = processId;
29
29
  this.logger = logger;
30
30
  this.ao = ao;
@@ -1,11 +1,10 @@
1
1
  import { createAxiosInstance } from '../utils/index.js';
2
2
  import { FailedRequestError, NotFound, UnknownError } from './error.js';
3
- import { DefaultLogger } from './logger.js';
3
+ import { Logger } from './logger.js';
4
4
  export class AxiosHTTPService {
5
5
  axios;
6
6
  logger;
7
- // TODO: re-implement axios-retry. Currently that package is broken for nodenext.
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: {
@@ -14,14 +14,9 @@
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
- export * from './ar-io.js';
18
17
  export * from './error.js';
19
18
  export * from './logger.js';
20
19
  export * from './ant.js';
21
- // contracts - deprecated
22
- export * from './contracts/remote-contract.js';
23
- export * from './contracts/warp-contract.js';
24
20
  // ao
25
21
  export * from './io.js';
26
- export * from './ant-ao.js';
27
22
  export * from './contracts/ao-process.js';
@@ -1,25 +1,8 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import Arweave from 'arweave';
18
1
  import { IO_TESTNET_PROCESS_ID } from '../constants.js';
19
2
  import { isProcessConfiguration, isProcessIdConfiguration, } from '../io.js';
3
+ import { defaultArweave } from './arweave.js';
20
4
  import { AOProcess } from './contracts/ao-process.js';
21
5
  import { InvalidContractConfigurationError } from './error.js';
22
- import { DefaultLogger } from './logger.js';
23
6
  export class IO {
24
7
  static init(config) {
25
8
  if (config && config.signer) {
@@ -35,7 +18,7 @@ export class IO {
35
18
  export class IOReadable {
36
19
  process;
37
20
  arweave;
38
- constructor(config, arweave = Arweave.init({})) {
21
+ constructor(config, arweave = defaultArweave) {
39
22
  if (!config) {
40
23
  this.process = new AOProcess({
41
24
  processId: IO_TESTNET_PROCESS_ID,
@@ -47,9 +30,6 @@ export class IOReadable {
47
30
  else if (isProcessIdConfiguration(config)) {
48
31
  this.process = new AOProcess({
49
32
  processId: config.processId,
50
- logger: new DefaultLogger({
51
- level: 'info',
52
- }),
53
33
  });
54
34
  }
55
35
  else {
@@ -120,9 +100,17 @@ export class IOReadable {
120
100
  ],
121
101
  });
122
102
  }
123
- async getArNSRecords() {
103
+ async getArNSRecords(pageParams) {
104
+ const allTags = [
105
+ { name: 'Action', value: 'Paginated-Records' },
106
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
107
+ { name: 'Limit', value: pageParams?.limit?.toString() },
108
+ { name: 'Sort-By', value: pageParams?.sortBy },
109
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
110
+ ];
111
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
124
112
  return this.process.read({
125
- tags: [{ name: 'Action', value: 'Records' }],
113
+ tags: prunedTags,
126
114
  });
127
115
  }
128
116
  async getArNSReservedNames() {
@@ -146,9 +134,17 @@ export class IOReadable {
146
134
  ],
147
135
  });
148
136
  }
149
- async getBalances() {
137
+ async getBalances(pageParams) {
138
+ const allTags = [
139
+ { name: 'Action', value: 'Paginated-Balances' },
140
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
141
+ { name: 'Limit', value: pageParams?.limit?.toString() },
142
+ { name: 'Sort-By', value: pageParams?.sortBy },
143
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
144
+ ];
145
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
150
146
  return this.process.read({
151
- tags: [{ name: 'Action', value: 'Balances' }],
147
+ tags: prunedTags,
152
148
  });
153
149
  }
154
150
  async getGateway({ address, }) {
@@ -159,9 +155,17 @@ export class IOReadable {
159
155
  ],
160
156
  });
161
157
  }
162
- async getGateways() {
158
+ async getGateways(pageParams) {
159
+ const allTags = [
160
+ { name: 'Action', value: 'Paginated-Gateways' },
161
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
162
+ { name: 'Limit', value: pageParams?.limit?.toString() },
163
+ { name: 'Sort-By', value: pageParams?.sortBy },
164
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
165
+ ];
166
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
163
167
  return this.process.read({
164
- tags: [{ name: 'Action', value: 'Gateways' }],
168
+ tags: prunedTags,
165
169
  });
166
170
  }
167
171
  async getCurrentEpoch() {
@@ -428,6 +432,13 @@ export class IOWriteable extends IOReadable {
428
432
  tags: prunedTags,
429
433
  });
430
434
  }
435
+ async leaveNetwork(options) {
436
+ const { tags = [] } = options || {};
437
+ return this.process.send({
438
+ signer: this.signer,
439
+ tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
440
+ });
441
+ }
431
442
  async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
432
443
  const { tags = [] } = options || {};
433
444
  const allTags = [