@xchainjs/xchain-thorchain 0.27.2 → 0.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.d.ts +4 -3
- package/lib/index.esm.js +21 -8
- package/lib/index.js +22 -7
- package/lib/types/client-types.d.ts +1 -0
- package/lib/util.d.ts +2 -0
- package/package.json +5 -5
package/lib/client.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
33
33
|
*
|
|
34
34
|
* @throws {"Invalid phrase"} Thrown if the given phase is invalid.
|
|
35
35
|
*/
|
|
36
|
-
constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
|
|
36
|
+
constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, customRequestHeaders, }: XChainClientParams & ThorchainClientParams);
|
|
37
37
|
/**
|
|
38
38
|
* Set/update the current network.
|
|
39
39
|
*
|
|
@@ -185,7 +185,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
185
185
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
186
186
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
187
187
|
*/
|
|
188
|
-
deposit({ walletIndex, asset, amount, memo, gasLimit, }: DepositParam): Promise<TxHash>;
|
|
188
|
+
deposit({ walletIndex, asset, amount, memo, gasLimit, sequence, }: DepositParam): Promise<TxHash>;
|
|
189
189
|
/**
|
|
190
190
|
* Transfer balances with MsgSend
|
|
191
191
|
*
|
|
@@ -195,8 +195,9 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
195
195
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
196
196
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
197
197
|
*/
|
|
198
|
-
transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, }: TxParams & {
|
|
198
|
+
transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, sequence, }: TxParams & {
|
|
199
199
|
gasLimit?: BigNumber;
|
|
200
|
+
sequence?: number;
|
|
200
201
|
}): Promise<TxHash>;
|
|
201
202
|
/**
|
|
202
203
|
* Transfer without broadcast balances with MsgSend
|
package/lib/index.esm.js
CHANGED
|
@@ -9934,7 +9934,16 @@ const getExplorerTxUrl = ({ urls, network, txID, }) => {
|
|
|
9934
9934
|
case Network.Testnet:
|
|
9935
9935
|
return `${url}?network=testnet`;
|
|
9936
9936
|
}
|
|
9937
|
-
};
|
|
9937
|
+
};
|
|
9938
|
+
const getAccount = (address, client) => {
|
|
9939
|
+
const accAddress = cosmosclient.AccAddress.fromString(address);
|
|
9940
|
+
return client.getAccount(accAddress);
|
|
9941
|
+
};
|
|
9942
|
+
const getSequence = (address, client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9943
|
+
var _e;
|
|
9944
|
+
const { sequence } = yield getAccount(address, client);
|
|
9945
|
+
return (_e = sequence === null || sequence === void 0 ? void 0 : sequence.toNumber()) !== null && _e !== void 0 ? _e : null;
|
|
9946
|
+
});
|
|
9938
9947
|
|
|
9939
9948
|
/**
|
|
9940
9949
|
* Custom Thorchain Client
|
|
@@ -9971,8 +9980,8 @@ class Client extends BaseXChainClient {
|
|
|
9971
9980
|
[Network.Mainnet]: 'thorchain-mainnet-v1',
|
|
9972
9981
|
[Network.Stagenet]: 'thorchain-stagenet-v2',
|
|
9973
9982
|
[Network.Testnet]: 'deprecated',
|
|
9974
|
-
}, }) {
|
|
9975
|
-
super(Chain.Cosmos, { network, rootDerivationPaths, phrase });
|
|
9983
|
+
}, customRequestHeaders = {}, }) {
|
|
9984
|
+
super(Chain.Cosmos, { network, rootDerivationPaths, phrase, customRequestHeaders });
|
|
9976
9985
|
/**
|
|
9977
9986
|
* Get transaction history of a given address with pagination options.
|
|
9978
9987
|
* By default it will return the transaction history of the current wallet.
|
|
@@ -10029,10 +10038,14 @@ class Client extends BaseXChainClient {
|
|
|
10029
10038
|
this.chainIds = chainIds;
|
|
10030
10039
|
registerSendCodecs();
|
|
10031
10040
|
registerDepositCodecs();
|
|
10041
|
+
if (this.clientUrl[Network.Mainnet].node.includes('ninerealms.com') && !this.customRequestHeaders['x-client-id']) {
|
|
10042
|
+
this.customRequestHeaders['x-client-id'] = 'xchainjs-client';
|
|
10043
|
+
}
|
|
10032
10044
|
this.cosmosClient = new CosmosSDKClient({
|
|
10033
10045
|
server: this.getClientUrl().node,
|
|
10034
10046
|
chainId: this.getChainId(network),
|
|
10035
10047
|
prefix: getPrefix(network),
|
|
10048
|
+
headers: this.customRequestHeaders,
|
|
10036
10049
|
});
|
|
10037
10050
|
}
|
|
10038
10051
|
/**
|
|
@@ -10264,7 +10277,7 @@ class Client extends BaseXChainClient {
|
|
|
10264
10277
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
10265
10278
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
10266
10279
|
*/
|
|
10267
|
-
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
|
|
10280
|
+
deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10268
10281
|
var _a, _b, _c, _d;
|
|
10269
10282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10270
10283
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
@@ -10310,7 +10323,7 @@ class Client extends BaseXChainClient {
|
|
|
10310
10323
|
txBody: depositTxBody,
|
|
10311
10324
|
signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
|
|
10312
10325
|
gasLimit: long_1.fromString(gasLimit.toFixed(0)),
|
|
10313
|
-
sequence: account.sequence || long_1.ZERO,
|
|
10326
|
+
sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
|
|
10314
10327
|
});
|
|
10315
10328
|
const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10316
10329
|
if (!txHash)
|
|
@@ -10327,7 +10340,7 @@ class Client extends BaseXChainClient {
|
|
|
10327
10340
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
10328
10341
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
10329
10342
|
*/
|
|
10330
|
-
transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
|
|
10343
|
+
transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10331
10344
|
var _a, _b, _c, _d;
|
|
10332
10345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10333
10346
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
@@ -10369,7 +10382,7 @@ class Client extends BaseXChainClient {
|
|
|
10369
10382
|
txBody: txBody,
|
|
10370
10383
|
gasLimit: long_1.fromString(gasLimit.toString()),
|
|
10371
10384
|
signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
|
|
10372
|
-
sequence: account.sequence || long_1.ZERO,
|
|
10385
|
+
sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
|
|
10373
10386
|
});
|
|
10374
10387
|
const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10375
10388
|
if (!txHash)
|
|
@@ -10458,4 +10471,4 @@ const msgNativeTxFromJson = (value) => {
|
|
|
10458
10471
|
return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
|
|
10459
10472
|
};
|
|
10460
10473
|
|
|
10461
|
-
export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
|
|
10474
|
+
export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
|
package/lib/index.js
CHANGED
|
@@ -9942,7 +9942,16 @@ const getExplorerTxUrl = ({ urls, network, txID, }) => {
|
|
|
9942
9942
|
case xchainClient.Network.Testnet:
|
|
9943
9943
|
return `${url}?network=testnet`;
|
|
9944
9944
|
}
|
|
9945
|
-
};
|
|
9945
|
+
};
|
|
9946
|
+
const getAccount = (address, client) => {
|
|
9947
|
+
const accAddress = core.cosmosclient.AccAddress.fromString(address);
|
|
9948
|
+
return client.getAccount(accAddress);
|
|
9949
|
+
};
|
|
9950
|
+
const getSequence = (address, client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9951
|
+
var _e;
|
|
9952
|
+
const { sequence } = yield getAccount(address, client);
|
|
9953
|
+
return (_e = sequence === null || sequence === void 0 ? void 0 : sequence.toNumber()) !== null && _e !== void 0 ? _e : null;
|
|
9954
|
+
});
|
|
9946
9955
|
|
|
9947
9956
|
/**
|
|
9948
9957
|
* Custom Thorchain Client
|
|
@@ -9979,8 +9988,8 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
9979
9988
|
[xchainClient.Network.Mainnet]: 'thorchain-mainnet-v1',
|
|
9980
9989
|
[xchainClient.Network.Stagenet]: 'thorchain-stagenet-v2',
|
|
9981
9990
|
[xchainClient.Network.Testnet]: 'deprecated',
|
|
9982
|
-
}, }) {
|
|
9983
|
-
super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase });
|
|
9991
|
+
}, customRequestHeaders = {}, }) {
|
|
9992
|
+
super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase, customRequestHeaders });
|
|
9984
9993
|
/**
|
|
9985
9994
|
* Get transaction history of a given address with pagination options.
|
|
9986
9995
|
* By default it will return the transaction history of the current wallet.
|
|
@@ -10037,10 +10046,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10037
10046
|
this.chainIds = chainIds;
|
|
10038
10047
|
registerSendCodecs();
|
|
10039
10048
|
registerDepositCodecs();
|
|
10049
|
+
if (this.clientUrl[xchainClient.Network.Mainnet].node.includes('ninerealms.com') && !this.customRequestHeaders['x-client-id']) {
|
|
10050
|
+
this.customRequestHeaders['x-client-id'] = 'xchainjs-client';
|
|
10051
|
+
}
|
|
10040
10052
|
this.cosmosClient = new xchainCosmos.CosmosSDKClient({
|
|
10041
10053
|
server: this.getClientUrl().node,
|
|
10042
10054
|
chainId: this.getChainId(network),
|
|
10043
10055
|
prefix: getPrefix(network),
|
|
10056
|
+
headers: this.customRequestHeaders,
|
|
10044
10057
|
});
|
|
10045
10058
|
}
|
|
10046
10059
|
/**
|
|
@@ -10272,7 +10285,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10272
10285
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
10273
10286
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
10274
10287
|
*/
|
|
10275
|
-
deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
|
|
10288
|
+
deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10276
10289
|
var _a, _b, _c, _d;
|
|
10277
10290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10278
10291
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
@@ -10318,7 +10331,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10318
10331
|
txBody: depositTxBody,
|
|
10319
10332
|
signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
|
|
10320
10333
|
gasLimit: long_1.fromString(gasLimit.toFixed(0)),
|
|
10321
|
-
sequence: account.sequence || long_1.ZERO,
|
|
10334
|
+
sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
|
|
10322
10335
|
});
|
|
10323
10336
|
const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10324
10337
|
if (!txHash)
|
|
@@ -10335,7 +10348,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10335
10348
|
* @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
|
|
10336
10349
|
* @throws {"Invalid transaction hash"} Thrown by missing tx hash
|
|
10337
10350
|
*/
|
|
10338
|
-
transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
|
|
10351
|
+
transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
|
|
10339
10352
|
var _a, _b, _c, _d;
|
|
10340
10353
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10341
10354
|
const balances = yield this.getBalance(this.getAddress(walletIndex));
|
|
@@ -10377,7 +10390,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10377
10390
|
txBody: txBody,
|
|
10378
10391
|
gasLimit: long_1.fromString(gasLimit.toString()),
|
|
10379
10392
|
signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
|
|
10380
|
-
sequence: account.sequence || long_1.ZERO,
|
|
10393
|
+
sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
|
|
10381
10394
|
});
|
|
10382
10395
|
const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
|
|
10383
10396
|
if (!txHash)
|
|
@@ -10478,6 +10491,7 @@ exports.buildDepositTx = buildDepositTx;
|
|
|
10478
10491
|
exports.buildTransferTx = buildTransferTx;
|
|
10479
10492
|
exports.buildUnsignedTx = buildUnsignedTx;
|
|
10480
10493
|
exports.defaultExplorerUrls = defaultExplorerUrls;
|
|
10494
|
+
exports.getAccount = getAccount;
|
|
10481
10495
|
exports.getBalance = getBalance;
|
|
10482
10496
|
exports.getChainId = getChainId;
|
|
10483
10497
|
exports.getDefaultFees = getDefaultFees;
|
|
@@ -10488,6 +10502,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
10488
10502
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
10489
10503
|
exports.getExplorerUrl = getExplorerUrl;
|
|
10490
10504
|
exports.getPrefix = getPrefix;
|
|
10505
|
+
exports.getSequence = getSequence;
|
|
10491
10506
|
exports.getTxType = getTxType;
|
|
10492
10507
|
exports.isBroadcastSuccess = isBroadcastSuccess;
|
|
10493
10508
|
exports.msgNativeTxFromJson = msgNativeTxFromJson;
|
package/lib/util.d.ts
CHANGED
|
@@ -191,3 +191,5 @@ export declare const getExplorerTxUrl: ({ urls, network, txID, }: {
|
|
|
191
191
|
network: Network;
|
|
192
192
|
txID: TxHash;
|
|
193
193
|
}) => string;
|
|
194
|
+
export declare const getAccount: (address: string, client: CosmosSDKClient) => Promise<proto.cosmos.auth.v1beta1.IBaseAccount>;
|
|
195
|
+
export declare const getSequence: (address: string, client: CosmosSDKClient) => Promise<number | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.5",
|
|
4
4
|
"description": "Custom Thorchain client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@cosmos-client/core": "0.45.13",
|
|
38
38
|
"@types/big.js": "^6.0.0",
|
|
39
|
-
"@xchainjs/xchain-client": "^0.13.
|
|
40
|
-
"@xchainjs/xchain-cosmos": "^0.20.
|
|
39
|
+
"@xchainjs/xchain-client": "^0.13.3",
|
|
40
|
+
"@xchainjs/xchain-cosmos": "^0.20.4",
|
|
41
41
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
42
42
|
"@xchainjs/xchain-util": "^0.11.0",
|
|
43
43
|
"axios": "^0.25.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@cosmos-client/core": "0.45.13",
|
|
52
|
-
"@xchainjs/xchain-client": "^0.13.
|
|
53
|
-
"@xchainjs/xchain-cosmos": "^0.
|
|
52
|
+
"@xchainjs/xchain-client": "^0.13.3",
|
|
53
|
+
"@xchainjs/xchain-cosmos": "^0.20.4",
|
|
54
54
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
55
55
|
"@xchainjs/xchain-util": "^0.11.0",
|
|
56
56
|
"axios": "^0.25.0",
|