@ar.io/sdk 1.2.1 → 2.0.0-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.
Files changed (48) hide show
  1. package/README.md +5 -1
  2. package/bundles/web.bundle.min.js +101 -333
  3. package/lib/cjs/common/ant.js +1 -351
  4. package/lib/cjs/common/index.js +0 -4
  5. package/lib/cjs/common/io.js +1 -1
  6. package/lib/cjs/types.js +0 -1
  7. package/lib/cjs/utils/arweave.js +1 -15
  8. package/lib/cjs/utils/graphql/index.js +0 -1
  9. package/lib/cjs/utils/index.js +0 -1
  10. package/lib/cjs/version.js +1 -1
  11. package/lib/esm/common/ant.js +2 -350
  12. package/lib/esm/common/index.js +0 -4
  13. package/lib/esm/common/io.js +1 -1
  14. package/lib/esm/types.js +0 -1
  15. package/lib/esm/utils/arweave.js +0 -12
  16. package/lib/esm/utils/graphql/index.js +0 -1
  17. package/lib/esm/utils/index.js +0 -1
  18. package/lib/esm/version.js +1 -1
  19. package/lib/types/common/ant.d.ts +1 -274
  20. package/lib/types/common/index.d.ts +0 -3
  21. package/lib/types/common.d.ts +1 -138
  22. package/lib/types/types.d.ts +0 -1
  23. package/lib/types/utils/arweave.d.ts +0 -5
  24. package/lib/types/utils/graphql/index.d.ts +0 -1
  25. package/lib/types/utils/index.d.ts +0 -1
  26. package/lib/types/version.d.ts +1 -1
  27. package/package.json +5 -10
  28. package/lib/cjs/arns-service.js +0 -2
  29. package/lib/cjs/common/ar-io.js +0 -741
  30. package/lib/cjs/common/contracts/remote-contract.js +0 -55
  31. package/lib/cjs/common/contracts/warp-contract.js +0 -176
  32. package/lib/cjs/common/warp.js +0 -25
  33. package/lib/cjs/utils/graphql/smartweave.js +0 -309
  34. package/lib/cjs/utils/smartweave.js +0 -58
  35. package/lib/esm/arns-service.js +0 -1
  36. package/lib/esm/common/ar-io.js +0 -735
  37. package/lib/esm/common/contracts/remote-contract.js +0 -51
  38. package/lib/esm/common/contracts/warp-contract.js +0 -172
  39. package/lib/esm/common/warp.js +0 -22
  40. package/lib/esm/utils/graphql/smartweave.js +0 -303
  41. package/lib/esm/utils/smartweave.js +0 -50
  42. package/lib/types/arns-service.d.ts +0 -23
  43. package/lib/types/common/ar-io.d.ts +0 -551
  44. package/lib/types/common/contracts/remote-contract.d.ts +0 -38
  45. package/lib/types/common/contracts/warp-contract.d.ts +0 -43
  46. package/lib/types/common/warp.d.ts +0 -1
  47. package/lib/types/utils/graphql/smartweave.d.ts +0 -47
  48. package/lib/types/utils/smartweave.d.ts +0 -41
