@ar.io/sdk 2.0.0-alpha.1 → 2.0.0-alpha.11

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 (41) hide show
  1. package/README.md +253 -129
  2. package/bundles/web.bundle.min.js +131 -98
  3. package/lib/cjs/common/ant.js +294 -3
  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 -1
  7. package/lib/cjs/common/io.js +87 -39
  8. package/lib/cjs/common/logger.js +31 -19
  9. package/lib/cjs/utils/http-client.js +1 -1
  10. package/lib/cjs/utils/index.js +1 -1
  11. package/lib/cjs/utils/{graphql/processes.js → processes.js} +40 -10
  12. package/lib/cjs/version.js +1 -1
  13. package/lib/esm/common/ant.js +290 -1
  14. package/lib/esm/common/contracts/ao-process.js +2 -2
  15. package/lib/esm/common/http.js +2 -3
  16. package/lib/esm/common/index.js +0 -1
  17. package/lib/esm/common/io.js +87 -36
  18. package/lib/esm/common/logger.js +29 -14
  19. package/lib/esm/utils/http-client.js +2 -2
  20. package/lib/esm/utils/index.js +1 -1
  21. package/lib/esm/utils/{graphql/processes.js → processes.js} +38 -9
  22. package/lib/esm/version.js +1 -1
  23. package/lib/types/common/ant.d.ts +174 -23
  24. package/lib/types/common/contracts/ao-process.d.ts +2 -2
  25. package/lib/types/common/http.d.ts +3 -2
  26. package/lib/types/common/index.d.ts +0 -1
  27. package/lib/types/common/io.d.ts +5 -4
  28. package/lib/types/common/logger.d.ts +10 -3
  29. package/lib/types/common.d.ts +0 -7
  30. package/lib/types/io.d.ts +28 -3
  31. package/lib/types/utils/http-client.d.ts +2 -2
  32. package/lib/types/utils/index.d.ts +1 -1
  33. package/lib/types/utils/{graphql/processes.d.ts → processes.d.ts} +6 -1
  34. package/lib/types/version.d.ts +1 -1
  35. package/package.json +6 -6
  36. package/lib/cjs/common/ant-ao.js +0 -297
  37. package/lib/cjs/utils/graphql/index.js +0 -33
  38. package/lib/esm/common/ant-ao.js +0 -292
  39. package/lib/esm/utils/graphql/index.js +0 -17
  40. package/lib/types/common/ant-ao.d.ts +0 -194
  41. package/lib/types/utils/graphql/index.d.ts +0 -17
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ANT = void 0;
3
+ exports.AoANTWriteable = exports.AoANTReadable = exports.ANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
6
  *
@@ -24,11 +24,302 @@ class ANT {
24
24
  // ao supported implementation
25
25
  if ((0, types_js_1.isProcessConfiguration)(config) || (0, types_js_1.isProcessIdConfiguration)(config)) {
26
26
  if (!signer) {
27
- return new index_js_1.AoANTReadable(config);
27
+ return new AoANTReadable(config);
28
28
  }
29
- return new index_js_1.AoANTWriteable({ signer, ...config });
29
+ return new AoANTWriteable({ signer, ...config });
30
30
  }
31
31
  throw new index_js_1.InvalidContractConfigurationError();
32
32
  }
33
33
  }
34
34
  exports.ANT = ANT;
