@xchainjs/xchain-doge 0.1.2 → 0.2.1
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/CHANGELOG.md +24 -0
- package/README.md +7 -39
- package/lib/blockcypher-api.d.ts +1 -1
- package/lib/client.d.ts +11 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.esm.js +564 -683
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +566 -683
- package/lib/index.js.map +1 -1
- package/lib/sochain-api.d.ts +22 -5
- package/lib/types/sochain-api-types.d.ts +0 -6
- package/lib/utils.d.ts +15 -6
- package/package.json +5 -5
package/lib/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import stream from 'stream';
|
|
|
5
5
|
import string_decoder$1 from 'string_decoder';
|
|
6
6
|
import crypto$1$1 from 'crypto';
|
|
7
7
|
import readableStream from 'readable-stream';
|
|
8
|
-
import axios from 'axios';
|
|
8
|
+
import axios$1 from 'axios';
|
|
9
9
|
|
|
10
10
|
/*! *****************************************************************************
|
|
11
11
|
Copyright (c) Microsoft Corporation.
|
|
@@ -21,33 +21,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
21
21
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
22
|
PERFORMANCE OF THIS SOFTWARE.
|
|
23
23
|
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise */
|
|
25
|
-
|
|
26
|
-
var extendStatics = function(d, b) {
|
|
27
|
-
extendStatics = Object.setPrototypeOf ||
|
|
28
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
30
|
-
return extendStatics(d, b);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function __extends(d, b) {
|
|
34
|
-
if (typeof b !== "function" && b !== null)
|
|
35
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
36
|
-
extendStatics(d, b);
|
|
37
|
-
function __() { this.constructor = d; }
|
|
38
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var __assign = function() {
|
|
42
|
-
__assign = Object.assign || function __assign(t) {
|
|
43
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
44
|
-
s = arguments[i];
|
|
45
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
};
|
|
49
|
-
return __assign.apply(this, arguments);
|
|
50
|
-
};
|
|
51
24
|
|
|
52
25
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
53
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -57,34 +30,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
57
30
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
58
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
59
32
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function __generator(thisArg, body) {
|
|
63
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
64
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
65
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
66
|
-
function step(op) {
|
|
67
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
-
while (_) try {
|
|
69
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
|
-
switch (op[0]) {
|
|
72
|
-
case 0: case 1: t = op; break;
|
|
73
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
74
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
75
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
76
|
-
default:
|
|
77
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
78
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
79
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
80
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
81
|
-
if (t[2]) _.ops.pop();
|
|
82
|
-
_.trys.pop(); continue;
|
|
83
|
-
}
|
|
84
|
-
op = body.call(thisArg, _);
|
|
85
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
86
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
87
|
-
}
|
|
88
33
|
}
|
|
89
34
|
|
|
90
35
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -61913,7 +61858,7 @@ var sha256$2 = createCommonjsModule(function (module, exports) {
|
|
|
61913
61858
|
* @param {string} phrase
|
|
61914
61859
|
* @returns {boolean} `true` or `false`
|
|
61915
61860
|
*/
|
|
61916
|
-
|
|
61861
|
+
const validatePhrase = (phrase) => {
|
|
61917
61862
|
return src_6(phrase);
|
|
61918
61863
|
};
|
|
61919
61864
|
/**
|
|
@@ -61924,7 +61869,7 @@ var validatePhrase = function (phrase) {
|
|
|
61924
61869
|
*
|
|
61925
61870
|
* @throws {"Invalid BIP39 phrase"} Thrown if phrase is an invalid one.
|
|
61926
61871
|
*/
|
|
61927
|
-
|
|
61872
|
+
const getSeed = (phrase) => {
|
|
61928
61873
|
if (!validatePhrase(phrase)) {
|
|
61929
61874
|
throw new Error('Invalid BIP39 phrase');
|
|
61930
61875
|
}
|
|
@@ -64851,14 +64796,14 @@ var bignumber$1 = createCommonjsModule$1(function (module) {
|
|
|
64851
64796
|
* @param {string | number | BigNumber.Instance} value
|
|
64852
64797
|
* @returns {BigNumber} The BigNumber interface from the given value.
|
|
64853
64798
|
*/
|
|
64854
|
-
|
|
64799
|
+
const bn$1 = (value) => new bignumber$1(value);
|
|
64855
64800
|
/**
|
|
64856
64801
|
* Helper to check whether a BigNumber is valid or not
|
|
64857
64802
|
*
|
|
64858
64803
|
* @param {BigNumber} value
|
|
64859
64804
|
* @returns {boolean} `true` or `false`.
|
|
64860
64805
|
* */
|
|
64861
|
-
|
|
64806
|
+
const isValidBN = (value) => !value.isNaN();
|
|
64862
64807
|
/**
|
|
64863
64808
|
* The enumuration for symbol position.
|
|
64864
64809
|
* `before` or `after`
|
|
@@ -64876,14 +64821,12 @@ var SymbolPosition;
|
|
|
64876
64821
|
* @param {number} decimalPlaces The decimal place. (optional)
|
|
64877
64822
|
* @returns {BigNumber} The BigNumber interface from the given value and decimal.
|
|
64878
64823
|
* */
|
|
64879
|
-
|
|
64880
|
-
|
|
64881
|
-
|
|
64882
|
-
var fixedBN = isValidBN(n) ? n.toFixed(decimalPlaces) : bn$1(0).toFixed(decimalPlaces);
|
|
64824
|
+
const fixedBN = (value, decimalPlaces = 2) => {
|
|
64825
|
+
const n = bn$1(value || 0);
|
|
64826
|
+
const fixedBN = isValidBN(n) ? n.toFixed(decimalPlaces) : bn$1(0).toFixed(decimalPlaces);
|
|
64883
64827
|
return bn$1(fixedBN);
|
|
64884
64828
|
};
|
|
64885
64829
|
|
|
64886
|
-
var _a;
|
|
64887
64830
|
var Chain;
|
|
64888
64831
|
(function (Chain) {
|
|
64889
64832
|
Chain["Binance"] = "BNB";
|
|
@@ -64894,38 +64837,41 @@ var Chain;
|
|
|
64894
64837
|
Chain["Polkadot"] = "POLKA";
|
|
64895
64838
|
Chain["BitcoinCash"] = "BCH";
|
|
64896
64839
|
Chain["Litecoin"] = "LTC";
|
|
64840
|
+
Chain["Terra"] = "TERRA";
|
|
64897
64841
|
Chain["Doge"] = "DOGE";
|
|
64898
64842
|
})(Chain || (Chain = {}));
|
|
64899
|
-
|
|
64900
|
-
|
|
64901
|
-
|
|
64902
|
-
|
|
64903
|
-
|
|
64904
|
-
|
|
64905
|
-
|
|
64906
|
-
|
|
64907
|
-
|
|
64843
|
+
const BNBChain = Chain.Binance;
|
|
64844
|
+
const BTCChain = Chain.Bitcoin;
|
|
64845
|
+
const ETHChain = Chain.Ethereum;
|
|
64846
|
+
const THORChain = Chain.THORChain;
|
|
64847
|
+
const CosmosChain = Chain.Cosmos;
|
|
64848
|
+
const PolkadotChain = Chain.Polkadot;
|
|
64849
|
+
const BCHChain = Chain.BitcoinCash;
|
|
64850
|
+
const LTCChain = Chain.Litecoin;
|
|
64851
|
+
const TerraChain = Chain.Terra;
|
|
64852
|
+
const DOGEChain = Chain.Doge;
|
|
64908
64853
|
/**
|
|
64909
64854
|
* Convert chain to string.
|
|
64910
64855
|
*
|
|
64911
64856
|
* @param {Chain} chainId.
|
|
64912
64857
|
* @returns {string} The string based on the given chain type.
|
|
64913
64858
|
*/
|
|
64914
|
-
|
|
64859
|
+
const chainToString = Object.assign((chainId) => {
|
|
64915
64860
|
if (!(chainId in chainToString))
|
|
64916
64861
|
return 'unknown chain';
|
|
64917
64862
|
return chainToString[chainId];
|
|
64918
|
-
},
|
|
64919
|
-
|
|
64920
|
-
|
|
64921
|
-
|
|
64922
|
-
|
|
64923
|
-
|
|
64924
|
-
|
|
64925
|
-
|
|
64926
|
-
|
|
64927
|
-
|
|
64928
|
-
|
|
64863
|
+
}, {
|
|
64864
|
+
[Chain.THORChain]: 'Thorchain',
|
|
64865
|
+
[Chain.Bitcoin]: 'Bitcoin',
|
|
64866
|
+
[Chain.BitcoinCash]: 'Bitcoin Cash',
|
|
64867
|
+
[Chain.Litecoin]: 'Litecoin',
|
|
64868
|
+
[Chain.Ethereum]: 'Ethereum',
|
|
64869
|
+
[Chain.Binance]: 'Binance Chain',
|
|
64870
|
+
[Chain.Cosmos]: 'Cosmos',
|
|
64871
|
+
[Chain.Polkadot]: 'Polkadot',
|
|
64872
|
+
[Chain.Terra]: 'Terra',
|
|
64873
|
+
[Chain.Doge]: 'Dogecoin',
|
|
64874
|
+
});
|
|
64929
64875
|
|
|
64930
64876
|
var Denomination;
|
|
64931
64877
|
(function (Denomination) {
|
|
@@ -64945,9 +64891,7 @@ var Denomination;
|
|
|
64945
64891
|
* @param {unknown} v
|
|
64946
64892
|
* @returns {boolean} `true` or `false`.
|
|
64947
64893
|
* */
|
|
64948
|
-
|
|
64949
|
-
return typeof v === 'string' || typeof v === 'number' || v instanceof bignumber$1;
|
|
64950
|
-
};
|
|
64894
|
+
const isBigNumberValue = (v) => typeof v === 'string' || typeof v === 'number' || v instanceof bignumber$1;
|
|
64951
64895
|
/**
|
|
64952
64896
|
* Default number of asset decimals
|
|
64953
64897
|
* For history reason and by starting the project on Binance chain assets, it's 8 decimal.
|
|
@@ -64958,7 +64902,7 @@ var isBigNumberValue = function (v) {
|
|
|
64958
64902
|
* 0.00000001 RUNE == 1 ð (tor)
|
|
64959
64903
|
* ```
|
|
64960
64904
|
* */
|
|
64961
|
-
|
|
64905
|
+
const ASSET_DECIMAL = 8;
|
|
64962
64906
|
/**
|
|
64963
64907
|
* Factory to create values of assets (e.g. RUNE)
|
|
64964
64908
|
*
|
|
@@ -64967,34 +64911,21 @@ var ASSET_DECIMAL = 8;
|
|
|
64967
64911
|
* @returns {AssetAmount} The asset amount from the given value and decimal.
|
|
64968
64912
|
*
|
|
64969
64913
|
**/
|
|
64970
|
-
|
|
64971
|
-
|
|
64972
|
-
var amount = fixedBN(value, decimal);
|
|
64914
|
+
const assetAmount = (value, decimal = ASSET_DECIMAL) => {
|
|
64915
|
+
const amount = fixedBN(value, decimal);
|
|
64973
64916
|
return {
|
|
64974
64917
|
type: Denomination.Asset,
|
|
64975
|
-
amount:
|
|
64976
|
-
plus:
|
|
64977
|
-
|
|
64978
|
-
|
|
64979
|
-
|
|
64980
|
-
|
|
64981
|
-
|
|
64982
|
-
|
|
64983
|
-
|
|
64984
|
-
|
|
64985
|
-
|
|
64986
|
-
return assetAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d);
|
|
64987
|
-
},
|
|
64988
|
-
div: function (v, d) {
|
|
64989
|
-
if (d === void 0) { d = decimal; }
|
|
64990
|
-
return assetAmount(amount.div(isBigNumberValue(v) ? v : v.amount()), d);
|
|
64991
|
-
},
|
|
64992
|
-
lt: function (v) { return amount.lt(isBigNumberValue(v) ? v : v.amount()); },
|
|
64993
|
-
lte: function (v) { return amount.lte(isBigNumberValue(v) ? v : v.amount()); },
|
|
64994
|
-
gt: function (v) { return amount.gt(isBigNumberValue(v) ? v : v.amount()); },
|
|
64995
|
-
gte: function (v) { return amount.gte(isBigNumberValue(v) ? v : v.amount()); },
|
|
64996
|
-
eq: function (v) { return amount.eq(isBigNumberValue(v) ? v : v.amount()); },
|
|
64997
|
-
decimal: decimal,
|
|
64918
|
+
amount: () => amount,
|
|
64919
|
+
plus: (v, d = decimal) => assetAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64920
|
+
minus: (v, d = decimal) => assetAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64921
|
+
times: (v, d = decimal) => assetAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64922
|
+
div: (v, d = decimal) => assetAmount(amount.div(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64923
|
+
lt: (v) => amount.lt(isBigNumberValue(v) ? v : v.amount()),
|
|
64924
|
+
lte: (v) => amount.lte(isBigNumberValue(v) ? v : v.amount()),
|
|
64925
|
+
gt: (v) => amount.gt(isBigNumberValue(v) ? v : v.amount()),
|
|
64926
|
+
gte: (v) => amount.gte(isBigNumberValue(v) ? v : v.amount()),
|
|
64927
|
+
eq: (v) => amount.eq(isBigNumberValue(v) ? v : v.amount()),
|
|
64928
|
+
decimal,
|
|
64998
64929
|
};
|
|
64999
64930
|
};
|
|
65000
64931
|
/**
|
|
@@ -65004,34 +64935,21 @@ var assetAmount = function (value, decimal) {
|
|
|
65004
64935
|
* @param {number} decimal The decimal places of its associated AssetAmount. (optional)
|
|
65005
64936
|
* @returns {BaseAmount} The base amount from the given value and decimal.
|
|
65006
64937
|
**/
|
|
65007
|
-
|
|
65008
|
-
|
|
65009
|
-
var amount = fixedBN(value, 0);
|
|
64938
|
+
const baseAmount = (value, decimal = ASSET_DECIMAL) => {
|
|
64939
|
+
const amount = fixedBN(value, 0);
|
|
65010
64940
|
return {
|
|
65011
64941
|
type: Denomination.Base,
|
|
65012
|
-
amount:
|
|
65013
|
-
plus:
|
|
65014
|
-
|
|
65015
|
-
|
|
65016
|
-
|
|
65017
|
-
|
|
65018
|
-
|
|
65019
|
-
|
|
65020
|
-
|
|
65021
|
-
|
|
65022
|
-
|
|
65023
|
-
return baseAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d);
|
|
65024
|
-
},
|
|
65025
|
-
div: function (v, d) {
|
|
65026
|
-
if (d === void 0) { d = decimal; }
|
|
65027
|
-
return baseAmount(amount.div(isBigNumberValue(v) ? v : v.amount()).decimalPlaces(0, bignumber$1.ROUND_DOWN), d);
|
|
65028
|
-
},
|
|
65029
|
-
lt: function (v) { return amount.lt(isBigNumberValue(v) ? v : v.amount()); },
|
|
65030
|
-
lte: function (v) { return amount.lte(isBigNumberValue(v) ? v : v.amount()); },
|
|
65031
|
-
gt: function (v) { return amount.gt(isBigNumberValue(v) ? v : v.amount()); },
|
|
65032
|
-
gte: function (v) { return amount.gte(isBigNumberValue(v) ? v : v.amount()); },
|
|
65033
|
-
eq: function (v) { return amount.eq(isBigNumberValue(v) ? v : v.amount()); },
|
|
65034
|
-
decimal: decimal,
|
|
64942
|
+
amount: () => amount,
|
|
64943
|
+
plus: (v, d = decimal) => baseAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64944
|
+
minus: (v, d = decimal) => baseAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64945
|
+
times: (v, d = decimal) => baseAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d),
|
|
64946
|
+
div: (v, d = decimal) => baseAmount(amount.div(isBigNumberValue(v) ? v : v.amount()).decimalPlaces(0, bignumber$1.ROUND_DOWN), d),
|
|
64947
|
+
lt: (v) => amount.lt(isBigNumberValue(v) ? v : v.amount()),
|
|
64948
|
+
lte: (v) => amount.lte(isBigNumberValue(v) ? v : v.amount()),
|
|
64949
|
+
gt: (v) => amount.gt(isBigNumberValue(v) ? v : v.amount()),
|
|
64950
|
+
gte: (v) => amount.gte(isBigNumberValue(v) ? v : v.amount()),
|
|
64951
|
+
eq: (v) => amount.eq(isBigNumberValue(v) ? v : v.amount()),
|
|
64952
|
+
decimal,
|
|
65035
64953
|
};
|
|
65036
64954
|
};
|
|
65037
64955
|
/**
|
|
@@ -65040,8 +64958,8 @@ var baseAmount = function (value, decimal) {
|
|
|
65040
64958
|
* @param {AssetAmount} asset
|
|
65041
64959
|
* @returns {BaseAmount} The base amount from the given AssetAmount.
|
|
65042
64960
|
* */
|
|
65043
|
-
|
|
65044
|
-
|
|
64961
|
+
const assetToBase = (asset) => {
|
|
64962
|
+
const value = asset
|
|
65045
64963
|
.amount()
|
|
65046
64964
|
.multipliedBy(Math.pow(10, asset.decimal))
|
|
65047
64965
|
.integerValue();
|
|
@@ -65053,73 +64971,74 @@ var assetToBase = function (asset) {
|
|
|
65053
64971
|
* Based on definition in Thorchain `common`
|
|
65054
64972
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65055
64973
|
*/
|
|
65056
|
-
|
|
64974
|
+
const AssetBNB = { chain: Chain.Binance, symbol: 'BNB', ticker: 'BNB', synth: false };
|
|
65057
64975
|
/**
|
|
65058
64976
|
* Base "chain" asset on bitcoin main net.
|
|
65059
64977
|
*
|
|
65060
64978
|
* Based on definition in Thorchain `common`
|
|
65061
64979
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65062
64980
|
*/
|
|
65063
|
-
|
|
64981
|
+
const AssetBTC = { chain: Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC', synth: false };
|
|
65064
64982
|
/**
|
|
65065
64983
|
* Base "chain" asset on bitcoin cash main net.
|
|
65066
64984
|
*
|
|
65067
64985
|
* Based on definition in Thorchain `common`
|
|
65068
64986
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65069
64987
|
*/
|
|
65070
|
-
|
|
64988
|
+
const AssetBCH = { chain: Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH', synth: false };
|
|
65071
64989
|
/**
|
|
65072
64990
|
* Base "chain" asset on litecoin main net.
|
|
65073
64991
|
*
|
|
65074
64992
|
* Based on definition in Thorchain `common`
|
|
65075
64993
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65076
64994
|
*/
|
|
65077
|
-
|
|
64995
|
+
const AssetLTC = { chain: Chain.Litecoin, symbol: 'LTC', ticker: 'LTC', synth: false };
|
|
65078
64996
|
/**
|
|
65079
64997
|
* Dogecoin asset
|
|
65080
64998
|
* Based on definition in Thorchain
|
|
65081
64999
|
* @see https://gitlab.com/thorchain/thornode/-/blob/781-add-doge-chain/common/asset.go#L24
|
|
65082
65000
|
*/
|
|
65083
|
-
|
|
65084
|
-
|
|
65001
|
+
const AssetDOGE = { chain: Chain.Doge, symbol: 'DOGE', ticker: 'DOGE', synth: false };
|
|
65002
|
+
const RUNE_TICKER = 'RUNE';
|
|
65085
65003
|
/**
|
|
65086
65004
|
* Base "chain" asset on ethereum main net.
|
|
65087
65005
|
*
|
|
65088
65006
|
* Based on definition in Thorchain `common`
|
|
65089
65007
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65090
65008
|
*/
|
|
65091
|
-
|
|
65009
|
+
const AssetETH = { chain: Chain.Ethereum, symbol: 'ETH', ticker: 'ETH', synth: false };
|
|
65092
65010
|
/**
|
|
65093
65011
|
* Base "chain" asset for RUNE-67C on Binance test net.
|
|
65094
65012
|
*
|
|
65095
65013
|
* Based on definition in Thorchain `common`
|
|
65096
65014
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65097
65015
|
*/
|
|
65098
|
-
|
|
65016
|
+
const AssetRune67C = { chain: Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
|
|
65099
65017
|
/**
|
|
65100
65018
|
* Base "chain" asset for RUNE-B1A on Binance main net.
|
|
65101
65019
|
*
|
|
65102
65020
|
* Based on definition in Thorchain `common`
|
|
65103
65021
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65104
65022
|
*/
|
|
65105
|
-
|
|
65023
|
+
const AssetRuneB1A = { chain: Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
|
|
65106
65024
|
/**
|
|
65107
65025
|
* Base "chain" asset on thorchain main net.
|
|
65108
65026
|
*
|
|
65109
65027
|
* Based on definition in Thorchain `common`
|
|
65110
65028
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65111
65029
|
*/
|
|
65112
|
-
|
|
65030
|
+
const AssetRuneNative = { chain: Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
|
|
65113
65031
|
/**
|
|
65114
65032
|
* Base "chain" asset for RUNE on ethereum main net.
|
|
65115
65033
|
*
|
|
65116
65034
|
* Based on definition in Thorchain `common`
|
|
65117
65035
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65118
65036
|
*/
|
|
65119
|
-
|
|
65037
|
+
const AssetRuneERC20 = {
|
|
65120
65038
|
chain: Chain.Ethereum,
|
|
65121
|
-
symbol: RUNE_TICKER
|
|
65039
|
+
symbol: `${RUNE_TICKER}-0x3155ba85d5f96b2d030a4966af206230e46849cb`,
|
|
65122
65040
|
ticker: RUNE_TICKER,
|
|
65041
|
+
synth: false,
|
|
65123
65042
|
};
|
|
65124
65043
|
/**
|
|
65125
65044
|
* Base "chain" asset for RUNE on ethereum main net.
|
|
@@ -65127,10 +65046,32 @@ var AssetRuneERC20 = {
|
|
|
65127
65046
|
* Based on definition in Thorchain `common`
|
|
65128
65047
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
65129
65048
|
*/
|
|
65130
|
-
|
|
65049
|
+
const AssetRuneERC20Testnet = {
|
|
65131
65050
|
chain: Chain.Ethereum,
|
|
65132
|
-
symbol: RUNE_TICKER
|
|
65051
|
+
symbol: `${RUNE_TICKER}-0xd601c6A3a36721320573885A8d8420746dA3d7A0`,
|
|
65133
65052
|
ticker: RUNE_TICKER,
|
|
65053
|
+
synth: false,
|
|
65054
|
+
};
|
|
65055
|
+
const SYNTH_DELIMITER = '/';
|
|
65056
|
+
const NON_SYNTH_DELIMITER = '.';
|
|
65057
|
+
/**
|
|
65058
|
+
* Returns an `Asset` as a string using following naming convention:
|
|
65059
|
+
*
|
|
65060
|
+
* `AAA.BBB-CCC`
|
|
65061
|
+
* where
|
|
65062
|
+
* chain: `AAA`
|
|
65063
|
+
* ticker (optional): `BBB`
|
|
65064
|
+
* symbol: `BBB-CCC` or `CCC` (if no ticker available)
|
|
65065
|
+
* symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
|
|
65066
|
+
*
|
|
65067
|
+
* @see https://docs.thorchain.org/developers/transaction-memos#asset-notation
|
|
65068
|
+
*
|
|
65069
|
+
* @param {Asset} asset The given asset.
|
|
65070
|
+
* @returns {string} The string from the given asset.
|
|
65071
|
+
*/
|
|
65072
|
+
const assetToString = ({ chain, symbol, synth }) => {
|
|
65073
|
+
const delimiter = synth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
|
|
65074
|
+
return `${chain}${delimiter}${symbol}`;
|
|
65134
65075
|
};
|
|
65135
65076
|
/**
|
|
65136
65077
|
* Currency symbols currently supported
|
|
@@ -65142,7 +65083,77 @@ var AssetCurrencySymbol;
|
|
|
65142
65083
|
AssetCurrencySymbol["SATOSHI"] = "\u26A1";
|
|
65143
65084
|
AssetCurrencySymbol["ETH"] = "\u039E";
|
|
65144
65085
|
AssetCurrencySymbol["USD"] = "$";
|
|
65145
|
-
})(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
|
|
65086
|
+
})(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
|
|
65087
|
+
|
|
65088
|
+
/*! *****************************************************************************
|
|
65089
|
+
Copyright (c) Microsoft Corporation.
|
|
65090
|
+
|
|
65091
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
65092
|
+
purpose with or without fee is hereby granted.
|
|
65093
|
+
|
|
65094
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
65095
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
65096
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
65097
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
65098
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
65099
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
65100
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
65101
|
+
***************************************************************************** */
|
|
65102
|
+
|
|
65103
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
65104
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
65105
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
65106
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
65107
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
65108
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
65109
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
65110
|
+
});
|
|
65111
|
+
}
|
|
65112
|
+
|
|
65113
|
+
const axios = require('axios');
|
|
65114
|
+
const midgardBaseUrls = {
|
|
65115
|
+
[Network.Testnet]: ['https://testnet.midgard.thorchain.info'],
|
|
65116
|
+
[Network.Mainnet]: ['https://midgard.ninerealms.com', 'https://midgard.thorswap.net'],
|
|
65117
|
+
};
|
|
65118
|
+
const getMimirDetails = (network = Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
65119
|
+
const path = '/v2/thorchain/mimir';
|
|
65120
|
+
for (const baseUrl of midgardBaseUrls[network]) {
|
|
65121
|
+
try {
|
|
65122
|
+
const { data } = yield axios.get(`${baseUrl}${path}`);
|
|
65123
|
+
return data;
|
|
65124
|
+
}
|
|
65125
|
+
catch (e) {
|
|
65126
|
+
console.error(e);
|
|
65127
|
+
}
|
|
65128
|
+
}
|
|
65129
|
+
throw new Error('Midgard not responding');
|
|
65130
|
+
});
|
|
65131
|
+
const getAllInboundDetails = (network = Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
65132
|
+
const path = '/v2/thorchain/inbound_addresses';
|
|
65133
|
+
for (const baseUrl of midgardBaseUrls[network]) {
|
|
65134
|
+
try {
|
|
65135
|
+
const { data } = yield axios.get(`${baseUrl}${path}`);
|
|
65136
|
+
return data;
|
|
65137
|
+
}
|
|
65138
|
+
catch (e) {
|
|
65139
|
+
console.error(e);
|
|
65140
|
+
}
|
|
65141
|
+
}
|
|
65142
|
+
throw new Error('Midgard not responding');
|
|
65143
|
+
});
|
|
65144
|
+
const getInboundDetails = (chain, network = Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
65145
|
+
const [mimirDetails, allInboundDetails] = yield Promise.all([getMimirDetails(network), getAllInboundDetails(network)]);
|
|
65146
|
+
const inboundDetail = allInboundDetails === null || allInboundDetails === void 0 ? void 0 : allInboundDetails.find((item) => item.chain === chain);
|
|
65147
|
+
const details = {
|
|
65148
|
+
vault: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.address) || '',
|
|
65149
|
+
haltedChain: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.halted) || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],
|
|
65150
|
+
haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],
|
|
65151
|
+
haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],
|
|
65152
|
+
};
|
|
65153
|
+
if (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.router)
|
|
65154
|
+
details.router = inboundDetail.router;
|
|
65155
|
+
return details;
|
|
65156
|
+
});
|
|
65146
65157
|
|
|
65147
65158
|
var inherits_browser$1 = createCommonjsModule$1(function (module) {
|
|
65148
65159
|
if (typeof Object.create === 'function') {
|
|
@@ -85115,39 +85126,27 @@ var src_10 = src$3.opcodes;
|
|
|
85115
85126
|
var src_11 = src$3.Transaction;
|
|
85116
85127
|
var src_12 = src$3.TransactionBuilder;
|
|
85117
85128
|
|
|
85118
|
-
|
|
85129
|
+
const DEFAULT_SUGGESTED_TRANSACTION_FEE = 150000;
|
|
85119
85130
|
/**
|
|
85120
85131
|
* Get Dogecoin suggested transaction fee.
|
|
85121
85132
|
*
|
|
85122
85133
|
* @returns {number} The Dogecoin suggested transaction fee per bytes in sat.
|
|
85123
85134
|
*/
|
|
85124
|
-
|
|
85125
|
-
|
|
85126
|
-
|
|
85127
|
-
|
|
85128
|
-
|
|
85129
|
-
|
|
85130
|
-
|
|
85131
|
-
|
|
85132
|
-
|
|
85133
|
-
|
|
85134
|
-
response = _b.sent();
|
|
85135
|
-
return [2 /*return*/, response.data.low_fee_per_kb / 1000]; // feePerKb to feePerByte
|
|
85136
|
-
case 2:
|
|
85137
|
-
error_1 = _b.sent();
|
|
85138
|
-
return [2 /*return*/, DEFAULT_SUGGESTED_TRANSACTION_FEE];
|
|
85139
|
-
case 3: return [2 /*return*/];
|
|
85140
|
-
}
|
|
85141
|
-
});
|
|
85142
|
-
});
|
|
85143
|
-
};
|
|
85144
|
-
var getSendTxUrl = function (_a) {
|
|
85145
|
-
var blockcypherUrl = _a.blockcypherUrl, network = _a.network;
|
|
85135
|
+
const getSuggestedTxFee = ({ blockcypherUrl }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85136
|
+
try {
|
|
85137
|
+
const response = yield axios$1.get(`${blockcypherUrl}/doge/main`);
|
|
85138
|
+
return response.data.low_fee_per_kb / 1000; // feePerKb to feePerByte
|
|
85139
|
+
}
|
|
85140
|
+
catch (error) {
|
|
85141
|
+
return DEFAULT_SUGGESTED_TRANSACTION_FEE;
|
|
85142
|
+
}
|
|
85143
|
+
});
|
|
85144
|
+
const getSendTxUrl = ({ blockcypherUrl, network }) => {
|
|
85146
85145
|
if (network === 'testnet') {
|
|
85147
85146
|
throw new Error('Testnet URL is not available for blockcypher');
|
|
85148
85147
|
}
|
|
85149
85148
|
else {
|
|
85150
|
-
return blockcypherUrl
|
|
85149
|
+
return `${blockcypherUrl}/doge/main/txs/push`;
|
|
85151
85150
|
}
|
|
85152
85151
|
};
|
|
85153
85152
|
|
|
@@ -85156,10 +85155,10 @@ var getSendTxUrl = function (_a) {
|
|
|
85156
85155
|
* 100000 satoshi/kB (similar to current `minrelaytxfee`)
|
|
85157
85156
|
* @see https://github.com/dogecoin/dogecoin/blob/master/src/validation.h#L58
|
|
85158
85157
|
*/
|
|
85159
|
-
|
|
85160
|
-
|
|
85158
|
+
const MIN_TX_FEE = 100000;
|
|
85159
|
+
const DOGE_DECIMAL = 8;
|
|
85161
85160
|
|
|
85162
|
-
|
|
85161
|
+
const toSochainNetwork = (network) => {
|
|
85163
85162
|
switch (network) {
|
|
85164
85163
|
case Network.Mainnet:
|
|
85165
85164
|
return 'DOGE';
|
|
@@ -85169,9 +85168,8 @@ var toSochainNetwork = function (network) {
|
|
|
85169
85168
|
return 'DOGETEST';
|
|
85170
85169
|
}
|
|
85171
85170
|
};
|
|
85172
|
-
|
|
85173
|
-
|
|
85174
|
-
return sochainUrl + "/send_tx/" + toSochainNetwork(network);
|
|
85171
|
+
const getSendTxUrl$1 = ({ sochainUrl, network }) => {
|
|
85172
|
+
return `${sochainUrl}/send_tx/${toSochainNetwork(network)}`;
|
|
85175
85173
|
};
|
|
85176
85174
|
/**
|
|
85177
85175
|
* Get address information.
|
|
@@ -85183,23 +85181,12 @@ var getSendTxUrl$1 = function (_a) {
|
|
|
85183
85181
|
* @param {string} address
|
|
85184
85182
|
* @returns {DogeAddressDTO}
|
|
85185
85183
|
*/
|
|
85186
|
-
|
|
85187
|
-
|
|
85188
|
-
|
|
85189
|
-
|
|
85190
|
-
|
|
85191
|
-
|
|
85192
|
-
case 0:
|
|
85193
|
-
url = sochainUrl + "/address/" + toSochainNetwork(network) + "/" + address;
|
|
85194
|
-
return [4 /*yield*/, axios.get(url)];
|
|
85195
|
-
case 1:
|
|
85196
|
-
response = _b.sent();
|
|
85197
|
-
addressResponse = response.data;
|
|
85198
|
-
return [2 /*return*/, addressResponse.data];
|
|
85199
|
-
}
|
|
85200
|
-
});
|
|
85201
|
-
});
|
|
85202
|
-
};
|
|
85184
|
+
const getAddress = ({ sochainUrl, network, address, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85185
|
+
const url = `${sochainUrl}/address/${toSochainNetwork(network)}/${address}`;
|
|
85186
|
+
const response = yield axios$1.get(url);
|
|
85187
|
+
const addressResponse = response.data;
|
|
85188
|
+
return addressResponse.data;
|
|
85189
|
+
});
|
|
85203
85190
|
/**
|
|
85204
85191
|
* Get transaction by hash.
|
|
85205
85192
|
*
|
|
@@ -85210,23 +85197,12 @@ var getAddress = function (_a) {
|
|
|
85210
85197
|
* @param {string} hash The transaction hash.
|
|
85211
85198
|
* @returns {Transactions}
|
|
85212
85199
|
*/
|
|
85213
|
-
|
|
85214
|
-
|
|
85215
|
-
|
|
85216
|
-
|
|
85217
|
-
|
|
85218
|
-
|
|
85219
|
-
case 0:
|
|
85220
|
-
url = sochainUrl + "/get_tx/" + toSochainNetwork(network) + "/" + hash;
|
|
85221
|
-
return [4 /*yield*/, axios.get(url)];
|
|
85222
|
-
case 1:
|
|
85223
|
-
response = _b.sent();
|
|
85224
|
-
tx = response.data;
|
|
85225
|
-
return [2 /*return*/, tx.data];
|
|
85226
|
-
}
|
|
85227
|
-
});
|
|
85228
|
-
});
|
|
85229
|
-
};
|
|
85200
|
+
const getTx = ({ sochainUrl, network, hash }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85201
|
+
const url = `${sochainUrl}/get_tx/${toSochainNetwork(network)}/${hash}`;
|
|
85202
|
+
const response = yield axios$1.get(url);
|
|
85203
|
+
const tx = response.data;
|
|
85204
|
+
return tx.data;
|
|
85205
|
+
});
|
|
85230
85206
|
/**
|
|
85231
85207
|
* Get address balance.
|
|
85232
85208
|
*
|
|
@@ -85237,27 +85213,16 @@ var getTx = function (_a) {
|
|
|
85237
85213
|
* @param {string} address
|
|
85238
85214
|
* @returns {number}
|
|
85239
85215
|
*/
|
|
85240
|
-
|
|
85241
|
-
|
|
85242
|
-
|
|
85243
|
-
|
|
85244
|
-
|
|
85245
|
-
|
|
85246
|
-
|
|
85247
|
-
|
|
85248
|
-
|
|
85249
|
-
|
|
85250
|
-
response = _b.sent();
|
|
85251
|
-
balanceResponse = response.data;
|
|
85252
|
-
confirmed = assetAmount(balanceResponse.data.confirmed_balance, DOGE_DECIMAL);
|
|
85253
|
-
unconfirmed = assetAmount(balanceResponse.data.unconfirmed_balance, DOGE_DECIMAL);
|
|
85254
|
-
netAmt = confirmed.amount().plus(unconfirmed.amount());
|
|
85255
|
-
result = assetToBase(assetAmount(netAmt, DOGE_DECIMAL));
|
|
85256
|
-
return [2 /*return*/, result];
|
|
85257
|
-
}
|
|
85258
|
-
});
|
|
85259
|
-
});
|
|
85260
|
-
};
|
|
85216
|
+
const getBalance = ({ sochainUrl, network, address, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85217
|
+
const url = `${sochainUrl}/get_address_balance/${toSochainNetwork(network)}/${address}`;
|
|
85218
|
+
const response = yield axios$1.get(url);
|
|
85219
|
+
const balanceResponse = response.data;
|
|
85220
|
+
const confirmed = assetAmount(balanceResponse.data.confirmed_balance, DOGE_DECIMAL);
|
|
85221
|
+
const unconfirmed = assetAmount(balanceResponse.data.unconfirmed_balance, DOGE_DECIMAL);
|
|
85222
|
+
const netAmt = confirmed.amount().plus(unconfirmed.amount());
|
|
85223
|
+
const result = assetToBase(assetAmount(netAmt, DOGE_DECIMAL));
|
|
85224
|
+
return result;
|
|
85225
|
+
});
|
|
85261
85226
|
/**
|
|
85262
85227
|
* Get unspent txs
|
|
85263
85228
|
*
|
|
@@ -85268,42 +85233,31 @@ var getBalance = function (_a) {
|
|
|
85268
85233
|
* @param {string} address
|
|
85269
85234
|
* @returns {DogeAddressUTXO[]}
|
|
85270
85235
|
*/
|
|
85271
|
-
|
|
85272
|
-
|
|
85273
|
-
|
|
85274
|
-
|
|
85275
|
-
|
|
85276
|
-
|
|
85277
|
-
|
|
85278
|
-
|
|
85279
|
-
|
|
85280
|
-
|
|
85281
|
-
|
|
85282
|
-
|
|
85283
|
-
|
|
85284
|
-
|
|
85285
|
-
|
|
85286
|
-
|
|
85287
|
-
|
|
85288
|
-
|
|
85289
|
-
response = resp.data;
|
|
85290
|
-
txs = response.data.txs;
|
|
85291
|
-
if (!(txs.length === 100)) return [3 /*break*/, 6];
|
|
85292
|
-
lastTxId = txs[99].txid;
|
|
85293
|
-
return [4 /*yield*/, getUnspentTxs({
|
|
85294
|
-
sochainUrl: sochainUrl,
|
|
85295
|
-
network: network,
|
|
85296
|
-
address: address,
|
|
85297
|
-
startingFromTxId: lastTxId,
|
|
85298
|
-
})];
|
|
85299
|
-
case 5:
|
|
85300
|
-
nextBatch = _b.sent();
|
|
85301
|
-
return [2 /*return*/, txs.concat(nextBatch)];
|
|
85302
|
-
case 6: return [2 /*return*/, txs];
|
|
85303
|
-
}
|
|
85236
|
+
const getUnspentTxs = ({ sochainUrl, network, address, startingFromTxId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85237
|
+
let resp = null;
|
|
85238
|
+
if (startingFromTxId) {
|
|
85239
|
+
resp = yield axios$1.get(`${sochainUrl}/get_tx_unspent/${toSochainNetwork(network)}/${address}/${startingFromTxId}`);
|
|
85240
|
+
}
|
|
85241
|
+
else {
|
|
85242
|
+
resp = yield axios$1.get(`${sochainUrl}/get_tx_unspent/${toSochainNetwork(network)}/${address}`);
|
|
85243
|
+
}
|
|
85244
|
+
const response = resp.data;
|
|
85245
|
+
const txs = response.data.txs;
|
|
85246
|
+
if (txs.length === 100) {
|
|
85247
|
+
//fetch the next batch
|
|
85248
|
+
const lastTxId = txs[99].txid;
|
|
85249
|
+
const nextBatch = yield getUnspentTxs({
|
|
85250
|
+
sochainUrl,
|
|
85251
|
+
network,
|
|
85252
|
+
address,
|
|
85253
|
+
startingFromTxId: lastTxId,
|
|
85304
85254
|
});
|
|
85305
|
-
|
|
85306
|
-
}
|
|
85255
|
+
return txs.concat(nextBatch);
|
|
85256
|
+
}
|
|
85257
|
+
else {
|
|
85258
|
+
return txs;
|
|
85259
|
+
}
|
|
85260
|
+
});
|
|
85307
85261
|
|
|
85308
85262
|
/*
|
|
85309
85263
|
info from:
|
|
@@ -86631,25 +86585,15 @@ var accumulative = function accumulative (utxos, outputs, feeRate) {
|
|
|
86631
86585
|
*
|
|
86632
86586
|
* @returns {string} Transaction ID.
|
|
86633
86587
|
*/
|
|
86634
|
-
|
|
86635
|
-
|
|
86636
|
-
|
|
86637
|
-
|
|
86638
|
-
|
|
86639
|
-
|
|
86640
|
-
|
|
86641
|
-
|
|
86642
|
-
|
|
86643
|
-
case 1:
|
|
86644
|
-
response = (_b.sent()).data;
|
|
86645
|
-
if (response.error) {
|
|
86646
|
-
throw new Error("failed to broadcast a transaction: " + response.error);
|
|
86647
|
-
}
|
|
86648
|
-
return [2 /*return*/, response.data.txid];
|
|
86649
|
-
}
|
|
86650
|
-
});
|
|
86651
|
-
});
|
|
86652
|
-
};
|
|
86588
|
+
const broadcastTxToSochain = ({ txHex, nodeUrl }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86589
|
+
const response = (yield axios$1.post(nodeUrl, {
|
|
86590
|
+
tx_hex: txHex,
|
|
86591
|
+
})).data;
|
|
86592
|
+
if (response.error) {
|
|
86593
|
+
throw new Error(`failed to broadcast a transaction: ${response.error}`);
|
|
86594
|
+
}
|
|
86595
|
+
return response.data.txid;
|
|
86596
|
+
});
|
|
86653
86597
|
/**
|
|
86654
86598
|
* Broadcast transaction.
|
|
86655
86599
|
*
|
|
@@ -86657,31 +86601,21 @@ var broadcastTxToSochain = function (_a) {
|
|
|
86657
86601
|
*
|
|
86658
86602
|
* @returns {string} Transaction ID.
|
|
86659
86603
|
*/
|
|
86660
|
-
|
|
86661
|
-
|
|
86662
|
-
|
|
86663
|
-
|
|
86664
|
-
|
|
86665
|
-
|
|
86666
|
-
|
|
86667
|
-
|
|
86668
|
-
|
|
86669
|
-
case 1:
|
|
86670
|
-
response = (_b.sent()).data;
|
|
86671
|
-
if (response.error) {
|
|
86672
|
-
throw new Error("failed to broadcast a transaction: " + response.error);
|
|
86673
|
-
}
|
|
86674
|
-
return [2 /*return*/, response.tx.hash];
|
|
86675
|
-
}
|
|
86676
|
-
});
|
|
86677
|
-
});
|
|
86678
|
-
};
|
|
86604
|
+
const broadcastTxToBlockCypher = ({ txHex, nodeUrl }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86605
|
+
const response = (yield axios$1.post(nodeUrl, {
|
|
86606
|
+
tx: txHex,
|
|
86607
|
+
})).data;
|
|
86608
|
+
if (response.error) {
|
|
86609
|
+
throw new Error(`failed to broadcast a transaction: ${response.error}`);
|
|
86610
|
+
}
|
|
86611
|
+
return response.tx.hash;
|
|
86612
|
+
});
|
|
86679
86613
|
|
|
86680
|
-
|
|
86681
|
-
|
|
86682
|
-
|
|
86683
|
-
|
|
86684
|
-
|
|
86614
|
+
const TX_EMPTY_SIZE$1 = 4 + 1 + 1 + 4; //10
|
|
86615
|
+
const TX_INPUT_BASE$1 = 32 + 4 + 1 + 4; // 41
|
|
86616
|
+
const TX_INPUT_PUBKEYHASH$1 = 107;
|
|
86617
|
+
const TX_OUTPUT_BASE$1 = 8 + 1; //9
|
|
86618
|
+
const TX_OUTPUT_PUBKEYHASH$1 = 25;
|
|
86685
86619
|
function inputBytes$1() {
|
|
86686
86620
|
return TX_INPUT_BASE$1 + TX_INPUT_PUBKEYHASH$1;
|
|
86687
86621
|
}
|
|
@@ -86691,8 +86625,8 @@ function inputBytes$1() {
|
|
|
86691
86625
|
* @param {string} memo The memo to be compiled.
|
|
86692
86626
|
* @returns {Buffer} The compiled memo.
|
|
86693
86627
|
*/
|
|
86694
|
-
|
|
86695
|
-
|
|
86628
|
+
const compileMemo = (memo) => {
|
|
86629
|
+
const data = Buffer.from(memo, 'utf8'); // converts MEMO to buffer
|
|
86696
86630
|
return src_7$1.compile([src_10.OP_RETURN, data]); // Compile OP_RETURN script
|
|
86697
86631
|
};
|
|
86698
86632
|
/**
|
|
@@ -86703,9 +86637,8 @@ var compileMemo = function (memo) {
|
|
|
86703
86637
|
* @param {Buffer} data The compiled memo (Optional).
|
|
86704
86638
|
* @returns {number} The fee amount.
|
|
86705
86639
|
*/
|
|
86706
|
-
function getFee(inputs, feeRate, data) {
|
|
86707
|
-
|
|
86708
|
-
var sum = TX_EMPTY_SIZE$1 +
|
|
86640
|
+
function getFee(inputs, feeRate, data = null) {
|
|
86641
|
+
let sum = TX_EMPTY_SIZE$1 +
|
|
86709
86642
|
inputs.reduce(function (a) {
|
|
86710
86643
|
return a + inputBytes$1();
|
|
86711
86644
|
}, 0) +
|
|
@@ -86717,7 +86650,7 @@ function getFee(inputs, feeRate, data) {
|
|
|
86717
86650
|
if (data) {
|
|
86718
86651
|
sum += TX_OUTPUT_BASE$1 + data.length;
|
|
86719
86652
|
}
|
|
86720
|
-
|
|
86653
|
+
const fee = sum * feeRate;
|
|
86721
86654
|
return fee > MIN_TX_FEE ? fee : MIN_TX_FEE;
|
|
86722
86655
|
}
|
|
86723
86656
|
/**
|
|
@@ -86726,7 +86659,7 @@ function getFee(inputs, feeRate, data) {
|
|
|
86726
86659
|
* @param {Network} network
|
|
86727
86660
|
* @returns {Dogecoin.networks.Network} The Doge network.
|
|
86728
86661
|
*/
|
|
86729
|
-
|
|
86662
|
+
const dogeNetwork = (network) => {
|
|
86730
86663
|
switch (network) {
|
|
86731
86664
|
case Network.Mainnet:
|
|
86732
86665
|
return coininfo_1.dogecoin.main.toBitcoinJS();
|
|
@@ -86734,44 +86667,36 @@ var dogeNetwork = function (network) {
|
|
|
86734
86667
|
return coininfo_1.dogecoin.main.toBitcoinJS();
|
|
86735
86668
|
case Network.Testnet: {
|
|
86736
86669
|
// Latest coininfo on NPM doesn't contain dogetest config information
|
|
86737
|
-
|
|
86670
|
+
const bip32 = {
|
|
86738
86671
|
private: 0x04358394,
|
|
86739
86672
|
public: 0x043587cf,
|
|
86740
86673
|
};
|
|
86741
|
-
|
|
86742
|
-
|
|
86743
|
-
return
|
|
86674
|
+
const test = coininfo_1.dogecoin.test;
|
|
86675
|
+
test.versions.bip32 = bip32;
|
|
86676
|
+
return test.toBitcoinJS();
|
|
86744
86677
|
}
|
|
86745
86678
|
}
|
|
86746
86679
|
};
|
|
86747
86680
|
/**
|
|
86748
86681
|
* Get the balances of an address.
|
|
86749
86682
|
*
|
|
86750
|
-
* @param
|
|
86683
|
+
* @param params
|
|
86751
86684
|
* @returns {Balance[]} The balances of the given address.
|
|
86752
86685
|
*/
|
|
86753
|
-
|
|
86754
|
-
|
|
86755
|
-
|
|
86756
|
-
|
|
86757
|
-
|
|
86758
|
-
|
|
86759
|
-
|
|
86760
|
-
|
|
86761
|
-
|
|
86762
|
-
|
|
86763
|
-
|
|
86764
|
-
|
|
86765
|
-
|
|
86766
|
-
|
|
86767
|
-
]];
|
|
86768
|
-
case 2:
|
|
86769
|
-
error_1 = _a.sent();
|
|
86770
|
-
throw new Error("Could not get balances for address " + params.address);
|
|
86771
|
-
case 3: return [2 /*return*/];
|
|
86772
|
-
}
|
|
86773
|
-
});
|
|
86774
|
-
}); };
|
|
86686
|
+
const getBalance$1 = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86687
|
+
try {
|
|
86688
|
+
const balance = yield getBalance(params);
|
|
86689
|
+
return [
|
|
86690
|
+
{
|
|
86691
|
+
asset: AssetDOGE,
|
|
86692
|
+
amount: balance,
|
|
86693
|
+
},
|
|
86694
|
+
];
|
|
86695
|
+
}
|
|
86696
|
+
catch (error) {
|
|
86697
|
+
throw new Error(`Could not get balances for address ${params.address}`);
|
|
86698
|
+
}
|
|
86699
|
+
});
|
|
86775
86700
|
/**
|
|
86776
86701
|
* Validate the Doge address.
|
|
86777
86702
|
*
|
|
@@ -86779,7 +86704,7 @@ var getBalance$1 = function (params) { return __awaiter(void 0, void 0, void 0,
|
|
|
86779
86704
|
* @param {Network} network
|
|
86780
86705
|
* @returns {boolean} `true` or `false`.
|
|
86781
86706
|
*/
|
|
86782
|
-
|
|
86707
|
+
const validateAddress = (address, network) => {
|
|
86783
86708
|
try {
|
|
86784
86709
|
src_2$2.toOutputScript(address, dogeNetwork(network));
|
|
86785
86710
|
return true;
|
|
@@ -86788,135 +86713,118 @@ var validateAddress = function (address, network) {
|
|
|
86788
86713
|
return false;
|
|
86789
86714
|
}
|
|
86790
86715
|
};
|
|
86716
|
+
// Stores list of txHex in memory to avoid requesting same data
|
|
86717
|
+
const txHexMap = {};
|
|
86718
|
+
/**
|
|
86719
|
+
* Helper to get `hex` of `Tx`
|
|
86720
|
+
*
|
|
86721
|
+
* It will try to get it from cache before requesting it from Sochain
|
|
86722
|
+
*/
|
|
86723
|
+
const getTxHex = ({ txHash, sochainUrl, network, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86724
|
+
// try to get hex from cache
|
|
86725
|
+
const txHex = txHexMap[txHash];
|
|
86726
|
+
if (!!txHex)
|
|
86727
|
+
return txHex;
|
|
86728
|
+
// or get it from Sochain
|
|
86729
|
+
const { tx_hex } = yield getTx({ hash: txHash, sochainUrl, network });
|
|
86730
|
+
// cache it
|
|
86731
|
+
txHexMap[txHash] = tx_hex;
|
|
86732
|
+
return tx_hex;
|
|
86733
|
+
});
|
|
86791
86734
|
/**
|
|
86792
86735
|
* Scan UTXOs from sochain.
|
|
86793
86736
|
*
|
|
86794
|
-
* @param
|
|
86737
|
+
* @param params
|
|
86795
86738
|
* @returns {UTXO[]} The UTXOs of the given address.
|
|
86796
86739
|
*/
|
|
86797
|
-
|
|
86798
|
-
|
|
86799
|
-
|
|
86800
|
-
|
|
86801
|
-
|
|
86802
|
-
case 1:
|
|
86803
|
-
unspent = _a.sent();
|
|
86804
|
-
utxos = [];
|
|
86805
|
-
for (_i = 0, unspent_1 = unspent; _i < unspent_1.length; _i++) {
|
|
86806
|
-
utxo = unspent_1[_i];
|
|
86807
|
-
utxos.push({
|
|
86808
|
-
hash: utxo.txid,
|
|
86809
|
-
index: utxo.output_no,
|
|
86810
|
-
value: assetToBase(assetAmount(utxo.value, DOGE_DECIMAL)).amount().toNumber(),
|
|
86811
|
-
});
|
|
86812
|
-
}
|
|
86813
|
-
return [2 /*return*/, utxos];
|
|
86814
|
-
}
|
|
86740
|
+
const scanUTXOs = ({ sochainUrl, network, address, withTxHex, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86741
|
+
const utxos = yield getUnspentTxs({
|
|
86742
|
+
sochainUrl,
|
|
86743
|
+
network,
|
|
86744
|
+
address,
|
|
86815
86745
|
});
|
|
86816
|
-
|
|
86746
|
+
return yield Promise.all(utxos.map((utxo) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86747
|
+
return ({
|
|
86748
|
+
hash: utxo.txid,
|
|
86749
|
+
index: utxo.output_no,
|
|
86750
|
+
value: assetToBase(assetAmount(utxo.value, DOGE_DECIMAL)).amount().toNumber(),
|
|
86751
|
+
txHex: withTxHex ? yield getTxHex({ txHash: utxo.txid, sochainUrl, network }) : undefined,
|
|
86752
|
+
});
|
|
86753
|
+
})));
|
|
86754
|
+
});
|
|
86817
86755
|
/**
|
|
86818
86756
|
* Build transcation.
|
|
86819
86757
|
*
|
|
86820
86758
|
* @param {BuildParams} params The transaction build options.
|
|
86821
86759
|
* @returns {Transaction}
|
|
86822
86760
|
*/
|
|
86823
|
-
|
|
86824
|
-
|
|
86825
|
-
|
|
86826
|
-
|
|
86827
|
-
|
|
86828
|
-
|
|
86829
|
-
|
|
86830
|
-
|
|
86831
|
-
|
|
86832
|
-
|
|
86833
|
-
|
|
86834
|
-
|
|
86835
|
-
|
|
86836
|
-
|
|
86837
|
-
|
|
86838
|
-
|
|
86839
|
-
|
|
86840
|
-
|
|
86841
|
-
|
|
86842
|
-
|
|
86843
|
-
|
|
86844
|
-
|
|
86845
|
-
|
|
86846
|
-
|
|
86847
|
-
|
|
86848
|
-
|
|
86849
|
-
|
|
86850
|
-
|
|
86851
|
-
|
|
86852
|
-
|
|
86853
|
-
|
|
86854
|
-
|
|
86855
|
-
;
|
|
86856
|
-
// TODO: Doge recommended fees is greater than the recommended by Bitcoinjs-lib (for BTC),
|
|
86857
|
-
// so we need to increase the maximum fee rate. Currently, the fast rate fee is near ~650000sats/byte
|
|
86858
|
-
psbt.setMaximumFeeRate(650000);
|
|
86859
|
-
params = { sochainUrl: sochainUrl, network: network, address: sender };
|
|
86860
|
-
_i = 0, inputs_1 = inputs;
|
|
86861
|
-
_h.label = 2;
|
|
86862
|
-
case 2:
|
|
86863
|
-
if (!(_i < inputs_1.length)) return [3 /*break*/, 5];
|
|
86864
|
-
utxo = inputs_1[_i];
|
|
86865
|
-
_d = (_c = psbt).addInput;
|
|
86866
|
-
_g = {
|
|
86867
|
-
hash: utxo.hash,
|
|
86868
|
-
index: utxo.index
|
|
86869
|
-
};
|
|
86870
|
-
_f = (_e = Buffer).from;
|
|
86871
|
-
return [4 /*yield*/, getTx(__assign({ hash: utxo.hash }, params))];
|
|
86872
|
-
case 3:
|
|
86873
|
-
_d.apply(_c, [(_g.nonWitnessUtxo = _f.apply(_e, [(_h.sent()).tx_hex, 'hex']),
|
|
86874
|
-
_g)]);
|
|
86875
|
-
_h.label = 4;
|
|
86876
|
-
case 4:
|
|
86877
|
-
_i++;
|
|
86878
|
-
return [3 /*break*/, 2];
|
|
86879
|
-
case 5:
|
|
86880
|
-
// Outputs
|
|
86881
|
-
outputs.forEach(function (output) {
|
|
86882
|
-
if (!output.address) {
|
|
86883
|
-
//an empty address means this is the change address
|
|
86884
|
-
output.address = sender;
|
|
86885
|
-
}
|
|
86886
|
-
if (!output.script) {
|
|
86887
|
-
psbt.addOutput(output);
|
|
86888
|
-
}
|
|
86889
|
-
else {
|
|
86890
|
-
//we need to add the compiled memo this way to
|
|
86891
|
-
//avoid dust error tx when accumulating memo output with 0 value
|
|
86892
|
-
if (compiledMemo) {
|
|
86893
|
-
psbt.addOutput({ script: compiledMemo, value: 0 });
|
|
86894
|
-
}
|
|
86895
|
-
}
|
|
86896
|
-
});
|
|
86897
|
-
return [2 /*return*/, { psbt: psbt, utxos: utxos }];
|
|
86898
|
-
}
|
|
86761
|
+
const buildTx = ({ amount, recipient, memo, feeRate, sender, network, sochainUrl, withTxHex = false, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86762
|
+
if (!validateAddress(recipient, network))
|
|
86763
|
+
throw new Error('Invalid address');
|
|
86764
|
+
const utxos = yield scanUTXOs({ sochainUrl, network, address: sender, withTxHex });
|
|
86765
|
+
if (utxos.length === 0)
|
|
86766
|
+
throw new Error('No utxos to send');
|
|
86767
|
+
const feeRateWhole = Number(feeRate.toFixed(0));
|
|
86768
|
+
const compiledMemo = memo ? compileMemo(memo) : null;
|
|
86769
|
+
const targetOutputs = [];
|
|
86770
|
+
//1. output to recipient
|
|
86771
|
+
targetOutputs.push({
|
|
86772
|
+
address: recipient,
|
|
86773
|
+
value: amount.amount().toNumber(),
|
|
86774
|
+
});
|
|
86775
|
+
//2. add output memo to targets (optional)
|
|
86776
|
+
if (compiledMemo) {
|
|
86777
|
+
targetOutputs.push({ script: compiledMemo, value: 0 });
|
|
86778
|
+
}
|
|
86779
|
+
const { inputs, outputs } = accumulative(utxos, targetOutputs, feeRateWhole);
|
|
86780
|
+
// .inputs and .outputs will be undefined if no solution was found
|
|
86781
|
+
if (!inputs || !outputs)
|
|
86782
|
+
throw new Error('Balance insufficient for transaction');
|
|
86783
|
+
const psbt = new src_9$1({ network: dogeNetwork(network) }); // Network-specific
|
|
86784
|
+
// TODO: Doge recommended fees is greater than the recommended by Bitcoinjs-lib (for BTC),
|
|
86785
|
+
// so we need to increase the maximum fee rate. Currently, the fast rate fee is near ~650000sats/byte
|
|
86786
|
+
psbt.setMaximumFeeRate(650000);
|
|
86787
|
+
const params = { sochainUrl, network, address: sender };
|
|
86788
|
+
for (const utxo of inputs) {
|
|
86789
|
+
psbt.addInput({
|
|
86790
|
+
hash: utxo.hash,
|
|
86791
|
+
index: utxo.index,
|
|
86792
|
+
nonWitnessUtxo: Buffer.from((yield getTx(Object.assign({ hash: utxo.hash }, params))).tx_hex, 'hex'),
|
|
86899
86793
|
});
|
|
86794
|
+
}
|
|
86795
|
+
// Outputs
|
|
86796
|
+
outputs.forEach((output) => {
|
|
86797
|
+
if (!output.address) {
|
|
86798
|
+
//an empty address means this is the change address
|
|
86799
|
+
output.address = sender;
|
|
86800
|
+
}
|
|
86801
|
+
if (!output.script) {
|
|
86802
|
+
psbt.addOutput(output);
|
|
86803
|
+
}
|
|
86804
|
+
else {
|
|
86805
|
+
//we need to add the compiled memo this way to
|
|
86806
|
+
//avoid dust error tx when accumulating memo output with 0 value
|
|
86807
|
+
if (compiledMemo) {
|
|
86808
|
+
psbt.addOutput({ script: compiledMemo, value: 0 });
|
|
86809
|
+
}
|
|
86810
|
+
}
|
|
86900
86811
|
});
|
|
86901
|
-
};
|
|
86812
|
+
return { psbt, utxos };
|
|
86813
|
+
});
|
|
86902
86814
|
/**
|
|
86903
86815
|
* Broadcast the transaction.
|
|
86904
86816
|
*
|
|
86905
86817
|
* @param {BroadcastTxParams} params The transaction broadcast options.
|
|
86906
86818
|
* @returns {TxHash} The transaction hash.
|
|
86907
86819
|
*/
|
|
86908
|
-
|
|
86909
|
-
|
|
86910
|
-
|
|
86911
|
-
|
|
86912
|
-
|
|
86913
|
-
|
|
86914
|
-
|
|
86915
|
-
|
|
86916
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
86917
|
-
}
|
|
86918
|
-
});
|
|
86919
|
-
}); };
|
|
86820
|
+
const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86821
|
+
if (params.network === Network.Testnet) {
|
|
86822
|
+
return yield broadcastTxToSochain(params);
|
|
86823
|
+
}
|
|
86824
|
+
else {
|
|
86825
|
+
return yield broadcastTxToBlockCypher(params);
|
|
86826
|
+
}
|
|
86827
|
+
});
|
|
86920
86828
|
/**
|
|
86921
86829
|
* Calculate fees based on fee rate and memo.
|
|
86922
86830
|
*
|
|
@@ -86924,9 +86832,9 @@ var broadcastTx = function (params) { return __awaiter(void 0, void 0, void 0, f
|
|
|
86924
86832
|
* @param {string} memo
|
|
86925
86833
|
* @returns {BaseAmount} The calculated fees based on fee rate and the memo.
|
|
86926
86834
|
*/
|
|
86927
|
-
|
|
86928
|
-
|
|
86929
|
-
|
|
86835
|
+
const calcFee = (feeRate, memo) => {
|
|
86836
|
+
const compiledMemo = memo ? compileMemo(memo) : null;
|
|
86837
|
+
const fee = getFee([], feeRate, compiledMemo);
|
|
86930
86838
|
return baseAmount(fee);
|
|
86931
86839
|
};
|
|
86932
86840
|
/**
|
|
@@ -86934,11 +86842,11 @@ var calcFee = function (feeRate, memo) {
|
|
|
86934
86842
|
*
|
|
86935
86843
|
* @returns {FeesWithRates} The default fees and rates.
|
|
86936
86844
|
*/
|
|
86937
|
-
|
|
86938
|
-
|
|
86845
|
+
const getDefaultFeesWithRates = () => {
|
|
86846
|
+
const rates = Object.assign({}, standardFeeRates(MIN_TX_FEE));
|
|
86939
86847
|
return {
|
|
86940
86848
|
fees: calcFees(rates, calcFee),
|
|
86941
|
-
rates
|
|
86849
|
+
rates,
|
|
86942
86850
|
};
|
|
86943
86851
|
};
|
|
86944
86852
|
/**
|
|
@@ -86946,8 +86854,8 @@ var getDefaultFeesWithRates = function () {
|
|
|
86946
86854
|
*
|
|
86947
86855
|
* @returns {Fees} The default fees.
|
|
86948
86856
|
*/
|
|
86949
|
-
|
|
86950
|
-
|
|
86857
|
+
const getDefaultFees = () => {
|
|
86858
|
+
const { fees } = getDefaultFeesWithRates();
|
|
86951
86859
|
return fees;
|
|
86952
86860
|
};
|
|
86953
86861
|
/**
|
|
@@ -86957,7 +86865,7 @@ var getDefaultFees = function () {
|
|
|
86957
86865
|
* @returns {string} The address prefix based on the network.
|
|
86958
86866
|
*
|
|
86959
86867
|
**/
|
|
86960
|
-
|
|
86868
|
+
const getPrefix = (network) => {
|
|
86961
86869
|
switch (network) {
|
|
86962
86870
|
case Network.Mainnet:
|
|
86963
86871
|
case Network.Stagenet:
|
|
@@ -86970,8 +86878,7 @@ var getPrefix = function (network) {
|
|
|
86970
86878
|
/**
|
|
86971
86879
|
* Custom Dogecoin client
|
|
86972
86880
|
*/
|
|
86973
|
-
|
|
86974
|
-
__extends(Client, _super);
|
|
86881
|
+
class Client extends UTXOClient {
|
|
86975
86882
|
/**
|
|
86976
86883
|
* Constructor
|
|
86977
86884
|
* Client is initialised with network type
|
|
@@ -86979,19 +86886,16 @@ var Client = /** @class */ (function (_super) {
|
|
|
86979
86886
|
*
|
|
86980
86887
|
* @param {DogecoinClientParams} params
|
|
86981
86888
|
*/
|
|
86982
|
-
|
|
86983
|
-
|
|
86984
|
-
|
|
86985
|
-
|
|
86986
|
-
|
|
86987
|
-
|
|
86988
|
-
|
|
86989
|
-
|
|
86990
|
-
|
|
86991
|
-
|
|
86992
|
-
_this.setSochainUrl(sochainUrl);
|
|
86993
|
-
_this.setBlockcypherUrl(blockcypherUrl);
|
|
86994
|
-
return _this;
|
|
86889
|
+
constructor({ network = Network.Testnet, sochainUrl = 'https://sochain.com/api/v2', blockcypherUrl = 'https://api.blockcypher.com/v1', phrase, rootDerivationPaths = {
|
|
86890
|
+
[Network.Mainnet]: `m/44'/3'/0'/0/`,
|
|
86891
|
+
[Network.Stagenet]: `m/44'/3'/0'/0/`,
|
|
86892
|
+
[Network.Testnet]: `m/44'/1'/0'/0/`,
|
|
86893
|
+
}, }) {
|
|
86894
|
+
super(Chain.Doge, { network, rootDerivationPaths, phrase });
|
|
86895
|
+
this.sochainUrl = '';
|
|
86896
|
+
this.blockcypherUrl = '';
|
|
86897
|
+
this.setSochainUrl(sochainUrl);
|
|
86898
|
+
this.setBlockcypherUrl(blockcypherUrl);
|
|
86995
86899
|
}
|
|
86996
86900
|
/**
|
|
86997
86901
|
* Set/Update the sochain url.
|
|
@@ -86999,24 +86903,24 @@ var Client = /** @class */ (function (_super) {
|
|
|
86999
86903
|
* @param {string} url The new sochain url.
|
|
87000
86904
|
* @returns {void}
|
|
87001
86905
|
*/
|
|
87002
|
-
|
|
86906
|
+
setSochainUrl(url) {
|
|
87003
86907
|
this.sochainUrl = url;
|
|
87004
|
-
}
|
|
86908
|
+
}
|
|
87005
86909
|
/**
|
|
87006
86910
|
* Set/Update the blockcypher url.
|
|
87007
86911
|
*
|
|
87008
86912
|
* @param {string} url The new blockcypher url.
|
|
87009
86913
|
* @returns {void}
|
|
87010
86914
|
*/
|
|
87011
|
-
|
|
86915
|
+
setBlockcypherUrl(url) {
|
|
87012
86916
|
this.blockcypherUrl = url;
|
|
87013
|
-
}
|
|
86917
|
+
}
|
|
87014
86918
|
/**
|
|
87015
86919
|
* Get the explorer url.
|
|
87016
86920
|
*
|
|
87017
86921
|
* @returns {string} The explorer url based on the network.
|
|
87018
86922
|
*/
|
|
87019
|
-
|
|
86923
|
+
getExplorerUrl() {
|
|
87020
86924
|
switch (this.network) {
|
|
87021
86925
|
case Network.Mainnet:
|
|
87022
86926
|
return 'https://blockchair.com/dogecoin';
|
|
@@ -87025,32 +86929,32 @@ var Client = /** @class */ (function (_super) {
|
|
|
87025
86929
|
case Network.Testnet:
|
|
87026
86930
|
return 'https://blockexplorer.one/dogecoin/testnet';
|
|
87027
86931
|
}
|
|
87028
|
-
}
|
|
86932
|
+
}
|
|
87029
86933
|
/**
|
|
87030
86934
|
* Get the explorer url for the given address.
|
|
87031
86935
|
*
|
|
87032
86936
|
* @param {Address} address
|
|
87033
86937
|
* @returns {string} The explorer url for the given address based on the network.
|
|
87034
86938
|
*/
|
|
87035
|
-
|
|
87036
|
-
return this.getExplorerUrl()
|
|
87037
|
-
}
|
|
86939
|
+
getExplorerAddressUrl(address) {
|
|
86940
|
+
return `${this.getExplorerUrl()}/address/${address}`;
|
|
86941
|
+
}
|
|
87038
86942
|
/**
|
|
87039
86943
|
* Get the explorer url for the given transaction id.
|
|
87040
86944
|
*
|
|
87041
86945
|
* @param {string} txID The transaction id
|
|
87042
86946
|
* @returns {string} The explorer url for the given transaction id based on the network.
|
|
87043
86947
|
*/
|
|
87044
|
-
|
|
86948
|
+
getExplorerTxUrl(txID) {
|
|
87045
86949
|
switch (this.network) {
|
|
87046
86950
|
case Network.Mainnet:
|
|
87047
|
-
return this.getExplorerUrl()
|
|
86951
|
+
return `${this.getExplorerUrl()}/transaction/${txID}`;
|
|
87048
86952
|
case Network.Stagenet:
|
|
87049
|
-
return this.getExplorerUrl()
|
|
86953
|
+
return `${this.getExplorerUrl()}/transaction/${txID}`;
|
|
87050
86954
|
case Network.Testnet:
|
|
87051
|
-
return this.getExplorerUrl()
|
|
86955
|
+
return `${this.getExplorerUrl()}/tx/${txID}`;
|
|
87052
86956
|
}
|
|
87053
|
-
}
|
|
86957
|
+
}
|
|
87054
86958
|
/**
|
|
87055
86959
|
* Get the current address.
|
|
87056
86960
|
*
|
|
@@ -87062,25 +86966,24 @@ var Client = /** @class */ (function (_super) {
|
|
|
87062
86966
|
* @throws {"Phrase must be provided"} Thrown if phrase has not been set before.
|
|
87063
86967
|
* @throws {"Address not defined"} Thrown if failed creating account from phrase.
|
|
87064
86968
|
*/
|
|
87065
|
-
|
|
87066
|
-
if (index === void 0) { index = 0; }
|
|
86969
|
+
getAddress(index = 0) {
|
|
87067
86970
|
if (index < 0) {
|
|
87068
86971
|
throw new Error('index must be greater than zero');
|
|
87069
86972
|
}
|
|
87070
86973
|
if (this.phrase) {
|
|
87071
|
-
|
|
87072
|
-
|
|
87073
|
-
|
|
86974
|
+
const dogeNetwork$1 = dogeNetwork(this.network);
|
|
86975
|
+
const dogeKeys = this.getDogeKeys(this.phrase, index);
|
|
86976
|
+
const { address } = src_6$1.p2pkh({
|
|
87074
86977
|
pubkey: dogeKeys.publicKey,
|
|
87075
86978
|
network: dogeNetwork$1,
|
|
87076
|
-
})
|
|
86979
|
+
});
|
|
87077
86980
|
if (!address) {
|
|
87078
86981
|
throw new Error('Address not defined');
|
|
87079
86982
|
}
|
|
87080
86983
|
return address;
|
|
87081
86984
|
}
|
|
87082
86985
|
throw new Error('Phrase must be provided');
|
|
87083
|
-
}
|
|
86986
|
+
}
|
|
87084
86987
|
/**
|
|
87085
86988
|
* @private
|
|
87086
86989
|
* Get private key.
|
|
@@ -87092,42 +86995,39 @@ var Client = /** @class */ (function (_super) {
|
|
|
87092
86995
|
*
|
|
87093
86996
|
* @throws {"Could not get private key from phrase"} Throws an error if failed creating Doge keys from the given phrase
|
|
87094
86997
|
* */
|
|
87095
|
-
|
|
87096
|
-
|
|
87097
|
-
|
|
87098
|
-
|
|
87099
|
-
var master = src_1$2.fromSeed(seed, dogeNetwork$1).derivePath(this.getFullDerivationPath(index));
|
|
86998
|
+
getDogeKeys(phrase, index = 0) {
|
|
86999
|
+
const dogeNetwork$1 = dogeNetwork(this.network);
|
|
87000
|
+
const seed = getSeed(phrase);
|
|
87001
|
+
const master = src_1$2.fromSeed(seed, dogeNetwork$1).derivePath(this.getFullDerivationPath(index));
|
|
87100
87002
|
if (!master.privateKey) {
|
|
87101
87003
|
throw new Error('Could not get private key from phrase');
|
|
87102
87004
|
}
|
|
87103
87005
|
return src_4$2.fromPrivateKey(master.privateKey, { network: dogeNetwork$1 });
|
|
87104
|
-
}
|
|
87006
|
+
}
|
|
87105
87007
|
/**
|
|
87106
87008
|
* Validate the given address.
|
|
87107
87009
|
*
|
|
87108
87010
|
* @param {Address} address
|
|
87109
87011
|
* @returns {boolean} `true` or `false`
|
|
87110
87012
|
*/
|
|
87111
|
-
|
|
87013
|
+
validateAddress(address) {
|
|
87112
87014
|
return validateAddress(address, this.network);
|
|
87113
|
-
}
|
|
87015
|
+
}
|
|
87114
87016
|
/**
|
|
87115
87017
|
* Get the Doge balance of a given address.
|
|
87116
87018
|
*
|
|
87117
87019
|
* @param {Address} address By default, it will return the balance of the current wallet. (optional)
|
|
87118
87020
|
* @returns {Balance[]} The Doge balance of the address.
|
|
87119
87021
|
*/
|
|
87120
|
-
|
|
87121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87122
|
-
return
|
|
87123
|
-
|
|
87124
|
-
|
|
87125
|
-
|
|
87126
|
-
address: address,
|
|
87127
|
-
})];
|
|
87022
|
+
getBalance(address) {
|
|
87023
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87024
|
+
return getBalance$1({
|
|
87025
|
+
sochainUrl: this.sochainUrl,
|
|
87026
|
+
network: this.network,
|
|
87027
|
+
address,
|
|
87128
87028
|
});
|
|
87129
87029
|
});
|
|
87130
|
-
}
|
|
87030
|
+
}
|
|
87131
87031
|
/**
|
|
87132
87032
|
* Get transaction history of a given address with pagination options.
|
|
87133
87033
|
* By default it will return the transaction history of the current wallet.
|
|
@@ -87135,167 +87035,155 @@ var Client = /** @class */ (function (_super) {
|
|
|
87135
87035
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
87136
87036
|
* @returns {TxsPage} The transaction history.
|
|
87137
87037
|
*/
|
|
87138
|
-
|
|
87038
|
+
getTransactions(params) {
|
|
87139
87039
|
var _a;
|
|
87140
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87141
|
-
|
|
87142
|
-
|
|
87143
|
-
|
|
87144
|
-
|
|
87145
|
-
|
|
87146
|
-
|
|
87147
|
-
|
|
87148
|
-
sochainUrl: this.sochainUrl,
|
|
87149
|
-
network: this.network,
|
|
87150
|
-
address: "" + (params === null || params === void 0 ? void 0 : params.address),
|
|
87151
|
-
})];
|
|
87152
|
-
case 1:
|
|
87153
|
-
response = _b.sent();
|
|
87154
|
-
total = response.txs.length;
|
|
87155
|
-
transactions = [];
|
|
87156
|
-
txs = response.txs.filter(function (_, index) { return offset <= index && index < offset + limit; });
|
|
87157
|
-
_i = 0, txs_1 = txs;
|
|
87158
|
-
_b.label = 2;
|
|
87159
|
-
case 2:
|
|
87160
|
-
if (!(_i < txs_1.length)) return [3 /*break*/, 5];
|
|
87161
|
-
txItem = txs_1[_i];
|
|
87162
|
-
return [4 /*yield*/, getTx({
|
|
87163
|
-
sochainUrl: this.sochainUrl,
|
|
87164
|
-
network: this.network,
|
|
87165
|
-
hash: txItem.txid,
|
|
87166
|
-
})];
|
|
87167
|
-
case 3:
|
|
87168
|
-
rawTx = _b.sent();
|
|
87169
|
-
tx = {
|
|
87170
|
-
asset: AssetDOGE,
|
|
87171
|
-
from: rawTx.inputs.map(function (i) { return ({
|
|
87172
|
-
from: i.address,
|
|
87173
|
-
amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)),
|
|
87174
|
-
}); }),
|
|
87175
|
-
to: rawTx.outputs
|
|
87176
|
-
// ignore tx with type 'nulldata'
|
|
87177
|
-
.filter(function (i) { return i.type !== 'nulldata'; })
|
|
87178
|
-
.map(function (i) { return ({ to: i.address, amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)) }); }),
|
|
87179
|
-
date: new Date(rawTx.time * 1000),
|
|
87180
|
-
type: TxType.Transfer,
|
|
87181
|
-
hash: rawTx.txid,
|
|
87182
|
-
};
|
|
87183
|
-
transactions.push(tx);
|
|
87184
|
-
_b.label = 4;
|
|
87185
|
-
case 4:
|
|
87186
|
-
_i++;
|
|
87187
|
-
return [3 /*break*/, 2];
|
|
87188
|
-
case 5:
|
|
87189
|
-
result = {
|
|
87190
|
-
total: total,
|
|
87191
|
-
txs: transactions,
|
|
87192
|
-
};
|
|
87193
|
-
return [2 /*return*/, result];
|
|
87194
|
-
}
|
|
87040
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87041
|
+
// Sochain API doesn't have pagination parameter
|
|
87042
|
+
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
87043
|
+
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
87044
|
+
const response = yield getAddress({
|
|
87045
|
+
sochainUrl: this.sochainUrl,
|
|
87046
|
+
network: this.network,
|
|
87047
|
+
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
87195
87048
|
});
|
|
87049
|
+
const total = response.txs.length;
|
|
87050
|
+
const transactions = [];
|
|
87051
|
+
const txs = response.txs.filter((_, index) => offset <= index && index < offset + limit);
|
|
87052
|
+
for (const txItem of txs) {
|
|
87053
|
+
const rawTx = yield getTx({
|
|
87054
|
+
sochainUrl: this.sochainUrl,
|
|
87055
|
+
network: this.network,
|
|
87056
|
+
hash: txItem.txid,
|
|
87057
|
+
});
|
|
87058
|
+
const tx = {
|
|
87059
|
+
asset: AssetDOGE,
|
|
87060
|
+
from: rawTx.inputs.map((i) => ({
|
|
87061
|
+
from: i.address,
|
|
87062
|
+
amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)),
|
|
87063
|
+
})),
|
|
87064
|
+
to: rawTx.outputs
|
|
87065
|
+
// ignore tx with type 'nulldata'
|
|
87066
|
+
.filter((i) => i.type !== 'nulldata')
|
|
87067
|
+
.map((i) => ({ to: i.address, amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)) })),
|
|
87068
|
+
date: new Date(rawTx.time * 1000),
|
|
87069
|
+
type: TxType.Transfer,
|
|
87070
|
+
hash: rawTx.txid,
|
|
87071
|
+
};
|
|
87072
|
+
transactions.push(tx);
|
|
87073
|
+
}
|
|
87074
|
+
const result = {
|
|
87075
|
+
total,
|
|
87076
|
+
txs: transactions,
|
|
87077
|
+
};
|
|
87078
|
+
return result;
|
|
87196
87079
|
});
|
|
87197
|
-
}
|
|
87080
|
+
}
|
|
87198
87081
|
/**
|
|
87199
87082
|
* Get the transaction details of a given transaction id.
|
|
87200
87083
|
*
|
|
87201
87084
|
* @param {string} txId The transaction id.
|
|
87202
87085
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
87203
87086
|
*/
|
|
87204
|
-
|
|
87205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87206
|
-
|
|
87207
|
-
|
|
87208
|
-
|
|
87209
|
-
|
|
87210
|
-
sochainUrl: this.sochainUrl,
|
|
87211
|
-
network: this.network,
|
|
87212
|
-
hash: txId,
|
|
87213
|
-
})];
|
|
87214
|
-
case 1:
|
|
87215
|
-
rawTx = _a.sent();
|
|
87216
|
-
return [2 /*return*/, {
|
|
87217
|
-
asset: AssetDOGE,
|
|
87218
|
-
from: rawTx.inputs.map(function (i) { return ({
|
|
87219
|
-
from: i.address,
|
|
87220
|
-
amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)),
|
|
87221
|
-
}); }),
|
|
87222
|
-
to: rawTx.outputs.map(function (i) { return ({ to: i.address, amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)) }); }),
|
|
87223
|
-
date: new Date(rawTx.time * 1000),
|
|
87224
|
-
type: TxType.Transfer,
|
|
87225
|
-
hash: rawTx.txid,
|
|
87226
|
-
}];
|
|
87227
|
-
}
|
|
87087
|
+
getTransactionData(txId) {
|
|
87088
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87089
|
+
const rawTx = yield getTx({
|
|
87090
|
+
sochainUrl: this.sochainUrl,
|
|
87091
|
+
network: this.network,
|
|
87092
|
+
hash: txId,
|
|
87228
87093
|
});
|
|
87094
|
+
return {
|
|
87095
|
+
asset: AssetDOGE,
|
|
87096
|
+
from: rawTx.inputs.map((i) => ({
|
|
87097
|
+
from: i.address,
|
|
87098
|
+
amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)),
|
|
87099
|
+
})),
|
|
87100
|
+
to: rawTx.outputs.map((i) => ({ to: i.address, amount: assetToBase(assetAmount(i.value, DOGE_DECIMAL)) })),
|
|
87101
|
+
date: new Date(rawTx.time * 1000),
|
|
87102
|
+
type: TxType.Transfer,
|
|
87103
|
+
hash: rawTx.txid,
|
|
87104
|
+
};
|
|
87229
87105
|
});
|
|
87230
|
-
}
|
|
87231
|
-
|
|
87232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87233
|
-
return
|
|
87234
|
-
switch (_a.label) {
|
|
87235
|
-
case 0: return [4 /*yield*/, getSuggestedTxFee({ blockcypherUrl: this.blockcypherUrl })];
|
|
87236
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
87237
|
-
}
|
|
87238
|
-
});
|
|
87106
|
+
}
|
|
87107
|
+
getSuggestedFeeRate() {
|
|
87108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87109
|
+
return yield getSuggestedTxFee({ blockcypherUrl: this.blockcypherUrl });
|
|
87239
87110
|
});
|
|
87240
|
-
}
|
|
87241
|
-
|
|
87242
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87243
|
-
return
|
|
87244
|
-
return [2 /*return*/, calcFee(feeRate, memo)];
|
|
87245
|
-
});
|
|
87111
|
+
}
|
|
87112
|
+
calcFee(feeRate, memo) {
|
|
87113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87114
|
+
return calcFee(feeRate, memo);
|
|
87246
87115
|
});
|
|
87247
|
-
}
|
|
87116
|
+
}
|
|
87248
87117
|
/**
|
|
87249
87118
|
* Transfer Doge.
|
|
87250
87119
|
*
|
|
87251
87120
|
* @param {TxParams&FeeRate} params The transfer options.
|
|
87252
87121
|
* @returns {TxHash} The transaction hash.
|
|
87253
87122
|
*/
|
|
87254
|
-
|
|
87255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87256
|
-
|
|
87257
|
-
|
|
87258
|
-
|
|
87259
|
-
|
|
87260
|
-
|
|
87261
|
-
|
|
87262
|
-
|
|
87263
|
-
|
|
87264
|
-
|
|
87265
|
-
|
|
87266
|
-
|
|
87267
|
-
|
|
87268
|
-
|
|
87269
|
-
|
|
87270
|
-
|
|
87271
|
-
|
|
87272
|
-
|
|
87273
|
-
|
|
87274
|
-
|
|
87275
|
-
|
|
87276
|
-
|
|
87277
|
-
|
|
87278
|
-
|
|
87279
|
-
|
|
87280
|
-
|
|
87281
|
-
|
|
87282
|
-
|
|
87283
|
-
|
|
87284
|
-
|
|
87285
|
-
|
|
87286
|
-
}
|
|
87287
|
-
return [4 /*yield*/, broadcastTx({
|
|
87288
|
-
network: this.network,
|
|
87289
|
-
txHex: txHex,
|
|
87290
|
-
nodeUrl: nodeUrl,
|
|
87291
|
-
})];
|
|
87292
|
-
case 4: return [2 /*return*/, _b.sent()];
|
|
87293
|
-
}
|
|
87123
|
+
transfer(params) {
|
|
87124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87125
|
+
const fromAddressIndex = (params === null || params === void 0 ? void 0 : params.walletIndex) || 0;
|
|
87126
|
+
const feeRate = params.feeRate || (yield this.getSuggestedFeeRate());
|
|
87127
|
+
const { psbt } = yield buildTx({
|
|
87128
|
+
amount: params.amount,
|
|
87129
|
+
recipient: params.recipient,
|
|
87130
|
+
memo: params.memo,
|
|
87131
|
+
feeRate,
|
|
87132
|
+
sender: this.getAddress(fromAddressIndex),
|
|
87133
|
+
sochainUrl: this.sochainUrl,
|
|
87134
|
+
network: this.network,
|
|
87135
|
+
withTxHex: false,
|
|
87136
|
+
});
|
|
87137
|
+
const dogeKeys = this.getDogeKeys(this.phrase, fromAddressIndex);
|
|
87138
|
+
psbt.signAllInputs(dogeKeys); // Sign all inputs
|
|
87139
|
+
psbt.finalizeAllInputs(); // Finalise inputs
|
|
87140
|
+
const txHex = psbt.extractTransaction().toHex(); // TX extracted and formatted to hex
|
|
87141
|
+
let nodeUrl;
|
|
87142
|
+
if (this.network === Network.Testnet) {
|
|
87143
|
+
nodeUrl = getSendTxUrl$1({
|
|
87144
|
+
network: this.network,
|
|
87145
|
+
sochainUrl: this.sochainUrl,
|
|
87146
|
+
});
|
|
87147
|
+
}
|
|
87148
|
+
else {
|
|
87149
|
+
nodeUrl = getSendTxUrl({ network: this.network, blockcypherUrl: this.blockcypherUrl });
|
|
87150
|
+
}
|
|
87151
|
+
return yield broadcastTx({
|
|
87152
|
+
network: this.network,
|
|
87153
|
+
txHex,
|
|
87154
|
+
nodeUrl,
|
|
87294
87155
|
});
|
|
87295
87156
|
});
|
|
87296
|
-
}
|
|
87297
|
-
|
|
87298
|
-
|
|
87157
|
+
}
|
|
87158
|
+
/**
|
|
87159
|
+
* Transaction to THORChain inbound address.
|
|
87160
|
+
*
|
|
87161
|
+
* @param {DepositParams} params The transaction options.
|
|
87162
|
+
* @returns {TxHash} The transaction hash.
|
|
87163
|
+
*
|
|
87164
|
+
* @throws {"halted chain"} Thrown if chain is halted.
|
|
87165
|
+
* @throws {"halted trading"} Thrown if trading is halted.
|
|
87166
|
+
*/
|
|
87167
|
+
deposit({ walletIndex = 0, asset = AssetDOGE, amount, memo }) {
|
|
87168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87169
|
+
const inboundDetails = yield getInboundDetails(asset.chain, this.network);
|
|
87170
|
+
if (inboundDetails.haltedChain) {
|
|
87171
|
+
throw new Error(`Halted chain for ${assetToString(asset)}`);
|
|
87172
|
+
}
|
|
87173
|
+
if (inboundDetails.haltedTrading) {
|
|
87174
|
+
throw new Error(`Halted trading for ${assetToString(asset)}`);
|
|
87175
|
+
}
|
|
87176
|
+
const txHash = yield this.transfer({
|
|
87177
|
+
walletIndex,
|
|
87178
|
+
asset,
|
|
87179
|
+
amount,
|
|
87180
|
+
recipient: inboundDetails.vault,
|
|
87181
|
+
memo,
|
|
87182
|
+
});
|
|
87183
|
+
return txHash;
|
|
87184
|
+
});
|
|
87185
|
+
}
|
|
87186
|
+
}
|
|
87299
87187
|
|
|
87300
87188
|
/**
|
|
87301
87189
|
* Create transaction info.
|
|
@@ -87303,20 +87191,13 @@ var Client = /** @class */ (function (_super) {
|
|
|
87303
87191
|
* @param {LedgerTxInfoParams} params The transaction build options.
|
|
87304
87192
|
* @returns {LedgerTxInfo} The transaction info used for ledger sign.
|
|
87305
87193
|
*/
|
|
87306
|
-
|
|
87307
|
-
|
|
87308
|
-
return
|
|
87309
|
-
|
|
87310
|
-
|
|
87311
|
-
|
|
87312
|
-
|
|
87313
|
-
return [2 /*return*/, {
|
|
87314
|
-
utxos: utxos,
|
|
87315
|
-
newTxHex: psbt.data.globalMap.unsignedTx.toBuffer().toString('hex'),
|
|
87316
|
-
}];
|
|
87317
|
-
}
|
|
87318
|
-
});
|
|
87319
|
-
}); };
|
|
87194
|
+
const createTxInfo = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87195
|
+
const { psbt, utxos } = yield buildTx(params);
|
|
87196
|
+
return {
|
|
87197
|
+
utxos,
|
|
87198
|
+
newTxHex: psbt.data.globalMap.unsignedTx.toBuffer().toString('hex'),
|
|
87199
|
+
};
|
|
87200
|
+
});
|
|
87320
87201
|
|
|
87321
|
-
export { Client, DOGE_DECIMAL, MIN_TX_FEE, broadcastTx, calcFee, createTxInfo, getDefaultFees, getDefaultFeesWithRates, getPrefix, scanUTXOs, validateAddress };
|
|
87202
|
+
export { Client, DOGE_DECIMAL, MIN_TX_FEE, broadcastTx, buildTx, calcFee, createTxInfo, getDefaultFees, getDefaultFeesWithRates, getPrefix, getSendTxUrl, scanUTXOs, validateAddress };
|
|
87322
87203
|
//# sourceMappingURL=index.esm.js.map
|