@xchainjs/xchain-thorchain 1.0.7 → 1.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/client.d.ts +31 -0
- package/lib/index.esm.js +100 -46
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +100 -46
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/package.json +7 -7
package/lib/client.d.ts
CHANGED
|
@@ -168,4 +168,35 @@ export declare class Client extends CosmosSDKClient implements ThorchainClient {
|
|
|
168
168
|
* @returns {Uint8Array} The hashed buffer
|
|
169
169
|
*/
|
|
170
170
|
private hash160;
|
|
171
|
+
/**
|
|
172
|
+
* Sign a transaction making a round robin over the clients urls provided to the client
|
|
173
|
+
*
|
|
174
|
+
* @param {string} sender Sender address
|
|
175
|
+
* @param {DecodedTxRaw} unsignedTx Unsigned transaction
|
|
176
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
177
|
+
* @param {BigNumber} gasLimit Transaction gas limit
|
|
178
|
+
* @returns {TxRaw} The raw signed transaction
|
|
179
|
+
*/
|
|
180
|
+
private roundRobinSign;
|
|
181
|
+
/**
|
|
182
|
+
* Sign and broadcast a transaction making a round robin over the clients urls provided to the client
|
|
183
|
+
*
|
|
184
|
+
* @param {string} sender Sender address
|
|
185
|
+
* @param {DecodedTxRaw} unsignedTx Unsigned transaction
|
|
186
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
187
|
+
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
188
|
+
*/
|
|
189
|
+
private roundRobinSignAndBroadcastTx;
|
|
190
|
+
/**
|
|
191
|
+
* Sign and broadcast a transaction making a round robin over the clients urls provided to the client
|
|
192
|
+
*
|
|
193
|
+
* @param {string} sender Sender address
|
|
194
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
195
|
+
* @param {BigNumber} gasLimit Gas limit for the transaction
|
|
196
|
+
* @param {BaseAmount} amount Amount to deposit
|
|
197
|
+
* @param {string} memo Deposit memo
|
|
198
|
+
* @param {Asset} asset Asset to deposit
|
|
199
|
+
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
200
|
+
*/
|
|
201
|
+
private roundRobinSignAndBroadcastDeposit;
|
|
171
202
|
}
|
package/lib/index.esm.js
CHANGED
|
@@ -127544,9 +127544,9 @@ var types = /*@__PURE__*/getDefaultExportFromCjs(MsgCompiled);
|
|
|
127544
127544
|
*/
|
|
127545
127545
|
const getDefaultClientUrls = () => {
|
|
127546
127546
|
return {
|
|
127547
|
-
[Network.Testnet]: 'deprecated',
|
|
127548
|
-
[Network.Stagenet]: 'https://stagenet-rpc.ninerealms.com',
|
|
127549
|
-
[Network.Mainnet]: 'https://rpc-v1.ninerealms.com',
|
|
127547
|
+
[Network.Testnet]: ['deprecated'],
|
|
127548
|
+
[Network.Stagenet]: ['https://stagenet-rpc.ninerealms.com'],
|
|
127549
|
+
[Network.Mainnet]: ['https://rpc-v1.ninerealms.com'],
|
|
127550
127550
|
};
|
|
127551
127551
|
};
|
|
127552
127552
|
/**
|
|
@@ -127753,13 +127753,7 @@ class Client extends Client$1 {
|
|
|
127753
127753
|
prefix: this.prefix,
|
|
127754
127754
|
hdPaths: [makeClientPath(this.getFullDerivationPath(params.walletIndex || 0))],
|
|
127755
127755
|
});
|
|
127756
|
-
const
|
|
127757
|
-
registry: this.registry,
|
|
127758
|
-
});
|
|
127759
|
-
const messages = unsignedTx.body.messages.map((message) => {
|
|
127760
|
-
return { typeUrl: this.getMsgTypeUrlByType(MsgTypes.TRANSFER), value: signingClient.registry.decode(message) };
|
|
127761
|
-
});
|
|
127762
|
-
const tx = yield signingClient.signAndBroadcast(sender, messages, this.getStandardFee(), unsignedTx.body.memo);
|
|
127756
|
+
const tx = yield this.roundRobinSignAndBroadcastTx(sender, unsignedTx, signer);
|
|
127763
127757
|
return tx.transactionHash;
|
|
127764
127758
|
});
|
|
127765
127759
|
}
|
|
@@ -127904,29 +127898,7 @@ class Client extends Client$1 {
|
|
|
127904
127898
|
prefix: this.prefix,
|
|
127905
127899
|
hdPaths: [makeClientPath(this.getFullDerivationPath(walletIndex || 0))],
|
|
127906
127900
|
});
|
|
127907
|
-
|
|
127908
|
-
const signingClient = yield build$7.SigningStargateClient.connectWithSigner(this.clientUrls[this.network], signer, {
|
|
127909
|
-
registry: this.registry,
|
|
127910
|
-
});
|
|
127911
|
-
// Sign and broadcast transaction
|
|
127912
|
-
const tx = yield signingClient.signAndBroadcast(sender, [
|
|
127913
|
-
{
|
|
127914
|
-
typeUrl: MSG_DEPOSIT_TYPE_URL,
|
|
127915
|
-
value: {
|
|
127916
|
-
signer: bech32ToBase64(sender),
|
|
127917
|
-
memo,
|
|
127918
|
-
coins: [
|
|
127919
|
-
{
|
|
127920
|
-
amount: amount.amount().toString(),
|
|
127921
|
-
asset,
|
|
127922
|
-
},
|
|
127923
|
-
],
|
|
127924
|
-
},
|
|
127925
|
-
},
|
|
127926
|
-
], {
|
|
127927
|
-
amount: [],
|
|
127928
|
-
gas: gasLimit.toString(),
|
|
127929
|
-
}, memo);
|
|
127901
|
+
const tx = yield this.roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset);
|
|
127930
127902
|
return tx.transactionHash;
|
|
127931
127903
|
});
|
|
127932
127904
|
}
|
|
@@ -127954,19 +127926,7 @@ class Client extends Client$1 {
|
|
|
127954
127926
|
prefix: this.prefix,
|
|
127955
127927
|
hdPaths: [makeClientPath(this.getFullDerivationPath(walletIndex))],
|
|
127956
127928
|
});
|
|
127957
|
-
|
|
127958
|
-
const signingClient = yield build$7.SigningStargateClient.connectWithSigner(this.clientUrls[this.network], signer, {
|
|
127959
|
-
registry: this.registry,
|
|
127960
|
-
});
|
|
127961
|
-
// Prepare messages
|
|
127962
|
-
const messages = unsignedTx.body.messages.map((message) => {
|
|
127963
|
-
return { typeUrl: this.getMsgTypeUrlByType(MsgTypes.TRANSFER), value: signingClient.registry.decode(message) };
|
|
127964
|
-
});
|
|
127965
|
-
// Sign transaction
|
|
127966
|
-
const rawTx = yield signingClient.sign(sender, messages, {
|
|
127967
|
-
amount: [],
|
|
127968
|
-
gas: gasLimit.toString(),
|
|
127969
|
-
}, unsignedTx.body.memo);
|
|
127929
|
+
const rawTx = yield this.roundRobinSign(sender, unsignedTx, signer, gasLimit);
|
|
127970
127930
|
// Return encoded signed transaction
|
|
127971
127931
|
return toBase64(tx$1.TxRaw.encode(rawTx).finish());
|
|
127972
127932
|
});
|
|
@@ -128049,6 +128009,100 @@ class Client extends Client$1 {
|
|
|
128049
128009
|
return createHash('ripemd160').update(sha256Hash).digest();
|
|
128050
128010
|
}
|
|
128051
128011
|
}
|
|
128012
|
+
/**
|
|
128013
|
+
* Sign a transaction making a round robin over the clients urls provided to the client
|
|
128014
|
+
*
|
|
128015
|
+
* @param {string} sender Sender address
|
|
128016
|
+
* @param {DecodedTxRaw} unsignedTx Unsigned transaction
|
|
128017
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
128018
|
+
* @param {BigNumber} gasLimit Transaction gas limit
|
|
128019
|
+
* @returns {TxRaw} The raw signed transaction
|
|
128020
|
+
*/
|
|
128021
|
+
roundRobinSign(sender, unsignedTx, signer, gasLimit) {
|
|
128022
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128023
|
+
// Connect to signing client
|
|
128024
|
+
for (const url of this.clientUrls[this.network]) {
|
|
128025
|
+
const signingClient = yield build$7.SigningStargateClient.connectWithSigner(url, signer, {
|
|
128026
|
+
registry: this.registry,
|
|
128027
|
+
});
|
|
128028
|
+
// Prepare messages
|
|
128029
|
+
const messages = unsignedTx.body.messages.map((message) => {
|
|
128030
|
+
return { typeUrl: this.getMsgTypeUrlByType(MsgTypes.TRANSFER), value: signingClient.registry.decode(message) };
|
|
128031
|
+
});
|
|
128032
|
+
// Sign transaction
|
|
128033
|
+
return yield signingClient.sign(sender, messages, {
|
|
128034
|
+
amount: [],
|
|
128035
|
+
gas: gasLimit.toString(),
|
|
128036
|
+
}, unsignedTx.body.memo);
|
|
128037
|
+
}
|
|
128038
|
+
throw Error('No clients available. Can not sign transaction');
|
|
128039
|
+
});
|
|
128040
|
+
}
|
|
128041
|
+
/**
|
|
128042
|
+
* Sign and broadcast a transaction making a round robin over the clients urls provided to the client
|
|
128043
|
+
*
|
|
128044
|
+
* @param {string} sender Sender address
|
|
128045
|
+
* @param {DecodedTxRaw} unsignedTx Unsigned transaction
|
|
128046
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
128047
|
+
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
128048
|
+
*/
|
|
128049
|
+
roundRobinSignAndBroadcastTx(sender, unsignedTx, signer) {
|
|
128050
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128051
|
+
for (const url of this.clientUrls[this.network]) {
|
|
128052
|
+
const signingClient = yield build$7.SigningStargateClient.connectWithSigner(url, signer, {
|
|
128053
|
+
registry: this.registry,
|
|
128054
|
+
});
|
|
128055
|
+
const messages = unsignedTx.body.messages.map((message) => {
|
|
128056
|
+
return { typeUrl: this.getMsgTypeUrlByType(MsgTypes.TRANSFER), value: signingClient.registry.decode(message) };
|
|
128057
|
+
});
|
|
128058
|
+
return yield signingClient.signAndBroadcast(sender, messages, this.getStandardFee(), unsignedTx.body.memo);
|
|
128059
|
+
}
|
|
128060
|
+
throw Error('No clients available. Can not sign and broadcast transaction');
|
|
128061
|
+
});
|
|
128062
|
+
}
|
|
128063
|
+
/**
|
|
128064
|
+
* Sign and broadcast a transaction making a round robin over the clients urls provided to the client
|
|
128065
|
+
*
|
|
128066
|
+
* @param {string} sender Sender address
|
|
128067
|
+
* @param {DirectSecp256k1HdWallet} signer Signer
|
|
128068
|
+
* @param {BigNumber} gasLimit Gas limit for the transaction
|
|
128069
|
+
* @param {BaseAmount} amount Amount to deposit
|
|
128070
|
+
* @param {string} memo Deposit memo
|
|
128071
|
+
* @param {Asset} asset Asset to deposit
|
|
128072
|
+
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
128073
|
+
*/
|
|
128074
|
+
roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset) {
|
|
128075
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128076
|
+
for (const url of this.clientUrls[this.network]) {
|
|
128077
|
+
try {
|
|
128078
|
+
const signingClient = yield build$7.SigningStargateClient.connectWithSigner(url, signer, {
|
|
128079
|
+
registry: this.registry,
|
|
128080
|
+
});
|
|
128081
|
+
// Sign and broadcast transaction
|
|
128082
|
+
return yield signingClient.signAndBroadcast(sender, [
|
|
128083
|
+
{
|
|
128084
|
+
typeUrl: MSG_DEPOSIT_TYPE_URL,
|
|
128085
|
+
value: {
|
|
128086
|
+
signer: bech32ToBase64(sender),
|
|
128087
|
+
memo,
|
|
128088
|
+
coins: [
|
|
128089
|
+
{
|
|
128090
|
+
amount: amount.amount().toString(),
|
|
128091
|
+
asset,
|
|
128092
|
+
},
|
|
128093
|
+
],
|
|
128094
|
+
},
|
|
128095
|
+
},
|
|
128096
|
+
], {
|
|
128097
|
+
amount: [],
|
|
128098
|
+
gas: gasLimit.toString(),
|
|
128099
|
+
}, memo);
|
|
128100
|
+
}
|
|
128101
|
+
catch (_a) { }
|
|
128102
|
+
}
|
|
128103
|
+
throw Error('No clients available. Can not sign and broadcast deposit transaction');
|
|
128104
|
+
});
|
|
128105
|
+
}
|
|
128052
128106
|
}
|
|
128053
128107
|
|
|
128054
128108
|
export { AssetRuneNative, Client, 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, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative };
|