@ar.io/sdk 1.2.1 → 2.0.0-alpha.2
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 +5 -1
- package/bundles/web.bundle.min.js +132 -331
- package/lib/cjs/common/ant.js +1 -351
- package/lib/cjs/common/index.js +0 -4
- package/lib/cjs/common/io.js +1 -1
- package/lib/cjs/common/logger.js +27 -15
- package/lib/cjs/types.js +0 -1
- package/lib/cjs/utils/arweave.js +1 -15
- package/lib/cjs/utils/graphql/index.js +0 -1
- package/lib/cjs/utils/index.js +0 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +2 -350
- package/lib/esm/common/index.js +0 -4
- package/lib/esm/common/io.js +1 -1
- package/lib/esm/common/logger.js +27 -12
- package/lib/esm/types.js +0 -1
- package/lib/esm/utils/arweave.js +0 -12
- package/lib/esm/utils/graphql/index.js +0 -1
- package/lib/esm/utils/index.js +0 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +1 -274
- package/lib/types/common/index.d.ts +0 -3
- package/lib/types/common/logger.d.ts +2 -2
- package/lib/types/common.d.ts +1 -138
- package/lib/types/types.d.ts +0 -1
- package/lib/types/utils/arweave.d.ts +0 -5
- package/lib/types/utils/graphql/index.d.ts +0 -1
- package/lib/types/utils/index.d.ts +0 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +5 -10
- package/lib/cjs/arns-service.js +0 -2
- package/lib/cjs/common/ar-io.js +0 -741
- package/lib/cjs/common/contracts/remote-contract.js +0 -55
- package/lib/cjs/common/contracts/warp-contract.js +0 -176
- package/lib/cjs/common/warp.js +0 -25
- package/lib/cjs/utils/graphql/smartweave.js +0 -309
- package/lib/cjs/utils/smartweave.js +0 -58
- package/lib/esm/arns-service.js +0 -1
- package/lib/esm/common/ar-io.js +0 -735
- package/lib/esm/common/contracts/remote-contract.js +0 -51
- package/lib/esm/common/contracts/warp-contract.js +0 -172
- package/lib/esm/common/warp.js +0 -22
- package/lib/esm/utils/graphql/smartweave.js +0 -303
- package/lib/esm/utils/smartweave.js +0 -50
- package/lib/types/arns-service.d.ts +0 -23
- package/lib/types/common/ar-io.d.ts +0 -551
- package/lib/types/common/contracts/remote-contract.d.ts +0 -38
- package/lib/types/common/contracts/warp-contract.d.ts +0 -43
- package/lib/types/common/warp.d.ts +0 -1
- package/lib/types/utils/graphql/smartweave.d.ts +0 -47
- package/lib/types/utils/smartweave.d.ts +0 -41
package/lib/esm/common/ant.js
CHANGED
|
@@ -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 {
|
|
18
|
-
import {
|
|
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 { AoANTReadable, AoANTWriteable, 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,314 +28,3 @@ export class ANT {
|
|
|
65
28
|
throw new InvalidContractConfigurationError();
|
|
66
29
|
}
|
|
67
30
|
}
|
|
68
|
-
export class ANTReadable {
|
|
69
|
-
contract;
|
|
70
|
-
constructor(config) {
|
|
71
|
-
if (isContractConfiguration(config)) {
|
|
72
|
-
this.contract = config.contract;
|
|
73
|
-
}
|
|
74
|
-
else if (isContractTxIdConfiguration(config)) {
|
|
75
|
-
this.contract = new RemoteContract({
|
|
76
|
-
contractTxId: config.contractTxId,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
throw new InvalidContractConfigurationError();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
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;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @param domain @type {string} The domain name.
|
|
103
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
104
|
-
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
105
|
-
* @example
|
|
106
|
-
* Get the current record
|
|
107
|
-
* ```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' } } });
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
async getRecord({ domain, evaluationOptions, }) {
|
|
117
|
-
const records = await this.getRecords({ evaluationOptions });
|
|
118
|
-
return records[domain];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
122
|
-
* @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
|
|
123
|
-
* @example
|
|
124
|
-
* Get the current records
|
|
125
|
-
* ```ts
|
|
126
|
-
* 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
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
async getRecords({ evaluationOptions, } = {}) {
|
|
135
|
-
const state = await this.contract.getState({ evaluationOptions });
|
|
136
|
-
return state.records;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
140
|
-
* @returns {Promise<string>} The owner of the ANT.
|
|
141
|
-
* @example
|
|
142
|
-
* Get the current owner
|
|
143
|
-
* ```ts
|
|
144
|
-
* ant.getOwner();
|
|
145
|
-
* ```
|
|
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
|
-
*/
|
|
152
|
-
async getOwner({ evaluationOptions, } = {}) {
|
|
153
|
-
const state = await this.contract.getState({ evaluationOptions });
|
|
154
|
-
return state.owner;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
158
|
-
* @returns {Promise<string[]>} The controllers of the ANT.
|
|
159
|
-
* @example
|
|
160
|
-
* Get the controllers of the ANT.
|
|
161
|
-
* ```ts
|
|
162
|
-
* ant.getControllers();
|
|
163
|
-
* ```
|
|
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
|
-
*/
|
|
170
|
-
async getControllers({ evaluationOptions, } = {}) {
|
|
171
|
-
const state = await this.contract.getState({ evaluationOptions });
|
|
172
|
-
return state.controllers;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
176
|
-
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
177
|
-
* @example
|
|
178
|
-
* Get the current name
|
|
179
|
-
* ```ts
|
|
180
|
-
* ant.getName();
|
|
181
|
-
* ```
|
|
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
|
-
*/
|
|
189
|
-
async getName({ evaluationOptions, } = {}) {
|
|
190
|
-
const state = await this.contract.getState({ evaluationOptions });
|
|
191
|
-
return state.name;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
195
|
-
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
196
|
-
* @example
|
|
197
|
-
* The current ticker of the ANT.
|
|
198
|
-
* ```ts
|
|
199
|
-
* ant.getTicker();
|
|
200
|
-
* ```
|
|
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
|
-
*/
|
|
208
|
-
async getTicker({ evaluationOptions, } = {}) {
|
|
209
|
-
const state = await this.contract.getState({ evaluationOptions });
|
|
210
|
-
return state.ticker;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
214
|
-
* @returns {Promise<Record<string, number>>} The balances of the ANT
|
|
215
|
-
* @example
|
|
216
|
-
* The current balances of the ANT.
|
|
217
|
-
* ```ts
|
|
218
|
-
* ant.getBalances();
|
|
219
|
-
* ```
|
|
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
|
-
*/
|
|
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 account you want the balance of.
|
|
234
|
-
* @returns {Promise<number>} The balance of the provided address
|
|
235
|
-
* @example
|
|
236
|
-
* The current balance of the address.
|
|
237
|
-
* ```ts
|
|
238
|
-
* ant.getBalance({ address });
|
|
239
|
-
* ```
|
|
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
|
-
*/
|
|
247
|
-
async getBalance({ address, evaluationOptions, }) {
|
|
248
|
-
const balances = await this.getBalances({ evaluationOptions });
|
|
249
|
-
return balances[address] || 0;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
export class ANTWritable extends ANTReadable {
|
|
253
|
-
signer;
|
|
254
|
-
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
|
-
}
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* @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.
|
|
274
|
-
* @example
|
|
275
|
-
* ```ts
|
|
276
|
-
* ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
async transfer({ target, }, options) {
|
|
280
|
-
return this.contract.writeInteraction({
|
|
281
|
-
functionName: ANT_CONTRACT_FUNCTIONS.TRANSFER,
|
|
282
|
-
inputs: { target },
|
|
283
|
-
signer: this.signer,
|
|
284
|
-
}, options);
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* @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.
|
|
289
|
-
* @example
|
|
290
|
-
* ```ts
|
|
291
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
292
|
-
* ```
|
|
293
|
-
*/
|
|
294
|
-
async setController({ controller, }, options) {
|
|
295
|
-
return this.contract.writeInteraction({
|
|
296
|
-
functionName: ANT_CONTRACT_FUNCTIONS.SET_CONTROLLER,
|
|
297
|
-
inputs: { target: controller },
|
|
298
|
-
signer: this.signer,
|
|
299
|
-
}, options);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* @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.
|
|
304
|
-
* @example
|
|
305
|
-
* ```ts
|
|
306
|
-
* ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
async removeController({ controller, }, options) {
|
|
310
|
-
return this.contract.writeInteraction({
|
|
311
|
-
functionName: ANT_CONTRACT_FUNCTIONS.REMOVE_CONTROLLER,
|
|
312
|
-
inputs: { target: controller },
|
|
313
|
-
signer: this.signer,
|
|
314
|
-
}, options);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* @param subDomain @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
318
|
-
* @param transactionId @type {string} The transactionId of the record.
|
|
319
|
-
* @param ttlSeconds @type {number} The time to live of the record.
|
|
320
|
-
* @returns {Promise<WriteInteractionResult>} The result of the interaction.
|
|
321
|
-
* @example
|
|
322
|
-
* ```ts
|
|
323
|
-
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
324
|
-
* ```
|
|
325
|
-
*/
|
|
326
|
-
async setRecord({ subDomain, transactionId, ttlSeconds, }, options) {
|
|
327
|
-
return this.contract.writeInteraction({
|
|
328
|
-
functionName: ANT_CONTRACT_FUNCTIONS.SET_RECORD,
|
|
329
|
-
inputs: { subDomain, transactionId, ttlSeconds },
|
|
330
|
-
signer: this.signer,
|
|
331
|
-
}, options);
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* @param subDomain @type {string} The record you want to remove.
|
|
335
|
-
* @returns {Promise<WriteInteractionResult>} The result of the interaction.
|
|
336
|
-
* @example
|
|
337
|
-
* ```ts
|
|
338
|
-
* ant.removeRecord({ subDomain: "shorts" });
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
async removeRecord({ subDomain, }, options) {
|
|
342
|
-
return this.contract.writeInteraction({
|
|
343
|
-
functionName: ANT_CONTRACT_FUNCTIONS.REMOVE_RECORD,
|
|
344
|
-
inputs: { subDomain },
|
|
345
|
-
signer: this.signer,
|
|
346
|
-
}, options);
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* @param ticker @type {string} Sets the ANT Ticker.
|
|
350
|
-
* @returns {Promise<WriteInteractionResult>} The result of the interaction.
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* ant.setTicker({ ticker: "KAPOW" });
|
|
354
|
-
* ```
|
|
355
|
-
*/
|
|
356
|
-
async setTicker({ ticker, }, options) {
|
|
357
|
-
return this.contract.writeInteraction({
|
|
358
|
-
functionName: ANT_CONTRACT_FUNCTIONS.SET_TICKER,
|
|
359
|
-
inputs: { ticker },
|
|
360
|
-
signer: this.signer,
|
|
361
|
-
}, options);
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* @param name @type {string} Sets the Name of the ANT.
|
|
365
|
-
* @returns {Promise<WriteInteractionResult>} The result of the interaction.
|
|
366
|
-
* @example
|
|
367
|
-
* ```ts
|
|
368
|
-
* ant.setName({ name: "ships at sea" });
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
async setName({ name }, options) {
|
|
372
|
-
return this.contract.writeInteraction({
|
|
373
|
-
functionName: ANT_CONTRACT_FUNCTIONS.SET_NAME,
|
|
374
|
-
inputs: { name },
|
|
375
|
-
signer: this.signer,
|
|
376
|
-
}, options);
|
|
377
|
-
}
|
|
378
|
-
}
|
package/lib/esm/common/index.js
CHANGED
|
@@ -14,13 +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
22
|
export * from './ant-ao.js';
|
package/lib/esm/common/io.js
CHANGED
|
@@ -35,7 +35,7 @@ export class IO {
|
|
|
35
35
|
export class IOReadable {
|
|
36
36
|
process;
|
|
37
37
|
arweave;
|
|
38
|
-
constructor(config, arweave = Arweave
|
|
38
|
+
constructor(config, arweave = new Arweave({})) {
|
|
39
39
|
if (!config) {
|
|
40
40
|
this.process = new AOProcess({
|
|
41
41
|
processId: IO_TESTNET_PROCESS_ID,
|
package/lib/esm/common/logger.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
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
19
|
export class DefaultLogger {
|
|
20
20
|
logger;
|
|
@@ -24,38 +24,53 @@ export class DefaultLogger {
|
|
|
24
24
|
this.silent = true;
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
this.logger =
|
|
27
|
+
this.logger = createLogger({
|
|
28
28
|
level,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
silent: this.silent,
|
|
30
|
+
defaultMeta: {
|
|
31
|
+
name: 'ar-io-sdk',
|
|
32
|
+
version,
|
|
33
|
+
},
|
|
34
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
32
35
|
});
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
if (typeof window !== 'undefined') {
|
|
39
|
+
this.logger = console;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.logger.add(new transports.Console({
|
|
43
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
33
46
|
}
|
|
34
47
|
info(message, ...args) {
|
|
35
48
|
if (this.silent)
|
|
36
49
|
return;
|
|
37
|
-
this.logger.info(...args
|
|
50
|
+
this.logger.info(message, ...args);
|
|
38
51
|
}
|
|
39
52
|
warn(message, ...args) {
|
|
40
53
|
if (this.silent)
|
|
41
54
|
return;
|
|
42
|
-
this.logger.warn(...args
|
|
55
|
+
this.logger.warn(message, ...args);
|
|
43
56
|
}
|
|
44
57
|
error(message, ...args) {
|
|
45
58
|
if (this.silent)
|
|
46
59
|
return;
|
|
47
|
-
this.logger.error(...args
|
|
60
|
+
this.logger.error(message, ...args);
|
|
48
61
|
}
|
|
49
62
|
debug(message, ...args) {
|
|
50
63
|
if (this.silent)
|
|
51
64
|
return;
|
|
52
|
-
this.logger.debug(...args
|
|
65
|
+
this.logger.debug(message, ...args);
|
|
53
66
|
}
|
|
54
67
|
setLogLevel(level) {
|
|
55
|
-
if (
|
|
56
|
-
this.silent =
|
|
68
|
+
if ('silent' in this.logger) {
|
|
69
|
+
this.logger.silent = level === 'none';
|
|
57
70
|
return;
|
|
58
71
|
}
|
|
59
|
-
this.logger
|
|
72
|
+
if ('level' in this.logger) {
|
|
73
|
+
this.logger.level = level;
|
|
74
|
+
}
|
|
60
75
|
}
|
|
61
76
|
}
|
package/lib/esm/types.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
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 './arns-service.js';
|
|
18
17
|
export * from './contract-state.js';
|
|
19
18
|
export * from './common.js';
|
|
20
19
|
export * from './token.js';
|
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -5,15 +5,3 @@ export const validateArweaveId = (id) => {
|
|
|
5
5
|
export function isBlockHeight(height) {
|
|
6
6
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
7
7
|
}
|
|
8
|
-
export const isTransaction = (tx) => {
|
|
9
|
-
const requiredTxKeys = ['id', 'owner', 'tags', 'signature'];
|
|
10
|
-
return requiredTxKeys.every((key) => key in tx);
|
|
11
|
-
};
|
|
12
|
-
export function tagsToObject(tags) {
|
|
13
|
-
return tags.reduce((decodedTags, tag) => {
|
|
14
|
-
const key = tag.get('name', { decode: true, string: true });
|
|
15
|
-
const value = tag.get('value', { decode: true, string: true });
|
|
16
|
-
decodedTags[key] = value;
|
|
17
|
-
return decodedTags;
|
|
18
|
-
}, {});
|
|
19
|
-
}
|
package/lib/esm/utils/index.js
CHANGED
package/lib/esm/version.js
CHANGED