@xchainjs/xchain-thorchain 3.0.6 → 3.0.8
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/clientKeystore.d.ts +1 -1
- package/lib/const.d.ts +12 -0
- package/lib/index.esm.js +32 -6
- package/lib/index.js +39 -8
- package/lib/types/client-types.d.ts +2 -2
- package/lib/utils.d.ts +7 -0
- package/package.json +7 -7
package/lib/clientKeystore.d.ts
CHANGED
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
|
@@ -4,8 +4,8 @@ import { decodeTxRaw, DirectSecp256k1HdWallet, encodePubkey, makeAuthInfoBytes }
|
|
|
4
4
|
import { SigningStargateClient, AminoTypes } from '@cosmjs/stargate';
|
|
5
5
|
import { Client as Client$1, bech32ToBase64, MsgTypes, makeClientPath, base64ToBech32 } from '@xchainjs/xchain-cosmos-sdk';
|
|
6
6
|
import { getSeed } from '@xchainjs/xchain-crypto';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { bech32 } from '@scure/base';
|
|
8
|
+
import BigNumber from 'bignumber.js';
|
|
9
9
|
import { HDKey } from '@scure/bip32';
|
|
10
10
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
11
11
|
import { createHash } from 'crypto';
|
|
@@ -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
|
*/
|
|
@@ -3487,9 +3513,9 @@ class ClientKeystore extends Client {
|
|
|
3487
3513
|
const pubKey = secp.pointFromScalar(child.privateKey, true);
|
|
3488
3514
|
if (!pubKey)
|
|
3489
3515
|
throw new Error('pubKey is null');
|
|
3490
|
-
const rawAddress = this.hash160(
|
|
3491
|
-
const words = toWords(
|
|
3492
|
-
const address = encode(this.prefix, words);
|
|
3516
|
+
const rawAddress = this.hash160(pubKey);
|
|
3517
|
+
const words = bech32.toWords(new Uint8Array(rawAddress));
|
|
3518
|
+
const address = bech32.encode(this.prefix, words);
|
|
3493
3519
|
return address;
|
|
3494
3520
|
}
|
|
3495
3521
|
/**
|
|
@@ -3945,4 +3971,4 @@ class ClientLedger extends Client {
|
|
|
3945
3971
|
}
|
|
3946
3972
|
}
|
|
3947
3973
|
|
|
3948
|
-
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
|
@@ -6,8 +6,8 @@ var protoSigning = require('@cosmjs/proto-signing');
|
|
|
6
6
|
var stargate = require('@cosmjs/stargate');
|
|
7
7
|
var xchainCosmosSdk = require('@xchainjs/xchain-cosmos-sdk');
|
|
8
8
|
var xchainCrypto = require('@xchainjs/xchain-crypto');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var base = require('@scure/base');
|
|
10
|
+
var BigNumber = require('bignumber.js');
|
|
11
11
|
var bip32 = require('@scure/bip32');
|
|
12
12
|
var tx = require('cosmjs-types/cosmos/tx/v1beta1/tx');
|
|
13
13
|
var crypto = require('crypto');
|
|
@@ -40,6 +40,7 @@ function _interopNamespace(e) {
|
|
|
40
40
|
return Object.freeze(n);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
|
|
43
44
|
var secp__namespace = /*#__PURE__*/_interopNamespace(secp);
|
|
44
45
|
var minimal__namespace = /*#__PURE__*/_interopNamespace(minimal);
|
|
45
46
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
@@ -3118,6 +3119,13 @@ const isAssetRuneNative = (asset) => xchainUtil.assetToString(asset) === xchainU
|
|
|
3118
3119
|
* @returns {boolean} `true` or `false`
|
|
3119
3120
|
*/
|
|
3120
3121
|
const isTCYAsset = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetTCY);
|
|
3122
|
+
/**
|
|
3123
|
+
* Checks whether an asset is the native RUJI asset
|
|
3124
|
+
*
|
|
3125
|
+
* @param {CompatibleAsset} asset
|
|
3126
|
+
* @returns {boolean} `true` or `false`
|
|
3127
|
+
*/
|
|
3128
|
+
const isRUJIAsset = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetRUJI);
|
|
3121
3129
|
/**
|
|
3122
3130
|
* Get denomination from Asset
|
|
3123
3131
|
*
|
|
@@ -3133,6 +3141,8 @@ const getDenom = (asset) => {
|
|
|
3133
3141
|
return xchainUtil.assetToString(asset).toLowerCase();
|
|
3134
3142
|
if (isTCYAsset(asset))
|
|
3135
3143
|
return TCY_DENOM;
|
|
3144
|
+
if (isRUJIAsset(asset))
|
|
3145
|
+
return RUJI_DENOM;
|
|
3136
3146
|
return xchainUtil.assetToString(asset).toLowerCase();
|
|
3137
3147
|
};
|
|
3138
3148
|
/**
|
|
@@ -3249,6 +3259,10 @@ const RUNE_DENOM = 'rune';
|
|
|
3249
3259
|
* Denomination of the TCY asset
|
|
3250
3260
|
*/
|
|
3251
3261
|
const TCY_DENOM = 'tcy';
|
|
3262
|
+
/**
|
|
3263
|
+
* Denomination of the ruji asset
|
|
3264
|
+
*/
|
|
3265
|
+
const RUJI_DENOM = 'x/ruji';
|
|
3252
3266
|
/**
|
|
3253
3267
|
* Ticker symbol for the RUNE asset
|
|
3254
3268
|
*/
|
|
@@ -3257,6 +3271,10 @@ const RUNE_TICKER = 'RUNE';
|
|
|
3257
3271
|
* Ticker symbol for the TCY asset
|
|
3258
3272
|
*/
|
|
3259
3273
|
const TCY_TICKER = 'TCY';
|
|
3274
|
+
/**
|
|
3275
|
+
* Ticker symbol for the RUJI asset
|
|
3276
|
+
*/
|
|
3277
|
+
const RUJI_TICKER = 'RUJI';
|
|
3260
3278
|
/**
|
|
3261
3279
|
* Default fee used by the client to make transactions
|
|
3262
3280
|
*/
|
|
@@ -3291,6 +3309,15 @@ const AssetTCY = {
|
|
|
3291
3309
|
ticker: TCY_TICKER,
|
|
3292
3310
|
type: xchainUtil.AssetType.TOKEN,
|
|
3293
3311
|
};
|
|
3312
|
+
/**
|
|
3313
|
+
* Native asset representation for TCY in Thorchain
|
|
3314
|
+
*/
|
|
3315
|
+
const AssetRUJI = {
|
|
3316
|
+
chain: THORChain,
|
|
3317
|
+
symbol: RUJI_TICKER,
|
|
3318
|
+
ticker: RUJI_TICKER,
|
|
3319
|
+
type: xchainUtil.AssetType.NATIVE,
|
|
3320
|
+
};
|
|
3294
3321
|
/**
|
|
3295
3322
|
* Message type URL used to make send transactions
|
|
3296
3323
|
*/
|
|
@@ -3514,9 +3541,9 @@ class ClientKeystore extends Client {
|
|
|
3514
3541
|
const pubKey = secp__namespace.pointFromScalar(child.privateKey, true);
|
|
3515
3542
|
if (!pubKey)
|
|
3516
3543
|
throw new Error('pubKey is null');
|
|
3517
|
-
const rawAddress = this.hash160(
|
|
3518
|
-
const words = bech32.toWords(
|
|
3519
|
-
const address = bech32.encode(this.prefix, words);
|
|
3544
|
+
const rawAddress = this.hash160(pubKey);
|
|
3545
|
+
const words = base.bech32.toWords(new Uint8Array(rawAddress));
|
|
3546
|
+
const address = base.bech32.encode(this.prefix, words);
|
|
3520
3547
|
return address;
|
|
3521
3548
|
}
|
|
3522
3549
|
/**
|
|
@@ -3595,7 +3622,7 @@ class ClientKeystore extends Client {
|
|
|
3595
3622
|
* value of 600000000 will be used
|
|
3596
3623
|
* @returns {string} The deposit hash
|
|
3597
3624
|
*/
|
|
3598
|
-
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new
|
|
3625
|
+
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new BigNumber__default.default(DEPOSIT_GAS_LIMIT_VALUE), }) {
|
|
3599
3626
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3600
3627
|
// Get sender address
|
|
3601
3628
|
const sender = yield this.getAddressAsync(walletIndex);
|
|
@@ -3613,7 +3640,7 @@ class ClientKeystore extends Client {
|
|
|
3613
3640
|
*
|
|
3614
3641
|
* @deprecated Use prepare Tx instead
|
|
3615
3642
|
*/
|
|
3616
|
-
transferOffline({ walletIndex = 0, recipient, asset, amount, memo, gasLimit = new
|
|
3643
|
+
transferOffline({ walletIndex = 0, recipient, asset, amount, memo, gasLimit = new BigNumber__default.default(DEFAULT_GAS_LIMIT_VALUE), }) {
|
|
3617
3644
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3618
3645
|
// Get sender address
|
|
3619
3646
|
const sender = yield this.getAddressAsync(walletIndex);
|
|
@@ -3815,7 +3842,7 @@ class ClientLedger extends Client {
|
|
|
3815
3842
|
* value of 600000000 will be used
|
|
3816
3843
|
* @returns {string} The deposit hash
|
|
3817
3844
|
*/
|
|
3818
|
-
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new
|
|
3845
|
+
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new BigNumber__default.default(DEPOSIT_GAS_LIMIT_VALUE), }) {
|
|
3819
3846
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3820
3847
|
const sender = yield this.getAddressAsync(walletIndex || 0);
|
|
3821
3848
|
const account = yield this.getAccount(sender);
|
|
@@ -3972,6 +3999,7 @@ class ClientLedger extends Client {
|
|
|
3972
3999
|
}
|
|
3973
4000
|
}
|
|
3974
4001
|
|
|
4002
|
+
exports.AssetRUJI = AssetRUJI;
|
|
3975
4003
|
exports.AssetRuneNative = AssetRuneNative;
|
|
3976
4004
|
exports.AssetTCY = AssetTCY;
|
|
3977
4005
|
exports.Client = ClientKeystore;
|
|
@@ -3983,6 +4011,8 @@ exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
|
|
|
3983
4011
|
exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
|
|
3984
4012
|
exports.MSG_DEPOSIT_TYPE_URL = MSG_DEPOSIT_TYPE_URL;
|
|
3985
4013
|
exports.MSG_SEND_TYPE_URL = MSG_SEND_TYPE_URL;
|
|
4014
|
+
exports.RUJI_DENOM = RUJI_DENOM;
|
|
4015
|
+
exports.RUJI_TICKER = RUJI_TICKER;
|
|
3986
4016
|
exports.RUNE_DECIMAL = RUNE_DECIMAL;
|
|
3987
4017
|
exports.RUNE_DENOM = RUNE_DENOM;
|
|
3988
4018
|
exports.RUNE_TICKER = RUNE_TICKER;
|
|
@@ -3999,6 +4029,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
3999
4029
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
4000
4030
|
exports.getPrefix = getPrefix;
|
|
4001
4031
|
exports.isAssetRuneNative = isAssetRuneNative;
|
|
4032
|
+
exports.isRUJIAsset = isRUJIAsset;
|
|
4002
4033
|
exports.isTCYAsset = isTCYAsset;
|
|
4003
4034
|
exports.parseAssetToTHORNodeAsset = parseAssetToTHORNodeAsset;
|
|
4004
4035
|
exports.parseDerivationPath = parseDerivationPath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompatibleAsset, Tx, TxParams as BaseTxParams } from '@xchainjs/xchain-cosmos-sdk';
|
|
2
2
|
import { BaseAmount } from '@xchainjs/xchain-util';
|
|
3
|
-
import
|
|
3
|
+
import type BigNumber from 'bignumber.js';
|
|
4
4
|
export type DepositParam = {
|
|
5
5
|
walletIndex?: number;
|
|
6
6
|
asset?: CompatibleAsset;
|
|
@@ -16,4 +16,4 @@ export type TxParams = BaseTxParams & {
|
|
|
16
16
|
export type TxOfflineParams = TxParams & {
|
|
17
17
|
gasLimit?: BigNumber;
|
|
18
18
|
};
|
|
19
|
-
export { CompatibleAsset };
|
|
19
|
+
export type { CompatibleAsset };
|
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.8",
|
|
4
4
|
"description": "Custom Thorchain client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"build": "yarn clean && rollup -c --bundleConfigAsCjs",
|
|
29
29
|
"build:release": "yarn exec rm -rf release && yarn pack && yarn exec \"mkdir release && tar zxvf package.tgz --directory release && rm package.tgz\"",
|
|
30
30
|
"test": "jest",
|
|
31
|
-
"e2e": "jest --config jest.config.e2e.
|
|
31
|
+
"e2e": "jest --config jest.config.e2e.mjs",
|
|
32
32
|
"lint": "eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0",
|
|
33
33
|
"start:example": "ts-node example/index.ts",
|
|
34
34
|
"generate:ThorchainMsgs": "./genMsgs.sh"
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@cosmjs/proto-signing": "0.33.1",
|
|
43
43
|
"@cosmjs/stargate": "0.33.1",
|
|
44
44
|
"@ledgerhq/hw-transport": "^6.31.6",
|
|
45
|
+
"@scure/base": "^1.2.6",
|
|
45
46
|
"@scure/bip32": "^1.7.0",
|
|
46
47
|
"@xchainjs/ledger-thorchain": "0.3.0",
|
|
47
|
-
"@xchainjs/xchain-client": "2.0.
|
|
48
|
-
"@xchainjs/xchain-cosmos-sdk": "2.0.
|
|
49
|
-
"@xchainjs/xchain-crypto": "1.0.
|
|
50
|
-
"@xchainjs/xchain-util": "2.0.
|
|
48
|
+
"@xchainjs/xchain-client": "2.0.4",
|
|
49
|
+
"@xchainjs/xchain-cosmos-sdk": "2.0.4",
|
|
50
|
+
"@xchainjs/xchain-crypto": "1.0.2",
|
|
51
|
+
"@xchainjs/xchain-util": "2.0.3",
|
|
51
52
|
"axios": "1.8.4",
|
|
52
|
-
"bech32": "^1.1.3",
|
|
53
53
|
"bignumber.js": "^9.0.0",
|
|
54
54
|
"cosmjs-types": "0.9.0",
|
|
55
55
|
"protobufjs": "6.11.4"
|