@xchainjs/xchain-thorchain 0.28.2 → 0.28.4
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/lib/client.d.ts +1 -1
- package/lib/const.d.ts +1 -1
- package/lib/index.esm.js +430 -439
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +430 -439
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -4257,7 +4257,7 @@ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
|
|
|
4257
4257
|
const RUNE_TICKER = 'RUNE';
|
|
4258
4258
|
const RUNE_DECIMAL = 8;
|
|
4259
4259
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4260
|
-
const DEFAULT_GAS_LIMIT_VALUE = '
|
|
4260
|
+
const DEFAULT_GAS_LIMIT_VALUE = '6000000';
|
|
4261
4261
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
4262
4262
|
const MAX_TX_COUNT_PER_PAGE = 100;
|
|
4263
4263
|
const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
@@ -4354,215 +4354,200 @@ var indexMinimal = {};
|
|
|
4354
4354
|
|
|
4355
4355
|
var minimal$1 = {};
|
|
4356
4356
|
|
|
4357
|
-
var aspromise;
|
|
4358
|
-
|
|
4357
|
+
var aspromise = asPromise;
|
|
4358
|
+
|
|
4359
|
+
/**
|
|
4360
|
+
* Callback as used by {@link util.asPromise}.
|
|
4361
|
+
* @typedef asPromiseCallback
|
|
4362
|
+
* @type {function}
|
|
4363
|
+
* @param {Error|null} error Error, if any
|
|
4364
|
+
* @param {...*} params Additional arguments
|
|
4365
|
+
* @returns {undefined}
|
|
4366
|
+
*/
|
|
4367
|
+
|
|
4368
|
+
/**
|
|
4369
|
+
* Returns a promise from a node-style callback function.
|
|
4370
|
+
* @memberof util
|
|
4371
|
+
* @param {asPromiseCallback} fn Function to call
|
|
4372
|
+
* @param {*} ctx Function context
|
|
4373
|
+
* @param {...*} params Function arguments
|
|
4374
|
+
* @returns {Promise<*>} Promisified function
|
|
4375
|
+
*/
|
|
4376
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
4377
|
+
var params = new Array(arguments.length - 1),
|
|
4378
|
+
offset = 0,
|
|
4379
|
+
index = 2,
|
|
4380
|
+
pending = true;
|
|
4381
|
+
while (index < arguments.length)
|
|
4382
|
+
params[offset++] = arguments[index++];
|
|
4383
|
+
return new Promise(function executor(resolve, reject) {
|
|
4384
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
4385
|
+
if (pending) {
|
|
4386
|
+
pending = false;
|
|
4387
|
+
if (err)
|
|
4388
|
+
reject(err);
|
|
4389
|
+
else {
|
|
4390
|
+
var params = new Array(arguments.length - 1),
|
|
4391
|
+
offset = 0;
|
|
4392
|
+
while (offset < params.length)
|
|
4393
|
+
params[offset++] = arguments[offset];
|
|
4394
|
+
resolve.apply(null, params);
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
};
|
|
4398
|
+
try {
|
|
4399
|
+
fn.apply(ctx || null, params);
|
|
4400
|
+
} catch (err) {
|
|
4401
|
+
if (pending) {
|
|
4402
|
+
pending = false;
|
|
4403
|
+
reject(err);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
});
|
|
4407
|
+
}
|
|
4359
4408
|
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
aspromise = asPromise;
|
|
4409
|
+
var base64$1 = {};
|
|
4410
|
+
|
|
4411
|
+
(function (exports) {
|
|
4364
4412
|
|
|
4365
4413
|
/**
|
|
4366
|
-
*
|
|
4367
|
-
* @
|
|
4368
|
-
* @
|
|
4369
|
-
* @param {Error|null} error Error, if any
|
|
4370
|
-
* @param {...*} params Additional arguments
|
|
4371
|
-
* @returns {undefined}
|
|
4414
|
+
* A minimal base64 implementation for number arrays.
|
|
4415
|
+
* @memberof util
|
|
4416
|
+
* @namespace
|
|
4372
4417
|
*/
|
|
4418
|
+
var base64 = exports;
|
|
4373
4419
|
|
|
4374
4420
|
/**
|
|
4375
|
-
*
|
|
4376
|
-
* @
|
|
4377
|
-
* @
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4421
|
+
* Calculates the byte length of a base64 encoded string.
|
|
4422
|
+
* @param {string} string Base64 encoded string
|
|
4423
|
+
* @returns {number} Byte length
|
|
4424
|
+
*/
|
|
4425
|
+
base64.length = function length(string) {
|
|
4426
|
+
var p = string.length;
|
|
4427
|
+
if (!p)
|
|
4428
|
+
return 0;
|
|
4429
|
+
var n = 0;
|
|
4430
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4431
|
+
++n;
|
|
4432
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
4433
|
+
};
|
|
4434
|
+
|
|
4435
|
+
// Base64 encoding table
|
|
4436
|
+
var b64 = new Array(64);
|
|
4437
|
+
|
|
4438
|
+
// Base64 decoding table
|
|
4439
|
+
var s64 = new Array(123);
|
|
4440
|
+
|
|
4441
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
4442
|
+
for (var i = 0; i < 64;)
|
|
4443
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
4444
|
+
|
|
4445
|
+
/**
|
|
4446
|
+
* Encodes a buffer to a base64 encoded string.
|
|
4447
|
+
* @param {Uint8Array} buffer Source buffer
|
|
4448
|
+
* @param {number} start Source start
|
|
4449
|
+
* @param {number} end Source end
|
|
4450
|
+
* @returns {string} Base64 encoded string
|
|
4381
4451
|
*/
|
|
4382
|
-
function
|
|
4383
|
-
var
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
} catch (err) {
|
|
4407
|
-
if (pending) {
|
|
4408
|
-
pending = false;
|
|
4409
|
-
reject(err);
|
|
4410
|
-
}
|
|
4452
|
+
base64.encode = function encode(buffer, start, end) {
|
|
4453
|
+
var parts = null,
|
|
4454
|
+
chunk = [];
|
|
4455
|
+
var i = 0, // output index
|
|
4456
|
+
j = 0, // goto index
|
|
4457
|
+
t; // temporary
|
|
4458
|
+
while (start < end) {
|
|
4459
|
+
var b = buffer[start++];
|
|
4460
|
+
switch (j) {
|
|
4461
|
+
case 0:
|
|
4462
|
+
chunk[i++] = b64[b >> 2];
|
|
4463
|
+
t = (b & 3) << 4;
|
|
4464
|
+
j = 1;
|
|
4465
|
+
break;
|
|
4466
|
+
case 1:
|
|
4467
|
+
chunk[i++] = b64[t | b >> 4];
|
|
4468
|
+
t = (b & 15) << 2;
|
|
4469
|
+
j = 2;
|
|
4470
|
+
break;
|
|
4471
|
+
case 2:
|
|
4472
|
+
chunk[i++] = b64[t | b >> 6];
|
|
4473
|
+
chunk[i++] = b64[b & 63];
|
|
4474
|
+
j = 0;
|
|
4475
|
+
break;
|
|
4411
4476
|
}
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4477
|
+
if (i > 8191) {
|
|
4478
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4479
|
+
i = 0;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
if (j) {
|
|
4483
|
+
chunk[i++] = b64[t];
|
|
4484
|
+
chunk[i++] = 61;
|
|
4485
|
+
if (j === 1)
|
|
4486
|
+
chunk[i++] = 61;
|
|
4487
|
+
}
|
|
4488
|
+
if (parts) {
|
|
4489
|
+
if (i)
|
|
4490
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4491
|
+
return parts.join("");
|
|
4492
|
+
}
|
|
4493
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4494
|
+
};
|
|
4495
|
+
|
|
4496
|
+
var invalidEncoding = "invalid encoding";
|
|
4425
4497
|
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
case 1:
|
|
4480
|
-
chunk[i++] = b64[t | b >> 4];
|
|
4481
|
-
t = (b & 15) << 2;
|
|
4482
|
-
j = 2;
|
|
4483
|
-
break;
|
|
4484
|
-
case 2:
|
|
4485
|
-
chunk[i++] = b64[t | b >> 6];
|
|
4486
|
-
chunk[i++] = b64[b & 63];
|
|
4487
|
-
j = 0;
|
|
4488
|
-
break;
|
|
4489
|
-
}
|
|
4490
|
-
if (i > 8191) {
|
|
4491
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4492
|
-
i = 0;
|
|
4493
|
-
}
|
|
4494
|
-
}
|
|
4495
|
-
if (j) {
|
|
4496
|
-
chunk[i++] = b64[t];
|
|
4497
|
-
chunk[i++] = 61;
|
|
4498
|
-
if (j === 1)
|
|
4499
|
-
chunk[i++] = 61;
|
|
4500
|
-
}
|
|
4501
|
-
if (parts) {
|
|
4502
|
-
if (i)
|
|
4503
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4504
|
-
return parts.join("");
|
|
4505
|
-
}
|
|
4506
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4507
|
-
};
|
|
4508
|
-
|
|
4509
|
-
var invalidEncoding = "invalid encoding";
|
|
4510
|
-
|
|
4511
|
-
/**
|
|
4512
|
-
* Decodes a base64 encoded string to a buffer.
|
|
4513
|
-
* @param {string} string Source string
|
|
4514
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
4515
|
-
* @param {number} offset Destination offset
|
|
4516
|
-
* @returns {number} Number of bytes written
|
|
4517
|
-
* @throws {Error} If encoding is invalid
|
|
4518
|
-
*/
|
|
4519
|
-
base64.decode = function decode(string, buffer, offset) {
|
|
4520
|
-
var start = offset;
|
|
4521
|
-
var j = 0, // goto index
|
|
4522
|
-
t; // temporary
|
|
4523
|
-
for (var i = 0; i < string.length;) {
|
|
4524
|
-
var c = string.charCodeAt(i++);
|
|
4525
|
-
if (c === 61 && j > 1)
|
|
4526
|
-
break;
|
|
4527
|
-
if ((c = s64[c]) === undefined)
|
|
4528
|
-
throw Error(invalidEncoding);
|
|
4529
|
-
switch (j) {
|
|
4530
|
-
case 0:
|
|
4531
|
-
t = c;
|
|
4532
|
-
j = 1;
|
|
4533
|
-
break;
|
|
4534
|
-
case 1:
|
|
4535
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4536
|
-
t = c;
|
|
4537
|
-
j = 2;
|
|
4538
|
-
break;
|
|
4539
|
-
case 2:
|
|
4540
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4541
|
-
t = c;
|
|
4542
|
-
j = 3;
|
|
4543
|
-
break;
|
|
4544
|
-
case 3:
|
|
4545
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
4546
|
-
j = 0;
|
|
4547
|
-
break;
|
|
4548
|
-
}
|
|
4549
|
-
}
|
|
4550
|
-
if (j === 1)
|
|
4551
|
-
throw Error(invalidEncoding);
|
|
4552
|
-
return offset - start;
|
|
4553
|
-
};
|
|
4554
|
-
|
|
4555
|
-
/**
|
|
4556
|
-
* Tests if the specified string appears to be base64 encoded.
|
|
4557
|
-
* @param {string} string String to test
|
|
4558
|
-
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
4559
|
-
*/
|
|
4560
|
-
base64.test = function test(string) {
|
|
4561
|
-
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
4562
|
-
};
|
|
4563
|
-
} (base64$1));
|
|
4564
|
-
return base64$1;
|
|
4565
|
-
}
|
|
4498
|
+
/**
|
|
4499
|
+
* Decodes a base64 encoded string to a buffer.
|
|
4500
|
+
* @param {string} string Source string
|
|
4501
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
4502
|
+
* @param {number} offset Destination offset
|
|
4503
|
+
* @returns {number} Number of bytes written
|
|
4504
|
+
* @throws {Error} If encoding is invalid
|
|
4505
|
+
*/
|
|
4506
|
+
base64.decode = function decode(string, buffer, offset) {
|
|
4507
|
+
var start = offset;
|
|
4508
|
+
var j = 0, // goto index
|
|
4509
|
+
t; // temporary
|
|
4510
|
+
for (var i = 0; i < string.length;) {
|
|
4511
|
+
var c = string.charCodeAt(i++);
|
|
4512
|
+
if (c === 61 && j > 1)
|
|
4513
|
+
break;
|
|
4514
|
+
if ((c = s64[c]) === undefined)
|
|
4515
|
+
throw Error(invalidEncoding);
|
|
4516
|
+
switch (j) {
|
|
4517
|
+
case 0:
|
|
4518
|
+
t = c;
|
|
4519
|
+
j = 1;
|
|
4520
|
+
break;
|
|
4521
|
+
case 1:
|
|
4522
|
+
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4523
|
+
t = c;
|
|
4524
|
+
j = 2;
|
|
4525
|
+
break;
|
|
4526
|
+
case 2:
|
|
4527
|
+
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4528
|
+
t = c;
|
|
4529
|
+
j = 3;
|
|
4530
|
+
break;
|
|
4531
|
+
case 3:
|
|
4532
|
+
buffer[offset++] = (t & 3) << 6 | c;
|
|
4533
|
+
j = 0;
|
|
4534
|
+
break;
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
if (j === 1)
|
|
4538
|
+
throw Error(invalidEncoding);
|
|
4539
|
+
return offset - start;
|
|
4540
|
+
};
|
|
4541
|
+
|
|
4542
|
+
/**
|
|
4543
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
4544
|
+
* @param {string} string String to test
|
|
4545
|
+
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
4546
|
+
*/
|
|
4547
|
+
base64.test = function test(string) {
|
|
4548
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
4549
|
+
};
|
|
4550
|
+
} (base64$1));
|
|
4566
4551
|
|
|
4567
4552
|
var eventemitter = EventEmitter;
|
|
4568
4553
|
|
|
@@ -4974,201 +4959,178 @@ function readUintBE(buf, pos) {
|
|
|
4974
4959
|
| buf[pos + 3]) >>> 0;
|
|
4975
4960
|
}
|
|
4976
4961
|
|
|
4977
|
-
var inquire_1;
|
|
4978
|
-
var hasRequiredInquire;
|
|
4979
|
-
|
|
4980
|
-
function requireInquire () {
|
|
4981
|
-
if (hasRequiredInquire) return inquire_1;
|
|
4982
|
-
hasRequiredInquire = 1;
|
|
4983
|
-
inquire_1 = inquire;
|
|
4962
|
+
var inquire_1 = inquire;
|
|
4984
4963
|
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
}
|
|
4999
|
-
return inquire_1;
|
|
4964
|
+
/**
|
|
4965
|
+
* Requires a module only if available.
|
|
4966
|
+
* @memberof util
|
|
4967
|
+
* @param {string} moduleName Module to require
|
|
4968
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
4969
|
+
*/
|
|
4970
|
+
function inquire(moduleName) {
|
|
4971
|
+
try {
|
|
4972
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
4973
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
4974
|
+
return mod;
|
|
4975
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
4976
|
+
return null;
|
|
5000
4977
|
}
|
|
5001
4978
|
|
|
5002
4979
|
var utf8$2 = {};
|
|
5003
4980
|
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
function requireUtf8 () {
|
|
5007
|
-
if (hasRequiredUtf8) return utf8$2;
|
|
5008
|
-
hasRequiredUtf8 = 1;
|
|
5009
|
-
(function (exports) {
|
|
4981
|
+
(function (exports) {
|
|
5010
4982
|
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
/**
|
|
5019
|
-
* Calculates the UTF8 byte length of a string.
|
|
5020
|
-
* @param {string} string String
|
|
5021
|
-
* @returns {number} Byte length
|
|
5022
|
-
*/
|
|
5023
|
-
utf8.length = function utf8_length(string) {
|
|
5024
|
-
var len = 0,
|
|
5025
|
-
c = 0;
|
|
5026
|
-
for (var i = 0; i < string.length; ++i) {
|
|
5027
|
-
c = string.charCodeAt(i);
|
|
5028
|
-
if (c < 128)
|
|
5029
|
-
len += 1;
|
|
5030
|
-
else if (c < 2048)
|
|
5031
|
-
len += 2;
|
|
5032
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5033
|
-
++i;
|
|
5034
|
-
len += 4;
|
|
5035
|
-
} else
|
|
5036
|
-
len += 3;
|
|
5037
|
-
}
|
|
5038
|
-
return len;
|
|
5039
|
-
};
|
|
5040
|
-
|
|
5041
|
-
/**
|
|
5042
|
-
* Reads UTF8 bytes as a string.
|
|
5043
|
-
* @param {Uint8Array} buffer Source buffer
|
|
5044
|
-
* @param {number} start Source start
|
|
5045
|
-
* @param {number} end Source end
|
|
5046
|
-
* @returns {string} String read
|
|
5047
|
-
*/
|
|
5048
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
5049
|
-
var len = end - start;
|
|
5050
|
-
if (len < 1)
|
|
5051
|
-
return "";
|
|
5052
|
-
var parts = null,
|
|
5053
|
-
chunk = [],
|
|
5054
|
-
i = 0, // char offset
|
|
5055
|
-
t; // temporary
|
|
5056
|
-
while (start < end) {
|
|
5057
|
-
t = buffer[start++];
|
|
5058
|
-
if (t < 128)
|
|
5059
|
-
chunk[i++] = t;
|
|
5060
|
-
else if (t > 191 && t < 224)
|
|
5061
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5062
|
-
else if (t > 239 && t < 365) {
|
|
5063
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5064
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
5065
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5066
|
-
} else
|
|
5067
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5068
|
-
if (i > 8191) {
|
|
5069
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5070
|
-
i = 0;
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
|
-
if (parts) {
|
|
5074
|
-
if (i)
|
|
5075
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5076
|
-
return parts.join("");
|
|
5077
|
-
}
|
|
5078
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5079
|
-
};
|
|
5080
|
-
|
|
5081
|
-
/**
|
|
5082
|
-
* Writes a string as UTF8 bytes.
|
|
5083
|
-
* @param {string} string Source string
|
|
5084
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
5085
|
-
* @param {number} offset Destination offset
|
|
5086
|
-
* @returns {number} Bytes written
|
|
5087
|
-
*/
|
|
5088
|
-
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5089
|
-
var start = offset,
|
|
5090
|
-
c1, // character 1
|
|
5091
|
-
c2; // character 2
|
|
5092
|
-
for (var i = 0; i < string.length; ++i) {
|
|
5093
|
-
c1 = string.charCodeAt(i);
|
|
5094
|
-
if (c1 < 128) {
|
|
5095
|
-
buffer[offset++] = c1;
|
|
5096
|
-
} else if (c1 < 2048) {
|
|
5097
|
-
buffer[offset++] = c1 >> 6 | 192;
|
|
5098
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5099
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5100
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5101
|
-
++i;
|
|
5102
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
5103
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5104
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5105
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5106
|
-
} else {
|
|
5107
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
5108
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5109
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5110
|
-
}
|
|
5111
|
-
}
|
|
5112
|
-
return offset - start;
|
|
5113
|
-
};
|
|
5114
|
-
} (utf8$2));
|
|
5115
|
-
return utf8$2;
|
|
5116
|
-
}
|
|
5117
|
-
|
|
5118
|
-
var pool_1;
|
|
5119
|
-
var hasRequiredPool;
|
|
5120
|
-
|
|
5121
|
-
function requirePool () {
|
|
5122
|
-
if (hasRequiredPool) return pool_1;
|
|
5123
|
-
hasRequiredPool = 1;
|
|
5124
|
-
pool_1 = pool;
|
|
4983
|
+
/**
|
|
4984
|
+
* A minimal UTF8 implementation for number arrays.
|
|
4985
|
+
* @memberof util
|
|
4986
|
+
* @namespace
|
|
4987
|
+
*/
|
|
4988
|
+
var utf8 = exports;
|
|
5125
4989
|
|
|
5126
4990
|
/**
|
|
5127
|
-
*
|
|
5128
|
-
* @
|
|
5129
|
-
* @
|
|
5130
|
-
* @param {number} size Buffer size
|
|
5131
|
-
* @returns {Uint8Array} Buffer
|
|
4991
|
+
* Calculates the UTF8 byte length of a string.
|
|
4992
|
+
* @param {string} string String
|
|
4993
|
+
* @returns {number} Byte length
|
|
5132
4994
|
*/
|
|
4995
|
+
utf8.length = function utf8_length(string) {
|
|
4996
|
+
var len = 0,
|
|
4997
|
+
c = 0;
|
|
4998
|
+
for (var i = 0; i < string.length; ++i) {
|
|
4999
|
+
c = string.charCodeAt(i);
|
|
5000
|
+
if (c < 128)
|
|
5001
|
+
len += 1;
|
|
5002
|
+
else if (c < 2048)
|
|
5003
|
+
len += 2;
|
|
5004
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5005
|
+
++i;
|
|
5006
|
+
len += 4;
|
|
5007
|
+
} else
|
|
5008
|
+
len += 3;
|
|
5009
|
+
}
|
|
5010
|
+
return len;
|
|
5011
|
+
};
|
|
5133
5012
|
|
|
5134
5013
|
/**
|
|
5135
|
-
*
|
|
5136
|
-
* @
|
|
5137
|
-
* @
|
|
5138
|
-
* @param {number}
|
|
5139
|
-
* @
|
|
5140
|
-
* @returns {Uint8Array} Buffer slice
|
|
5141
|
-
* @this {Uint8Array}
|
|
5014
|
+
* Reads UTF8 bytes as a string.
|
|
5015
|
+
* @param {Uint8Array} buffer Source buffer
|
|
5016
|
+
* @param {number} start Source start
|
|
5017
|
+
* @param {number} end Source end
|
|
5018
|
+
* @returns {string} String read
|
|
5142
5019
|
*/
|
|
5020
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
5021
|
+
var len = end - start;
|
|
5022
|
+
if (len < 1)
|
|
5023
|
+
return "";
|
|
5024
|
+
var parts = null,
|
|
5025
|
+
chunk = [],
|
|
5026
|
+
i = 0, // char offset
|
|
5027
|
+
t; // temporary
|
|
5028
|
+
while (start < end) {
|
|
5029
|
+
t = buffer[start++];
|
|
5030
|
+
if (t < 128)
|
|
5031
|
+
chunk[i++] = t;
|
|
5032
|
+
else if (t > 191 && t < 224)
|
|
5033
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5034
|
+
else if (t > 239 && t < 365) {
|
|
5035
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5036
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
5037
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5038
|
+
} else
|
|
5039
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5040
|
+
if (i > 8191) {
|
|
5041
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5042
|
+
i = 0;
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
if (parts) {
|
|
5046
|
+
if (i)
|
|
5047
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5048
|
+
return parts.join("");
|
|
5049
|
+
}
|
|
5050
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5051
|
+
};
|
|
5143
5052
|
|
|
5144
5053
|
/**
|
|
5145
|
-
*
|
|
5146
|
-
* @
|
|
5147
|
-
* @
|
|
5148
|
-
* @param {
|
|
5149
|
-
* @
|
|
5150
|
-
* @param {number} [size=8192] Slab size
|
|
5151
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
5054
|
+
* Writes a string as UTF8 bytes.
|
|
5055
|
+
* @param {string} string Source string
|
|
5056
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
5057
|
+
* @param {number} offset Destination offset
|
|
5058
|
+
* @returns {number} Bytes written
|
|
5152
5059
|
*/
|
|
5153
|
-
function
|
|
5154
|
-
var
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
var
|
|
5158
|
-
|
|
5159
|
-
if (
|
|
5160
|
-
|
|
5161
|
-
if (
|
|
5162
|
-
|
|
5163
|
-
offset =
|
|
5060
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5061
|
+
var start = offset,
|
|
5062
|
+
c1, // character 1
|
|
5063
|
+
c2; // character 2
|
|
5064
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5065
|
+
c1 = string.charCodeAt(i);
|
|
5066
|
+
if (c1 < 128) {
|
|
5067
|
+
buffer[offset++] = c1;
|
|
5068
|
+
} else if (c1 < 2048) {
|
|
5069
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
5070
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5071
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5072
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5073
|
+
++i;
|
|
5074
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
5075
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5076
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5077
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5078
|
+
} else {
|
|
5079
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
5080
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5081
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5164
5082
|
}
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5083
|
+
}
|
|
5084
|
+
return offset - start;
|
|
5085
|
+
};
|
|
5086
|
+
} (utf8$2));
|
|
5087
|
+
|
|
5088
|
+
var pool_1 = pool;
|
|
5089
|
+
|
|
5090
|
+
/**
|
|
5091
|
+
* An allocator as used by {@link util.pool}.
|
|
5092
|
+
* @typedef PoolAllocator
|
|
5093
|
+
* @type {function}
|
|
5094
|
+
* @param {number} size Buffer size
|
|
5095
|
+
* @returns {Uint8Array} Buffer
|
|
5096
|
+
*/
|
|
5097
|
+
|
|
5098
|
+
/**
|
|
5099
|
+
* A slicer as used by {@link util.pool}.
|
|
5100
|
+
* @typedef PoolSlicer
|
|
5101
|
+
* @type {function}
|
|
5102
|
+
* @param {number} start Start offset
|
|
5103
|
+
* @param {number} end End offset
|
|
5104
|
+
* @returns {Uint8Array} Buffer slice
|
|
5105
|
+
* @this {Uint8Array}
|
|
5106
|
+
*/
|
|
5107
|
+
|
|
5108
|
+
/**
|
|
5109
|
+
* A general purpose buffer pool.
|
|
5110
|
+
* @memberof util
|
|
5111
|
+
* @function
|
|
5112
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5113
|
+
* @param {PoolSlicer} slice Slicer
|
|
5114
|
+
* @param {number} [size=8192] Slab size
|
|
5115
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5116
|
+
*/
|
|
5117
|
+
function pool(alloc, slice, size) {
|
|
5118
|
+
var SIZE = size || 8192;
|
|
5119
|
+
var MAX = SIZE >>> 1;
|
|
5120
|
+
var slab = null;
|
|
5121
|
+
var offset = SIZE;
|
|
5122
|
+
return function pool_alloc(size) {
|
|
5123
|
+
if (size < 1 || size > MAX)
|
|
5124
|
+
return alloc(size);
|
|
5125
|
+
if (offset + size > SIZE) {
|
|
5126
|
+
slab = alloc(SIZE);
|
|
5127
|
+
offset = 0;
|
|
5128
|
+
}
|
|
5129
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5130
|
+
if (offset & 7) // align to 32 bit
|
|
5131
|
+
offset = (offset | 7) + 1;
|
|
5132
|
+
return buf;
|
|
5133
|
+
};
|
|
5172
5134
|
}
|
|
5173
5135
|
|
|
5174
5136
|
var longbits;
|
|
@@ -5388,10 +5350,10 @@ function requireMinimal () {
|
|
|
5388
5350
|
var util = exports;
|
|
5389
5351
|
|
|
5390
5352
|
// used to return a Promise where callback is omitted
|
|
5391
|
-
util.asPromise =
|
|
5353
|
+
util.asPromise = aspromise;
|
|
5392
5354
|
|
|
5393
5355
|
// converts to / from base64 encoded strings
|
|
5394
|
-
util.base64 =
|
|
5356
|
+
util.base64 = base64$1;
|
|
5395
5357
|
|
|
5396
5358
|
// base class of rpc.Service
|
|
5397
5359
|
util.EventEmitter = eventemitter;
|
|
@@ -5400,13 +5362,13 @@ function requireMinimal () {
|
|
|
5400
5362
|
util.float = float;
|
|
5401
5363
|
|
|
5402
5364
|
// requires modules optionally and hides the call from bundlers
|
|
5403
|
-
util.inquire =
|
|
5365
|
+
util.inquire = inquire_1;
|
|
5404
5366
|
|
|
5405
5367
|
// converts to / from utf8 encoded strings
|
|
5406
|
-
util.utf8 =
|
|
5368
|
+
util.utf8 = utf8$2;
|
|
5407
5369
|
|
|
5408
5370
|
// provides a node-like buffer pool in the browser
|
|
5409
|
-
util.pool =
|
|
5371
|
+
util.pool = pool_1;
|
|
5410
5372
|
|
|
5411
5373
|
// utility to work with the low and high bits of a 64 bit value
|
|
5412
5374
|
util.LongBits = requireLongbits();
|
|
@@ -10191,7 +10153,10 @@ class Client extends BaseXChainClient {
|
|
|
10191
10153
|
const txs = [];
|
|
10192
10154
|
for (let i = 0; i < history.length; i += 10) {
|
|
10193
10155
|
const batch = history.slice(i, i + 10);
|
|
10194
|
-
const result = yield Promise.all(batch.map(({ hash }) => this
|
|
10156
|
+
const result = yield Promise.all(batch.map(({ hash }) => __awaiter(this, void 0, void 0, function* () {
|
|
10157
|
+
const data = yield this.getTransactionData(hash, address);
|
|
10158
|
+
return data;
|
|
10159
|
+
})));
|
|
10195
10160
|
txs.push(...result);
|
|
10196
10161
|
delay(2000); // Delay to avoid 503 from ninerealms server
|
|
10197
10162
|
}
|
|
@@ -10424,65 +10389,91 @@ class Client extends BaseXChainClient {
|
|
|
10424
10389
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10425
10390
|
*/
|
|
10426
10391
|
getTransactionData(txId, address) {
|
|
10427
|
-
var _a, _b, _c;
|
|
10392
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10428
10393
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10429
|
-
const
|
|
10430
|
-
if (
|
|
10431
|
-
|
|
10432
|
-
const
|
|
10433
|
-
const
|
|
10434
|
-
if (!
|
|
10435
|
-
throw new Error(
|
|
10436
|
-
|
|
10437
|
-
const
|
|
10438
|
-
const
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
const
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
const
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10394
|
+
const txResult = yield this.fetchTransaction(txId);
|
|
10395
|
+
if (txResult && txResult.logs) {
|
|
10396
|
+
// extract values from the response
|
|
10397
|
+
const transferEvent = (_a = txResult.logs[0].events) === null || _a === void 0 ? void 0 : _a.find((event) => event.type === 'transfer');
|
|
10398
|
+
const messageEvent = (_b = txResult.logs[0].events) === null || _b === void 0 ? void 0 : _b.find((event) => event.type === 'message');
|
|
10399
|
+
if (!transferEvent || !messageEvent) {
|
|
10400
|
+
throw new Error('Invalid transaction data');
|
|
10401
|
+
}
|
|
10402
|
+
const attributeGroups = {};
|
|
10403
|
+
for (const attr of transferEvent.attributes) {
|
|
10404
|
+
if (!attributeGroups[attr.key]) {
|
|
10405
|
+
attributeGroups[attr.key] = [];
|
|
10406
|
+
}
|
|
10407
|
+
attributeGroups[attr.key].push(attr.value);
|
|
10408
|
+
}
|
|
10409
|
+
const assetAmount = attributeGroups['amount'][1]
|
|
10410
|
+
? attributeGroups['amount'][1].split(/(?<=\d)(?=\D)/).filter(Boolean)[0]
|
|
10411
|
+
: attributeGroups['amount'][0].split(/(?<=\d)(?=\D)/).filter(Boolean)[0];
|
|
10412
|
+
const assetString = attributeGroups['amount'][1]
|
|
10413
|
+
? attributeGroups['amount'][1]
|
|
10414
|
+
.split(/(?<=\d)(?=\D)/)
|
|
10415
|
+
.filter(Boolean)[1]
|
|
10416
|
+
.replace(/[a-z]/g, (letter) => letter.toUpperCase())
|
|
10417
|
+
: attributeGroups['amount'][0]
|
|
10418
|
+
.split(/(?<=\d)(?=\D)/)
|
|
10419
|
+
.filter(Boolean)[1]
|
|
10420
|
+
.replace(/[a-z]/g, (letter) => letter.toUpperCase());
|
|
10421
|
+
const fromAddress = ((_c = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _c === void 0 ? void 0 : _c.value)
|
|
10422
|
+
? (_d = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _d === void 0 ? void 0 : _d.value
|
|
10423
|
+
: address;
|
|
10424
|
+
const memo = ((_e = txResult.tx) === null || _e === void 0 ? void 0 : _e.body) ? txResult.tx.body.memo.split(':') : '';
|
|
10425
|
+
const toAddress = memo[2] ? memo[2] : '';
|
|
10426
|
+
const toAsset = memo[1] ? assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10427
|
+
const date = new Date(txResult.timestamp);
|
|
10428
|
+
const typeString = (_f = messageEvent.attributes.find((attr) => attr.key === 'action')) === null || _f === void 0 ? void 0 : _f.value;
|
|
10429
|
+
const hash = txResult.txhash;
|
|
10430
|
+
if (assetString && hash && fromAddress && typeString) {
|
|
10431
|
+
const fromAsset = assetString === 'RUNE' ? AssetRuneNative : assetFromStringEx(assetString);
|
|
10432
|
+
const txData = txResult && txResult.raw_log
|
|
10433
|
+
? getDepositTxDataFromLogs(txResult.logs, `${fromAddress}`, fromAsset, toAsset)
|
|
10455
10434
|
: null;
|
|
10456
|
-
//console.log(JSON.stringify(txData, null, 2))
|
|
10457
10435
|
if (!txData)
|
|
10458
10436
|
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10437
|
+
if (isAssetRuneNative(toAsset) || toAsset.synth) {
|
|
10438
|
+
const { from, to, type } = txData;
|
|
10439
|
+
const tx = {
|
|
10440
|
+
asset: fromAsset,
|
|
10441
|
+
from: from,
|
|
10442
|
+
to: to,
|
|
10443
|
+
date: date,
|
|
10444
|
+
type: type,
|
|
10445
|
+
hash: hash,
|
|
10446
|
+
};
|
|
10447
|
+
return tx;
|
|
10448
|
+
}
|
|
10449
|
+
else {
|
|
10450
|
+
const tx = {
|
|
10451
|
+
asset: fromAsset,
|
|
10452
|
+
from: [{ from: fromAddress, amount: baseAmount(assetAmount), asset: fromAsset }],
|
|
10453
|
+
to: [{ to: toAddress, amount: baseAmount(memo[3]), asset: toAsset }],
|
|
10454
|
+
date: date,
|
|
10455
|
+
type: TxType.Transfer,
|
|
10456
|
+
hash: hash,
|
|
10457
|
+
};
|
|
10458
|
+
return tx;
|
|
10459
|
+
}
|
|
10460
|
+
}
|
|
10461
|
+
else {
|
|
10462
|
+
const tx = {
|
|
10463
|
+
asset: {
|
|
10464
|
+
chain: '',
|
|
10465
|
+
symbol: '',
|
|
10466
|
+
ticker: '',
|
|
10467
|
+
synth: false,
|
|
10468
|
+
},
|
|
10469
|
+
from: [],
|
|
10470
|
+
to: [],
|
|
10471
|
+
date: new Date(),
|
|
10472
|
+
type: TxType.Transfer,
|
|
10473
|
+
hash: '',
|
|
10467
10474
|
};
|
|
10475
|
+
return tx;
|
|
10468
10476
|
}
|
|
10469
|
-
// synths and other tx types
|
|
10470
|
-
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10471
|
-
const assetTo = assetFromStringEx(messageBody[7]);
|
|
10472
|
-
const txData = txResult && txResult.logs
|
|
10473
|
-
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10474
|
-
: null;
|
|
10475
|
-
if (!txData)
|
|
10476
|
-
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10477
|
-
const { from, to, type } = txData;
|
|
10478
|
-
return {
|
|
10479
|
-
hash: txId,
|
|
10480
|
-
asset: senderAsset,
|
|
10481
|
-
from,
|
|
10482
|
-
to,
|
|
10483
|
-
date: new Date(txResult.timestamp),
|
|
10484
|
-
type,
|
|
10485
|
-
};
|
|
10486
10477
|
}
|
|
10487
10478
|
else {
|
|
10488
10479
|
return yield this.getTransactionDataThornode(txId);
|