@xchainjs/xchain-thorchain 0.28.7 → 0.28.9
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 -1
- package/lib/index.esm.js +353 -294
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +353 -294
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
package/lib/index.esm.js
CHANGED
|
@@ -4344,8 +4344,8 @@ const FallBackUrls = [
|
|
|
4344
4344
|
rpc: ['https://stagenet-rpc.ninerealms.com'],
|
|
4345
4345
|
},
|
|
4346
4346
|
[Network.Mainnet]: {
|
|
4347
|
-
node: ['https://thornode-v1.ninerealms.com'
|
|
4348
|
-
rpc: ['https://rpc-v1.ninerealms.com'
|
|
4347
|
+
node: ['https://thornode-v1.ninerealms.com'],
|
|
4348
|
+
rpc: ['https://rpc-v1.ninerealms.com'],
|
|
4349
4349
|
},
|
|
4350
4350
|
},
|
|
4351
4351
|
];
|
|
@@ -4354,56 +4354,64 @@ var indexMinimal = {};
|
|
|
4354
4354
|
|
|
4355
4355
|
var minimal$1 = {};
|
|
4356
4356
|
|
|
4357
|
-
var aspromise
|
|
4357
|
+
var aspromise;
|
|
4358
|
+
var hasRequiredAspromise;
|
|
4359
|
+
|
|
4360
|
+
function requireAspromise () {
|
|
4361
|
+
if (hasRequiredAspromise) return aspromise;
|
|
4362
|
+
hasRequiredAspromise = 1;
|
|
4363
|
+
aspromise = asPromise;
|
|
4358
4364
|
|
|
4359
|
-
/**
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4365
|
+
/**
|
|
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}
|
|
4372
|
+
*/
|
|
4367
4373
|
|
|
4368
|
-
/**
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
function asPromise(fn, ctx/*, varargs */) {
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4374
|
+
/**
|
|
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
|
|
4381
|
+
*/
|
|
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
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
return aspromise;
|
|
4407
4415
|
}
|
|
4408
4416
|
|
|
4409
4417
|
var base64$1 = {};
|
|
@@ -4549,81 +4557,89 @@ var base64$1 = {};
|
|
|
4549
4557
|
};
|
|
4550
4558
|
} (base64$1));
|
|
4551
4559
|
|
|
4552
|
-
var eventemitter
|
|
4560
|
+
var eventemitter;
|
|
4561
|
+
var hasRequiredEventemitter;
|
|
4562
|
+
|
|
4563
|
+
function requireEventemitter () {
|
|
4564
|
+
if (hasRequiredEventemitter) return eventemitter;
|
|
4565
|
+
hasRequiredEventemitter = 1;
|
|
4566
|
+
eventemitter = EventEmitter;
|
|
4553
4567
|
|
|
4554
|
-
/**
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
function EventEmitter() {
|
|
4568
|
+
/**
|
|
4569
|
+
* Constructs a new event emitter instance.
|
|
4570
|
+
* @classdesc A minimal event emitter.
|
|
4571
|
+
* @memberof util
|
|
4572
|
+
* @constructor
|
|
4573
|
+
*/
|
|
4574
|
+
function EventEmitter() {
|
|
4561
4575
|
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
}
|
|
4576
|
+
/**
|
|
4577
|
+
* Registered listeners.
|
|
4578
|
+
* @type {Object.<string,*>}
|
|
4579
|
+
* @private
|
|
4580
|
+
*/
|
|
4581
|
+
this._listeners = {};
|
|
4582
|
+
}
|
|
4569
4583
|
|
|
4570
|
-
/**
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
};
|
|
4584
|
+
/**
|
|
4585
|
+
* Registers an event listener.
|
|
4586
|
+
* @param {string} evt Event name
|
|
4587
|
+
* @param {function} fn Listener
|
|
4588
|
+
* @param {*} [ctx] Listener context
|
|
4589
|
+
* @returns {util.EventEmitter} `this`
|
|
4590
|
+
*/
|
|
4591
|
+
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4592
|
+
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
4593
|
+
fn : fn,
|
|
4594
|
+
ctx : ctx || this
|
|
4595
|
+
});
|
|
4596
|
+
return this;
|
|
4597
|
+
};
|
|
4584
4598
|
|
|
4585
|
-
/**
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
};
|
|
4599
|
+
/**
|
|
4600
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
4601
|
+
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
4602
|
+
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
4603
|
+
* @returns {util.EventEmitter} `this`
|
|
4604
|
+
*/
|
|
4605
|
+
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4606
|
+
if (evt === undefined)
|
|
4607
|
+
this._listeners = {};
|
|
4608
|
+
else {
|
|
4609
|
+
if (fn === undefined)
|
|
4610
|
+
this._listeners[evt] = [];
|
|
4611
|
+
else {
|
|
4612
|
+
var listeners = this._listeners[evt];
|
|
4613
|
+
for (var i = 0; i < listeners.length;)
|
|
4614
|
+
if (listeners[i].fn === fn)
|
|
4615
|
+
listeners.splice(i, 1);
|
|
4616
|
+
else
|
|
4617
|
+
++i;
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
return this;
|
|
4621
|
+
};
|
|
4608
4622
|
|
|
4609
|
-
/**
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
EventEmitter.prototype.emit = function emit(evt) {
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
};
|
|
4623
|
+
/**
|
|
4624
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
4625
|
+
* @param {string} evt Event name
|
|
4626
|
+
* @param {...*} args Arguments
|
|
4627
|
+
* @returns {util.EventEmitter} `this`
|
|
4628
|
+
*/
|
|
4629
|
+
EventEmitter.prototype.emit = function emit(evt) {
|
|
4630
|
+
var listeners = this._listeners[evt];
|
|
4631
|
+
if (listeners) {
|
|
4632
|
+
var args = [],
|
|
4633
|
+
i = 1;
|
|
4634
|
+
for (; i < arguments.length;)
|
|
4635
|
+
args.push(arguments[i++]);
|
|
4636
|
+
for (i = 0; i < listeners.length;)
|
|
4637
|
+
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
4638
|
+
}
|
|
4639
|
+
return this;
|
|
4640
|
+
};
|
|
4641
|
+
return eventemitter;
|
|
4642
|
+
}
|
|
4627
4643
|
|
|
4628
4644
|
var float = factory(factory);
|
|
4629
4645
|
|
|
@@ -4978,159 +4994,174 @@ function inquire(moduleName) {
|
|
|
4978
4994
|
|
|
4979
4995
|
var utf8$2 = {};
|
|
4980
4996
|
|
|
4981
|
-
|
|
4997
|
+
var hasRequiredUtf8;
|
|
4998
|
+
|
|
4999
|
+
function requireUtf8 () {
|
|
5000
|
+
if (hasRequiredUtf8) return utf8$2;
|
|
5001
|
+
hasRequiredUtf8 = 1;
|
|
5002
|
+
(function (exports) {
|
|
4982
5003
|
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
5004
|
+
/**
|
|
5005
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5006
|
+
* @memberof util
|
|
5007
|
+
* @namespace
|
|
5008
|
+
*/
|
|
5009
|
+
var utf8 = exports;
|
|
5010
|
+
|
|
5011
|
+
/**
|
|
5012
|
+
* Calculates the UTF8 byte length of a string.
|
|
5013
|
+
* @param {string} string String
|
|
5014
|
+
* @returns {number} Byte length
|
|
5015
|
+
*/
|
|
5016
|
+
utf8.length = function utf8_length(string) {
|
|
5017
|
+
var len = 0,
|
|
5018
|
+
c = 0;
|
|
5019
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5020
|
+
c = string.charCodeAt(i);
|
|
5021
|
+
if (c < 128)
|
|
5022
|
+
len += 1;
|
|
5023
|
+
else if (c < 2048)
|
|
5024
|
+
len += 2;
|
|
5025
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5026
|
+
++i;
|
|
5027
|
+
len += 4;
|
|
5028
|
+
} else
|
|
5029
|
+
len += 3;
|
|
5030
|
+
}
|
|
5031
|
+
return len;
|
|
5032
|
+
};
|
|
5033
|
+
|
|
5034
|
+
/**
|
|
5035
|
+
* Reads UTF8 bytes as a string.
|
|
5036
|
+
* @param {Uint8Array} buffer Source buffer
|
|
5037
|
+
* @param {number} start Source start
|
|
5038
|
+
* @param {number} end Source end
|
|
5039
|
+
* @returns {string} String read
|
|
5040
|
+
*/
|
|
5041
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
5042
|
+
var len = end - start;
|
|
5043
|
+
if (len < 1)
|
|
5044
|
+
return "";
|
|
5045
|
+
var parts = null,
|
|
5046
|
+
chunk = [],
|
|
5047
|
+
i = 0, // char offset
|
|
5048
|
+
t; // temporary
|
|
5049
|
+
while (start < end) {
|
|
5050
|
+
t = buffer[start++];
|
|
5051
|
+
if (t < 128)
|
|
5052
|
+
chunk[i++] = t;
|
|
5053
|
+
else if (t > 191 && t < 224)
|
|
5054
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5055
|
+
else if (t > 239 && t < 365) {
|
|
5056
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5057
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
5058
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5059
|
+
} else
|
|
5060
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5061
|
+
if (i > 8191) {
|
|
5062
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5063
|
+
i = 0;
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
if (parts) {
|
|
5067
|
+
if (i)
|
|
5068
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5069
|
+
return parts.join("");
|
|
5070
|
+
}
|
|
5071
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5072
|
+
};
|
|
5073
|
+
|
|
5074
|
+
/**
|
|
5075
|
+
* Writes a string as UTF8 bytes.
|
|
5076
|
+
* @param {string} string Source string
|
|
5077
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
5078
|
+
* @param {number} offset Destination offset
|
|
5079
|
+
* @returns {number} Bytes written
|
|
5080
|
+
*/
|
|
5081
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5082
|
+
var start = offset,
|
|
5083
|
+
c1, // character 1
|
|
5084
|
+
c2; // character 2
|
|
5085
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5086
|
+
c1 = string.charCodeAt(i);
|
|
5087
|
+
if (c1 < 128) {
|
|
5088
|
+
buffer[offset++] = c1;
|
|
5089
|
+
} else if (c1 < 2048) {
|
|
5090
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
5091
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5092
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5093
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5094
|
+
++i;
|
|
5095
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
5096
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5097
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5098
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5099
|
+
} else {
|
|
5100
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
5101
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5102
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
return offset - start;
|
|
5106
|
+
};
|
|
5107
|
+
} (utf8$2));
|
|
5108
|
+
return utf8$2;
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
var pool_1;
|
|
5112
|
+
var hasRequiredPool;
|
|
5113
|
+
|
|
5114
|
+
function requirePool () {
|
|
5115
|
+
if (hasRequiredPool) return pool_1;
|
|
5116
|
+
hasRequiredPool = 1;
|
|
5117
|
+
pool_1 = pool;
|
|
4989
5118
|
|
|
4990
5119
|
/**
|
|
4991
|
-
*
|
|
4992
|
-
* @
|
|
4993
|
-
* @
|
|
5120
|
+
* An allocator as used by {@link util.pool}.
|
|
5121
|
+
* @typedef PoolAllocator
|
|
5122
|
+
* @type {function}
|
|
5123
|
+
* @param {number} size Buffer size
|
|
5124
|
+
* @returns {Uint8Array} Buffer
|
|
4994
5125
|
*/
|
|
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
|
-
};
|
|
5012
5126
|
|
|
5013
5127
|
/**
|
|
5014
|
-
*
|
|
5015
|
-
* @
|
|
5016
|
-
* @
|
|
5017
|
-
* @param {number}
|
|
5018
|
-
* @
|
|
5128
|
+
* A slicer as used by {@link util.pool}.
|
|
5129
|
+
* @typedef PoolSlicer
|
|
5130
|
+
* @type {function}
|
|
5131
|
+
* @param {number} start Start offset
|
|
5132
|
+
* @param {number} end End offset
|
|
5133
|
+
* @returns {Uint8Array} Buffer slice
|
|
5134
|
+
* @this {Uint8Array}
|
|
5019
5135
|
*/
|
|
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
|
-
};
|
|
5052
5136
|
|
|
5053
5137
|
/**
|
|
5054
|
-
*
|
|
5055
|
-
* @
|
|
5056
|
-
* @
|
|
5057
|
-
* @param {
|
|
5058
|
-
* @
|
|
5138
|
+
* A general purpose buffer pool.
|
|
5139
|
+
* @memberof util
|
|
5140
|
+
* @function
|
|
5141
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5142
|
+
* @param {PoolSlicer} slice Slicer
|
|
5143
|
+
* @param {number} [size=8192] Slab size
|
|
5144
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5059
5145
|
*/
|
|
5060
|
-
|
|
5061
|
-
var
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
if (
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
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;
|
|
5146
|
+
function pool(alloc, slice, size) {
|
|
5147
|
+
var SIZE = size || 8192;
|
|
5148
|
+
var MAX = SIZE >>> 1;
|
|
5149
|
+
var slab = null;
|
|
5150
|
+
var offset = SIZE;
|
|
5151
|
+
return function pool_alloc(size) {
|
|
5152
|
+
if (size < 1 || size > MAX)
|
|
5153
|
+
return alloc(size);
|
|
5154
|
+
if (offset + size > SIZE) {
|
|
5155
|
+
slab = alloc(SIZE);
|
|
5156
|
+
offset = 0;
|
|
5082
5157
|
}
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
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
|
-
};
|
|
5158
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5159
|
+
if (offset & 7) // align to 32 bit
|
|
5160
|
+
offset = (offset | 7) + 1;
|
|
5161
|
+
return buf;
|
|
5162
|
+
};
|
|
5163
|
+
}
|
|
5164
|
+
return pool_1;
|
|
5134
5165
|
}
|
|
5135
5166
|
|
|
5136
5167
|
var longbits;
|
|
@@ -5350,13 +5381,13 @@ function requireMinimal () {
|
|
|
5350
5381
|
var util = exports;
|
|
5351
5382
|
|
|
5352
5383
|
// used to return a Promise where callback is omitted
|
|
5353
|
-
util.asPromise =
|
|
5384
|
+
util.asPromise = requireAspromise();
|
|
5354
5385
|
|
|
5355
5386
|
// converts to / from base64 encoded strings
|
|
5356
5387
|
util.base64 = base64$1;
|
|
5357
5388
|
|
|
5358
5389
|
// base class of rpc.Service
|
|
5359
|
-
util.EventEmitter =
|
|
5390
|
+
util.EventEmitter = requireEventemitter();
|
|
5360
5391
|
|
|
5361
5392
|
// float handling accross browsers
|
|
5362
5393
|
util.float = float;
|
|
@@ -5365,10 +5396,10 @@ function requireMinimal () {
|
|
|
5365
5396
|
util.inquire = inquire_1;
|
|
5366
5397
|
|
|
5367
5398
|
// converts to / from utf8 encoded strings
|
|
5368
|
-
util.utf8 =
|
|
5399
|
+
util.utf8 = requireUtf8();
|
|
5369
5400
|
|
|
5370
5401
|
// provides a node-like buffer pool in the browser
|
|
5371
|
-
util.pool =
|
|
5402
|
+
util.pool = requirePool();
|
|
5372
5403
|
|
|
5373
5404
|
// utility to work with the low and high bits of a 64 bit value
|
|
5374
5405
|
util.LongBits = requireLongbits();
|
|
@@ -10650,7 +10681,8 @@ class Client extends BaseXChainClient {
|
|
|
10650
10681
|
transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new BigNumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10651
10682
|
var _a, _b, _c, _d;
|
|
10652
10683
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10653
|
-
const
|
|
10684
|
+
const sender = this.getAddress(walletIndex);
|
|
10685
|
+
const balances = yield this.getBalance(sender);
|
|
10654
10686
|
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);
|
|
10655
10687
|
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);
|
|
10656
10688
|
const fee = (yield this.getFees()).average;
|
|
@@ -10666,35 +10698,25 @@ class Client extends BaseXChainClient {
|
|
|
10666
10698
|
throw new Error('insufficient funds');
|
|
10667
10699
|
}
|
|
10668
10700
|
}
|
|
10669
|
-
const
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
memo: memo,
|
|
10678
|
-
assetAmount: amount,
|
|
10679
|
-
assetDenom: denom,
|
|
10680
|
-
chainId: this.getChainId(),
|
|
10681
|
-
nodeUrl: this.getClientUrl().node,
|
|
10701
|
+
const unsignedTxData = yield this.prepareTx({
|
|
10702
|
+
sender,
|
|
10703
|
+
asset,
|
|
10704
|
+
amount,
|
|
10705
|
+
recipient,
|
|
10706
|
+
memo,
|
|
10707
|
+
gasLimit,
|
|
10708
|
+
sequence,
|
|
10682
10709
|
});
|
|
10683
|
-
const
|
|
10684
|
-
const
|
|
10710
|
+
const decodedTx = cosmosclient.proto.cosmos.tx.v1beta1.TxRaw.decode(Buffer.from(unsignedTxData.rawUnsignedTx, 'base64'));
|
|
10711
|
+
const txBuilder = new cosmosclient.TxBuilder(this.getCosmosClient().sdk, cosmosclient.proto.cosmos.tx.v1beta1.TxBody.decode(decodedTx.body_bytes), cosmosclient.proto.cosmos.tx.v1beta1.AuthInfo.decode(decodedTx.auth_info_bytes));
|
|
10712
|
+
const { account_number: accountNumber } = yield this.getCosmosClient().getAccount(cosmosclient.AccAddress.fromString(sender));
|
|
10685
10713
|
if (!accountNumber)
|
|
10686
|
-
throw Error(`
|
|
10687
|
-
const
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
sequence: sequence ? Long$1.fromNumber(sequence) : account.sequence || Long$1.ZERO,
|
|
10693
|
-
});
|
|
10694
|
-
const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10695
|
-
if (!txHash)
|
|
10696
|
-
throw Error(`Invalid transaction hash: ${txHash}`);
|
|
10697
|
-
return txHash;
|
|
10714
|
+
throw Error(`Transfer failed - missing account number`);
|
|
10715
|
+
const privKey = this.getCosmosClient().getPrivKeyFromMnemonic(this.phrase, this.getFullDerivationPath(walletIndex));
|
|
10716
|
+
const signDocBytes = txBuilder.signDocBytes(accountNumber);
|
|
10717
|
+
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
10718
|
+
const signedTx = txBuilder.txBytes();
|
|
10719
|
+
return this.broadcastTx(signedTx);
|
|
10698
10720
|
});
|
|
10699
10721
|
}
|
|
10700
10722
|
broadcastTx(txHex) {
|
|
@@ -10705,6 +10727,7 @@ class Client extends BaseXChainClient {
|
|
|
10705
10727
|
/**
|
|
10706
10728
|
* Transfer without broadcast balances with MsgSend
|
|
10707
10729
|
*
|
|
10730
|
+
* @deprecated use instead prepareTx
|
|
10708
10731
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
10709
10732
|
* @returns {string} The signed transaction bytes.
|
|
10710
10733
|
*/
|
|
@@ -10764,6 +10787,42 @@ class Client extends BaseXChainClient {
|
|
|
10764
10787
|
}
|
|
10765
10788
|
});
|
|
10766
10789
|
}
|
|
10790
|
+
/**
|
|
10791
|
+
* Prepare transfer.
|
|
10792
|
+
*
|
|
10793
|
+
* @param {TxParams&Address&BigNumber} params The transfer options.
|
|
10794
|
+
* @returns {PreparedTx} The raw unsigned transaction.
|
|
10795
|
+
*/
|
|
10796
|
+
prepareTx({ sender, recipient, amount, memo, asset = AssetRuneNative, gasLimit = new BigNumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10797
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10798
|
+
if (!this.validateAddress(sender))
|
|
10799
|
+
throw Error('Invalid sender address');
|
|
10800
|
+
if (!this.validateAddress(recipient))
|
|
10801
|
+
throw Error('Invalid recipient address');
|
|
10802
|
+
const denom = getDenom(asset);
|
|
10803
|
+
const txBody = yield buildTransferTx({
|
|
10804
|
+
fromAddress: sender,
|
|
10805
|
+
toAddress: recipient,
|
|
10806
|
+
memo,
|
|
10807
|
+
assetAmount: amount,
|
|
10808
|
+
assetDenom: denom,
|
|
10809
|
+
chainId: this.getChainId(),
|
|
10810
|
+
nodeUrl: this.getClientUrl().node,
|
|
10811
|
+
});
|
|
10812
|
+
const account = yield this.getCosmosClient().getAccount(cosmosclient.AccAddress.fromString(sender));
|
|
10813
|
+
const { pub_key: pubkey } = account;
|
|
10814
|
+
if (!pubkey)
|
|
10815
|
+
throw Error(`Transfer failed - missing pub key`);
|
|
10816
|
+
const txBuilder = buildUnsignedTx({
|
|
10817
|
+
cosmosSdk: this.getCosmosClient().sdk,
|
|
10818
|
+
txBody,
|
|
10819
|
+
gasLimit: Long$1.fromString(gasLimit.toString()),
|
|
10820
|
+
signerPubkey: pubkey,
|
|
10821
|
+
sequence: sequence ? Long$1.fromNumber(sequence) : account.sequence || Long$1.ZERO,
|
|
10822
|
+
});
|
|
10823
|
+
return { rawUnsignedTx: txBuilder.txBytes() };
|
|
10824
|
+
});
|
|
10825
|
+
}
|
|
10767
10826
|
}
|
|
10768
10827
|
|
|
10769
10828
|
class MsgNativeTx {
|