@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.js
CHANGED
|
@@ -4372,8 +4372,8 @@ const FallBackUrls = [
|
|
|
4372
4372
|
rpc: ['https://stagenet-rpc.ninerealms.com'],
|
|
4373
4373
|
},
|
|
4374
4374
|
[lib.Network.Mainnet]: {
|
|
4375
|
-
node: ['https://thornode-v1.ninerealms.com'
|
|
4376
|
-
rpc: ['https://rpc-v1.ninerealms.com'
|
|
4375
|
+
node: ['https://thornode-v1.ninerealms.com'],
|
|
4376
|
+
rpc: ['https://rpc-v1.ninerealms.com'],
|
|
4377
4377
|
},
|
|
4378
4378
|
},
|
|
4379
4379
|
];
|
|
@@ -4382,56 +4382,64 @@ var indexMinimal = {};
|
|
|
4382
4382
|
|
|
4383
4383
|
var minimal$1 = {};
|
|
4384
4384
|
|
|
4385
|
-
var aspromise
|
|
4385
|
+
var aspromise;
|
|
4386
|
+
var hasRequiredAspromise;
|
|
4387
|
+
|
|
4388
|
+
function requireAspromise () {
|
|
4389
|
+
if (hasRequiredAspromise) return aspromise;
|
|
4390
|
+
hasRequiredAspromise = 1;
|
|
4391
|
+
aspromise = asPromise;
|
|
4386
4392
|
|
|
4387
|
-
/**
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4393
|
+
/**
|
|
4394
|
+
* Callback as used by {@link util.asPromise}.
|
|
4395
|
+
* @typedef asPromiseCallback
|
|
4396
|
+
* @type {function}
|
|
4397
|
+
* @param {Error|null} error Error, if any
|
|
4398
|
+
* @param {...*} params Additional arguments
|
|
4399
|
+
* @returns {undefined}
|
|
4400
|
+
*/
|
|
4395
4401
|
|
|
4396
|
-
/**
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
function asPromise(fn, ctx/*, varargs */) {
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4402
|
+
/**
|
|
4403
|
+
* Returns a promise from a node-style callback function.
|
|
4404
|
+
* @memberof util
|
|
4405
|
+
* @param {asPromiseCallback} fn Function to call
|
|
4406
|
+
* @param {*} ctx Function context
|
|
4407
|
+
* @param {...*} params Function arguments
|
|
4408
|
+
* @returns {Promise<*>} Promisified function
|
|
4409
|
+
*/
|
|
4410
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
4411
|
+
var params = new Array(arguments.length - 1),
|
|
4412
|
+
offset = 0,
|
|
4413
|
+
index = 2,
|
|
4414
|
+
pending = true;
|
|
4415
|
+
while (index < arguments.length)
|
|
4416
|
+
params[offset++] = arguments[index++];
|
|
4417
|
+
return new Promise(function executor(resolve, reject) {
|
|
4418
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
4419
|
+
if (pending) {
|
|
4420
|
+
pending = false;
|
|
4421
|
+
if (err)
|
|
4422
|
+
reject(err);
|
|
4423
|
+
else {
|
|
4424
|
+
var params = new Array(arguments.length - 1),
|
|
4425
|
+
offset = 0;
|
|
4426
|
+
while (offset < params.length)
|
|
4427
|
+
params[offset++] = arguments[offset];
|
|
4428
|
+
resolve.apply(null, params);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
};
|
|
4432
|
+
try {
|
|
4433
|
+
fn.apply(ctx || null, params);
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
if (pending) {
|
|
4436
|
+
pending = false;
|
|
4437
|
+
reject(err);
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
});
|
|
4441
|
+
}
|
|
4442
|
+
return aspromise;
|
|
4435
4443
|
}
|
|
4436
4444
|
|
|
4437
4445
|
var base64$1 = {};
|
|
@@ -4577,81 +4585,89 @@ var base64$1 = {};
|
|
|
4577
4585
|
};
|
|
4578
4586
|
} (base64$1));
|
|
4579
4587
|
|
|
4580
|
-
var eventemitter
|
|
4588
|
+
var eventemitter;
|
|
4589
|
+
var hasRequiredEventemitter;
|
|
4590
|
+
|
|
4591
|
+
function requireEventemitter () {
|
|
4592
|
+
if (hasRequiredEventemitter) return eventemitter;
|
|
4593
|
+
hasRequiredEventemitter = 1;
|
|
4594
|
+
eventemitter = EventEmitter;
|
|
4581
4595
|
|
|
4582
|
-
/**
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
function EventEmitter() {
|
|
4596
|
+
/**
|
|
4597
|
+
* Constructs a new event emitter instance.
|
|
4598
|
+
* @classdesc A minimal event emitter.
|
|
4599
|
+
* @memberof util
|
|
4600
|
+
* @constructor
|
|
4601
|
+
*/
|
|
4602
|
+
function EventEmitter() {
|
|
4589
4603
|
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
}
|
|
4604
|
+
/**
|
|
4605
|
+
* Registered listeners.
|
|
4606
|
+
* @type {Object.<string,*>}
|
|
4607
|
+
* @private
|
|
4608
|
+
*/
|
|
4609
|
+
this._listeners = {};
|
|
4610
|
+
}
|
|
4597
4611
|
|
|
4598
|
-
/**
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
};
|
|
4612
|
+
/**
|
|
4613
|
+
* Registers an event listener.
|
|
4614
|
+
* @param {string} evt Event name
|
|
4615
|
+
* @param {function} fn Listener
|
|
4616
|
+
* @param {*} [ctx] Listener context
|
|
4617
|
+
* @returns {util.EventEmitter} `this`
|
|
4618
|
+
*/
|
|
4619
|
+
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4620
|
+
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
4621
|
+
fn : fn,
|
|
4622
|
+
ctx : ctx || this
|
|
4623
|
+
});
|
|
4624
|
+
return this;
|
|
4625
|
+
};
|
|
4612
4626
|
|
|
4613
|
-
/**
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
};
|
|
4627
|
+
/**
|
|
4628
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
4629
|
+
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
4630
|
+
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
4631
|
+
* @returns {util.EventEmitter} `this`
|
|
4632
|
+
*/
|
|
4633
|
+
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4634
|
+
if (evt === undefined)
|
|
4635
|
+
this._listeners = {};
|
|
4636
|
+
else {
|
|
4637
|
+
if (fn === undefined)
|
|
4638
|
+
this._listeners[evt] = [];
|
|
4639
|
+
else {
|
|
4640
|
+
var listeners = this._listeners[evt];
|
|
4641
|
+
for (var i = 0; i < listeners.length;)
|
|
4642
|
+
if (listeners[i].fn === fn)
|
|
4643
|
+
listeners.splice(i, 1);
|
|
4644
|
+
else
|
|
4645
|
+
++i;
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
return this;
|
|
4649
|
+
};
|
|
4636
4650
|
|
|
4637
|
-
/**
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
EventEmitter.prototype.emit = function emit(evt) {
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
};
|
|
4651
|
+
/**
|
|
4652
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
4653
|
+
* @param {string} evt Event name
|
|
4654
|
+
* @param {...*} args Arguments
|
|
4655
|
+
* @returns {util.EventEmitter} `this`
|
|
4656
|
+
*/
|
|
4657
|
+
EventEmitter.prototype.emit = function emit(evt) {
|
|
4658
|
+
var listeners = this._listeners[evt];
|
|
4659
|
+
if (listeners) {
|
|
4660
|
+
var args = [],
|
|
4661
|
+
i = 1;
|
|
4662
|
+
for (; i < arguments.length;)
|
|
4663
|
+
args.push(arguments[i++]);
|
|
4664
|
+
for (i = 0; i < listeners.length;)
|
|
4665
|
+
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
4666
|
+
}
|
|
4667
|
+
return this;
|
|
4668
|
+
};
|
|
4669
|
+
return eventemitter;
|
|
4670
|
+
}
|
|
4655
4671
|
|
|
4656
4672
|
var float = factory(factory);
|
|
4657
4673
|
|
|
@@ -5006,159 +5022,174 @@ function inquire(moduleName) {
|
|
|
5006
5022
|
|
|
5007
5023
|
var utf8$2 = {};
|
|
5008
5024
|
|
|
5009
|
-
|
|
5025
|
+
var hasRequiredUtf8;
|
|
5026
|
+
|
|
5027
|
+
function requireUtf8 () {
|
|
5028
|
+
if (hasRequiredUtf8) return utf8$2;
|
|
5029
|
+
hasRequiredUtf8 = 1;
|
|
5030
|
+
(function (exports) {
|
|
5010
5031
|
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5032
|
+
/**
|
|
5033
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5034
|
+
* @memberof util
|
|
5035
|
+
* @namespace
|
|
5036
|
+
*/
|
|
5037
|
+
var utf8 = exports;
|
|
5038
|
+
|
|
5039
|
+
/**
|
|
5040
|
+
* Calculates the UTF8 byte length of a string.
|
|
5041
|
+
* @param {string} string String
|
|
5042
|
+
* @returns {number} Byte length
|
|
5043
|
+
*/
|
|
5044
|
+
utf8.length = function utf8_length(string) {
|
|
5045
|
+
var len = 0,
|
|
5046
|
+
c = 0;
|
|
5047
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5048
|
+
c = string.charCodeAt(i);
|
|
5049
|
+
if (c < 128)
|
|
5050
|
+
len += 1;
|
|
5051
|
+
else if (c < 2048)
|
|
5052
|
+
len += 2;
|
|
5053
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5054
|
+
++i;
|
|
5055
|
+
len += 4;
|
|
5056
|
+
} else
|
|
5057
|
+
len += 3;
|
|
5058
|
+
}
|
|
5059
|
+
return len;
|
|
5060
|
+
};
|
|
5061
|
+
|
|
5062
|
+
/**
|
|
5063
|
+
* Reads UTF8 bytes as a string.
|
|
5064
|
+
* @param {Uint8Array} buffer Source buffer
|
|
5065
|
+
* @param {number} start Source start
|
|
5066
|
+
* @param {number} end Source end
|
|
5067
|
+
* @returns {string} String read
|
|
5068
|
+
*/
|
|
5069
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
5070
|
+
var len = end - start;
|
|
5071
|
+
if (len < 1)
|
|
5072
|
+
return "";
|
|
5073
|
+
var parts = null,
|
|
5074
|
+
chunk = [],
|
|
5075
|
+
i = 0, // char offset
|
|
5076
|
+
t; // temporary
|
|
5077
|
+
while (start < end) {
|
|
5078
|
+
t = buffer[start++];
|
|
5079
|
+
if (t < 128)
|
|
5080
|
+
chunk[i++] = t;
|
|
5081
|
+
else if (t > 191 && t < 224)
|
|
5082
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5083
|
+
else if (t > 239 && t < 365) {
|
|
5084
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5085
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
5086
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5087
|
+
} else
|
|
5088
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5089
|
+
if (i > 8191) {
|
|
5090
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5091
|
+
i = 0;
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
if (parts) {
|
|
5095
|
+
if (i)
|
|
5096
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5097
|
+
return parts.join("");
|
|
5098
|
+
}
|
|
5099
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5100
|
+
};
|
|
5101
|
+
|
|
5102
|
+
/**
|
|
5103
|
+
* Writes a string as UTF8 bytes.
|
|
5104
|
+
* @param {string} string Source string
|
|
5105
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
5106
|
+
* @param {number} offset Destination offset
|
|
5107
|
+
* @returns {number} Bytes written
|
|
5108
|
+
*/
|
|
5109
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5110
|
+
var start = offset,
|
|
5111
|
+
c1, // character 1
|
|
5112
|
+
c2; // character 2
|
|
5113
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5114
|
+
c1 = string.charCodeAt(i);
|
|
5115
|
+
if (c1 < 128) {
|
|
5116
|
+
buffer[offset++] = c1;
|
|
5117
|
+
} else if (c1 < 2048) {
|
|
5118
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
5119
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5120
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5121
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5122
|
+
++i;
|
|
5123
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
5124
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5125
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5126
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5127
|
+
} else {
|
|
5128
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
5129
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5130
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5131
|
+
}
|
|
5132
|
+
}
|
|
5133
|
+
return offset - start;
|
|
5134
|
+
};
|
|
5135
|
+
} (utf8$2));
|
|
5136
|
+
return utf8$2;
|
|
5137
|
+
}
|
|
5138
|
+
|
|
5139
|
+
var pool_1;
|
|
5140
|
+
var hasRequiredPool;
|
|
5141
|
+
|
|
5142
|
+
function requirePool () {
|
|
5143
|
+
if (hasRequiredPool) return pool_1;
|
|
5144
|
+
hasRequiredPool = 1;
|
|
5145
|
+
pool_1 = pool;
|
|
5017
5146
|
|
|
5018
5147
|
/**
|
|
5019
|
-
*
|
|
5020
|
-
* @
|
|
5021
|
-
* @
|
|
5148
|
+
* An allocator as used by {@link util.pool}.
|
|
5149
|
+
* @typedef PoolAllocator
|
|
5150
|
+
* @type {function}
|
|
5151
|
+
* @param {number} size Buffer size
|
|
5152
|
+
* @returns {Uint8Array} Buffer
|
|
5022
5153
|
*/
|
|
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
5154
|
|
|
5041
5155
|
/**
|
|
5042
|
-
*
|
|
5043
|
-
* @
|
|
5044
|
-
* @
|
|
5045
|
-
* @param {number}
|
|
5046
|
-
* @
|
|
5156
|
+
* A slicer as used by {@link util.pool}.
|
|
5157
|
+
* @typedef PoolSlicer
|
|
5158
|
+
* @type {function}
|
|
5159
|
+
* @param {number} start Start offset
|
|
5160
|
+
* @param {number} end End offset
|
|
5161
|
+
* @returns {Uint8Array} Buffer slice
|
|
5162
|
+
* @this {Uint8Array}
|
|
5047
5163
|
*/
|
|
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
5164
|
|
|
5081
5165
|
/**
|
|
5082
|
-
*
|
|
5083
|
-
* @
|
|
5084
|
-
* @
|
|
5085
|
-
* @param {
|
|
5086
|
-
* @
|
|
5166
|
+
* A general purpose buffer pool.
|
|
5167
|
+
* @memberof util
|
|
5168
|
+
* @function
|
|
5169
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5170
|
+
* @param {PoolSlicer} slice Slicer
|
|
5171
|
+
* @param {number} [size=8192] Slab size
|
|
5172
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5087
5173
|
*/
|
|
5088
|
-
|
|
5089
|
-
var
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
if (
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
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;
|
|
5174
|
+
function pool(alloc, slice, size) {
|
|
5175
|
+
var SIZE = size || 8192;
|
|
5176
|
+
var MAX = SIZE >>> 1;
|
|
5177
|
+
var slab = null;
|
|
5178
|
+
var offset = SIZE;
|
|
5179
|
+
return function pool_alloc(size) {
|
|
5180
|
+
if (size < 1 || size > MAX)
|
|
5181
|
+
return alloc(size);
|
|
5182
|
+
if (offset + size > SIZE) {
|
|
5183
|
+
slab = alloc(SIZE);
|
|
5184
|
+
offset = 0;
|
|
5110
5185
|
}
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
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
|
-
};
|
|
5186
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5187
|
+
if (offset & 7) // align to 32 bit
|
|
5188
|
+
offset = (offset | 7) + 1;
|
|
5189
|
+
return buf;
|
|
5190
|
+
};
|
|
5191
|
+
}
|
|
5192
|
+
return pool_1;
|
|
5162
5193
|
}
|
|
5163
5194
|
|
|
5164
5195
|
var longbits;
|
|
@@ -5378,13 +5409,13 @@ function requireMinimal () {
|
|
|
5378
5409
|
var util = exports;
|
|
5379
5410
|
|
|
5380
5411
|
// used to return a Promise where callback is omitted
|
|
5381
|
-
util.asPromise =
|
|
5412
|
+
util.asPromise = requireAspromise();
|
|
5382
5413
|
|
|
5383
5414
|
// converts to / from base64 encoded strings
|
|
5384
5415
|
util.base64 = base64$1;
|
|
5385
5416
|
|
|
5386
5417
|
// base class of rpc.Service
|
|
5387
|
-
util.EventEmitter =
|
|
5418
|
+
util.EventEmitter = requireEventemitter();
|
|
5388
5419
|
|
|
5389
5420
|
// float handling accross browsers
|
|
5390
5421
|
util.float = float;
|
|
@@ -5393,10 +5424,10 @@ function requireMinimal () {
|
|
|
5393
5424
|
util.inquire = inquire_1;
|
|
5394
5425
|
|
|
5395
5426
|
// converts to / from utf8 encoded strings
|
|
5396
|
-
util.utf8 =
|
|
5427
|
+
util.utf8 = requireUtf8();
|
|
5397
5428
|
|
|
5398
5429
|
// provides a node-like buffer pool in the browser
|
|
5399
|
-
util.pool =
|
|
5430
|
+
util.pool = requirePool();
|
|
5400
5431
|
|
|
5401
5432
|
// utility to work with the low and high bits of a 64 bit value
|
|
5402
5433
|
util.LongBits = requireLongbits();
|
|
@@ -10678,7 +10709,8 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10678
10709
|
transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new BigNumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10679
10710
|
var _a, _b, _c, _d;
|
|
10680
10711
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10681
|
-
const
|
|
10712
|
+
const sender = this.getAddress(walletIndex);
|
|
10713
|
+
const balances = yield this.getBalance(sender);
|
|
10682
10714
|
const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, RUNE_DECIMAL);
|
|
10683
10715
|
const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => xchainUtil.assetToString(assetInList) === xchainUtil.assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : xchainUtil.baseAmount(0, RUNE_DECIMAL);
|
|
10684
10716
|
const fee = (yield this.getFees()).average;
|
|
@@ -10694,35 +10726,25 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10694
10726
|
throw new Error('insufficient funds');
|
|
10695
10727
|
}
|
|
10696
10728
|
}
|
|
10697
|
-
const
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
memo: memo,
|
|
10706
|
-
assetAmount: amount,
|
|
10707
|
-
assetDenom: denom,
|
|
10708
|
-
chainId: this.getChainId(),
|
|
10709
|
-
nodeUrl: this.getClientUrl().node,
|
|
10729
|
+
const unsignedTxData = yield this.prepareTx({
|
|
10730
|
+
sender,
|
|
10731
|
+
asset,
|
|
10732
|
+
amount,
|
|
10733
|
+
recipient,
|
|
10734
|
+
memo,
|
|
10735
|
+
gasLimit,
|
|
10736
|
+
sequence,
|
|
10710
10737
|
});
|
|
10711
|
-
const
|
|
10712
|
-
const
|
|
10738
|
+
const decodedTx = cosmosclient__default["default"].proto.cosmos.tx.v1beta1.TxRaw.decode(Buffer.from(unsignedTxData.rawUnsignedTx, 'base64'));
|
|
10739
|
+
const txBuilder = new cosmosclient__default["default"].TxBuilder(this.getCosmosClient().sdk, cosmosclient__default["default"].proto.cosmos.tx.v1beta1.TxBody.decode(decodedTx.body_bytes), cosmosclient__default["default"].proto.cosmos.tx.v1beta1.AuthInfo.decode(decodedTx.auth_info_bytes));
|
|
10740
|
+
const { account_number: accountNumber } = yield this.getCosmosClient().getAccount(cosmosclient__default["default"].AccAddress.fromString(sender));
|
|
10713
10741
|
if (!accountNumber)
|
|
10714
|
-
throw Error(`
|
|
10715
|
-
const
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
sequence: sequence ? Long$1.fromNumber(sequence) : account.sequence || Long$1.ZERO,
|
|
10721
|
-
});
|
|
10722
|
-
const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10723
|
-
if (!txHash)
|
|
10724
|
-
throw Error(`Invalid transaction hash: ${txHash}`);
|
|
10725
|
-
return txHash;
|
|
10742
|
+
throw Error(`Transfer failed - missing account number`);
|
|
10743
|
+
const privKey = this.getCosmosClient().getPrivKeyFromMnemonic(this.phrase, this.getFullDerivationPath(walletIndex));
|
|
10744
|
+
const signDocBytes = txBuilder.signDocBytes(accountNumber);
|
|
10745
|
+
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
10746
|
+
const signedTx = txBuilder.txBytes();
|
|
10747
|
+
return this.broadcastTx(signedTx);
|
|
10726
10748
|
});
|
|
10727
10749
|
}
|
|
10728
10750
|
broadcastTx(txHex) {
|
|
@@ -10733,6 +10755,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10733
10755
|
/**
|
|
10734
10756
|
* Transfer without broadcast balances with MsgSend
|
|
10735
10757
|
*
|
|
10758
|
+
* @deprecated use instead prepareTx
|
|
10736
10759
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
10737
10760
|
* @returns {string} The signed transaction bytes.
|
|
10738
10761
|
*/
|
|
@@ -10792,6 +10815,42 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10792
10815
|
}
|
|
10793
10816
|
});
|
|
10794
10817
|
}
|
|
10818
|
+
/**
|
|
10819
|
+
* Prepare transfer.
|
|
10820
|
+
*
|
|
10821
|
+
* @param {TxParams&Address&BigNumber} params The transfer options.
|
|
10822
|
+
* @returns {PreparedTx} The raw unsigned transaction.
|
|
10823
|
+
*/
|
|
10824
|
+
prepareTx({ sender, recipient, amount, memo, asset = AssetRuneNative, gasLimit = new BigNumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10825
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10826
|
+
if (!this.validateAddress(sender))
|
|
10827
|
+
throw Error('Invalid sender address');
|
|
10828
|
+
if (!this.validateAddress(recipient))
|
|
10829
|
+
throw Error('Invalid recipient address');
|
|
10830
|
+
const denom = getDenom(asset);
|
|
10831
|
+
const txBody = yield buildTransferTx({
|
|
10832
|
+
fromAddress: sender,
|
|
10833
|
+
toAddress: recipient,
|
|
10834
|
+
memo,
|
|
10835
|
+
assetAmount: amount,
|
|
10836
|
+
assetDenom: denom,
|
|
10837
|
+
chainId: this.getChainId(),
|
|
10838
|
+
nodeUrl: this.getClientUrl().node,
|
|
10839
|
+
});
|
|
10840
|
+
const account = yield this.getCosmosClient().getAccount(cosmosclient__default["default"].AccAddress.fromString(sender));
|
|
10841
|
+
const { pub_key: pubkey } = account;
|
|
10842
|
+
if (!pubkey)
|
|
10843
|
+
throw Error(`Transfer failed - missing pub key`);
|
|
10844
|
+
const txBuilder = buildUnsignedTx({
|
|
10845
|
+
cosmosSdk: this.getCosmosClient().sdk,
|
|
10846
|
+
txBody,
|
|
10847
|
+
gasLimit: Long$1.fromString(gasLimit.toString()),
|
|
10848
|
+
signerPubkey: pubkey,
|
|
10849
|
+
sequence: sequence ? Long$1.fromNumber(sequence) : account.sequence || Long$1.ZERO,
|
|
10850
|
+
});
|
|
10851
|
+
return { rawUnsignedTx: txBuilder.txBytes() };
|
|
10852
|
+
});
|
|
10853
|
+
}
|
|
10795
10854
|
}
|
|
10796
10855
|
|
|
10797
10856
|
class MsgNativeTx {
|