35
+ class AoANTReadable {
36
+ process;
37
+ constructor(config) {
38
+ if ((0, types_js_1.isProcessConfiguration)(config)) {
39
+ this.process = config.process;
40
+ }
41
+ else if ((0, types_js_1.isProcessIdConfiguration)(config)) {
42
+ this.process = new index_js_1.AOProcess({
43
+ processId: config.processId,
44
+ });
45
+ }
46
+ else {
47
+ throw new index_js_1.InvalidContractConfigurationError();
48
+ }
49
+ }
50
+ async getState() {
51
+ const tags = [{ name: 'Action', value: 'State' }];
52
+ const res = await this.process.read({
53
+ tags,
54
+ });
55
+ return res;
56
+ }
57
+ async getInfo() {
58
+ const tags = [{ name: 'Action', value: 'Info' }];
59
+ const info = await this.process.read({
60
+ tags,
61
+ });
62
+ return info;
63
+ }
64
+ /**
65
+ * @param undername @type {string} The domain name.
66
+ * @returns {Promise<ANTRecord>} The record of the undername domain.
67
+ * @example
68
+ * Get the current record
69
+ * ```ts
70
+ * ant.getRecord({ undername: "john" });
71
+ * ```
72
+ */
73
+ async getRecord({ undername }) {
74
+ const tags = [
75
+ { name: 'Sub-Domain', value: undername },
76
+ { name: 'Action', value: 'Record' },
77
+ ];
78
+ const record = await this.process.read({
79
+ tags,
80
+ });
81
+ return record;
82
+ }
83
+ /**
84
+ * @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
85
+ * @example
86
+ * Get the current records
87
+ * ```ts
88
+ * ant.getRecords();
89
+ * ````
90
+ */
91
+ async getRecords() {
92
+ const tags = [{ name: 'Action', value: 'Records' }];
93
+ const records = await this.process.read({
94
+ tags,
95
+ });
96
+ return records;
97
+ }
98
+ /**
99
+ * @returns {Promise<string>} The owner of the ANT.
100
+ * @example
101
+ * Get the current owner
102
+ * ```ts
103
+ * ant.getOwner();
104
+ * ```
105
+ */
106
+ async getOwner() {
107
+ const info = await this.getInfo();
108
+ return info.Owner;
109
+ }
110
+ /**
111
+ * @returns {Promise<string[]>} The controllers of the ANT.
112
+ * @example
113
+ * Get the controllers of the ANT.
114
+ * ```ts
115
+ * ant.getControllers();
116
+ * ```
117
+ */
118
+ async getControllers() {
119
+ const tags = [{ name: 'Action', value: 'Controllers' }];
120
+ const controllers = await this.process.read({
121
+ tags,
122
+ });
123
+ return controllers;
124
+ }
125
+ /**
126
+ * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
127
+ * @example
128
+ * Get the current name
129
+ * ```ts
130
+ * ant.getName();
131
+ * ```
132
+ */
133
+ async getName() {
134
+ const info = await this.getInfo();
135
+ return info.Name;
136
+ }
137
+ /**
138
+ * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
139
+ * @example
140
+ * The current ticker of the ANT.
141
+ * ```ts
142
+ * ant.getTicker();
143
+ * ```
144
+ */
145
+ async getTicker() {
146
+ const info = await this.getInfo();
147
+ return info.Ticker;
148
+ }
149
+ /**
150
+ * @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
151
+ * @example
152
+ * The current balances of the ANT.
153
+ * ```ts
154
+ * ant.getBalances();
155
+ * ```
156
+ */
157
+ async getBalances() {
158
+ const tags = [{ name: 'Action', value: 'Balances' }];
159
+ const balances = await this.process.read({
160
+ tags,
161
+ });
162
+ return balances;
163
+ }
164
+ /**
165
+ * @param address @type {string} The address of the account you want the balance of.
166
+ * @returns {Promise<number>} The balance of the provided address
167
+ * @example
168
+ * The current balance of the address.
169
+ * ```ts
170
+ * ant.getBalance({ address });
171
+ * ```
172
+ */
173
+ async getBalance({ address }) {
174
+ const tags = [
175
+ { name: 'Action', value: 'Balance' },
176
+ { name: 'Recipient', value: address },
177
+ ];
178
+ const balance = await this.process.read({
179
+ tags,
180
+ });
181
+ return balance;
182
+ }
183
+ }
184
+ exports.AoANTReadable = AoANTReadable;
185
+ class AoANTWriteable extends AoANTReadable {
186
+ signer;
187
+ constructor({ signer, ...config }) {
188
+ super(config);
189
+ this.signer = signer;
190
+ }
191
+ /**
192
+ * @param target @type {string} The address of the account you want to transfer the ANT to.
193
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
194
+ * @example
195
+ * ```ts
196
+ * ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
197
+ * ```
198
+ */
199
+ async transfer({ target }) {
200
+ const tags = [
201
+ { name: 'Action', value: 'Transfer' },
202
+ { name: 'Recipient', value: target },
203
+ ];
204
+ return this.process.send({
205
+ tags,
206
+ data: {},
207
+ signer: this.signer,
208
+ });
209
+ }
210
+ /**
211
+ * @param controller @type {string} The address of the account you want to set as a controller.
212
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
213
+ * @example
214
+ * ```ts
215
+ * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
216
+ * ```
217
+ */
218
+ async addController({ controller, }) {
219
+ const tags = [
220
+ { name: 'Action', value: 'Add-Controller' },
221
+ { name: 'Controller', value: controller },
222
+ ];
223
+ return this.process.send({
224
+ tags,
225
+ data: {},
226
+ signer: this.signer,
227
+ });
228
+ }
229
+ /**
230
+ * @param controller @type {string} The address of the account you want to remove from the controllers list
231
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
232
+ * @example
233
+ * ```ts
234
+ * ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
235
+ * ```
236
+ */
237
+ async removeController({ controller, }) {
238
+ const tags = [
239
+ { name: 'Action', value: 'Remove-Controller' },
240
+ { name: 'Controller', value: controller },
241
+ ];
242
+ return this.process.send({
243
+ tags,
244
+ data: {},
245
+ signer: this.signer,
246
+ });
247
+ }
248
+ /**
249
+ * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
250
+ * @param transactionId @type {string} The transactionId of the record.
251
+ * @param ttlSeconds @type {number} The time to live of the record.
252
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
253
+ * @example
254
+ * ```ts
255
+ * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
256
+ * ```
257
+ */
258
+ async setRecord({ undername, transactionId, ttlSeconds, }) {
259
+ return this.process.send({
260
+ tags: [
261
+ { name: 'Action', value: 'Set-Record' },
262
+ { name: 'Sub-Domain', value: undername },
263
+ { name: 'Transaction-Id', value: transactionId },
264
+ { name: 'TTL-Seconds', value: ttlSeconds.toString() },
265
+ ],
266
+ data: { transactionId, ttlSeconds },
267
+ signer: this.signer,
268
+ });
269
+ }
270
+ /**
271
+ * @param undername @type {string} The record you want to remove.
272
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
273
+ * @example
274
+ * ```ts
275
+ * ant.removeRecord({ subDomain: "shorts" });
276
+ * ```
277
+ */
278
+ async removeRecord({ undername, }) {
279
+ return this.process.send({
280
+ tags: [
281
+ { name: 'Action', value: 'Remove-Record' },
282
+ { name: 'Sub-Domain', value: undername },
283
+ ],
284
+ data: { undername },
285
+ signer: this.signer,
286
+ });
287
+ }
288
+ /**
289
+ * @param ticker @type {string} Sets the ANT Ticker.
290
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
291
+ * @example
292
+ * ```ts
293
+ * ant.setTicker({ ticker: "KAPOW" });
294
+ * ```
295
+ */
296
+ async setTicker({ ticker }) {
297
+ return this.process.send({
298
+ tags: [
299
+ { name: 'Action', value: 'Set-Ticker' },
300
+ { name: 'Ticker', value: ticker },
301
+ ],
302
+ data: { ticker },
303
+ signer: this.signer,
304
+ });
305
+ }
306
+ /**
307
+ * @param name @type {string} Sets the Name of the ANT.
308
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
309
+ * @example
310
+ * ```ts
311
+ * ant.setName({ name: "ships at sea" });
312
+ * ```
313
+ */
314
+ async setName({ name }) {
315
+ return this.process.send({
316
+ tags: [
317
+ { name: 'Action', value: 'Set-Name' },
318
+ { name: 'Name', value: name },
319
+ ],
320
+ data: { name },
321
+ signer: this.signer,
322
+ });
323
+ }
324
+ }
325
+ exports.AoANTWriteable = AoANTWriteable;
@@ -27,7 +27,7 @@ class AOProcess {
27
27
  logger;
28
28
  processId;
29
29
  ao;
30
- constructor({ processId, ao = (0, aoconnect_1.connect)(), logger = new logger_js_1.DefaultLogger({ level: 'info' }), }) {
30
+ constructor({ processId, ao = (0, aoconnect_1.connect)(), logger = logger_js_1.Logger.default, }) {
31
31
  this.processId = processId;
32
32
  this.logger = logger;
33
33
  this.ao = ao;
@@ -7,8 +7,7 @@ const logger_js_1 = require("./logger.js");
7
7
  class AxiosHTTPService {
8
8
  axios;
9
9
  logger;
10
- // TODO: re-implement axios-retry. Currently that package is broken for nodenext.
11
- constructor({ url, logger = new logger_js_1.DefaultLogger(), }) {
10
+ constructor({ url, logger = logger_js_1.Logger.default, }) {
12
11
  this.logger = logger;
13
12
  this.axios = (0, index_js_1.createAxiosInstance)({
14
13
  axiosConfig: {
@@ -35,5 +35,4 @@ __exportStar(require("./logger.js"), exports);
35
35
  __exportStar(require("./ant.js"), exports);
36
36
  // ao
37
37
  __exportStar(require("./io.js"), exports);
38
- __exportStar(require("./ant-ao.js"), exports);
39
38
  __exportStar(require("./contracts/ao-process.js"), exports);
@@ -1,31 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.IOWriteable = exports.IOReadable = exports.IO = void 0;
7
- /**
8
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
9
- *
10
- * This program is free software: you can redistribute it and/or modify
11
- * it under the terms of the GNU Affero General Public License as published by
12
- * the Free Software Foundation, either version 3 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU Affero General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Affero General Public License
21
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
22
- */
23
- const arweave_1 = __importDefault(require("arweave"));
24
4
  const constants_js_1 = require("../constants.js");
25
5
  const io_js_1 = require("../io.js");
6
+ const arweave_js_1 = require("./arweave.js");
26
7
  const ao_process_js_1 = require("./contracts/ao-process.js");
27
8
  const error_js_1 = require("./error.js");
28
- const logger_js_1 = require("./logger.js");
29
9
  class IO {
30
10
  static init(config) {
31
11
  if (config && config.signer) {
@@ -42,7 +22,7 @@ exports.IO = IO;
42
22
  class IOReadable {
43
23
  process;
44
24
  arweave;
45
- constructor(config, arweave = new arweave_1.default({})) {
25
+ constructor(config, arweave = arweave_js_1.defaultArweave) {
46
26
  if (!config) {
47
27
  this.process = new ao_process_js_1.AOProcess({
48
28
  processId: constants_js_1.IO_TESTNET_PROCESS_ID,
@@ -54,9 +34,6 @@ class IOReadable {
54
34
  else if ((0, io_js_1.isProcessIdConfiguration)(config)) {
55
35
  this.process = new ao_process_js_1.AOProcess({
56
36
  processId: config.processId,
57
- logger: new logger_js_1.DefaultLogger({
58
- level: 'info',
59
- }),
60
37
  });
61
38
  }
62
39
  else {
@@ -75,7 +52,12 @@ class IOReadable {
75
52
  {
76
53
  name: 'Timestamp',
77
54
  value: params?.timestamp?.toString() ??
78
- (await this.arweave.blocks.getCurrent().catch(() => {
55
+ (await this.arweave.blocks
56
+ .getCurrent()
57
+ .then((block) => {
58
+ return { timestamp: block.timestamp * 1000 };
59
+ })
60
+ .catch(() => {
79
61
  return { timestamp: Date.now() }; // fallback to current time
80
62
  })).timestamp.toString(),
81
63
  },
@@ -95,7 +77,12 @@ class IOReadable {
95
77
  {
96
78
  name: 'Timestamp',
97
79
  value: epoch?.timestamp?.toString() ??
98
- (await this.arweave.blocks.getCurrent().catch(() => {
80
+ (await this.arweave.blocks
81
+ .getCurrent()
82
+ .then((block) => {
83
+ return { timestamp: block.timestamp * 1000 };
84
+ })
85
+ .catch(() => {
99
86
  return { timestamp: Date.now() }; // fallback to current time
100
87
  })).timestamp.toString(),
101
88
  },
@@ -117,9 +104,17 @@ class IOReadable {
117
104
  ],
118
105
  });
119
106
  }
120
- async getArNSRecords() {
107
+ async getArNSRecords(pageParams) {
108
+ const allTags = [
109
+ { name: 'Action', value: 'Paginated-Records' },
110
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
111
+ { name: 'Limit', value: pageParams?.limit?.toString() },
112
+ { name: 'Sort-By', value: pageParams?.sortBy },
113
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
114
+ ];
115
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
121
116
  return this.process.read({
122
- tags: [{ name: 'Action', value: 'Records' }],
117
+ tags: prunedTags,
123
118
  });
124
119
  }
125
120
  async getArNSReservedNames() {
@@ -143,9 +138,17 @@ class IOReadable {
143
138
  ],
144
139
  });
145
140
  }
146
- async getBalances() {
141
+ async getBalances(pageParams) {
142
+ const allTags = [
143
+ { name: 'Action', value: 'Paginated-Balances' },
144
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
145
+ { name: 'Limit', value: pageParams?.limit?.toString() },
146
+ { name: 'Sort-By', value: pageParams?.sortBy },
147
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
148
+ ];
149
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
147
150
  return this.process.read({
148
- tags: [{ name: 'Action', value: 'Balances' }],
151
+ tags: prunedTags,
149
152
  });
150
153
  }
151
154
  async getGateway({ address, }) {
@@ -156,9 +159,17 @@ class IOReadable {
156
159
  ],
157
160
  });
158
161
  }
159
- async getGateways() {
162
+ async getGateways(pageParams) {
163
+ const allTags = [
164
+ { name: 'Action', value: 'Paginated-Gateways' },
165
+ { name: 'Cursor', value: pageParams?.cursor?.toString() },
166
+ { name: 'Limit', value: pageParams?.limit?.toString() },
167
+ { name: 'Sort-By', value: pageParams?.sortBy },
168
+ { name: 'Sort-Order', value: pageParams?.sortOrder },
169
+ ];
170
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
160
171
  return this.process.read({
161
- tags: [{ name: 'Action', value: 'Gateways' }],
172
+ tags: prunedTags,
162
173
  });
163
174
  }
164
175
  async getCurrentEpoch() {
@@ -167,7 +178,12 @@ class IOReadable {
167
178
  { name: 'Action', value: 'Epoch' },
168
179
  {
169
180
  name: 'Timestamp',
170
- value: (await this.arweave.blocks.getCurrent().catch(() => {
181
+ value: (await this.arweave.blocks
182
+ .getCurrent()
183
+ .then((block) => {
184
+ return { timestamp: block.timestamp * 1000 };
185
+ })
186
+ .catch(() => {
171
187
  return { timestamp: Date.now() }; // fallback to current time
172
188
  })).timestamp.toString(),
173
189
  },
@@ -180,7 +196,12 @@ class IOReadable {
180
196
  {
181
197
  name: 'Timestamp',
182
198
  value: epoch?.timestamp?.toString() ??
183
- (await this.arweave.blocks.getCurrent().catch(() => {
199
+ (await this.arweave.blocks
200
+ .getCurrent()
201
+ .then((block) => {
202
+ return { timestamp: block.timestamp * 1000 };
203
+ })
204
+ .catch(() => {
184
205
  return { timestamp: Date.now() }; // fallback to current time
185
206
  })).timestamp.toString(),
186
207
  },
@@ -200,7 +221,12 @@ class IOReadable {
200
221
  {
201
222
  name: 'Timestamp',
202
223
  value: epoch?.timestamp?.toString() ??
203
- (await this.arweave.blocks.getCurrent().catch(() => {
224
+ (await this.arweave.blocks
225
+ .getCurrent()
226
+ .then((block) => {
227
+ return { timestamp: block.timestamp * 1000 };
228
+ })
229
+ .catch(() => {
204
230
  return { timestamp: Date.now() }; // fallback to current time
205
231
  })).timestamp.toString(),
206
232
  },
@@ -220,7 +246,12 @@ class IOReadable {
220
246
  {
221
247
  name: 'Timestamp',
222
248
  value: epoch?.timestamp?.toString() ??
223
- (await this.arweave.blocks.getCurrent().catch(() => {
249
+ (await this.arweave.blocks
250
+ .getCurrent()
251
+ .then((block) => {
252
+ return { timestamp: block.timestamp * 1000 };
253
+ })
254
+ .catch(() => {
224
255
  return { timestamp: `${Date.now()}` }; // fallback to current time
225
256
  })).timestamp.toString(),
226
257
  },
@@ -240,7 +271,12 @@ class IOReadable {
240
271
  {
241
272
  name: 'Timestamp',
242
273
  value: epoch?.timestamp?.toString() ??
243
- (await this.arweave.blocks.getCurrent().catch(() => {
274
+ (await this.arweave.blocks
275
+ .getCurrent()
276
+ .then((block) => {
277
+ return { timestamp: block.timestamp * 1000 };
278
+ })
279
+ .catch(() => {
244
280
  return { timestamp: Date.now() }; // fallback to current time
245
281
  })).timestamp.toString(),
246
282
  },
@@ -279,7 +315,12 @@ class IOReadable {
279
315
  },
280
316
  {
281
317
  name: 'Timestamp',
282
- value: (await this.arweave.blocks.getCurrent().catch(() => {
318
+ value: (await this.arweave.blocks
319
+ .getCurrent()
320
+ .then((block) => {
321
+ return { timestamp: block.timestamp * 1000 };
322
+ })
323
+ .catch(() => {
283
324
  return { timestamp: Date.now() }; // fallback to current time
284
325
  })).timestamp.toString(),
285
326
  },
@@ -396,6 +437,13 @@ class IOWriteable extends IOReadable {
396
437
  tags: prunedTags,
397
438
  });
398
439
  }
440
+ async leaveNetwork(options) {
441
+ const { tags = [] } = options || {};
442
+ return this.process.send({
443
+ signer: this.signer,
444
+ tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
445
+ });
446
+ }
399
447
  async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
400
448
  const { tags = [] } = options || {};
401
449
  const allTags = [
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DefaultLogger = void 0;
3
+ exports.Logger = void 0;
7
4
  /**
8
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
9
6
  *
@@ -20,49 +17,64 @@ exports.DefaultLogger = void 0;
20
17
  * You should have received a copy of the GNU Affero General Public License
21
18
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22
19
  */
23
- const bunyan_1 = __importDefault(require("bunyan"));
20
+ const winston_1 = require("winston");
24
21
  const version_js_1 = require("../version.js");
25
- class DefaultLogger {
22
+ class Logger {
26
23
  logger;
27
24
  silent = false;
25
+ static default = new Logger();
28
26
  constructor({ level = 'info', } = {}) {
29
27
  if (level === 'none') {
30
28
  this.silent = true;
31
29
  return;
32
30
  }
33
- this.logger = bunyan_1.default.createLogger({
31
+ this.logger = (0, winston_1.createLogger)({
34
32
  level,
35
- name: 'ar-io-sdk',
36
- version: version_js_1.version,
37
- serializers: bunyan_1.default.stdSerializers,
33
+ silent: this.silent,
34
+ defaultMeta: {
35
+ name: 'ar-io-sdk',
36
+ version: version_js_1.version,
37
+ },
38
+ format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.json()),
38
39
  });
40
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
+ // @ts-ignore
42
+ if (typeof window !== 'undefined') {
43
+ this.logger = console;
44
+ }
45
+ else {
46
+ this.logger.add(new winston_1.transports.Console({
47
+ format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.json()),
48
+ }));
49
+ }
39
50
  }
40
51
  info(message, ...args) {
41
52
  if (this.silent)
42
53
  return;
43
- this.logger.info(...args, message);
54
+ this.logger.info(message, ...args);
44
55
  }
45
56
  warn(message, ...args) {
46
57
  if (this.silent)
47
58
  return;
48
- this.logger.warn(...args, message);
59
+ this.logger.warn(message, ...args);
49
60
  }
50
61
  error(message, ...args) {
51
62
  if (this.silent)
52
63
  return;
53
- this.logger.error(...args, message);
64
+ this.logger.error(message, ...args);
54
65
  }
55
66
  debug(message, ...args) {
56
67
  if (this.silent)
57
68
  return;
58
- this.logger.debug(...args, message);
69
+ this.logger.debug(message, ...args);
59
70
  }
60
71
  setLogLevel(level) {
61
- if (level === 'none') {
62
- this.silent = true;
63
- return;
72
+ if ('silent' in this.logger) {
73
+ this.logger.silent = level === 'none';
74
+ }
75
+ if ('level' in this.logger) {
76
+ this.logger.level = level;
64
77
  }
65
- this.logger.level(level);
66
78
  }
67
79
  }
68
- exports.DefaultLogger = DefaultLogger;
80
+ exports.Logger = Logger;
@@ -24,7 +24,7 @@ const axios_1 = __importDefault(require("axios"));
24
24
  const axios_retry_1 = __importDefault(require("axios-retry"));
25
25
  const logger_js_1 = require("../common/logger.js");
26
26
  const version_js_1 = require("../version.js");
27
- const createAxiosInstance = ({ axiosConfig = {}, logger = new logger_js_1.DefaultLogger(), retryConfig = {
27
+ const createAxiosInstance = ({ axiosConfig = {}, logger = logger_js_1.Logger.default, retryConfig = {
28
28
  retries: 5,
29
29
  retryDelay: axios_retry_1.default.exponentialDelay,
30
30
  retryCondition: (error) => axios_retry_1.default.isRetryableError(error),
@@ -32,6 +32,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
32
  */
33
33
  __exportStar(require("./arweave.js"), exports);
34
34
  __exportStar(require("./http-client.js"), exports);
35
- __exportStar(require("./graphql/index.js"), exports);
36
35
  __exportStar(require("./ao.js"), exports);
37
36
  __exportStar(require("./json.js"), exports);
37
+ __exportStar(require("./processes.js"), exports);