@injectivelabs/wallet-core 1.19.15 → 1.19.16
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/dist/cjs/index.cjs +15 -20
- package/dist/cjs/index.d.cts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +15 -20
- package/package.json +7 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -420,10 +420,8 @@ var MsgBroadcaster = class {
|
|
|
420
420
|
var _tx$gas, _baseAccount$pubKey;
|
|
421
421
|
const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
|
|
422
422
|
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
|
|
423
|
-
const evmChainId = await this.getEvmChainId();
|
|
423
|
+
const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
|
|
424
424
|
if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
425
|
-
/** Account Details * */
|
|
426
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
427
425
|
const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight.toString()).plus(txTimeoutInBlocks);
|
|
428
426
|
const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
|
|
429
427
|
const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
|
|
@@ -511,10 +509,8 @@ var MsgBroadcaster = class {
|
|
|
511
509
|
var _tx$gas2, _baseAccount$pubKey2;
|
|
512
510
|
const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
|
|
513
511
|
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
|
|
514
|
-
const evmChainId = await this.getEvmChainId();
|
|
512
|
+
const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
|
|
515
513
|
if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
516
|
-
/** Account Details * */
|
|
517
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
518
514
|
const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
|
|
519
515
|
const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
|
|
520
516
|
const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
|
|
@@ -671,11 +667,10 @@ var MsgBroadcaster = class {
|
|
|
671
667
|
if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Leap].includes(walletStrategy.getWallet())) {
|
|
672
668
|
if (await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
|
|
673
669
|
}
|
|
674
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
670
|
+
const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
|
|
675
671
|
const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
|
|
676
672
|
const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
|
|
677
673
|
const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
|
|
678
|
-
const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
|
|
679
674
|
const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
|
|
680
675
|
walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
681
676
|
/** Prepare the Transaction * */
|
|
@@ -756,9 +751,8 @@ var MsgBroadcaster = class {
|
|
|
756
751
|
}
|
|
757
752
|
if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
758
753
|
const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
|
|
759
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
754
|
+
const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
|
|
760
755
|
const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
|
|
761
|
-
const pubKey = await walletStrategy.getPubKey();
|
|
762
756
|
const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
|
|
763
757
|
/** EIP712 for signing on Ethereum wallets */
|
|
764
758
|
const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
|
|
@@ -842,7 +836,7 @@ var MsgBroadcaster = class {
|
|
|
842
836
|
if (httpHeaders) transactionApi.setMetadata(httpHeaders);
|
|
843
837
|
const fetchAccountBlockDetails = async () => {
|
|
844
838
|
try {
|
|
845
|
-
const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
839
|
+
const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
|
|
846
840
|
return {
|
|
847
841
|
baseAccount: baseAccount$1,
|
|
848
842
|
latestHeight: latestHeight$1
|
|
@@ -1032,20 +1026,21 @@ var MsgBroadcaster = class {
|
|
|
1032
1026
|
throw e;
|
|
1033
1027
|
}
|
|
1034
1028
|
}
|
|
1035
|
-
async fetchAccountAndBlockDetails(address) {
|
|
1029
|
+
async fetchAccountAndBlockDetails(address, existingAccountDetails) {
|
|
1036
1030
|
const { endpoints, httpHeaders } = this;
|
|
1037
|
-
const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
|
|
1038
1031
|
const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
|
|
1039
|
-
if (httpHeaders)
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1032
|
+
if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
|
|
1033
|
+
if (existingAccountDetails) return {
|
|
1034
|
+
baseAccount: existingAccountDetails,
|
|
1035
|
+
latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
|
|
1036
|
+
};
|
|
1037
|
+
const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
|
|
1038
|
+
if (httpHeaders) chainClient.setMetadata(httpHeaders);
|
|
1039
|
+
const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
|
|
1044
1040
|
const { baseAccount } = accountDetails;
|
|
1045
1041
|
return {
|
|
1046
1042
|
baseAccount,
|
|
1047
|
-
latestHeight:
|
|
1048
|
-
accountDetails
|
|
1043
|
+
latestHeight: latestBlock.header.height.toString()
|
|
1049
1044
|
};
|
|
1050
1045
|
}
|
|
1051
1046
|
};
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
|
6
6
|
import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
|
|
7
7
|
import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
|
|
8
8
|
import { Network, NetworkEndpoints } from "@injectivelabs/networks";
|
|
9
|
+
import { AuthBaseAccount } from "@injectivelabs/sdk-ts/client/chain";
|
|
9
10
|
|
|
10
11
|
//#region src/utils/tx.d.ts
|
|
11
12
|
declare const checkIfTxRunOutOfGas: (e: unknown) => boolean;
|
|
@@ -78,6 +79,7 @@ interface MsgBroadcasterTxOptions {
|
|
|
78
79
|
ethereumAddress?: string;
|
|
79
80
|
injectiveAddress?: string;
|
|
80
81
|
msgs: Msgs | Msgs[];
|
|
82
|
+
accountDetails?: AuthBaseAccount;
|
|
81
83
|
gas?: {
|
|
82
84
|
gasPrice?: string;
|
|
83
85
|
gas?: number; /** gas limit */
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
|
|
2
2
|
import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
|
|
3
3
|
import { Network, NetworkEndpoints } from "@injectivelabs/networks";
|
|
4
|
+
import { AuthBaseAccount } from "@injectivelabs/sdk-ts/client/chain";
|
|
4
5
|
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
5
6
|
import { StdSignDoc } from "@keplr-wallet/types";
|
|
6
7
|
import { OfflineSigner } from "@cosmjs/proto-signing";
|
|
@@ -78,6 +79,7 @@ interface MsgBroadcasterTxOptions {
|
|
|
78
79
|
ethereumAddress?: string;
|
|
79
80
|
injectiveAddress?: string;
|
|
80
81
|
msgs: Msgs | Msgs[];
|
|
82
|
+
accountDetails?: AuthBaseAccount;
|
|
81
83
|
gas?: {
|
|
82
84
|
gasPrice?: string;
|
|
83
85
|
gas?: number; /** gas limit */
|
package/dist/esm/index.js
CHANGED
|
@@ -420,10 +420,8 @@ var MsgBroadcaster = class {
|
|
|
420
420
|
var _tx$gas, _baseAccount$pubKey;
|
|
421
421
|
const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
|
|
422
422
|
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
|
|
423
|
-
const evmChainId = await this.getEvmChainId();
|
|
423
|
+
const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
|
|
424
424
|
if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
425
|
-
/** Account Details * */
|
|
426
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
427
425
|
const timeoutHeight = toBigNumber(latestHeight.toString()).plus(txTimeoutInBlocks);
|
|
428
426
|
const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
|
|
429
427
|
const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
|
|
@@ -511,10 +509,8 @@ var MsgBroadcaster = class {
|
|
|
511
509
|
var _tx$gas2, _baseAccount$pubKey2;
|
|
512
510
|
const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
|
|
513
511
|
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
|
|
514
|
-
const evmChainId = await this.getEvmChainId();
|
|
512
|
+
const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
|
|
515
513
|
if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
516
|
-
/** Account Details * */
|
|
517
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
518
514
|
const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
|
|
519
515
|
const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
|
|
520
516
|
const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
|
|
@@ -671,11 +667,10 @@ var MsgBroadcaster = class {
|
|
|
671
667
|
if ([Wallet.Keplr, Wallet.Leap].includes(walletStrategy.getWallet())) {
|
|
672
668
|
if (await walletStrategy.getWalletDeviceType() === WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
|
|
673
669
|
}
|
|
674
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
670
|
+
const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
|
|
675
671
|
const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
|
|
676
672
|
const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
|
|
677
673
|
const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet) ? SIGN_EIP712 : SIGN_DIRECT;
|
|
678
|
-
const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
|
|
679
674
|
const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || getGasPriceBasedOnMessage(msgs)).toString();
|
|
680
675
|
walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
|
|
681
676
|
/** Prepare the Transaction * */
|
|
@@ -756,9 +751,8 @@ var MsgBroadcaster = class {
|
|
|
756
751
|
}
|
|
757
752
|
if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
|
|
758
753
|
const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
|
|
759
|
-
const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
754
|
+
const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
|
|
760
755
|
const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
|
|
761
|
-
const pubKey = await walletStrategy.getPubKey();
|
|
762
756
|
const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || getGasPriceBasedOnMessage(msgs)).toString();
|
|
763
757
|
/** EIP712 for signing on Ethereum wallets */
|
|
764
758
|
const eip712TypedData = getEip712TypedData({
|
|
@@ -842,7 +836,7 @@ var MsgBroadcaster = class {
|
|
|
842
836
|
if (httpHeaders) transactionApi.setMetadata(httpHeaders);
|
|
843
837
|
const fetchAccountBlockDetails = async () => {
|
|
844
838
|
try {
|
|
845
|
-
const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
|
|
839
|
+
const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
|
|
846
840
|
return {
|
|
847
841
|
baseAccount: baseAccount$1,
|
|
848
842
|
latestHeight: latestHeight$1
|
|
@@ -1032,20 +1026,21 @@ var MsgBroadcaster = class {
|
|
|
1032
1026
|
throw e;
|
|
1033
1027
|
}
|
|
1034
1028
|
}
|
|
1035
|
-
async fetchAccountAndBlockDetails(address) {
|
|
1029
|
+
async fetchAccountAndBlockDetails(address, existingAccountDetails) {
|
|
1036
1030
|
const { endpoints, httpHeaders } = this;
|
|
1037
|
-
const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
|
|
1038
1031
|
const tendermintClient = new ChainGrpcTendermintApi(endpoints.grpc);
|
|
1039
|
-
if (httpHeaders)
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1032
|
+
if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
|
|
1033
|
+
if (existingAccountDetails) return {
|
|
1034
|
+
baseAccount: existingAccountDetails,
|
|
1035
|
+
latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
|
|
1036
|
+
};
|
|
1037
|
+
const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
|
|
1038
|
+
if (httpHeaders) chainClient.setMetadata(httpHeaders);
|
|
1039
|
+
const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
|
|
1044
1040
|
const { baseAccount } = accountDetails;
|
|
1045
1041
|
return {
|
|
1046
1042
|
baseAccount,
|
|
1047
|
-
latestHeight:
|
|
1048
|
-
accountDetails
|
|
1043
|
+
latestHeight: latestBlock.header.height.toString()
|
|
1049
1044
|
};
|
|
1050
1045
|
}
|
|
1051
1046
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.16",
|
|
4
4
|
"description": "Core wallet strategy",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@keplr-wallet/types": "^0.12.296",
|
|
46
46
|
"eventemitter3": "^5.0.1",
|
|
47
|
-
"@injectivelabs/exceptions": "1.19.
|
|
48
|
-
"@injectivelabs/
|
|
49
|
-
"@injectivelabs/
|
|
50
|
-
"@injectivelabs/
|
|
51
|
-
"@injectivelabs/
|
|
52
|
-
"@injectivelabs/wallet-base": "1.19.
|
|
47
|
+
"@injectivelabs/exceptions": "1.19.16",
|
|
48
|
+
"@injectivelabs/sdk-ts": "1.19.16",
|
|
49
|
+
"@injectivelabs/networks": "1.19.16",
|
|
50
|
+
"@injectivelabs/ts-types": "1.19.16",
|
|
51
|
+
"@injectivelabs/utils": "1.19.16",
|
|
52
|
+
"@injectivelabs/wallet-base": "1.19.16"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|