@injectivelabs/wallet-ledger 1.16.13-alpha.3 → 1.16.13-alpha.4
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.
|
@@ -57,8 +57,11 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
57
57
|
const signedTransaction = await this.signEvmTransaction(txData, args);
|
|
58
58
|
try {
|
|
59
59
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const provider = await alchemy.config.getProvider();
|
|
61
|
+
const txHash = await provider.send('eth_sendRawTransaction', [
|
|
62
|
+
signedTransaction,
|
|
63
|
+
]);
|
|
64
|
+
return txHash;
|
|
62
65
|
}
|
|
63
66
|
catch (e) {
|
|
64
67
|
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
@@ -167,26 +170,34 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
167
170
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
168
171
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
169
172
|
const nonce = await alchemy.core.getTransactionCount(args.address);
|
|
173
|
+
const parseHexValue = (value) => {
|
|
174
|
+
if (typeof value === 'string') {
|
|
175
|
+
const hexValue = value.startsWith('0x') ? value : `0x${value}`;
|
|
176
|
+
return BigInt(hexValue);
|
|
177
|
+
}
|
|
178
|
+
return BigInt(value);
|
|
179
|
+
};
|
|
170
180
|
const eip1559TxData = {
|
|
171
181
|
type: 'eip1559',
|
|
172
182
|
chainId,
|
|
173
183
|
nonce,
|
|
174
184
|
to: txData.to,
|
|
175
|
-
value:
|
|
185
|
+
value: parseHexValue(txData.value || '0x0'),
|
|
176
186
|
data: txData.data,
|
|
177
|
-
gas:
|
|
178
|
-
maxFeePerGas:
|
|
179
|
-
maxPriorityFeePerGas:
|
|
187
|
+
gas: parseHexValue(txData.gas),
|
|
188
|
+
maxFeePerGas: parseHexValue(txData.maxFeePerGas),
|
|
189
|
+
maxPriorityFeePerGas: parseHexValue(txData.maxPriorityFeePerGas),
|
|
180
190
|
};
|
|
181
|
-
// Serialize the transaction
|
|
191
|
+
// Serialize the transaction
|
|
182
192
|
const serializedTx = (0, viem_1.serializeTransaction)(eip1559TxData);
|
|
183
|
-
const
|
|
184
|
-
const encodedMessageHex = messageHash.slice(2); // Remove 0x prefix
|
|
193
|
+
const serializedTxHex = serializedTx.slice(2); // Remove 0x prefix
|
|
185
194
|
try {
|
|
186
195
|
const ledger = await this.ledger.getInstance();
|
|
187
196
|
const { derivationPath } = await this.getWalletForAddress(args.address);
|
|
188
|
-
|
|
189
|
-
const
|
|
197
|
+
// Resolve transaction for Ledger display
|
|
198
|
+
const resolution = await ledgerService.resolveTransaction(serializedTxHex, {}, {});
|
|
199
|
+
// Sign the transaction with Ledger
|
|
200
|
+
const txSig = await ledger.signTransaction(derivationPath, serializedTxHex, resolution);
|
|
190
201
|
const signedTxData = {
|
|
191
202
|
...eip1559TxData,
|
|
192
203
|
v: BigInt(`0x${txSig.v}`),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
|
|
3
|
-
import { toHex,
|
|
3
|
+
import { toHex, serializeTransaction } from 'viem';
|
|
4
4
|
import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
|
|
5
5
|
import { ErrorType, LedgerException, WalletException, GeneralException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
|
|
6
|
-
import {
|
|
6
|
+
import { WalletAction, getKeyFromRpcUrl, WalletDeviceType, BaseConcreteStrategy, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
|
|
7
7
|
import LedgerHW from './hw/index.js';
|
|
8
8
|
import { loadLedgerServiceType } from './../lib.js';
|
|
9
9
|
import { domainHash, messageHash } from './utils.js';
|
|
@@ -52,8 +52,11 @@ export default class LedgerBase extends BaseConcreteStrategy {
|
|
|
52
52
|
const signedTransaction = await this.signEvmTransaction(txData, args);
|
|
53
53
|
try {
|
|
54
54
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const provider = await alchemy.config.getProvider();
|
|
56
|
+
const txHash = await provider.send('eth_sendRawTransaction', [
|
|
57
|
+
signedTransaction,
|
|
58
|
+
]);
|
|
59
|
+
return txHash;
|
|
57
60
|
}
|
|
58
61
|
catch (e) {
|
|
59
62
|
throw new LedgerException(new Error(e.message), {
|
|
@@ -162,26 +165,34 @@ export default class LedgerBase extends BaseConcreteStrategy {
|
|
|
162
165
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
163
166
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
164
167
|
const nonce = await alchemy.core.getTransactionCount(args.address);
|
|
168
|
+
const parseHexValue = (value) => {
|
|
169
|
+
if (typeof value === 'string') {
|
|
170
|
+
const hexValue = value.startsWith('0x') ? value : `0x${value}`;
|
|
171
|
+
return BigInt(hexValue);
|
|
172
|
+
}
|
|
173
|
+
return BigInt(value);
|
|
174
|
+
};
|
|
165
175
|
const eip1559TxData = {
|
|
166
176
|
type: 'eip1559',
|
|
167
177
|
chainId,
|
|
168
178
|
nonce,
|
|
169
179
|
to: txData.to,
|
|
170
|
-
value:
|
|
180
|
+
value: parseHexValue(txData.value || '0x0'),
|
|
171
181
|
data: txData.data,
|
|
172
|
-
gas:
|
|
173
|
-
maxFeePerGas:
|
|
174
|
-
maxPriorityFeePerGas:
|
|
182
|
+
gas: parseHexValue(txData.gas),
|
|
183
|
+
maxFeePerGas: parseHexValue(txData.maxFeePerGas),
|
|
184
|
+
maxPriorityFeePerGas: parseHexValue(txData.maxPriorityFeePerGas),
|
|
175
185
|
};
|
|
176
|
-
// Serialize the transaction
|
|
186
|
+
// Serialize the transaction
|
|
177
187
|
const serializedTx = serializeTransaction(eip1559TxData);
|
|
178
|
-
const
|
|
179
|
-
const encodedMessageHex = messageHash.slice(2); // Remove 0x prefix
|
|
188
|
+
const serializedTxHex = serializedTx.slice(2); // Remove 0x prefix
|
|
180
189
|
try {
|
|
181
190
|
const ledger = await this.ledger.getInstance();
|
|
182
191
|
const { derivationPath } = await this.getWalletForAddress(args.address);
|
|
183
|
-
|
|
184
|
-
const
|
|
192
|
+
// Resolve transaction for Ledger display
|
|
193
|
+
const resolution = await ledgerService.resolveTransaction(serializedTxHex, {}, {});
|
|
194
|
+
// Sign the transaction with Ledger
|
|
195
|
+
const txSig = await ledger.signTransaction(derivationPath, serializedTxHex, resolution);
|
|
185
196
|
const signedTxData = {
|
|
186
197
|
...eip1559TxData,
|
|
187
198
|
v: BigInt(`0x${txSig.v}`),
|
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
|
+
"version": "1.16.13-alpha.4",
|
|
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.
|
|
65
|
-
"@injectivelabs/sdk-ts": "1.16.13-alpha.
|
|
66
|
-
"@injectivelabs/ts-types": "1.16.13-alpha.
|
|
67
|
-
"@injectivelabs/wallet-base": "1.16.13-alpha.
|
|
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",
|
|
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": "
|
|
75
|
+
"gitHead": "38872f985bdce134a3e6f9f7b7e0e3e5c5cd36b1"
|
|
76
76
|
}
|