@xchainjs/xchain-thorchain 3.0.5 → 3.0.7
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/const.d.ts +12 -0
- package/lib/index.esm.js +34 -6
- package/lib/index.js +38 -5
- package/lib/utils.d.ts +7 -0
- package/package.json +17 -17
package/lib/const.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const RUNE_DENOM = "rune";
|
|
|
16
16
|
* Denomination of the TCY asset
|
|
17
17
|
*/
|
|
18
18
|
export declare const TCY_DENOM = "tcy";
|
|
19
|
+
/**
|
|
20
|
+
* Denomination of the ruji asset
|
|
21
|
+
*/
|
|
22
|
+
export declare const RUJI_DENOM = "x/ruji";
|
|
19
23
|
/**
|
|
20
24
|
* Ticker symbol for the RUNE asset
|
|
21
25
|
*/
|
|
@@ -24,6 +28,10 @@ export declare const RUNE_TICKER = "RUNE";
|
|
|
24
28
|
* Ticker symbol for the TCY asset
|
|
25
29
|
*/
|
|
26
30
|
export declare const TCY_TICKER = "TCY";
|
|
31
|
+
/**
|
|
32
|
+
* Ticker symbol for the RUJI asset
|
|
33
|
+
*/
|
|
34
|
+
export declare const RUJI_TICKER = "RUJI";
|
|
27
35
|
/**
|
|
28
36
|
* Default fee used by the client to make transactions
|
|
29
37
|
*/
|
|
@@ -48,6 +56,10 @@ export declare const AssetRuneNative: Asset;
|
|
|
48
56
|
* Native asset representation for TCY in Thorchain
|
|
49
57
|
*/
|
|
50
58
|
export declare const AssetTCY: TokenAsset;
|
|
59
|
+
/**
|
|
60
|
+
* Native asset representation for TCY in Thorchain
|
|
61
|
+
*/
|
|
62
|
+
export declare const AssetRUJI: Asset;
|
|
51
63
|
/**
|
|
52
64
|
* Message type URL used to make send transactions
|
|
53
65
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -6,10 +6,10 @@ import { Client as Client$1, bech32ToBase64, MsgTypes, makeClientPath, base64ToB
|
|
|
6
6
|
import { getSeed } from '@xchainjs/xchain-crypto';
|
|
7
7
|
import { toWords, encode } from 'bech32';
|
|
8
8
|
import { BigNumber } from 'bignumber.js';
|
|
9
|
-
import {
|
|
9
|
+
import { HDKey } from '@scure/bip32';
|
|
10
10
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
11
11
|
import { createHash } from 'crypto';
|
|
12
|
-
import
|
|
12
|
+
import * as secp from '@bitcoin-js/tiny-secp256k1-asmjs';
|
|
13
13
|
import { assetToString, isSynthAsset, isSecuredAsset, AssetType, assetToBase, assetAmount, eqAsset, assetFromString, assetFromStringEx } from '@xchainjs/xchain-util';
|
|
14
14
|
import { Network } from '@xchainjs/xchain-client';
|
|
15
15
|
import * as minimal from 'protobufjs/minimal';
|
|
@@ -3091,6 +3091,13 @@ const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(Asse
|
|
|
3091
3091
|
* @returns {boolean} `true` or `false`
|
|
3092
3092
|
*/
|
|
3093
3093
|
const isTCYAsset = (asset) => assetToString(asset) === assetToString(AssetTCY);
|
|
3094
|
+
/**
|
|
3095
|
+
* Checks whether an asset is the native RUJI asset
|
|
3096
|
+
*
|
|
3097
|
+
* @param {CompatibleAsset} asset
|
|
3098
|
+
* @returns {boolean} `true` or `false`
|
|
3099
|
+
*/
|
|
3100
|
+
const isRUJIAsset = (asset) => assetToString(asset) === assetToString(AssetRUJI);
|
|
3094
3101
|
/**
|
|
3095
3102
|
* Get denomination from Asset
|
|
3096
3103
|
*
|
|
@@ -3106,6 +3113,8 @@ const getDenom = (asset) => {
|
|
|
3106
3113
|
return assetToString(asset).toLowerCase();
|
|
3107
3114
|
if (isTCYAsset(asset))
|
|
3108
3115
|
return TCY_DENOM;
|
|
3116
|
+
if (isRUJIAsset(asset))
|
|
3117
|
+
return RUJI_DENOM;
|
|
3109
3118
|
return assetToString(asset).toLowerCase();
|
|
3110
3119
|
};
|
|
3111
3120
|
/**
|
|
@@ -3222,6 +3231,10 @@ const RUNE_DENOM = 'rune';
|
|
|
3222
3231
|
* Denomination of the TCY asset
|
|
3223
3232
|
*/
|
|
3224
3233
|
const TCY_DENOM = 'tcy';
|
|
3234
|
+
/**
|
|
3235
|
+
* Denomination of the ruji asset
|
|
3236
|
+
*/
|
|
3237
|
+
const RUJI_DENOM = 'x/ruji';
|
|
3225
3238
|
/**
|
|
3226
3239
|
* Ticker symbol for the RUNE asset
|
|
3227
3240
|
*/
|
|
@@ -3230,6 +3243,10 @@ const RUNE_TICKER = 'RUNE';
|
|
|
3230
3243
|
* Ticker symbol for the TCY asset
|
|
3231
3244
|
*/
|
|
3232
3245
|
const TCY_TICKER = 'TCY';
|
|
3246
|
+
/**
|
|
3247
|
+
* Ticker symbol for the RUJI asset
|
|
3248
|
+
*/
|
|
3249
|
+
const RUJI_TICKER = 'RUJI';
|
|
3233
3250
|
/**
|
|
3234
3251
|
* Default fee used by the client to make transactions
|
|
3235
3252
|
*/
|
|
@@ -3264,6 +3281,15 @@ const AssetTCY = {
|
|
|
3264
3281
|
ticker: TCY_TICKER,
|
|
3265
3282
|
type: AssetType.TOKEN,
|
|
3266
3283
|
};
|
|
3284
|
+
/**
|
|
3285
|
+
* Native asset representation for TCY in Thorchain
|
|
3286
|
+
*/
|
|
3287
|
+
const AssetRUJI = {
|
|
3288
|
+
chain: THORChain,
|
|
3289
|
+
symbol: RUJI_TICKER,
|
|
3290
|
+
ticker: RUJI_TICKER,
|
|
3291
|
+
type: AssetType.NATIVE,
|
|
3292
|
+
};
|
|
3267
3293
|
/**
|
|
3268
3294
|
* Message type URL used to make send transactions
|
|
3269
3295
|
*/
|
|
@@ -3479,12 +3505,14 @@ class ClientKeystore extends Client {
|
|
|
3479
3505
|
*/
|
|
3480
3506
|
getAddress(walletIndex) {
|
|
3481
3507
|
const seed = getSeed(this.phrase);
|
|
3482
|
-
const node =
|
|
3483
|
-
const child = node.
|
|
3508
|
+
const node = HDKey.fromMasterSeed(seed);
|
|
3509
|
+
const child = node.derive(this.getFullDerivationPath(walletIndex || 0));
|
|
3484
3510
|
if (!child.privateKey)
|
|
3485
3511
|
throw new Error('child does not have a privateKey');
|
|
3486
3512
|
// TODO: Make this method async and use CosmosJS official address generation strategy
|
|
3487
|
-
const pubKey =
|
|
3513
|
+
const pubKey = secp.pointFromScalar(child.privateKey, true);
|
|
3514
|
+
if (!pubKey)
|
|
3515
|
+
throw new Error('pubKey is null');
|
|
3488
3516
|
const rawAddress = this.hash160(Uint8Array.from(pubKey));
|
|
3489
3517
|
const words = toWords(Buffer.from(rawAddress));
|
|
3490
3518
|
const address = encode(this.prefix, words);
|
|
@@ -3943,4 +3971,4 @@ class ClientLedger extends Client {
|
|
|
3943
3971
|
}
|
|
3944
3972
|
}
|
|
3945
3973
|
|
|
3946
|
-
export { AssetRuneNative, AssetTCY, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, TCY_DENOM, TCY_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, isTCYAsset, parseAssetToTHORNodeAsset, parseDerivationPath, sortAndStringifyJson, sortedObject };
|
|
3974
|
+
export { AssetRUJI, AssetRuneNative, AssetTCY, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUJI_DENOM, RUJI_TICKER, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, TCY_DENOM, TCY_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, isRUJIAsset, isTCYAsset, parseAssetToTHORNodeAsset, parseDerivationPath, sortAndStringifyJson, sortedObject };
|
package/lib/index.js
CHANGED
|
@@ -8,10 +8,10 @@ var xchainCosmosSdk = require('@xchainjs/xchain-cosmos-sdk');
|
|
|
8
8
|
var xchainCrypto = require('@xchainjs/xchain-crypto');
|
|
9
9
|
var bech32 = require('bech32');
|
|
10
10
|
var bignumber_js = require('bignumber.js');
|
|
11
|
-
var bip32 = require('bip32');
|
|
11
|
+
var bip32 = require('@scure/bip32');
|
|
12
12
|
var tx = require('cosmjs-types/cosmos/tx/v1beta1/tx');
|
|
13
13
|
var crypto = require('crypto');
|
|
14
|
-
var
|
|
14
|
+
var secp = require('@bitcoin-js/tiny-secp256k1-asmjs');
|
|
15
15
|
var xchainUtil = require('@xchainjs/xchain-util');
|
|
16
16
|
var xchainClient = require('@xchainjs/xchain-client');
|
|
17
17
|
var minimal = require('protobufjs/minimal');
|
|
@@ -40,6 +40,7 @@ function _interopNamespace(e) {
|
|
|
40
40
|
return Object.freeze(n);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
var secp__namespace = /*#__PURE__*/_interopNamespace(secp);
|
|
43
44
|
var minimal__namespace = /*#__PURE__*/_interopNamespace(minimal);
|
|
44
45
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
45
46
|
var THORChainApp__default = /*#__PURE__*/_interopDefault(THORChainApp);
|
|
@@ -3117,6 +3118,13 @@ const isAssetRuneNative = (asset) => xchainUtil.assetToString(asset) === xchainU
|
|
|
3117
3118
|
* @returns {boolean} `true` or `false`
|
|
3118
3119
|
*/
|
|
3119
3120
|
const isTCYAsset = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetTCY);
|
|
3121
|
+
/**
|
|
3122
|
+
* Checks whether an asset is the native RUJI asset
|
|
3123
|
+
*
|
|
3124
|
+
* @param {CompatibleAsset} asset
|
|
3125
|
+
* @returns {boolean} `true` or `false`
|
|
3126
|
+
*/
|
|
3127
|
+
const isRUJIAsset = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetRUJI);
|
|
3120
3128
|
/**
|
|
3121
3129
|
* Get denomination from Asset
|
|
3122
3130
|
*
|
|
@@ -3132,6 +3140,8 @@ const getDenom = (asset) => {
|
|
|
3132
3140
|
return xchainUtil.assetToString(asset).toLowerCase();
|
|
3133
3141
|
if (isTCYAsset(asset))
|
|
3134
3142
|
return TCY_DENOM;
|
|
3143
|
+
if (isRUJIAsset(asset))
|
|
3144
|
+
return RUJI_DENOM;
|
|
3135
3145
|
return xchainUtil.assetToString(asset).toLowerCase();
|
|
3136
3146
|
};
|
|
3137
3147
|
/**
|
|
@@ -3248,6 +3258,10 @@ const RUNE_DENOM = 'rune';
|
|
|
3248
3258
|
* Denomination of the TCY asset
|
|
3249
3259
|
*/
|
|
3250
3260
|
const TCY_DENOM = 'tcy';
|
|
3261
|
+
/**
|
|
3262
|
+
* Denomination of the ruji asset
|
|
3263
|
+
*/
|
|
3264
|
+
const RUJI_DENOM = 'x/ruji';
|
|
3251
3265
|
/**
|
|
3252
3266
|
* Ticker symbol for the RUNE asset
|
|
3253
3267
|
*/
|
|
@@ -3256,6 +3270,10 @@ const RUNE_TICKER = 'RUNE';
|
|
|
3256
3270
|
* Ticker symbol for the TCY asset
|
|
3257
3271
|
*/
|
|
3258
3272
|
const TCY_TICKER = 'TCY';
|
|
3273
|
+
/**
|
|
3274
|
+
* Ticker symbol for the RUJI asset
|
|
3275
|
+
*/
|
|
3276
|
+
const RUJI_TICKER = 'RUJI';
|
|
3259
3277
|
/**
|
|
3260
3278
|
* Default fee used by the client to make transactions
|
|
3261
3279
|
*/
|
|
@@ -3290,6 +3308,15 @@ const AssetTCY = {
|
|
|
3290
3308
|
ticker: TCY_TICKER,
|
|
3291
3309
|
type: xchainUtil.AssetType.TOKEN,
|
|
3292
3310
|
};
|
|
3311
|
+
/**
|
|
3312
|
+
* Native asset representation for TCY in Thorchain
|
|
3313
|
+
*/
|
|
3314
|
+
const AssetRUJI = {
|
|
3315
|
+
chain: THORChain,
|
|
3316
|
+
symbol: RUJI_TICKER,
|
|
3317
|
+
ticker: RUJI_TICKER,
|
|
3318
|
+
type: xchainUtil.AssetType.NATIVE,
|
|
3319
|
+
};
|
|
3293
3320
|
/**
|
|
3294
3321
|
* Message type URL used to make send transactions
|
|
3295
3322
|
*/
|
|
@@ -3505,12 +3532,14 @@ class ClientKeystore extends Client {
|
|
|
3505
3532
|
*/
|
|
3506
3533
|
getAddress(walletIndex) {
|
|
3507
3534
|
const seed = xchainCrypto.getSeed(this.phrase);
|
|
3508
|
-
const node = bip32.
|
|
3509
|
-
const child = node.
|
|
3535
|
+
const node = bip32.HDKey.fromMasterSeed(seed);
|
|
3536
|
+
const child = node.derive(this.getFullDerivationPath(walletIndex || 0));
|
|
3510
3537
|
if (!child.privateKey)
|
|
3511
3538
|
throw new Error('child does not have a privateKey');
|
|
3512
3539
|
// TODO: Make this method async and use CosmosJS official address generation strategy
|
|
3513
|
-
const pubKey =
|
|
3540
|
+
const pubKey = secp__namespace.pointFromScalar(child.privateKey, true);
|
|
3541
|
+
if (!pubKey)
|
|
3542
|
+
throw new Error('pubKey is null');
|
|
3514
3543
|
const rawAddress = this.hash160(Uint8Array.from(pubKey));
|
|
3515
3544
|
const words = bech32.toWords(Buffer.from(rawAddress));
|
|
3516
3545
|
const address = bech32.encode(this.prefix, words);
|
|
@@ -3969,6 +3998,7 @@ class ClientLedger extends Client {
|
|
|
3969
3998
|
}
|
|
3970
3999
|
}
|
|
3971
4000
|
|
|
4001
|
+
exports.AssetRUJI = AssetRUJI;
|
|
3972
4002
|
exports.AssetRuneNative = AssetRuneNative;
|
|
3973
4003
|
exports.AssetTCY = AssetTCY;
|
|
3974
4004
|
exports.Client = ClientKeystore;
|
|
@@ -3980,6 +4010,8 @@ exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
|
|
|
3980
4010
|
exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
|
|
3981
4011
|
exports.MSG_DEPOSIT_TYPE_URL = MSG_DEPOSIT_TYPE_URL;
|
|
3982
4012
|
exports.MSG_SEND_TYPE_URL = MSG_SEND_TYPE_URL;
|
|
4013
|
+
exports.RUJI_DENOM = RUJI_DENOM;
|
|
4014
|
+
exports.RUJI_TICKER = RUJI_TICKER;
|
|
3983
4015
|
exports.RUNE_DECIMAL = RUNE_DECIMAL;
|
|
3984
4016
|
exports.RUNE_DENOM = RUNE_DENOM;
|
|
3985
4017
|
exports.RUNE_TICKER = RUNE_TICKER;
|
|
@@ -3996,6 +4028,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
3996
4028
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
3997
4029
|
exports.getPrefix = getPrefix;
|
|
3998
4030
|
exports.isAssetRuneNative = isAssetRuneNative;
|
|
4031
|
+
exports.isRUJIAsset = isRUJIAsset;
|
|
3999
4032
|
exports.isTCYAsset = isTCYAsset;
|
|
4000
4033
|
exports.parseAssetToTHORNodeAsset = parseAssetToTHORNodeAsset;
|
|
4001
4034
|
exports.parseDerivationPath = parseDerivationPath;
|
package/lib/utils.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export declare const isAssetRuneNative: (asset: CompatibleAsset) => boolean;
|
|
|
35
35
|
* @returns {boolean} `true` or `false`
|
|
36
36
|
*/
|
|
37
37
|
export declare const isTCYAsset: (asset: CompatibleAsset) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks whether an asset is the native RUJI asset
|
|
40
|
+
*
|
|
41
|
+
* @param {CompatibleAsset} asset
|
|
42
|
+
* @returns {boolean} `true` or `false`
|
|
43
|
+
*/
|
|
44
|
+
export declare const isRUJIAsset: (asset: CompatibleAsset) => boolean;
|
|
38
45
|
/**
|
|
39
46
|
* Get denomination from Asset
|
|
40
47
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "Custom Thorchain client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -34,25 +34,25 @@
|
|
|
34
34
|
"generate:ThorchainMsgs": "./genMsgs.sh"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@cosmjs/
|
|
39
|
-
"@cosmjs/
|
|
40
|
-
"@cosmjs/
|
|
41
|
-
"@cosmjs/
|
|
42
|
-
"@cosmjs/
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@xchainjs/
|
|
47
|
-
"@xchainjs/xchain-
|
|
48
|
-
"@xchainjs/xchain-
|
|
37
|
+
"@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
|
|
38
|
+
"@cosmjs/amino": "0.33.1",
|
|
39
|
+
"@cosmjs/crypto": "0.33.1",
|
|
40
|
+
"@cosmjs/encoding": "0.33.1",
|
|
41
|
+
"@cosmjs/math": "0.33.1",
|
|
42
|
+
"@cosmjs/proto-signing": "0.33.1",
|
|
43
|
+
"@cosmjs/stargate": "0.33.1",
|
|
44
|
+
"@ledgerhq/hw-transport": "^6.31.6",
|
|
45
|
+
"@scure/bip32": "^1.7.0",
|
|
46
|
+
"@xchainjs/ledger-thorchain": "0.3.0",
|
|
47
|
+
"@xchainjs/xchain-client": "2.0.3",
|
|
48
|
+
"@xchainjs/xchain-cosmos-sdk": "2.0.3",
|
|
49
|
+
"@xchainjs/xchain-crypto": "1.0.1",
|
|
50
|
+
"@xchainjs/xchain-util": "2.0.2",
|
|
49
51
|
"axios": "1.8.4",
|
|
50
52
|
"bech32": "^1.1.3",
|
|
51
|
-
"bignumber.js": "9.0.0",
|
|
52
|
-
"bip32": "^2.0.6",
|
|
53
|
+
"bignumber.js": "^9.0.0",
|
|
53
54
|
"cosmjs-types": "0.9.0",
|
|
54
|
-
"protobufjs": "6.11.4"
|
|
55
|
-
"secp256k1": "5.0.1"
|
|
55
|
+
"protobufjs": "6.11.4"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public",
|