@injectivelabs/wallet-ledger 1.16.13-alpha.4 → 1.16.13-alpha.6

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.
@@ -36,7 +36,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
36
36
  }): Promise<DirectSignResponse>;
37
37
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
38
38
  getEthereumChainId(): Promise<string>;
39
- getEvmTransactionReceipt(txHash: string): Promise<string>;
39
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<string>;
40
40
  getPubKey(): Promise<string>;
41
41
  private signEvmTransaction;
42
42
  private getWalletForAddress;
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("@injectivelabs/utils");
7
+ const viem_1 = require("viem");
6
8
  const ts_types_1 = require("@injectivelabs/ts-types");
7
9
  const sdk_ts_1 = require("@injectivelabs/sdk-ts");
8
- const viem_1 = require("viem");
9
10
  const alchemy_sdk_1 = require("alchemy-sdk");
10
11
  const exceptions_1 = require("@injectivelabs/exceptions");
11
12
  const wallet_base_1 = require("@injectivelabs/wallet-base");
@@ -159,8 +160,26 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
159
160
  const alchemyProvider = await alchemy.config.getProvider();
160
161
  return alchemyProvider.network.chainId.toString();
161
162
  }
162
- async getEvmTransactionReceipt(txHash) {
163
- return Promise.resolve(txHash);
163
+ async getEvmTransactionReceipt(txHash, evmChainId) {
164
+ const alchemy = await this.getAlchemy(evmChainId);
165
+ const provider = await alchemy.config.getProvider();
166
+ const interval = 3000;
167
+ const maxAttempts = 10;
168
+ let attempts = 0;
169
+ while (attempts < maxAttempts) {
170
+ attempts++;
171
+ await (0, utils_1.sleep)(interval);
172
+ try {
173
+ const receipt = await provider.send('eth_getTransactionReceipt', [
174
+ txHash,
175
+ ]);
176
+ if (receipt) {
177
+ return txHash;
178
+ }
179
+ }
180
+ catch { }
181
+ }
182
+ throw new Error(`Failed to retrieve transaction receipt for txHash: ${txHash}`);
164
183
  }
165
184
  async getPubKey() {
166
185
  throw new exceptions_1.WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
@@ -36,7 +36,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
36
36
  }): Promise<DirectSignResponse>;
37
37
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
38
38
  getEthereumChainId(): Promise<string>;
39
- getEvmTransactionReceipt(txHash: string): Promise<string>;
39
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<string>;
40
40
  getPubKey(): Promise<string>;
41
41
  private signEvmTransaction;
42
42
  private getWalletForAddress;
@@ -1,6 +1,7 @@
1
+ import { sleep } from '@injectivelabs/utils';
2
+ import { toHex, serializeTransaction } from 'viem';
1
3
  import { EvmChainId } from '@injectivelabs/ts-types';
2
4
  import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
3
- import { toHex, serializeTransaction } from 'viem';
4
5
  import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
5
6
  import { ErrorType, LedgerException, WalletException, GeneralException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
6
7
  import { WalletAction, getKeyFromRpcUrl, WalletDeviceType, BaseConcreteStrategy, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
@@ -154,8 +155,26 @@ export default class LedgerBase extends BaseConcreteStrategy {
154
155
  const alchemyProvider = await alchemy.config.getProvider();
155
156
  return alchemyProvider.network.chainId.toString();
156
157
  }
157
- async getEvmTransactionReceipt(txHash) {
158
- return Promise.resolve(txHash);
158
+ async getEvmTransactionReceipt(txHash, evmChainId) {
159
+ const alchemy = await this.getAlchemy(evmChainId);
160
+ const provider = await alchemy.config.getProvider();
161
+ const interval = 3000;
162
+ const maxAttempts = 10;
163
+ let attempts = 0;
164
+ while (attempts < maxAttempts) {
165
+ attempts++;
166
+ await sleep(interval);
167
+ try {
168
+ const receipt = await provider.send('eth_getTransactionReceipt', [
169
+ txHash,
170
+ ]);
171
+ if (receipt) {
172
+ return txHash;
173
+ }
174
+ }
175
+ catch { }
176
+ }
177
+ throw new Error(`Failed to retrieve transaction receipt for txHash: ${txHash}`);
159
178
  }
160
179
  async getPubKey() {
161
180
  throw new WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-ledger",
3
3
  "description": "Ledger wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.16.13-alpha.4",
4
+ "version": "1.16.13-alpha.6",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -61,10 +61,10 @@
61
61
  "@bangjelkoski/ledgerhq-hw-transport": "6.31.4-beta.0",
62
62
  "@bangjelkoski/ledgerhq-hw-transport-webhid": "6.30.0-beta.0",
63
63
  "@bangjelkoski/ledgerhq-hw-transport-webusb": "6.29.4-beta.0",
64
- "@injectivelabs/exceptions": "1.16.13-alpha.4",
65
- "@injectivelabs/sdk-ts": "1.16.13-alpha.4",
66
- "@injectivelabs/ts-types": "1.16.13-alpha.4",
67
- "@injectivelabs/wallet-base": "1.16.13-alpha.4",
64
+ "@injectivelabs/exceptions": "1.16.13-alpha.6",
65
+ "@injectivelabs/sdk-ts": "1.16.13-alpha.6",
66
+ "@injectivelabs/ts-types": "1.16.13-alpha.6",
67
+ "@injectivelabs/wallet-base": "1.16.13-alpha.6",
68
68
  "alchemy-sdk": "^3.4.7",
69
69
  "viem": "^2.33.2"
70
70
  },
@@ -72,5 +72,5 @@
72
72
  "@types/ledgerhq__hw-transport-webusb": "^4.70.1",
73
73
  "shx": "^0.3.4"
74
74
  },
75
- "gitHead": "38872f985bdce134a3e6f9f7b7e0e3e5c5cd36b1"
75
+ "gitHead": "4239109ab41807561f8ed8fcb98339387bfc8547"
76
76
  }