@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.js
CHANGED
|
@@ -4285,7 +4285,7 @@ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
|
|
|
4285
4285
|
const RUNE_TICKER = 'RUNE';
|
|
4286
4286
|
const RUNE_DECIMAL = 8;
|
|
4287
4287
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4288
|
-
const DEFAULT_GAS_LIMIT_VALUE = '
|
|
4288
|
+
const DEFAULT_GAS_LIMIT_VALUE = '6000000';
|
|
4289
4289
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
4290
4290
|
const MAX_TX_COUNT_PER_PAGE = 100;
|
|
4291
4291
|
const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
@@ -4382,215 +4382,200 @@ var indexMinimal = {};
|
|
|
4382
4382
|
|
|
4383
4383
|
var minimal$1 = {};
|
|
4384
4384
|
|
|
4385
|
-
var aspromise;
|
|
4386
|
-
|
|
4385
|
+
var aspromise = asPromise;
|
|
4386
|
+
|
|
4387
|
+
/**
|
|
4388
|
+
* Callback as used by {@link util.asPromise}.
|
|
4389
|
+
* @typedef asPromiseCallback
|
|
4390
|
+
* @type {function}
|
|
4391
|
+
* @param {Error|null} error Error, if any
|
|
4392
|
+
* @param {...*} params Additional arguments
|
|
4393
|
+
* @returns {undefined}
|
|
4394
|
+
*/
|
|
4395
|
+
|
|
4396
|
+
/**
|
|
4397
|
+
* Returns a promise from a node-style callback function.
|
|
4398
|
+
* @memberof util
|
|
4399
|
+
* @param {asPromiseCallback} fn Function to call
|
|
4400
|
+
* @param {*} ctx Function context
|
|
4401
|
+
* @param {...*} params Function arguments
|
|
4402
|
+
* @returns {Promise<*>} Promisified function
|
|
4403
|
+
*/
|
|
4404
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
4405
|
+
var params = new Array(arguments.length - 1),
|
|
4406
|
+
offset = 0,
|
|
4407
|
+
index = 2,
|
|
4408
|
+
pending = true;
|
|
4409
|
+
while (index < arguments.length)
|
|
4410
|
+
params[offset++] = arguments[index++];
|
|
4411
|
+
return new Promise(function executor(resolve, reject) {
|
|
4412
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
4413
|
+
if (pending) {
|
|
4414
|
+
pending = false;
|
|
4415
|
+
if (err)
|
|
4416
|
+
reject(err);
|
|
4417
|
+
else {
|
|
4418
|
+
var params = new Array(arguments.length - 1),
|
|
4419
|
+
offset = 0;
|
|
4420
|
+
while (offset < params.length)
|
|
4421
|
+
params[offset++] = arguments[offset];
|
|
4422
|
+
resolve.apply(null, params);
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
};
|
|
4426
|
+
try {
|
|
4427
|
+
fn.apply(ctx || null, params);
|
|
4428
|
+
} catch (err) {
|
|
4429
|
+
if (pending) {
|
|
4430
|
+
pending = false;
|
|
4431
|
+
reject(err);
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
});
|
|
4435
|
+
}
|
|
4387
4436
|
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
aspromise = asPromise;
|
|
4437
|
+
var base64$1 = {};
|
|
4438
|
+
|
|
4439
|
+
(function (exports) {
|
|
4392
4440
|
|
|
4393
4441
|
/**
|
|
4394
|
-
*
|
|
4395
|
-
* @
|
|
4396
|
-
* @
|
|
4397
|
-
* @param {Error|null} error Error, if any
|
|
4398
|
-
* @param {...*} params Additional arguments
|
|
4399
|
-
* @returns {undefined}
|
|
4442
|
+
* A minimal base64 implementation for number arrays.
|
|
4443
|
+
* @memberof util
|
|
4444
|
+
* @namespace
|
|
4400
4445
|
*/
|
|
4446
|
+
var base64 = exports;
|
|
4401
4447
|
|
|
4402
4448
|
/**
|
|
4403
|
-
*
|
|
4404
|
-
* @
|
|
4405
|
-
* @
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4449
|
+
* Calculates the byte length of a base64 encoded string.
|
|
4450
|
+
* @param {string} string Base64 encoded string
|
|
4451
|
+
* @returns {number} Byte length
|
|
4452
|
+
*/
|
|
4453
|
+
base64.length = function length(string) {
|
|
4454
|
+
var p = string.length;
|
|
4455
|
+
if (!p)
|
|
4456
|
+
return 0;
|
|
4457
|
+
var n = 0;
|
|
4458
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4459
|
+
++n;
|
|
4460
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
4461
|
+
};
|
|
4462
|
+
|
|
4463
|
+
// Base64 encoding table
|
|
4464
|
+
var b64 = new Array(64);
|
|
4465
|
+
|
|
4466
|
+
// Base64 decoding table
|
|
4467
|
+
var s64 = new Array(123);
|
|
4468
|
+
|
|
4469
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
4470
|
+
for (var i = 0; i < 64;)
|
|
4471
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
4472
|
+
|
|
4473
|
+
/**
|
|
4474
|
+
* Encodes a buffer to a base64 encoded string.
|
|
4475
|
+
* @param {Uint8Array} buffer Source buffer
|
|
4476
|
+
* @param {number} start Source start
|
|
4477
|
+
* @param {number} end Source end
|
|
4478
|
+
* @returns {string} Base64 encoded string
|
|
4409
4479
|
*/
|
|
4410
|
-
function
|
|
4411
|
-
var
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
} catch (err) {
|
|
4435
|
-
if (pending) {
|
|
4436
|
-
pending = false;
|
|
4437
|
-
reject(err);
|
|
4438
|
-
}
|
|
4480
|
+
base64.encode = function encode(buffer, start, end) {
|
|
4481
|
+
var parts = null,
|
|
4482
|
+
chunk = [];
|
|
4483
|
+
var i = 0, // output index
|
|
4484
|
+
j = 0, // goto index
|
|
4485
|
+
t; // temporary
|
|
4486
|
+
while (start < end) {
|
|
4487
|
+
var b = buffer[start++];
|
|
4488
|
+
switch (j) {
|
|
4489
|
+
case 0:
|
|
4490
|
+
chunk[i++] = b64[b >> 2];
|
|
4491
|
+
t = (b & 3) << 4;
|
|
4492
|
+
j = 1;
|
|
4493
|
+
break;
|
|
4494
|
+
case 1:
|
|
4495
|
+
chunk[i++] = b64[t | b >> 4];
|
|
4496
|
+
t = (b & 15) << 2;
|
|
4497
|
+
j = 2;
|
|
4498
|
+
break;
|
|
4499
|
+
case 2:
|
|
4500
|
+
chunk[i++] = b64[t | b >> 6];
|
|
4501
|
+
chunk[i++] = b64[b & 63];
|
|
4502
|
+
j = 0;
|
|
4503
|
+
break;
|
|
4439
4504
|
}
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
}
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4505
|
+
if (i > 8191) {
|
|
4506
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4507
|
+
i = 0;
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
if (j) {
|
|
4511
|
+
chunk[i++] = b64[t];
|
|
4512
|
+
chunk[i++] = 61;
|
|
4513
|
+
if (j === 1)
|
|
4514
|
+
chunk[i++] = 61;
|
|
4515
|
+
}
|
|
4516
|
+
if (parts) {
|
|
4517
|
+
if (i)
|
|
4518
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4519
|
+
return parts.join("");
|
|
4520
|
+
}
|
|
4521
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4522
|
+
};
|
|
4523
|
+
|
|
4524
|
+
var invalidEncoding = "invalid encoding";
|
|
4453
4525
|
|
|
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
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
case 1:
|
|
4508
|
-
chunk[i++] = b64[t | b >> 4];
|
|
4509
|
-
t = (b & 15) << 2;
|
|
4510
|
-
j = 2;
|
|
4511
|
-
break;
|
|
4512
|
-
case 2:
|
|
4513
|
-
chunk[i++] = b64[t | b >> 6];
|
|
4514
|
-
chunk[i++] = b64[b & 63];
|
|
4515
|
-
j = 0;
|
|
4516
|
-
break;
|
|
4517
|
-
}
|
|
4518
|
-
if (i > 8191) {
|
|
4519
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4520
|
-
i = 0;
|
|
4521
|
-
}
|
|
4522
|
-
}
|
|
4523
|
-
if (j) {
|
|
4524
|
-
chunk[i++] = b64[t];
|
|
4525
|
-
chunk[i++] = 61;
|
|
4526
|
-
if (j === 1)
|
|
4527
|
-
chunk[i++] = 61;
|
|
4528
|
-
}
|
|
4529
|
-
if (parts) {
|
|
4530
|
-
if (i)
|
|
4531
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4532
|
-
return parts.join("");
|
|
4533
|
-
}
|
|
4534
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4535
|
-
};
|
|
4536
|
-
|
|
4537
|
-
var invalidEncoding = "invalid encoding";
|
|
4538
|
-
|
|
4539
|
-
/**
|
|
4540
|
-
* Decodes a base64 encoded string to a buffer.
|
|
4541
|
-
* @param {string} string Source string
|
|
4542
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
4543
|
-
* @param {number} offset Destination offset
|
|
4544
|
-
* @returns {number} Number of bytes written
|
|
4545
|
-
* @throws {Error} If encoding is invalid
|
|
4546
|
-
*/
|
|
4547
|
-
base64.decode = function decode(string, buffer, offset) {
|
|
4548
|
-
var start = offset;
|
|
4549
|
-
var j = 0, // goto index
|
|
4550
|
-
t; // temporary
|
|
4551
|
-
for (var i = 0; i < string.length;) {
|
|
4552
|
-
var c = string.charCodeAt(i++);
|
|
4553
|
-
if (c === 61 && j > 1)
|
|
4554
|
-
break;
|
|
4555
|
-
if ((c = s64[c]) === undefined)
|
|
4556
|
-
throw Error(invalidEncoding);
|
|
4557
|
-
switch (j) {
|
|
4558
|
-
case 0:
|
|
4559
|
-
t = c;
|
|
4560
|
-
j = 1;
|
|
4561
|
-
break;
|
|
4562
|
-
case 1:
|
|
4563
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4564
|
-
t = c;
|
|
4565
|
-
j = 2;
|
|
4566
|
-
break;
|
|
4567
|
-
case 2:
|
|
4568
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4569
|
-
t = c;
|
|
4570
|
-
j = 3;
|
|
4571
|
-
break;
|
|
4572
|
-
case 3:
|
|
4573
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
4574
|
-
j = 0;
|
|
4575
|
-
break;
|
|
4576
|
-
}
|
|
4577
|
-
}
|
|
4578
|
-
if (j === 1)
|
|
4579
|
-
throw Error(invalidEncoding);
|
|
4580
|
-
return offset - start;
|
|
4581
|
-
};
|
|
4582
|
-
|
|
4583
|
-
/**
|
|
4584
|
-
* Tests if the specified string appears to be base64 encoded.
|
|
4585
|
-
* @param {string} string String to test
|
|
4586
|
-
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
4587
|
-
*/
|
|
4588
|
-
base64.test = function test(string) {
|
|
4589
|
-
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
4590
|
-
};
|
|
4591
|
-
} (base64$1));
|
|
4592
|
-
return base64$1;
|
|
4593
|
-
}
|
|
4526
|
+
/**
|
|
4527
|
+
* Decodes a base64 encoded string to a buffer.
|
|
4528
|
+
* @param {string} string Source string
|
|
4529
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
4530
|
+
* @param {number} offset Destination offset
|
|
4531
|
+
* @returns {number} Number of bytes written
|
|
4532
|
+
* @throws {Error} If encoding is invalid
|
|
4533
|
+
*/
|
|
4534
|
+
base64.decode = function decode(string, buffer, offset) {
|
|
4535
|
+
var start = offset;
|
|
4536
|
+
var j = 0, // goto index
|
|
4537
|
+
t; // temporary
|
|
4538
|
+
for (var i = 0; i < string.length;) {
|
|
4539
|
+
var c = string.charCodeAt(i++);
|
|
4540
|
+
if (c === 61 && j > 1)
|
|
4541
|
+
break;
|
|
4542
|
+
if ((c = s64[c]) === undefined)
|
|
4543
|
+
throw Error(invalidEncoding);
|
|
4544
|
+
switch (j) {
|
|
4545
|
+
case 0:
|
|
4546
|
+
t = c;
|
|
4547
|
+
j = 1;
|
|
4548
|
+
break;
|
|
4549
|
+
case 1:
|
|
4550
|
+
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4551
|
+
t = c;
|
|
4552
|
+
j = 2;
|
|
4553
|
+
break;
|
|
4554
|
+
case 2:
|
|
4555
|
+
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4556
|
+
t = c;
|
|
4557
|
+
j = 3;
|
|
4558
|
+
break;
|
|
4559
|
+
case 3:
|
|
4560
|
+
buffer[offset++] = (t & 3) << 6 | c;
|
|
4561
|
+
j = 0;
|
|
4562
|
+
break;
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
if (j === 1)
|
|
4566
|
+
throw Error(invalidEncoding);
|
|
4567
|
+
return offset - start;
|
|
4568
|
+
};
|
|
4569
|
+
|
|
4570
|
+
/**
|
|
4571
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
4572
|
+
* @param {string} string String to test
|
|
4573
|
+
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
4574
|
+
*/
|
|
4575
|
+
base64.test = function test(string) {
|
|
4576
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
4577
|
+
};
|
|
4578
|
+
} (base64$1));
|
|
4594
4579
|
|
|
4595
4580
|
var eventemitter = EventEmitter;
|
|
4596
4581
|
|
|
@@ -5002,201 +4987,178 @@ function readUintBE(buf, pos) {
|
|
|
5002
4987
|
| buf[pos + 3]) >>> 0;
|
|
5003
4988
|
}
|
|
5004
4989
|
|
|
5005
|
-
var inquire_1;
|
|
5006
|
-
var hasRequiredInquire;
|
|
5007
|
-
|
|
5008
|
-
function requireInquire () {
|
|
5009
|
-
if (hasRequiredInquire) return inquire_1;
|
|
5010
|
-
hasRequiredInquire = 1;
|
|
5011
|
-
inquire_1 = inquire;
|
|
4990
|
+
var inquire_1 = inquire;
|
|
5012
4991
|
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
}
|
|
5027
|
-
return inquire_1;
|
|
4992
|
+
/**
|
|
4993
|
+
* Requires a module only if available.
|
|
4994
|
+
* @memberof util
|
|
4995
|
+
* @param {string} moduleName Module to require
|
|
4996
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
4997
|
+
*/
|
|
4998
|
+
function inquire(moduleName) {
|
|
4999
|
+
try {
|
|
5000
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
5001
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
5002
|
+
return mod;
|
|
5003
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
5004
|
+
return null;
|
|
5028
5005
|
}
|
|
5029
5006
|
|
|
5030
5007
|
var utf8$2 = {};
|
|
5031
5008
|
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
function requireUtf8 () {
|
|
5035
|
-
if (hasRequiredUtf8) return utf8$2;
|
|
5036
|
-
hasRequiredUtf8 = 1;
|
|
5037
|
-
(function (exports) {
|
|
5009
|
+
(function (exports) {
|
|
5038
5010
|
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
/**
|
|
5047
|
-
* Calculates the UTF8 byte length of a string.
|
|
5048
|
-
* @param {string} string String
|
|
5049
|
-
* @returns {number} Byte length
|
|
5050
|
-
*/
|
|
5051
|
-
utf8.length = function utf8_length(string) {
|
|
5052
|
-
var len = 0,
|
|
5053
|
-
c = 0;
|
|
5054
|
-
for (var i = 0; i < string.length; ++i) {
|
|
5055
|
-
c = string.charCodeAt(i);
|
|
5056
|
-
if (c < 128)
|
|
5057
|
-
len += 1;
|
|
5058
|
-
else if (c < 2048)
|
|
5059
|
-
len += 2;
|
|
5060
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5061
|
-
++i;
|
|
5062
|
-
len += 4;
|
|
5063
|
-
} else
|
|
5064
|
-
len += 3;
|
|
5065
|
-
}
|
|
5066
|
-
return len;
|
|
5067
|
-
};
|
|
5068
|
-
|
|
5069
|
-
/**
|
|
5070
|
-
* Reads UTF8 bytes as a string.
|
|
5071
|
-
* @param {Uint8Array} buffer Source buffer
|
|
5072
|
-
* @param {number} start Source start
|
|
5073
|
-
* @param {number} end Source end
|
|
5074
|
-
* @returns {string} String read
|
|
5075
|
-
*/
|
|
5076
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
5077
|
-
var len = end - start;
|
|
5078
|
-
if (len < 1)
|
|
5079
|
-
return "";
|
|
5080
|
-
var parts = null,
|
|
5081
|
-
chunk = [],
|
|
5082
|
-
i = 0, // char offset
|
|
5083
|
-
t; // temporary
|
|
5084
|
-
while (start < end) {
|
|
5085
|
-
t = buffer[start++];
|
|
5086
|
-
if (t < 128)
|
|
5087
|
-
chunk[i++] = t;
|
|
5088
|
-
else if (t > 191 && t < 224)
|
|
5089
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5090
|
-
else if (t > 239 && t < 365) {
|
|
5091
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5092
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
5093
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5094
|
-
} else
|
|
5095
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5096
|
-
if (i > 8191) {
|
|
5097
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5098
|
-
i = 0;
|
|
5099
|
-
}
|
|
5100
|
-
}
|
|
5101
|
-
if (parts) {
|
|
5102
|
-
if (i)
|
|
5103
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5104
|
-
return parts.join("");
|
|
5105
|
-
}
|
|
5106
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5107
|
-
};
|
|
5108
|
-
|
|
5109
|
-
/**
|
|
5110
|
-
* Writes a string as UTF8 bytes.
|
|
5111
|
-
* @param {string} string Source string
|
|
5112
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
5113
|
-
* @param {number} offset Destination offset
|
|
5114
|
-
* @returns {number} Bytes written
|
|
5115
|
-
*/
|
|
5116
|
-
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5117
|
-
var start = offset,
|
|
5118
|
-
c1, // character 1
|
|
5119
|
-
c2; // character 2
|
|
5120
|
-
for (var i = 0; i < string.length; ++i) {
|
|
5121
|
-
c1 = string.charCodeAt(i);
|
|
5122
|
-
if (c1 < 128) {
|
|
5123
|
-
buffer[offset++] = c1;
|
|
5124
|
-
} else if (c1 < 2048) {
|
|
5125
|
-
buffer[offset++] = c1 >> 6 | 192;
|
|
5126
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5127
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5128
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5129
|
-
++i;
|
|
5130
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
5131
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5132
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5133
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5134
|
-
} else {
|
|
5135
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
5136
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5137
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5138
|
-
}
|
|
5139
|
-
}
|
|
5140
|
-
return offset - start;
|
|
5141
|
-
};
|
|
5142
|
-
} (utf8$2));
|
|
5143
|
-
return utf8$2;
|
|
5144
|
-
}
|
|
5145
|
-
|
|
5146
|
-
var pool_1;
|
|
5147
|
-
var hasRequiredPool;
|
|
5148
|
-
|
|
5149
|
-
function requirePool () {
|
|
5150
|
-
if (hasRequiredPool) return pool_1;
|
|
5151
|
-
hasRequiredPool = 1;
|
|
5152
|
-
pool_1 = pool;
|
|
5011
|
+
/**
|
|
5012
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5013
|
+
* @memberof util
|
|
5014
|
+
* @namespace
|
|
5015
|
+
*/
|
|
5016
|
+
var utf8 = exports;
|
|
5153
5017
|
|
|
5154
5018
|
/**
|
|
5155
|
-
*
|
|
5156
|
-
* @
|
|
5157
|
-
* @
|
|
5158
|
-
* @param {number} size Buffer size
|
|
5159
|
-
* @returns {Uint8Array} Buffer
|
|
5019
|
+
* Calculates the UTF8 byte length of a string.
|
|
5020
|
+
* @param {string} string String
|
|
5021
|
+
* @returns {number} Byte length
|
|
5160
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
|
+
};
|
|
5161
5040
|
|
|
5162
5041
|
/**
|
|
5163
|
-
*
|
|
5164
|
-
* @
|
|
5165
|
-
* @
|
|
5166
|
-
* @param {number}
|
|
5167
|
-
* @
|
|
5168
|
-
* @returns {Uint8Array} Buffer slice
|
|
5169
|
-
* @this {Uint8Array}
|
|
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
|
|
5170
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
|
+
};
|
|
5171
5080
|
|
|
5172
5081
|
/**
|
|
5173
|
-
*
|
|
5174
|
-
* @
|
|
5175
|
-
* @
|
|
5176
|
-
* @param {
|
|
5177
|
-
* @
|
|
5178
|
-
* @param {number} [size=8192] Slab size
|
|
5179
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
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
|
|
5180
5087
|
*/
|
|
5181
|
-
function
|
|
5182
|
-
var
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
var
|
|
5186
|
-
|
|
5187
|
-
if (
|
|
5188
|
-
|
|
5189
|
-
if (
|
|
5190
|
-
|
|
5191
|
-
offset =
|
|
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;
|
|
5192
5110
|
}
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5111
|
+
}
|
|
5112
|
+
return offset - start;
|
|
5113
|
+
};
|
|
5114
|
+
} (utf8$2));
|
|
5115
|
+
|
|
5116
|
+
var pool_1 = pool;
|
|
5117
|
+
|
|
5118
|
+
/**
|
|
5119
|
+
* An allocator as used by {@link util.pool}.
|
|
5120
|
+
* @typedef PoolAllocator
|
|
5121
|
+
* @type {function}
|
|
5122
|
+
* @param {number} size Buffer size
|
|
5123
|
+
* @returns {Uint8Array} Buffer
|
|
5124
|
+
*/
|
|
5125
|
+
|
|
5126
|
+
/**
|
|
5127
|
+
* A slicer as used by {@link util.pool}.
|
|
5128
|
+
* @typedef PoolSlicer
|
|
5129
|
+
* @type {function}
|
|
5130
|
+
* @param {number} start Start offset
|
|
5131
|
+
* @param {number} end End offset
|
|
5132
|
+
* @returns {Uint8Array} Buffer slice
|
|
5133
|
+
* @this {Uint8Array}
|
|
5134
|
+
*/
|
|
5135
|
+
|
|
5136
|
+
/**
|
|
5137
|
+
* A general purpose buffer pool.
|
|
5138
|
+
* @memberof util
|
|
5139
|
+
* @function
|
|
5140
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5141
|
+
* @param {PoolSlicer} slice Slicer
|
|
5142
|
+
* @param {number} [size=8192] Slab size
|
|
5143
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5144
|
+
*/
|
|
5145
|
+
function pool(alloc, slice, size) {
|
|
5146
|
+
var SIZE = size || 8192;
|
|
5147
|
+
var MAX = SIZE >>> 1;
|
|
5148
|
+
var slab = null;
|
|
5149
|
+
var offset = SIZE;
|
|
5150
|
+
return function pool_alloc(size) {
|
|
5151
|
+
if (size < 1 || size > MAX)
|
|
5152
|
+
return alloc(size);
|
|
5153
|
+
if (offset + size > SIZE) {
|
|
5154
|
+
slab = alloc(SIZE);
|
|
5155
|
+
offset = 0;
|
|
5156
|
+
}
|
|
5157
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5158
|
+
if (offset & 7) // align to 32 bit
|
|
5159
|
+
offset = (offset | 7) + 1;
|
|
5160
|
+
return buf;
|
|
5161
|
+
};
|
|
5200
5162
|
}
|
|
5201
5163
|
|
|
5202
5164
|
var longbits;
|
|
@@ -5416,10 +5378,10 @@ function requireMinimal () {
|
|
|
5416
5378
|
var util = exports;
|
|
5417
5379
|
|
|
5418
5380
|
// used to return a Promise where callback is omitted
|
|
5419
|
-
util.asPromise =
|
|
5381
|
+
util.asPromise = aspromise;
|
|
5420
5382
|
|
|
5421
5383
|
// converts to / from base64 encoded strings
|
|
5422
|
-
util.base64 =
|
|
5384
|
+
util.base64 = base64$1;
|
|
5423
5385
|
|
|
5424
5386
|
// base class of rpc.Service
|
|
5425
5387
|
util.EventEmitter = eventemitter;
|
|
@@ -5428,13 +5390,13 @@ function requireMinimal () {
|
|
|
5428
5390
|
util.float = float;
|
|
5429
5391
|
|
|
5430
5392
|
// requires modules optionally and hides the call from bundlers
|
|
5431
|
-
util.inquire =
|
|
5393
|
+
util.inquire = inquire_1;
|
|
5432
5394
|
|
|
5433
5395
|
// converts to / from utf8 encoded strings
|
|
5434
|
-
util.utf8 =
|
|
5396
|
+
util.utf8 = utf8$2;
|
|
5435
5397
|
|
|
5436
5398
|
// provides a node-like buffer pool in the browser
|
|
5437
|
-
util.pool =
|
|
5399
|
+
util.pool = pool_1;
|
|
5438
5400
|
|
|
5439
5401
|
// utility to work with the low and high bits of a 64 bit value
|
|
5440
5402
|
util.LongBits = requireLongbits();
|
|
@@ -10219,7 +10181,10 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10219
10181
|
const txs = [];
|
|
10220
10182
|
for (let i = 0; i < history.length; i += 10) {
|
|
10221
10183
|
const batch = history.slice(i, i + 10);
|
|
10222
|
-
const result = yield Promise.all(batch.map(({ hash }) => this
|
|
10184
|
+
const result = yield Promise.all(batch.map(({ hash }) => __awaiter(this, void 0, void 0, function* () {
|
|
10185
|
+
const data = yield this.getTransactionData(hash, address);
|
|
10186
|
+
return data;
|
|
10187
|
+
})));
|
|
10223
10188
|
txs.push(...result);
|
|
10224
10189
|
xchainUtil.delay(2000); // Delay to avoid 503 from ninerealms server
|
|
10225
10190
|
}
|
|
@@ -10452,65 +10417,91 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10452
10417
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10453
10418
|
*/
|
|
10454
10419
|
getTransactionData(txId, address) {
|
|
10455
|
-
var _a, _b, _c;
|
|
10420
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10456
10421
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10457
|
-
const
|
|
10458
|
-
if (
|
|
10459
|
-
|
|
10460
|
-
const
|
|
10461
|
-
const
|
|
10462
|
-
if (!
|
|
10463
|
-
throw new Error(
|
|
10464
|
-
|
|
10465
|
-
const
|
|
10466
|
-
const
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
const
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
const
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10422
|
+
const txResult = yield this.fetchTransaction(txId);
|
|
10423
|
+
if (txResult && txResult.logs) {
|
|
10424
|
+
// extract values from the response
|
|
10425
|
+
const transferEvent = (_a = txResult.logs[0].events) === null || _a === void 0 ? void 0 : _a.find((event) => event.type === 'transfer');
|
|
10426
|
+
const messageEvent = (_b = txResult.logs[0].events) === null || _b === void 0 ? void 0 : _b.find((event) => event.type === 'message');
|
|
10427
|
+
if (!transferEvent || !messageEvent) {
|
|
10428
|
+
throw new Error('Invalid transaction data');
|
|
10429
|
+
}
|
|
10430
|
+
const attributeGroups = {};
|
|
10431
|
+
for (const attr of transferEvent.attributes) {
|
|
10432
|
+
if (!attributeGroups[attr.key]) {
|
|
10433
|
+
attributeGroups[attr.key] = [];
|
|
10434
|
+
}
|
|
10435
|
+
attributeGroups[attr.key].push(attr.value);
|
|
10436
|
+
}
|
|
10437
|
+
const assetAmount = attributeGroups['amount'][1]
|
|
10438
|
+
? attributeGroups['amount'][1].split(/(?<=\d)(?=\D)/).filter(Boolean)[0]
|
|
10439
|
+
: attributeGroups['amount'][0].split(/(?<=\d)(?=\D)/).filter(Boolean)[0];
|
|
10440
|
+
const assetString = attributeGroups['amount'][1]
|
|
10441
|
+
? attributeGroups['amount'][1]
|
|
10442
|
+
.split(/(?<=\d)(?=\D)/)
|
|
10443
|
+
.filter(Boolean)[1]
|
|
10444
|
+
.replace(/[a-z]/g, (letter) => letter.toUpperCase())
|
|
10445
|
+
: attributeGroups['amount'][0]
|
|
10446
|
+
.split(/(?<=\d)(?=\D)/)
|
|
10447
|
+
.filter(Boolean)[1]
|
|
10448
|
+
.replace(/[a-z]/g, (letter) => letter.toUpperCase());
|
|
10449
|
+
const fromAddress = ((_c = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _c === void 0 ? void 0 : _c.value)
|
|
10450
|
+
? (_d = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _d === void 0 ? void 0 : _d.value
|
|
10451
|
+
: address;
|
|
10452
|
+
const memo = ((_e = txResult.tx) === null || _e === void 0 ? void 0 : _e.body) ? txResult.tx.body.memo.split(':') : '';
|
|
10453
|
+
const toAddress = memo[2] ? memo[2] : '';
|
|
10454
|
+
const toAsset = memo[1] ? xchainUtil.assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10455
|
+
const date = new Date(txResult.timestamp);
|
|
10456
|
+
const typeString = (_f = messageEvent.attributes.find((attr) => attr.key === 'action')) === null || _f === void 0 ? void 0 : _f.value;
|
|
10457
|
+
const hash = txResult.txhash;
|
|
10458
|
+
if (assetString && hash && fromAddress && typeString) {
|
|
10459
|
+
const fromAsset = assetString === 'RUNE' ? AssetRuneNative : xchainUtil.assetFromStringEx(assetString);
|
|
10460
|
+
const txData = txResult && txResult.raw_log
|
|
10461
|
+
? getDepositTxDataFromLogs(txResult.logs, `${fromAddress}`, fromAsset, toAsset)
|
|
10483
10462
|
: null;
|
|
10484
|
-
//console.log(JSON.stringify(txData, null, 2))
|
|
10485
10463
|
if (!txData)
|
|
10486
10464
|
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10465
|
+
if (isAssetRuneNative(toAsset) || toAsset.synth) {
|
|
10466
|
+
const { from, to, type } = txData;
|
|
10467
|
+
const tx = {
|
|
10468
|
+
asset: fromAsset,
|
|
10469
|
+
from: from,
|
|
10470
|
+
to: to,
|
|
10471
|
+
date: date,
|
|
10472
|
+
type: type,
|
|
10473
|
+
hash: hash,
|
|
10474
|
+
};
|
|
10475
|
+
return tx;
|
|
10476
|
+
}
|
|
10477
|
+
else {
|
|
10478
|
+
const tx = {
|
|
10479
|
+
asset: fromAsset,
|
|
10480
|
+
from: [{ from: fromAddress, amount: xchainUtil.baseAmount(assetAmount), asset: fromAsset }],
|
|
10481
|
+
to: [{ to: toAddress, amount: xchainUtil.baseAmount(memo[3]), asset: toAsset }],
|
|
10482
|
+
date: date,
|
|
10483
|
+
type: xchainClient.TxType.Transfer,
|
|
10484
|
+
hash: hash,
|
|
10485
|
+
};
|
|
10486
|
+
return tx;
|
|
10487
|
+
}
|
|
10488
|
+
}
|
|
10489
|
+
else {
|
|
10490
|
+
const tx = {
|
|
10491
|
+
asset: {
|
|
10492
|
+
chain: '',
|
|
10493
|
+
symbol: '',
|
|
10494
|
+
ticker: '',
|
|
10495
|
+
synth: false,
|
|
10496
|
+
},
|
|
10497
|
+
from: [],
|
|
10498
|
+
to: [],
|
|
10499
|
+
date: new Date(),
|
|
10500
|
+
type: xchainClient.TxType.Transfer,
|
|
10501
|
+
hash: '',
|
|
10495
10502
|
};
|
|
10503
|
+
return tx;
|
|
10496
10504
|
}
|
|
10497
|
-
// synths and other tx types
|
|
10498
|
-
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10499
|
-
const assetTo = xchainUtil.assetFromStringEx(messageBody[7]);
|
|
10500
|
-
const txData = txResult && txResult.logs
|
|
10501
|
-
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10502
|
-
: null;
|
|
10503
|
-
if (!txData)
|
|
10504
|
-
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10505
|
-
const { from, to, type } = txData;
|
|
10506
|
-
return {
|
|
10507
|
-
hash: txId,
|
|
10508
|
-
asset: senderAsset,
|
|
10509
|
-
from,
|
|
10510
|
-
to,
|
|
10511
|
-
date: new Date(txResult.timestamp),
|
|
10512
|
-
type,
|
|
10513
|
-
};
|
|
10514
10505
|
}
|
|
10515
10506
|
else {
|
|
10516
10507
|
return yield this.getTransactionDataThornode(txId);
|