@xchainjs/xchain-thorchain 0.28.0 → 0.28.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/lib/client.d.ts +13 -2
- package/lib/const.d.ts +18 -1
- package/lib/index.esm.js +451 -353
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +452 -353
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
package/lib/index.esm.js
CHANGED
|
@@ -4255,7 +4255,7 @@ const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
|
|
|
4255
4255
|
const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
|
|
4256
4256
|
const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
|
|
4257
4257
|
const RUNE_TICKER = 'RUNE';
|
|
4258
|
-
const
|
|
4258
|
+
const RUNE_DECIMAL = 8;
|
|
4259
4259
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4260
4260
|
const DEFAULT_GAS_LIMIT_VALUE = '4000000';
|
|
4261
4261
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
@@ -4330,205 +4330,239 @@ const AssetRuneERC20Testnet = {
|
|
|
4330
4330
|
ticker: RUNE_TICKER,
|
|
4331
4331
|
synth: false,
|
|
4332
4332
|
};
|
|
4333
|
+
/**
|
|
4334
|
+
* Fall back node's and rpc's
|
|
4335
|
+
*/
|
|
4336
|
+
const FallBackUrls = [
|
|
4337
|
+
{
|
|
4338
|
+
[Network.Testnet]: {
|
|
4339
|
+
node: ['deprecated'],
|
|
4340
|
+
rpc: ['deprecated'],
|
|
4341
|
+
},
|
|
4342
|
+
[Network.Stagenet]: {
|
|
4343
|
+
node: ['https://stagenet-thornode.ninerealms.com'],
|
|
4344
|
+
rpc: ['https://stagenet-rpc.ninerealms.com'],
|
|
4345
|
+
},
|
|
4346
|
+
[Network.Mainnet]: {
|
|
4347
|
+
node: ['https://thornode-v1.ninerealms.com', 'https://thornode.thorswap.net/'],
|
|
4348
|
+
rpc: ['https://rpc-v1.ninerealms.com', 'https://rpc.thorswap.net'],
|
|
4349
|
+
},
|
|
4350
|
+
},
|
|
4351
|
+
];
|
|
4333
4352
|
|
|
4334
4353
|
var indexMinimal = {};
|
|
4335
4354
|
|
|
4336
4355
|
var minimal$1 = {};
|
|
4337
4356
|
|
|
4338
|
-
var aspromise
|
|
4339
|
-
|
|
4340
|
-
/**
|
|
4341
|
-
* Callback as used by {@link util.asPromise}.
|
|
4342
|
-
* @typedef asPromiseCallback
|
|
4343
|
-
* @type {function}
|
|
4344
|
-
* @param {Error|null} error Error, if any
|
|
4345
|
-
* @param {...*} params Additional arguments
|
|
4346
|
-
* @returns {undefined}
|
|
4347
|
-
*/
|
|
4348
|
-
|
|
4349
|
-
/**
|
|
4350
|
-
* Returns a promise from a node-style callback function.
|
|
4351
|
-
* @memberof util
|
|
4352
|
-
* @param {asPromiseCallback} fn Function to call
|
|
4353
|
-
* @param {*} ctx Function context
|
|
4354
|
-
* @param {...*} params Function arguments
|
|
4355
|
-
* @returns {Promise<*>} Promisified function
|
|
4356
|
-
*/
|
|
4357
|
-
function asPromise(fn, ctx/*, varargs */) {
|
|
4358
|
-
var params = new Array(arguments.length - 1),
|
|
4359
|
-
offset = 0,
|
|
4360
|
-
index = 2,
|
|
4361
|
-
pending = true;
|
|
4362
|
-
while (index < arguments.length)
|
|
4363
|
-
params[offset++] = arguments[index++];
|
|
4364
|
-
return new Promise(function executor(resolve, reject) {
|
|
4365
|
-
params[offset] = function callback(err/*, varargs */) {
|
|
4366
|
-
if (pending) {
|
|
4367
|
-
pending = false;
|
|
4368
|
-
if (err)
|
|
4369
|
-
reject(err);
|
|
4370
|
-
else {
|
|
4371
|
-
var params = new Array(arguments.length - 1),
|
|
4372
|
-
offset = 0;
|
|
4373
|
-
while (offset < params.length)
|
|
4374
|
-
params[offset++] = arguments[offset];
|
|
4375
|
-
resolve.apply(null, params);
|
|
4376
|
-
}
|
|
4377
|
-
}
|
|
4378
|
-
};
|
|
4379
|
-
try {
|
|
4380
|
-
fn.apply(ctx || null, params);
|
|
4381
|
-
} catch (err) {
|
|
4382
|
-
if (pending) {
|
|
4383
|
-
pending = false;
|
|
4384
|
-
reject(err);
|
|
4385
|
-
}
|
|
4386
|
-
}
|
|
4387
|
-
});
|
|
4388
|
-
}
|
|
4357
|
+
var aspromise;
|
|
4358
|
+
var hasRequiredAspromise;
|
|
4389
4359
|
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4360
|
+
function requireAspromise () {
|
|
4361
|
+
if (hasRequiredAspromise) return aspromise;
|
|
4362
|
+
hasRequiredAspromise = 1;
|
|
4363
|
+
aspromise = asPromise;
|
|
4393
4364
|
|
|
4394
4365
|
/**
|
|
4395
|
-
*
|
|
4396
|
-
* @
|
|
4397
|
-
* @
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
/**
|
|
4402
|
-
* Calculates the byte length of a base64 encoded string.
|
|
4403
|
-
* @param {string} string Base64 encoded string
|
|
4404
|
-
* @returns {number} Byte length
|
|
4405
|
-
*/
|
|
4406
|
-
base64.length = function length(string) {
|
|
4407
|
-
var p = string.length;
|
|
4408
|
-
if (!p)
|
|
4409
|
-
return 0;
|
|
4410
|
-
var n = 0;
|
|
4411
|
-
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4412
|
-
++n;
|
|
4413
|
-
return Math.ceil(string.length * 3) / 4 - n;
|
|
4414
|
-
};
|
|
4415
|
-
|
|
4416
|
-
// Base64 encoding table
|
|
4417
|
-
var b64 = new Array(64);
|
|
4418
|
-
|
|
4419
|
-
// Base64 decoding table
|
|
4420
|
-
var s64 = new Array(123);
|
|
4421
|
-
|
|
4422
|
-
// 65..90, 97..122, 48..57, 43, 47
|
|
4423
|
-
for (var i = 0; i < 64;)
|
|
4424
|
-
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
4425
|
-
|
|
4426
|
-
/**
|
|
4427
|
-
* Encodes a buffer to a base64 encoded string.
|
|
4428
|
-
* @param {Uint8Array} buffer Source buffer
|
|
4429
|
-
* @param {number} start Source start
|
|
4430
|
-
* @param {number} end Source end
|
|
4431
|
-
* @returns {string} Base64 encoded string
|
|
4366
|
+
* Callback as used by {@link util.asPromise}.
|
|
4367
|
+
* @typedef asPromiseCallback
|
|
4368
|
+
* @type {function}
|
|
4369
|
+
* @param {Error|null} error Error, if any
|
|
4370
|
+
* @param {...*} params Additional arguments
|
|
4371
|
+
* @returns {undefined}
|
|
4432
4372
|
*/
|
|
4433
|
-
base64.encode = function encode(buffer, start, end) {
|
|
4434
|
-
var parts = null,
|
|
4435
|
-
chunk = [];
|
|
4436
|
-
var i = 0, // output index
|
|
4437
|
-
j = 0, // goto index
|
|
4438
|
-
t; // temporary
|
|
4439
|
-
while (start < end) {
|
|
4440
|
-
var b = buffer[start++];
|
|
4441
|
-
switch (j) {
|
|
4442
|
-
case 0:
|
|
4443
|
-
chunk[i++] = b64[b >> 2];
|
|
4444
|
-
t = (b & 3) << 4;
|
|
4445
|
-
j = 1;
|
|
4446
|
-
break;
|
|
4447
|
-
case 1:
|
|
4448
|
-
chunk[i++] = b64[t | b >> 4];
|
|
4449
|
-
t = (b & 15) << 2;
|
|
4450
|
-
j = 2;
|
|
4451
|
-
break;
|
|
4452
|
-
case 2:
|
|
4453
|
-
chunk[i++] = b64[t | b >> 6];
|
|
4454
|
-
chunk[i++] = b64[b & 63];
|
|
4455
|
-
j = 0;
|
|
4456
|
-
break;
|
|
4457
|
-
}
|
|
4458
|
-
if (i > 8191) {
|
|
4459
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4460
|
-
i = 0;
|
|
4461
|
-
}
|
|
4462
|
-
}
|
|
4463
|
-
if (j) {
|
|
4464
|
-
chunk[i++] = b64[t];
|
|
4465
|
-
chunk[i++] = 61;
|
|
4466
|
-
if (j === 1)
|
|
4467
|
-
chunk[i++] = 61;
|
|
4468
|
-
}
|
|
4469
|
-
if (parts) {
|
|
4470
|
-
if (i)
|
|
4471
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4472
|
-
return parts.join("");
|
|
4473
|
-
}
|
|
4474
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4475
|
-
};
|
|
4476
|
-
|
|
4477
|
-
var invalidEncoding = "invalid encoding";
|
|
4478
4373
|
|
|
4479
4374
|
/**
|
|
4480
|
-
*
|
|
4481
|
-
* @
|
|
4482
|
-
* @param {
|
|
4483
|
-
* @param {
|
|
4484
|
-
* @
|
|
4485
|
-
* @
|
|
4375
|
+
* Returns a promise from a node-style callback function.
|
|
4376
|
+
* @memberof util
|
|
4377
|
+
* @param {asPromiseCallback} fn Function to call
|
|
4378
|
+
* @param {*} ctx Function context
|
|
4379
|
+
* @param {...*} params Function arguments
|
|
4380
|
+
* @returns {Promise<*>} Promisified function
|
|
4486
4381
|
*/
|
|
4487
|
-
|
|
4488
|
-
var
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4382
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
4383
|
+
var params = new Array(arguments.length - 1),
|
|
4384
|
+
offset = 0,
|
|
4385
|
+
index = 2,
|
|
4386
|
+
pending = true;
|
|
4387
|
+
while (index < arguments.length)
|
|
4388
|
+
params[offset++] = arguments[index++];
|
|
4389
|
+
return new Promise(function executor(resolve, reject) {
|
|
4390
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
4391
|
+
if (pending) {
|
|
4392
|
+
pending = false;
|
|
4393
|
+
if (err)
|
|
4394
|
+
reject(err);
|
|
4395
|
+
else {
|
|
4396
|
+
var params = new Array(arguments.length - 1),
|
|
4397
|
+
offset = 0;
|
|
4398
|
+
while (offset < params.length)
|
|
4399
|
+
params[offset++] = arguments[offset];
|
|
4400
|
+
resolve.apply(null, params);
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
};
|
|
4404
|
+
try {
|
|
4405
|
+
fn.apply(ctx || null, params);
|
|
4406
|
+
} catch (err) {
|
|
4407
|
+
if (pending) {
|
|
4408
|
+
pending = false;
|
|
4409
|
+
reject(err);
|
|
4410
|
+
}
|
|
4516
4411
|
}
|
|
4517
|
-
}
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
return aspromise;
|
|
4415
|
+
}
|
|
4416
|
+
|
|
4417
|
+
var base64$1 = {};
|
|
4418
|
+
|
|
4419
|
+
var hasRequiredBase64;
|
|
4420
|
+
|
|
4421
|
+
function requireBase64 () {
|
|
4422
|
+
if (hasRequiredBase64) return base64$1;
|
|
4423
|
+
hasRequiredBase64 = 1;
|
|
4424
|
+
(function (exports) {
|
|
4522
4425
|
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4426
|
+
/**
|
|
4427
|
+
* A minimal base64 implementation for number arrays.
|
|
4428
|
+
* @memberof util
|
|
4429
|
+
* @namespace
|
|
4430
|
+
*/
|
|
4431
|
+
var base64 = exports;
|
|
4432
|
+
|
|
4433
|
+
/**
|
|
4434
|
+
* Calculates the byte length of a base64 encoded string.
|
|
4435
|
+
* @param {string} string Base64 encoded string
|
|
4436
|
+
* @returns {number} Byte length
|
|
4437
|
+
*/
|
|
4438
|
+
base64.length = function length(string) {
|
|
4439
|
+
var p = string.length;
|
|
4440
|
+
if (!p)
|
|
4441
|
+
return 0;
|
|
4442
|
+
var n = 0;
|
|
4443
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4444
|
+
++n;
|
|
4445
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
4446
|
+
};
|
|
4447
|
+
|
|
4448
|
+
// Base64 encoding table
|
|
4449
|
+
var b64 = new Array(64);
|
|
4450
|
+
|
|
4451
|
+
// Base64 decoding table
|
|
4452
|
+
var s64 = new Array(123);
|
|
4453
|
+
|
|
4454
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
4455
|
+
for (var i = 0; i < 64;)
|
|
4456
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
4457
|
+
|
|
4458
|
+
/**
|
|
4459
|
+
* Encodes a buffer to a base64 encoded string.
|
|
4460
|
+
* @param {Uint8Array} buffer Source buffer
|
|
4461
|
+
* @param {number} start Source start
|
|
4462
|
+
* @param {number} end Source end
|
|
4463
|
+
* @returns {string} Base64 encoded string
|
|
4464
|
+
*/
|
|
4465
|
+
base64.encode = function encode(buffer, start, end) {
|
|
4466
|
+
var parts = null,
|
|
4467
|
+
chunk = [];
|
|
4468
|
+
var i = 0, // output index
|
|
4469
|
+
j = 0, // goto index
|
|
4470
|
+
t; // temporary
|
|
4471
|
+
while (start < end) {
|
|
4472
|
+
var b = buffer[start++];
|
|
4473
|
+
switch (j) {
|
|
4474
|
+
case 0:
|
|
4475
|
+
chunk[i++] = b64[b >> 2];
|
|
4476
|
+
t = (b & 3) << 4;
|
|
4477
|
+
j = 1;
|
|
4478
|
+
break;
|
|
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
|
+
}
|
|
4532
4566
|
|
|
4533
4567
|
var eventemitter = EventEmitter;
|
|
4534
4568
|
|
|
@@ -4967,159 +5001,174 @@ function requireInquire () {
|
|
|
4967
5001
|
|
|
4968
5002
|
var utf8$2 = {};
|
|
4969
5003
|
|
|
4970
|
-
|
|
5004
|
+
var hasRequiredUtf8;
|
|
5005
|
+
|
|
5006
|
+
function requireUtf8 () {
|
|
5007
|
+
if (hasRequiredUtf8) return utf8$2;
|
|
5008
|
+
hasRequiredUtf8 = 1;
|
|
5009
|
+
(function (exports) {
|
|
4971
5010
|
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5011
|
+
/**
|
|
5012
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5013
|
+
* @memberof util
|
|
5014
|
+
* @namespace
|
|
5015
|
+
*/
|
|
5016
|
+
var utf8 = exports;
|
|
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;
|
|
4978
5125
|
|
|
4979
5126
|
/**
|
|
4980
|
-
*
|
|
4981
|
-
* @
|
|
4982
|
-
* @
|
|
5127
|
+
* An allocator as used by {@link util.pool}.
|
|
5128
|
+
* @typedef PoolAllocator
|
|
5129
|
+
* @type {function}
|
|
5130
|
+
* @param {number} size Buffer size
|
|
5131
|
+
* @returns {Uint8Array} Buffer
|
|
4983
5132
|
*/
|
|
4984
|
-
utf8.length = function utf8_length(string) {
|
|
4985
|
-
var len = 0,
|
|
4986
|
-
c = 0;
|
|
4987
|
-
for (var i = 0; i < string.length; ++i) {
|
|
4988
|
-
c = string.charCodeAt(i);
|
|
4989
|
-
if (c < 128)
|
|
4990
|
-
len += 1;
|
|
4991
|
-
else if (c < 2048)
|
|
4992
|
-
len += 2;
|
|
4993
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
4994
|
-
++i;
|
|
4995
|
-
len += 4;
|
|
4996
|
-
} else
|
|
4997
|
-
len += 3;
|
|
4998
|
-
}
|
|
4999
|
-
return len;
|
|
5000
|
-
};
|
|
5001
5133
|
|
|
5002
5134
|
/**
|
|
5003
|
-
*
|
|
5004
|
-
* @
|
|
5005
|
-
* @
|
|
5006
|
-
* @param {number}
|
|
5007
|
-
* @
|
|
5135
|
+
* A slicer as used by {@link util.pool}.
|
|
5136
|
+
* @typedef PoolSlicer
|
|
5137
|
+
* @type {function}
|
|
5138
|
+
* @param {number} start Start offset
|
|
5139
|
+
* @param {number} end End offset
|
|
5140
|
+
* @returns {Uint8Array} Buffer slice
|
|
5141
|
+
* @this {Uint8Array}
|
|
5008
5142
|
*/
|
|
5009
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
5010
|
-
var len = end - start;
|
|
5011
|
-
if (len < 1)
|
|
5012
|
-
return "";
|
|
5013
|
-
var parts = null,
|
|
5014
|
-
chunk = [],
|
|
5015
|
-
i = 0, // char offset
|
|
5016
|
-
t; // temporary
|
|
5017
|
-
while (start < end) {
|
|
5018
|
-
t = buffer[start++];
|
|
5019
|
-
if (t < 128)
|
|
5020
|
-
chunk[i++] = t;
|
|
5021
|
-
else if (t > 191 && t < 224)
|
|
5022
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5023
|
-
else if (t > 239 && t < 365) {
|
|
5024
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5025
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
5026
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5027
|
-
} else
|
|
5028
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5029
|
-
if (i > 8191) {
|
|
5030
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5031
|
-
i = 0;
|
|
5032
|
-
}
|
|
5033
|
-
}
|
|
5034
|
-
if (parts) {
|
|
5035
|
-
if (i)
|
|
5036
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5037
|
-
return parts.join("");
|
|
5038
|
-
}
|
|
5039
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5040
|
-
};
|
|
5041
5143
|
|
|
5042
5144
|
/**
|
|
5043
|
-
*
|
|
5044
|
-
* @
|
|
5045
|
-
* @
|
|
5046
|
-
* @param {
|
|
5047
|
-
* @
|
|
5145
|
+
* A general purpose buffer pool.
|
|
5146
|
+
* @memberof util
|
|
5147
|
+
* @function
|
|
5148
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5149
|
+
* @param {PoolSlicer} slice Slicer
|
|
5150
|
+
* @param {number} [size=8192] Slab size
|
|
5151
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5048
5152
|
*/
|
|
5049
|
-
|
|
5050
|
-
var
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
if (
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5061
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5062
|
-
++i;
|
|
5063
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
5064
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5065
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5066
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5067
|
-
} else {
|
|
5068
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
5069
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5070
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5153
|
+
function pool(alloc, slice, size) {
|
|
5154
|
+
var SIZE = size || 8192;
|
|
5155
|
+
var MAX = SIZE >>> 1;
|
|
5156
|
+
var slab = null;
|
|
5157
|
+
var offset = SIZE;
|
|
5158
|
+
return function pool_alloc(size) {
|
|
5159
|
+
if (size < 1 || size > MAX)
|
|
5160
|
+
return alloc(size);
|
|
5161
|
+
if (offset + size > SIZE) {
|
|
5162
|
+
slab = alloc(SIZE);
|
|
5163
|
+
offset = 0;
|
|
5071
5164
|
}
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
/**
|
|
5080
|
-
* An allocator as used by {@link util.pool}.
|
|
5081
|
-
* @typedef PoolAllocator
|
|
5082
|
-
* @type {function}
|
|
5083
|
-
* @param {number} size Buffer size
|
|
5084
|
-
* @returns {Uint8Array} Buffer
|
|
5085
|
-
*/
|
|
5086
|
-
|
|
5087
|
-
/**
|
|
5088
|
-
* A slicer as used by {@link util.pool}.
|
|
5089
|
-
* @typedef PoolSlicer
|
|
5090
|
-
* @type {function}
|
|
5091
|
-
* @param {number} start Start offset
|
|
5092
|
-
* @param {number} end End offset
|
|
5093
|
-
* @returns {Uint8Array} Buffer slice
|
|
5094
|
-
* @this {Uint8Array}
|
|
5095
|
-
*/
|
|
5096
|
-
|
|
5097
|
-
/**
|
|
5098
|
-
* A general purpose buffer pool.
|
|
5099
|
-
* @memberof util
|
|
5100
|
-
* @function
|
|
5101
|
-
* @param {PoolAllocator} alloc Allocator
|
|
5102
|
-
* @param {PoolSlicer} slice Slicer
|
|
5103
|
-
* @param {number} [size=8192] Slab size
|
|
5104
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
5105
|
-
*/
|
|
5106
|
-
function pool(alloc, slice, size) {
|
|
5107
|
-
var SIZE = size || 8192;
|
|
5108
|
-
var MAX = SIZE >>> 1;
|
|
5109
|
-
var slab = null;
|
|
5110
|
-
var offset = SIZE;
|
|
5111
|
-
return function pool_alloc(size) {
|
|
5112
|
-
if (size < 1 || size > MAX)
|
|
5113
|
-
return alloc(size);
|
|
5114
|
-
if (offset + size > SIZE) {
|
|
5115
|
-
slab = alloc(SIZE);
|
|
5116
|
-
offset = 0;
|
|
5117
|
-
}
|
|
5118
|
-
var buf = slice.call(slab, offset, offset += size);
|
|
5119
|
-
if (offset & 7) // align to 32 bit
|
|
5120
|
-
offset = (offset | 7) + 1;
|
|
5121
|
-
return buf;
|
|
5122
|
-
};
|
|
5165
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5166
|
+
if (offset & 7) // align to 32 bit
|
|
5167
|
+
offset = (offset | 7) + 1;
|
|
5168
|
+
return buf;
|
|
5169
|
+
};
|
|
5170
|
+
}
|
|
5171
|
+
return pool_1;
|
|
5123
5172
|
}
|
|
5124
5173
|
|
|
5125
5174
|
var longbits;
|
|
@@ -5339,10 +5388,10 @@ function requireMinimal () {
|
|
|
5339
5388
|
var util = exports;
|
|
5340
5389
|
|
|
5341
5390
|
// used to return a Promise where callback is omitted
|
|
5342
|
-
util.asPromise =
|
|
5391
|
+
util.asPromise = requireAspromise();
|
|
5343
5392
|
|
|
5344
5393
|
// converts to / from base64 encoded strings
|
|
5345
|
-
util.base64 =
|
|
5394
|
+
util.base64 = requireBase64();
|
|
5346
5395
|
|
|
5347
5396
|
// base class of rpc.Service
|
|
5348
5397
|
util.EventEmitter = eventemitter;
|
|
@@ -5354,10 +5403,10 @@ function requireMinimal () {
|
|
|
5354
5403
|
util.inquire = requireInquire();
|
|
5355
5404
|
|
|
5356
5405
|
// converts to / from utf8 encoded strings
|
|
5357
|
-
util.utf8 =
|
|
5406
|
+
util.utf8 = requireUtf8();
|
|
5358
5407
|
|
|
5359
5408
|
// provides a node-like buffer pool in the browser
|
|
5360
|
-
util.pool =
|
|
5409
|
+
util.pool = requirePool();
|
|
5361
5410
|
|
|
5362
5411
|
// utility to work with the low and high bits of a 64 bit value
|
|
5363
5412
|
util.LongBits = requireLongbits();
|
|
@@ -9798,14 +9847,14 @@ const getDepositTxDataFromLogs = (logs, address, senderAsset, receiverAsset) =>
|
|
|
9798
9847
|
if (type === 'transfer') {
|
|
9799
9848
|
return attributes.reduce((acc2, { key, value }, index) => {
|
|
9800
9849
|
if (index % 3 === 0)
|
|
9801
|
-
acc2.push({ sender: '', recipient: '', amount: baseAmount(0,
|
|
9850
|
+
acc2.push({ sender: '', recipient: '', amount: baseAmount(0, RUNE_DECIMAL) });
|
|
9802
9851
|
const newData = acc2[acc2.length - 1];
|
|
9803
9852
|
if (key === 'sender')
|
|
9804
9853
|
newData.sender = value;
|
|
9805
9854
|
if (key === 'recipient')
|
|
9806
9855
|
newData.recipient = value;
|
|
9807
9856
|
if (key === 'amount')
|
|
9808
|
-
newData.amount = baseAmount(value.replace(/rune/, ''),
|
|
9857
|
+
newData.amount = baseAmount(value.replace(/rune/, ''), RUNE_DECIMAL);
|
|
9809
9858
|
return acc2;
|
|
9810
9859
|
}, acc);
|
|
9811
9860
|
}
|
|
@@ -9824,7 +9873,7 @@ const getDepositTxDataFromLogs = (logs, address, senderAsset, receiverAsset) =>
|
|
|
9824
9873
|
* @returns {Fees} The default fee.
|
|
9825
9874
|
*/
|
|
9826
9875
|
const getDefaultFees = () => {
|
|
9827
|
-
const fee = assetToBase(assetAmount(0.02 /* 0.02 RUNE */,
|
|
9876
|
+
const fee = assetToBase(assetAmount(0.02 /* 0.02 RUNE */, RUNE_DECIMAL));
|
|
9828
9877
|
return singleFee(FeeType.FlatFee, fee);
|
|
9829
9878
|
};
|
|
9830
9879
|
/**
|
|
@@ -9978,7 +10027,7 @@ const getBalance = ({ address, assets, cosmosClient, }) => __awaiter(void 0, voi
|
|
|
9978
10027
|
return balances
|
|
9979
10028
|
.map((balance) => ({
|
|
9980
10029
|
asset: (balance.denom && assetFromDenom(balance.denom)) || AssetRuneNative,
|
|
9981
|
-
amount: baseAmount(balance.amount,
|
|
10030
|
+
amount: baseAmount(balance.amount, RUNE_DECIMAL),
|
|
9982
10031
|
}))
|
|
9983
10032
|
.filter((balance) => !assets || assets.filter((asset) => assetToString(balance.asset) === assetToString(asset)).length);
|
|
9984
10033
|
});
|
|
@@ -10323,6 +10372,51 @@ class Client extends BaseXChainClient {
|
|
|
10323
10372
|
return getBalance({ address, assets, cosmosClient: this.getCosmosClient() });
|
|
10324
10373
|
});
|
|
10325
10374
|
}
|
|
10375
|
+
/**
|
|
10376
|
+
*
|
|
10377
|
+
* @returns asset info
|
|
10378
|
+
*/
|
|
10379
|
+
getAssetInfo() {
|
|
10380
|
+
const assetInfo = {
|
|
10381
|
+
asset: AssetRuneNative,
|
|
10382
|
+
decimal: RUNE_DECIMAL,
|
|
10383
|
+
};
|
|
10384
|
+
return assetInfo;
|
|
10385
|
+
}
|
|
10386
|
+
/**
|
|
10387
|
+
*
|
|
10388
|
+
* @param txId - tx hash
|
|
10389
|
+
* @returns txResponse
|
|
10390
|
+
*/
|
|
10391
|
+
fetchTransaction(txId) {
|
|
10392
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10393
|
+
try {
|
|
10394
|
+
const transaction = yield this.cosmosClient.txsHashGet(txId);
|
|
10395
|
+
return transaction;
|
|
10396
|
+
}
|
|
10397
|
+
catch (error) {
|
|
10398
|
+
for (const fallback of FallBackUrls) {
|
|
10399
|
+
for (const network of Object.keys(fallback)) {
|
|
10400
|
+
try {
|
|
10401
|
+
const networkObj = fallback[network];
|
|
10402
|
+
const clientUrl = networkObj.node;
|
|
10403
|
+
const cosmosClient = new CosmosSDKClient({
|
|
10404
|
+
server: Array.isArray(clientUrl) ? clientUrl[0] : clientUrl,
|
|
10405
|
+
chainId: this.getChainId(network),
|
|
10406
|
+
prefix: getPrefix(network),
|
|
10407
|
+
});
|
|
10408
|
+
const tx = yield cosmosClient.txsHashGet(txId);
|
|
10409
|
+
return tx;
|
|
10410
|
+
}
|
|
10411
|
+
catch (error) {
|
|
10412
|
+
// Handle specific error if needed
|
|
10413
|
+
}
|
|
10414
|
+
}
|
|
10415
|
+
}
|
|
10416
|
+
return null;
|
|
10417
|
+
}
|
|
10418
|
+
});
|
|
10419
|
+
}
|
|
10326
10420
|
/**
|
|
10327
10421
|
* Get the transaction details of a given transaction id.
|
|
10328
10422
|
*
|
|
@@ -10332,8 +10426,9 @@ class Client extends BaseXChainClient {
|
|
|
10332
10426
|
getTransactionData(txId, address) {
|
|
10333
10427
|
var _a, _b, _c;
|
|
10334
10428
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10335
|
-
|
|
10336
|
-
|
|
10429
|
+
const response = yield this.fetchTransaction(txId);
|
|
10430
|
+
if (response) {
|
|
10431
|
+
const txResult = response;
|
|
10337
10432
|
const bond = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'bond');
|
|
10338
10433
|
const transfer = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'transfer');
|
|
10339
10434
|
if (!transfer)
|
|
@@ -10353,10 +10448,10 @@ class Client extends BaseXChainClient {
|
|
|
10353
10448
|
if (!bond)
|
|
10354
10449
|
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10355
10450
|
// Rune only transactions
|
|
10356
|
-
if (
|
|
10451
|
+
if (action === 'send' || bond[0].type === 'bond') {
|
|
10357
10452
|
const assetTo = AssetRuneNative;
|
|
10358
10453
|
const txData = txResult && txResult.logs
|
|
10359
|
-
? getDepositTxDataFromLogs(txResult.logs, senderAddress
|
|
10454
|
+
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10360
10455
|
: null;
|
|
10361
10456
|
//console.log(JSON.stringify(txData, null, 2))
|
|
10362
10457
|
if (!txData)
|
|
@@ -10374,7 +10469,9 @@ class Client extends BaseXChainClient {
|
|
|
10374
10469
|
// synths and other tx types
|
|
10375
10470
|
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10376
10471
|
const assetTo = assetFromStringEx(messageBody[7]);
|
|
10377
|
-
const txData = txResult && txResult.logs
|
|
10472
|
+
const txData = txResult && txResult.logs
|
|
10473
|
+
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10474
|
+
: null;
|
|
10378
10475
|
if (!txData)
|
|
10379
10476
|
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10380
10477
|
const { from, to, type } = txData;
|
|
@@ -10387,8 +10484,9 @@ class Client extends BaseXChainClient {
|
|
|
10387
10484
|
type,
|
|
10388
10485
|
};
|
|
10389
10486
|
}
|
|
10390
|
-
|
|
10391
|
-
|
|
10487
|
+
else {
|
|
10488
|
+
return yield this.getTransactionDataThornode(txId);
|
|
10489
|
+
}
|
|
10392
10490
|
});
|
|
10393
10491
|
}
|
|
10394
10492
|
/** This function is used when in bound or outbound tx is not of thorchain
|
|
@@ -10417,7 +10515,7 @@ class Client extends BaseXChainClient {
|
|
|
10417
10515
|
asset = assetFromStringEx(getTx.observed_tx.tx.coins[0].asset);
|
|
10418
10516
|
amount = getTx.observed_tx.tx.coins[0].amount;
|
|
10419
10517
|
const addressTo = getTx.observed_tx.tx.to_address ? getTx.observed_tx.tx.to_address : 'undefined';
|
|
10420
|
-
const to = [{ to: addressTo, amount: baseAmount(amount,
|
|
10518
|
+
const to = [{ to: addressTo, amount: baseAmount(amount, RUNE_DECIMAL), asset: asset }];
|
|
10421
10519
|
const txData = {
|
|
10422
10520
|
hash: txId,
|
|
10423
10521
|
asset: senderAsset,
|
|
@@ -10433,7 +10531,7 @@ class Client extends BaseXChainClient {
|
|
|
10433
10531
|
amount = splitMemo[3];
|
|
10434
10532
|
const receiverAsset = asset;
|
|
10435
10533
|
const recieverAmount = amount;
|
|
10436
|
-
const to = [{ to: address, amount: baseAmount(recieverAmount,
|
|
10534
|
+
const to = [{ to: address, amount: baseAmount(recieverAmount, RUNE_DECIMAL), asset: receiverAsset }];
|
|
10437
10535
|
const txData = {
|
|
10438
10536
|
hash: txId,
|
|
10439
10537
|
asset: senderAsset,
|
|
@@ -10464,11 +10562,11 @@ class Client extends BaseXChainClient {
|
|
|
10464
10562
|
result.observed_tx.tx.coins.forEach((coin) => {
|
|
10465
10563
|
from.push({
|
|
10466
10564
|
from: result.observed_tx.tx.from_address,
|
|
10467
|
-
amount: baseAmount(coin.amount,
|
|
10565
|
+
amount: baseAmount(coin.amount, RUNE_DECIMAL),
|
|
10468
10566
|
});
|
|
10469
10567
|
to.push({
|
|
10470
10568
|
to: result.observed_tx.tx.to_address,
|
|
10471
|
-
amount: baseAmount(coin.amount,
|
|
10569
|
+
amount: baseAmount(coin.amount, RUNE_DECIMAL),
|
|
10472
10570
|
});
|
|
10473
10571
|
asset = assetFromString(coin.asset);
|
|
10474
10572
|
});
|
|
@@ -10494,8 +10592,8 @@ class Client extends BaseXChainClient {
|
|
|
10494
10592
|
var _a, _b, _c, _d;
|
|
10495
10593
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10496
10594
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
10497
|
-
const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0,
|
|
10498
|
-
const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0,
|
|
10595
|
+
const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0, RUNE_DECIMAL);
|
|
10596
|
+
const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0, RUNE_DECIMAL);
|
|
10499
10597
|
const { average: fee } = yield this.getFees();
|
|
10500
10598
|
if (isAssetRuneNative(asset)) {
|
|
10501
10599
|
// amount + fee < runeBalance
|
|
@@ -10557,8 +10655,8 @@ class Client extends BaseXChainClient {
|
|
|
10557
10655
|
var _a, _b, _c, _d;
|
|
10558
10656
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10559
10657
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
10560
|
-
const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0,
|
|
10561
|
-
const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0,
|
|
10658
|
+
const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0, RUNE_DECIMAL);
|
|
10659
|
+
const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0, RUNE_DECIMAL);
|
|
10562
10660
|
const fee = (yield this.getFees()).average;
|
|
10563
10661
|
if (isAssetRuneNative(asset)) {
|
|
10564
10662
|
// amount + fee < runeBalance
|
|
@@ -10614,7 +10712,7 @@ class Client extends BaseXChainClient {
|
|
|
10614
10712
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
10615
10713
|
* @returns {string} The signed transaction bytes.
|
|
10616
10714
|
*/
|
|
10617
|
-
transferOffline({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = baseAmount(0,
|
|
10715
|
+
transferOffline({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = baseAmount(0, RUNE_DECIMAL), fromAccountNumber = Long$1.ZERO, fromSequence = Long$1.ZERO, gasLimit = new BigNumber(DEFAULT_GAS_LIMIT_VALUE), }) {
|
|
10618
10716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10619
10717
|
const fee = (yield this.getFees()).average;
|
|
10620
10718
|
if (isAssetRuneNative(asset)) {
|
|
@@ -10689,5 +10787,5 @@ const msgNativeTxFromJson = (value) => {
|
|
|
10689
10787
|
return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
|
|
10690
10788
|
};
|
|
10691
10789
|
|
|
10692
|
-
export { AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, Client,
|
|
10790
|
+
export { AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, Client, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, FallBackUrls, MAX_PAGES_PER_FUNCTION_CALL, MAX_TX_COUNT_PER_FUNCTION_CALL, MAX_TX_COUNT_PER_PAGE, MsgNativeTx, RUNE_DECIMAL, RUNE_SYMBOL, THORChain, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
|
|
10693
10791
|
//# sourceMappingURL=index.esm.js.map
|