@injectivelabs/wallet-trezor 1.16.13-alpha.2 → 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.
- package/dist/cjs/strategy/Base.js +27 -11
- package/dist/esm/strategy/Base.js +28 -12
- package/package.json +6 -6
|
@@ -54,8 +54,11 @@ class TrezorBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
54
54
|
const signedTransaction = await this.signEvmTransaction(txData, args);
|
|
55
55
|
try {
|
|
56
56
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const provider = await alchemy.config.getProvider();
|
|
58
|
+
const txHash = await provider.send('eth_sendRawTransaction', [
|
|
59
|
+
signedTransaction,
|
|
60
|
+
]);
|
|
61
|
+
return txHash;
|
|
59
62
|
}
|
|
60
63
|
catch (e) {
|
|
61
64
|
throw new exceptions_1.TrezorException(new Error(e.message), {
|
|
@@ -175,16 +178,29 @@ class TrezorBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
175
178
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
176
179
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
177
180
|
const nonce = await alchemy.core.getTransactionCount(args.address);
|
|
178
|
-
//
|
|
181
|
+
// Handle hex string values properly (with or without 0x prefix)
|
|
182
|
+
const parseHexValue = (value) => {
|
|
183
|
+
if (typeof value === 'string') {
|
|
184
|
+
const hexValue = value.startsWith('0x') ? value : `0x${value}`;
|
|
185
|
+
return BigInt(hexValue);
|
|
186
|
+
}
|
|
187
|
+
return BigInt(value);
|
|
188
|
+
};
|
|
189
|
+
// Convert to BigInt first, then to hex for Trezor
|
|
190
|
+
const valueBigInt = parseHexValue(txData.value || '0x0');
|
|
191
|
+
const gasBigInt = parseHexValue(txData.gas);
|
|
192
|
+
const maxFeePerGasBigInt = parseHexValue(txData.maxFeePerGas);
|
|
193
|
+
const maxPriorityFeePerGasBigInt = parseHexValue(txData.maxPriorityFeePerGas);
|
|
194
|
+
// Create transaction data for Trezor API (needs hex strings)
|
|
179
195
|
const trezorTxData = {
|
|
180
196
|
to: txData.to,
|
|
181
|
-
value: (0, viem_1.toHex)(
|
|
182
|
-
gasLimit: (0, viem_1.toHex)(
|
|
197
|
+
value: (0, viem_1.toHex)(valueBigInt),
|
|
198
|
+
gasLimit: (0, viem_1.toHex)(gasBigInt),
|
|
183
199
|
nonce: (0, viem_1.toHex)(nonce),
|
|
184
200
|
data: txData.data || '0x',
|
|
185
201
|
chainId,
|
|
186
|
-
maxFeePerGas: (0, viem_1.toHex)(
|
|
187
|
-
maxPriorityFeePerGas: (0, viem_1.toHex)(
|
|
202
|
+
maxFeePerGas: (0, viem_1.toHex)(maxFeePerGasBigInt),
|
|
203
|
+
maxPriorityFeePerGas: (0, viem_1.toHex)(maxPriorityFeePerGasBigInt),
|
|
188
204
|
};
|
|
189
205
|
try {
|
|
190
206
|
await this.trezor.connect();
|
|
@@ -207,11 +223,11 @@ class TrezorBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
207
223
|
chainId,
|
|
208
224
|
nonce,
|
|
209
225
|
to: txData.to,
|
|
210
|
-
value:
|
|
226
|
+
value: valueBigInt,
|
|
211
227
|
data: (txData.data || '0x'),
|
|
212
|
-
gas:
|
|
213
|
-
maxFeePerGas:
|
|
214
|
-
maxPriorityFeePerGas:
|
|
228
|
+
gas: gasBigInt,
|
|
229
|
+
maxFeePerGas: maxFeePerGasBigInt,
|
|
230
|
+
maxPriorityFeePerGas: maxPriorityFeePerGasBigInt,
|
|
215
231
|
v: BigInt(response.payload.v),
|
|
216
232
|
r: response.payload.r,
|
|
217
233
|
s: response.payload.s,
|
|
@@ -3,7 +3,7 @@ import { EvmChainId } from '@injectivelabs/ts-types';
|
|
|
3
3
|
import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
|
|
4
4
|
import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
|
|
5
5
|
import { ErrorType, WalletException, TrezorException, 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 { loadTrezorConnect } from './lib.js';
|
|
8
8
|
import { transformTypedData } from '../utils.js';
|
|
9
9
|
import { BaseTrezorTransport } from './hw/index.js';
|
|
@@ -52,8 +52,11 @@ export default class TrezorBase 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 TrezorException(new Error(e.message), {
|
|
@@ -173,16 +176,29 @@ export default class TrezorBase extends BaseConcreteStrategy {
|
|
|
173
176
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
174
177
|
const alchemy = await this.getAlchemy(args.evmChainId);
|
|
175
178
|
const nonce = await alchemy.core.getTransactionCount(args.address);
|
|
176
|
-
//
|
|
179
|
+
// Handle hex string values properly (with or without 0x prefix)
|
|
180
|
+
const parseHexValue = (value) => {
|
|
181
|
+
if (typeof value === 'string') {
|
|
182
|
+
const hexValue = value.startsWith('0x') ? value : `0x${value}`;
|
|
183
|
+
return BigInt(hexValue);
|
|
184
|
+
}
|
|
185
|
+
return BigInt(value);
|
|
186
|
+
};
|
|
187
|
+
// Convert to BigInt first, then to hex for Trezor
|
|
188
|
+
const valueBigInt = parseHexValue(txData.value || '0x0');
|
|
189
|
+
const gasBigInt = parseHexValue(txData.gas);
|
|
190
|
+
const maxFeePerGasBigInt = parseHexValue(txData.maxFeePerGas);
|
|
191
|
+
const maxPriorityFeePerGasBigInt = parseHexValue(txData.maxPriorityFeePerGas);
|
|
192
|
+
// Create transaction data for Trezor API (needs hex strings)
|
|
177
193
|
const trezorTxData = {
|
|
178
194
|
to: txData.to,
|
|
179
|
-
value: toHex(
|
|
180
|
-
gasLimit: toHex(
|
|
195
|
+
value: toHex(valueBigInt),
|
|
196
|
+
gasLimit: toHex(gasBigInt),
|
|
181
197
|
nonce: toHex(nonce),
|
|
182
198
|
data: txData.data || '0x',
|
|
183
199
|
chainId,
|
|
184
|
-
maxFeePerGas: toHex(
|
|
185
|
-
maxPriorityFeePerGas: toHex(
|
|
200
|
+
maxFeePerGas: toHex(maxFeePerGasBigInt),
|
|
201
|
+
maxPriorityFeePerGas: toHex(maxPriorityFeePerGasBigInt),
|
|
186
202
|
};
|
|
187
203
|
try {
|
|
188
204
|
await this.trezor.connect();
|
|
@@ -205,11 +221,11 @@ export default class TrezorBase extends BaseConcreteStrategy {
|
|
|
205
221
|
chainId,
|
|
206
222
|
nonce,
|
|
207
223
|
to: txData.to,
|
|
208
|
-
value:
|
|
224
|
+
value: valueBigInt,
|
|
209
225
|
data: (txData.data || '0x'),
|
|
210
|
-
gas:
|
|
211
|
-
maxFeePerGas:
|
|
212
|
-
maxPriorityFeePerGas:
|
|
226
|
+
gas: gasBigInt,
|
|
227
|
+
maxFeePerGas: maxFeePerGasBigInt,
|
|
228
|
+
maxPriorityFeePerGas: maxPriorityFeePerGasBigInt,
|
|
213
229
|
v: BigInt(response.payload.v),
|
|
214
230
|
r: response.payload.r,
|
|
215
231
|
s: response.payload.s,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-trezor",
|
|
3
3
|
"description": "Trezor 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": {
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@bangjelkoski/trezor-connect-web": "^9.4.7-beta.1",
|
|
60
|
-
"@injectivelabs/exceptions": "1.16.13-alpha.
|
|
61
|
-
"@injectivelabs/sdk-ts": "1.16.13-alpha.
|
|
62
|
-
"@injectivelabs/ts-types": "1.16.13-alpha.
|
|
63
|
-
"@injectivelabs/wallet-base": "1.16.13-alpha.
|
|
60
|
+
"@injectivelabs/exceptions": "1.16.13-alpha.4",
|
|
61
|
+
"@injectivelabs/sdk-ts": "1.16.13-alpha.4",
|
|
62
|
+
"@injectivelabs/ts-types": "1.16.13-alpha.4",
|
|
63
|
+
"@injectivelabs/wallet-base": "1.16.13-alpha.4",
|
|
64
64
|
"alchemy-sdk": "^3.4.7",
|
|
65
65
|
"viem": "^2.33.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"shx": "^0.3.3"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "38872f985bdce134a3e6f9f7b7e0e3e5c5cd36b1"
|
|
71
71
|
}
|