@@ -1,741 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArIOWritable = exports.ArIOReadable = exports.ArIO = void 0;
4
- /**
5
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Affero General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Affero General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Affero General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
- const constants_js_1 = require("../constants.js");
21
- const types_js_1 = require("../types.js");
22
- const smartweave_js_1 = require("../utils/smartweave.js");
23
- const remote_contract_js_1 = require("./contracts/remote-contract.js");
24
- const index_js_1 = require("./index.js");
25
- /**
26
- * The ArIO class provides an interface to interact with the Arweave Interoperability Contract.
27
- * @deprecated - This class will be removed in the next major release.
28
- * @example
29
- * ```ts
30
- * import { ArIO } from '@permaweb/ar-io';
31
- * const arIO = ArIO.init();
32
- * ```
33
- */
34
- class ArIO {
35
- /**
36
- * @param config - @type {ContractConfiguration} The configuration object.
37
- * @returns {WarpContract<ArIOState>} The contract object.
38
- * @example
39
- * Using the contract object
40
- * ```ts
41
- * ArIO.createContract({ contract: new WarpContract<ArIOState>({ contractTxId: 'myContractTxId' });
42
- * ```
43
- * Using the contractTxId
44
- * ```ts
45
- * ArIO.createContract({ contractTxId: 'myContractTxId' });
46
- * ```
47
- */
48
- static createWriteableContract(config) {
49
- if (!config || Object.keys(config).length === 0) {
50
- return new index_js_1.WarpContract({
51
- contractTxId: constants_js_1.ARNS_TESTNET_REGISTRY_TX,
52
- });
53
- }
54
- else if ((0, smartweave_js_1.isContractConfiguration)(config)) {
55
- return config.contract instanceof index_js_1.WarpContract
56
- ? config.contract
57
- : new index_js_1.WarpContract(config.contract.configuration());
58
- }
59
- else if ((0, smartweave_js_1.isContractTxIdConfiguration)(config)) {
60
- return new index_js_1.WarpContract({ contractTxId: config.contractTxId });
61
- }
62
- else {
63
- throw new index_js_1.InvalidContractConfigurationError();
64
- }
65
- }
66
- static init(config) {
67
- if (config && config.signer !== undefined) {
68
- const { signer, ...rest } = config;
69
- const contract = this.createWriteableContract(rest);
70
- return new ArIOWritable({ signer, contract });
71
- }
72
- else {
73
- return new ArIOReadable(config);
74
- }
75
- }
76
- }
77
- exports.ArIO = ArIO;
78
- class ArIOReadable {
79
- contract;
80
- constructor(config) {
81
- if (!config || config === undefined) {
82
- this.contract = new remote_contract_js_1.RemoteContract({
83
- contractTxId: constants_js_1.ARNS_TESTNET_REGISTRY_TX,
84
- });
85
- }
86
- else if ((0, smartweave_js_1.isContractConfiguration)(config)) {
87
- this.contract = config.contract;
88
- }
89
- else if ((0, smartweave_js_1.isContractTxIdConfiguration)(config)) {
90
- this.contract = new remote_contract_js_1.RemoteContract({
91
- contractTxId: config.contractTxId,
92
- });
93
- }
94
- else {
95
- throw new index_js_1.InvalidContractConfigurationError();
96
- }
97
- }
98
- /**
99
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
100
- * @returns {Promise<ArIOState>} The state of the contract.
101
- * @example
102
- * Get the current state
103
- * ```ts
104
- * arIO.getState();
105
- * ```
106
- * Get the state at a specific block height or sortkey
107
- * ```ts
108
- * arIO.getState({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
109
- * arIO.getState({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
110
- * ```
111
- */
112
- async getState(params = {}) {
113
- const state = await this.contract.getState(params);
114
- return state;
115
- }
116
- /**
117
- * @param domain @type {string} The domain name.
118
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
119
- * @returns {Promise<ArNSNameData | undefined>} The record of the undername domain.
120
- * @example
121
- * Get the current record
122
- * ```ts
123
- * arIO.getRecord({ domain: "john" });
124
- * ```
125
- * Get the record at a specific block height or sortkey
126
- * ```ts
127
- * arIO.getRecord({ domain: "john", evaluationOptions: { evalTo: { blockHeight: 1000 } } });
128
- * arIO.getRecord({ domain: "john", evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
129
- * ```
130
- */
131
- async getArNSRecord({ domain, evaluationOptions, }) {
132
- const records = await this.getArNSRecords({ evaluationOptions });
133
- return records[domain];
134
- }
135
- /**
136
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
137
- * @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
138
- * @example
139
- * Get the current records
140
- * ```ts
141
- * ant.getRecords();
142
- * ```
143
- * Get the records at a specific block height or sortkey
144
- * ```ts
145
- * ant.getRecords({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
146
- * ant.getRecords({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
147
- * ```
148
- */
149
- async getArNSRecords({ evaluationOptions, } = {}) {
150
- const state = await this.contract.getState({ evaluationOptions });
151
- return state.records;
152
- }
153
- /**
154
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
155
- * @returns {Promise<Record<string, ArNSReservedNameData>>} The reserved names.
156
- * @example
157
- * Get the current reserved names
158
- * ```ts
159
- * arIO.getArNSReservedNames();
160
- * ```
161
- * Get the reserved names at a specific block height or sortkey
162
- * ```ts
163
- * arIO.getArNSReservedNames({ evaluationOptions: { evalTo: { blockHeight: 1000 } });
164
- * arIO.getArNSReservedNames({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } });
165
- * ```
166
- */
167
- async getArNSReservedNames({ evaluationOptions, } = {}) {
168
- const state = await this.contract.getState({ evaluationOptions });
169
- return state.reserved;
170
- }
171
- /**
172
- * @param domain @type {string} The domain name.
173
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
174
- * @returns {Promise<ArNSReservedNameData | undefined>} The reserved name data.
175
- * @example
176
- * Get the current reserved name
177
- * ```ts
178
- * arIO.getArNSReservedName({ domain: "myDomain" });
179
- * ```
180
- * Get the reserved name at a specific block height or sortkey
181
- * ```ts
182
- * arIO.getArNSReservedName({ domain: "myDomain", evaluationOptions: { evalTo: { blockHeight: 1000 } });
183
- * arIO.getArNSReservedName({ domain: "myDomain", evaluationOptions: { evalTo: { sortKey: 'mySortKey' } });
184
- * ```
185
- */
186
- async getArNSReservedName({ domain, evaluationOptions, }) {
187
- const reservedNames = await this.getArNSReservedNames({
188
- evaluationOptions,
189
- });
190
- return reservedNames[domain];
191
- }
192
- /**
193
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
194
- * @param address @type {string} The address of the account you want the balance of.
195
- * @returns {Promise<number>} The balance of the provided address
196
- * @example
197
- * The current balance of the address.
198
- * ```ts
199
- * arIO.getBalance({ address });
200
- * ```
201
- * @example
202
- * Get the balance at a specific block height or sortkey
203
- * ```ts
204
- * arIO.getBalance({ address, evaluationOptions: { evalTo: { blockHeight: 1000 } } });
205
- * arIO.getBalance({ address, evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
206
- * ```
207
- */
208
- async getBalance({ address, evaluationOptions, }) {
209
- const balances = await this.getBalances({ evaluationOptions });
210
- return balances[address] || 0;
211
- }
212
- /**
213
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
214
- * @returns {Promise<Record<string, number>>} The balances of the ArIO Contract
215
- * @example
216
- * The current balances of the ANT.
217
- * ```ts
218
- * arIO.getBalances();
219
- * ```
220
- * @example
221
- * Get the balances at a specific block height or sortkey
222
- * ```ts
223
- * arIO.getBalances({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
224
- * arIO.getBalances({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
225
- * ```
226
- */
227
- async getBalances({ evaluationOptions } = {}) {
228
- const state = await this.contract.getState({ evaluationOptions });
229
- return state.balances;
230
- }
231
- /**
232
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
233
- * @param address @type {string} The address of the gateway you want information about.
234
- * @returns {Promise<Gateway>} The balance of the provided address
235
- * @example
236
- * The current gateway info of the address.
237
- * ```ts
238
- * arIO.getGateway({ address });
239
- * ```
240
- * @example
241
- * Get the gateway info of the address at a certain block height or sortkey
242
- * ```ts
243
- * arIO.getGateway({ address, evaluationOptions: { evalTo: { blockHeight: 1000 } } });
244
- * arIO.getGateway({ address, evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
245
- * ```
246
- */
247
- async getGateway({ address, evaluationOptions, }) {
248
- return this.contract
249
- .readInteraction({
250
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.GATEWAY,
251
- inputs: {
252
- target: address,
253
- },
254
- evaluationOptions,
255
- })
256
- .catch(() => {
257
- return undefined;
258
- });
259
- }
260
- /**
261
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
262
- * @returns {Promise<Record<string, Gateway> >} The registered gateways of the ArIO Network.
263
- * @example
264
- * The current gateways.
265
- * ```ts
266
- * arIO.getGateways();
267
- * ```
268
- * @example
269
- * Get the gateways at a specific block height or sortkey
270
- * ```ts
271
- * arIO.getGateways({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
272
- * arIO.getGateways({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
273
- * ```
274
- */
275
- async getGateways({ evaluationOptions } = {}) {
276
- return this.contract.readInteraction({
277
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.GATEWAYS,
278
- evaluationOptions,
279
- });
280
- }
281
- /**
282
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
283
- * @returns {Promise<EpochDistributionData>} The current distribution data of the epoch.
284
- * @example
285
- * The current epoch
286
- * ```ts
287
- * arIO.getCurrentEpoch();
288
- * ```
289
- * @example
290
- * Get the epoch at a given block height or sortkey
291
- * ```ts
292
- * arIO.getCurrentEpoch({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
293
- * arIO.getCurrentEpoch({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
294
- * ```
295
- */
296
- async getCurrentEpoch({ evaluationOptions, } = {}) {
297
- return this.contract.readInteraction({
298
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.EPOCH,
299
- evaluationOptions,
300
- });
301
- }
302
- /**
303
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
304
- * @param blockHeight @type {number} The block height of the epoch you want to get.
305
- * @returns {Promise<EpochDistributionData>} The current distribution data of the epoch.
306
- * @example
307
- * The current epoch
308
- * ```ts
309
- * arIO.getEpoch({ blockHeight: 1000 });
310
- * ```
311
- * @example
312
- * Get the epoch at a given block height or sortkey
313
- * ```ts
314
- * arIO.getEpoch({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
315
- * arIO.getEpoch({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
316
- * ```
317
- */
318
- async getEpoch({ blockHeight, evaluationOptions, }) {
319
- return this.contract.readInteraction({
320
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.EPOCH,
321
- inputs: {
322
- height: blockHeight,
323
- },
324
- evaluationOptions,
325
- });
326
- }
327
- /**
328
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
329
- * @returns {Promise<WeightedObserver[]>} The current distribution data of the epoch.
330
- * @example
331
- * Current prescribed observers
332
- * ```ts
333
- * arIO.getPrescribedObservers();
334
- * ```
335
- * @example
336
- * Get the previous prescribed observers at a given block height or sortkey
337
- * ```ts
338
- * arIO.getPrescribedObservers({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
339
- * arIO.getPrescribedObservers({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
340
- * ```
341
- */
342
- async getPrescribedObservers({ evaluationOptions, } = {}) {
343
- return this.contract.readInteraction({
344
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.PRESCRIBED_OBSERVERS,
345
- evaluationOptions,
346
- });
347
- }
348
- /**
349
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
350
- * @returns {Promise<Observations>} The current observations data.
351
- * @example
352
- * All observations.
353
- * ```ts
354
- * arIO.getObservations();
355
- * ```
356
- * @example
357
- * Get observations at a given block height or sortkey
358
- * ```ts
359
- * arIO.getObservations({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
360
- * arIO.getObservations({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
361
- * ```
362
- */
363
- async getObservations({ evaluationOptions, } = {}) {
364
- const { observations } = await this.contract.getState({
365
- evaluationOptions,
366
- });
367
- return observations;
368
- }
369
- /**
370
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
371
- * @returns {Promise<EpochDistributionData>} The current distribution data of the epoch.
372
- * @example
373
- * Get the current distribution data.
374
- * ```ts
375
- * arIO.getDistributions();
376
- * ```
377
- * @example
378
- * Get distributions at a given block height or sortkey
379
- * ```ts
380
- * arIO.getDistributions({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
381
- * arIO.getDistributions({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
382
- * ```
383
- */
384
- async getDistributions({ evaluationOptions, } = {}) {
385
- const { distributions } = await this.contract.getState({
386
- evaluationOptions,
387
- });
388
- return distributions;
389
- }
390
- /**
391
- * Fetches the in-auction domain or the pricing data for how much it would cost to initiate the auction.
392
- *
393
- * @param domain @type {string} The domain name in auction
394
- * @param type @type {RegistrationType} The type of registration, relevant for reading auction prices
395
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
396
- * @returns {Promise<ArNSAuctionData>} The auction data for the specified name.
397
- * @example
398
- * Get the current auction data
399
- * ```ts
400
- * arIO.getAuction({ domain: 'myDomain' });
401
- * ```
402
- * @example
403
- * Get the auction data at a given block height or sortkey
404
- * ```ts
405
- * arIO.getAuction({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
406
- * arIO.getAuction({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
407
- * ```
408
- */
409
- async getAuction({ domain, type, evaluationOptions, }) {
410
- return this.contract.readInteraction({
411
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.AUCTION,
412
- inputs: {
413
- name: domain,
414
- type,
415
- },
416
- evaluationOptions,
417
- });
418
- }
419
- /**
420
- * Fetches the current auctions.
421
- *
422
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
423
- * @returns {Promise<Record<string, ArNSAuctionData>>} The current auctions data.
424
- * @example
425
- * Get the current auction data
426
- * ```ts
427
- * arIO.getAuctions();
428
- * ```
429
- * @example
430
- * Get the auction data at a given block height or sortkey
431
- * ```ts
432
- * arIO.getAuctions({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
433
- * arIO.getAuctions({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
434
- * ```
435
- */
436
- async getAuctions({ evaluationOptions, } = {}) {
437
- const { auctions } = await this.contract.getState({
438
- evaluationOptions,
439
- });
440
- return auctions;
441
- }
442
- /**
443
- * Fetches the price for an interaction
444
- *
445
- * @param evaluationOptions @type {EvaluationOptions} The evaluation options.
446
- * @returns {Promise<number>} The price to perform the interaction - eg the registration cost.
447
- * @example
448
- * Get the current auction data
449
- * ```ts
450
- * arIO.getPriceForInteraction({
451
- * interactionName: 'buyRecord',
452
- * payload: { name: 'ardrive', years: 1, type: 'lease', auction: false},
453
- * });
454
- * ```
455
- * @example
456
- * Get the auction data at a given block height or sortkey
457
- * ```ts
458
- * arIO.getPriceForInteraction({
459
- * interactionName: 'buyRecord',
460
- * payload: { name: 'ardrive', years: 1, type: 'lease', auction: false},
461
- * evaluationOptions: { evalTo: { blockHeight: 1000 } }
462
- * });
463
- *
464
- * arIO.getPriceForInteraction({
465
- * interactionName: 'buyRecord',
466
- * payload: { name: 'ardrive', years: 1, type: 'lease', auction: false},
467
- * evaluationOptions: { evalTo: { sortKey: 'mySortKey' } }
468
- * });
469
- * ```
470
- */
471
- async getPriceForInteraction({ interactionName, payload, evaluationOptions, }) {
472
- const { price } = await this.contract.readInteraction({
473
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.PRICE_FOR_INTERACTION,
474
- inputs: {
475
- interactionName,
476
- ...payload,
477
- },
478
- evaluationOptions,
479
- });
480
- return price;
481
- }
482
- }
483
- exports.ArIOReadable = ArIOReadable;
484
- class ArIOWritable extends ArIOReadable {
485
- signer;
486
- constructor({ signer, ...config }) {
487
- if (Object.keys(config).length === 0) {
488
- super({
489
- contract: new index_js_1.WarpContract({
490
- contractTxId: constants_js_1.ARNS_TESTNET_REGISTRY_TX,
491
- }),
492
- });
493
- this.signer = signer;
494
- }
495
- else if ((0, smartweave_js_1.isContractConfiguration)(config)) {
496
- super({ contract: config.contract });
497
- this.signer = signer;
498
- }
499
- else if ((0, smartweave_js_1.isContractTxIdConfiguration)(config)) {
500
- super({
501
- contract: new index_js_1.WarpContract({
502
- contractTxId: config.contractTxId,
503
- }),
504
- });
505
- this.signer = signer;
506
- }
507
- else {
508
- throw new index_js_1.InvalidContractConfigurationError();
509
- }
510
- }
511
- /**
512
- * @param target @type {string} The address of the account you want to transfer IO tokens to.
513
- * @param qty @type {number | mIOToken} The amount of IO or mIO to transfer.
514
- * @param denomination @type {DENOMINATIONS} The denomination of the amount to transfer (io or mio).
515
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
516
- * @example
517
- * mIO transfer
518
- * ```ts
519
- * arIO.transfer({
520
- * target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk",
521
- * qty: 1 * 10 ** 6,
522
- * denomination: DENOMINATIONS.MIO
523
- * });
524
- *```
525
- * IO transfer
526
- * ```ts
527
- * arIO.transfer({
528
- target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk",
529
- qty: new IOToken(100).toMIO(),
530
- denomination: DENOMINATIONS.IO
531
- });
532
- * ```
533
- */
534
- async transfer({ target, qty, denomination = types_js_1.DENOMINATIONS.IO, }, options) {
535
- let convertedQty = qty;
536
- // the contract will no longer support denominations
537
- if (denomination === types_js_1.DENOMINATIONS.IO && typeof qty === 'number') {
538
- convertedQty = new types_js_1.IOToken(qty).toMIO();
539
- }
540
- return this.contract.writeInteraction({
541
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.TRANSFER,
542
- inputs: {
543
- target,
544
- qty: convertedQty.valueOf(), // convert to number if mIO is provided
545
- },
546
- signer: this.signer,
547
- }, options);
548
- }
549
- /**
550
- * @param params @type {JoinNetworkParams} Your gateway configuration.
551
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
552
- * @example
553
- * Join the network with the your configuration.
554
- * ```ts
555
- * const jointNetworkParams = {
556
- qty: new IOToken(10000).toMIO(), // initial operator stake
557
- allowDelegatedStaking: true, // delegated staking settings
558
- minDelegatedStake: new IOToken(100).toMIO(), // min delegated stake
559
- delegateRewardShareRatio: 1, // delegate reward share ratio
560
- autoStake: true, // auto stake operator tokens
561
- label: 'john smith', // min 1, max 64 characters
562
- note: 'The example gateway', // max 256 characters
563
- properties: 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44', // Arweave transaction ID containing additional properties of the Gateway.
564
- observerWallet: '0VE0wIhDy90WiQoV3U2PeY44FH1aVetOoulPGqgYukj', // wallet address of the observer
565
- fqdn: 'example.com', // fully qualified domain name
566
- port: 443, // port number
567
- protocol: 'https', // protocol
568
- };
569
- * arIO.joinNetwork(jointNetworkParams);
570
- * ```
571
- */
572
- async joinNetwork({ qty, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerWallet, }, options) {
573
- return this.contract.writeInteraction({
574
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.JOIN_NETWORK,
575
- inputs: {
576
- qty: qty.valueOf(), // convert to number if mIO is provided
577
- allowDelegatedStaking,
578
- delegateRewardShareRatio,
579
- fqdn,
580
- label,
581
- minDelegatedStake: minDelegatedStake.valueOf(), // convert to number if mIO is provided
582
- note,
583
- port,
584
- properties,
585
- protocol,
586
- autoStake,
587
- observerWallet,
588
- },
589
- signer: this.signer,
590
- }, options);
591
- }
592
- /**
593
- * @param params @type {UpdateGatewaySettingsParams} Gateway settings to update
594
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
595
- * @example
596
- * Update a setting of the gateway.
597
- * ```ts
598
- * arIO.updateGatewaySettings({ autoStake: true, minDelegatedStake: new IOToken(100).toMIO()});
599
- * ```
600
- */
601
- async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerWallet, }, options) {
602
- return this.contract.writeInteraction({
603
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.UPDATE_GATEWAY_SETTINGS,
604
- inputs: {
605
- allowDelegatedStaking,
606
- delegateRewardShareRatio,
607
- fqdn,
608
- label,
609
- minDelegatedStake: minDelegatedStake?.valueOf(), // convert to number if mIO is provided
610
- note,
611
- port,
612
- properties,
613
- protocol,
614
- autoStake,
615
- observerWallet,
616
- },
617
- signer: this.signer,
618
- }, options);
619
- }
620
- /**
621
- * @param target @type {string} The gateway you wish to delegate stake to.
622
- * @param qty @type {number | mIOToken} The amount of stake to delegate represented in mIO.
623
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
624
- * @example
625
- * Delegate stake to a gateway.
626
- * ```ts
627
- * arIO.increaseDelegateStake({ target: "FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44", qty: 1000 });
628
- * ```
629
- */
630
- async increaseDelegateStake(params, options) {
631
- return this.contract.writeInteraction({
632
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.DELEGATE_STAKE,
633
- inputs: {
634
- target: params.target,
635
- qty: params.qty.valueOf(), // convert to number if mIO is provided
636
- },
637
- signer: this.signer,
638
- }, options);
639
- }
640
- /**
641
- * @param target @type {string} The gateway you wish to decrease stake at.
642
- * @param qty @type {number | mIOToken} The amount of stake to decrease represented in mIO.
643
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
644
- * @example
645
- * Decrease your delegated staked tokens at a gateway.
646
- * ```ts
647
- * arIO.decreaseDelegateStake({ target: "FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44", qty: new IOToken(1000).toMIO() });
648
- * ```
649
- */
650
- async decreaseDelegateStake(params, options) {
651
- return this.contract.writeInteraction({
652
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.DECREASE_DELEGATE_STAKE,
653
- inputs: {
654
- target: params.target,
655
- qty: params.qty.valueOf(), // convert to number if mIO is provided
656
- },
657
- signer: this.signer,
658
- }, options);
659
- }
660
- /**
661
- * @param qty @type {number | mIOToken} The amount of stake to increase by represented in mIO.
662
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
663
- * @example
664
- * Increase your staked tokens as an operator
665
- * ```new IOToken(1000).toMIO()
666
- * arIO.increaseOperatorStake({ qty: new IOToken(1000).toMIO() });
667
- * ```
668
- */
669
- async increaseOperatorStake(params, options) {
670
- return this.contract.writeInteraction({
671
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.INCREASE_OPERATOR_STAKE,
672
- inputs: {
673
- qty: params.qty.valueOf(), // convert to number if mIO is provided
674
- },
675
- signer: this.signer,
676
- }, options);
677
- }
678
- /**
679
- * @param qty @type {number} The amount of stake to decrease by.
680
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
681
- * @example
682
- * Decrease your staked tokens as an operator
683
- * ```ts
684
- * arIO.decreaseOperatorStake({ qty: 1000 });
685
- * ```
686
- */
687
- async decreaseOperatorStake(params, options) {
688
- const res = this.contract.writeInteraction({
689
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.DECREASE_OPERATOR_STAKE,
690
- inputs: {
691
- qty: params.qty.valueOf(), // convert to number if mIO is provided
692
- },
693
- signer: this.signer,
694
- }, options);
695
- return res;
696
- }
697
- /**
698
- * @param reportTxId @type {TransactionId} The transaction ID of the report.
699
- * @param failedGateways @type {WalletAddress[]} The failed gateways you are reporting.
700
- * @returns {Promise<WriteInteractionResult>} The result of the interaction.
701
- * @example
702
- * Save your observations.
703
- * ```ts
704
- * arIO.saveObservations({
705
- * reportTxId: '5f7aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2Pe6ko',
706
- * failedGateways: ['FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44']
707
- * });
708
- * ```
709
- */
710
- async saveObservations(params, options) {
711
- return this.contract.writeInteraction({
712
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.SAVE_OBSERVATIONS,
713
- inputs: {
714
- observerReportTxId: params.reportTxId,
715
- failedGateways: params.failedGateways,
716
- },
717
- signer: this.signer,
718
- }, options);
719
- }
720
- async extendLease(params, options) {
721
- return this.contract.writeInteraction({
722
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.EXTEND_RECORD,
723
- inputs: {
724
- name: params.domain,
725
- years: params.years,
726
- },
727
- signer: this.signer,
728
- }, options);
729
- }
730
- async increaseUndernameLimit(params, options) {
731
- return this.contract.writeInteraction({
732
- functionName: types_js_1.AR_IO_CONTRACT_FUNCTIONS.INCREASE_UNDERNAME_COUNT,
733
- inputs: {
734
- name: params.domain,
735
- qty: params.qty,
736
- },
737
- signer: this.signer,
738
- }, options);
739
- }
740
- }
741
- exports.ArIOWritable = ArIOWritable;