@swapkit/wallet-hardware 4.9.12 → 4.9.13
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/ledger/index.cjs +2 -2
- package/dist/ledger/index.cjs.map +3 -3
- package/dist/ledger/index.js +2 -2
- package/dist/ledger/index.js.map +3 -3
- package/dist/types/keepkey/index.d.ts +1 -1
- package/dist/types/ledger/clients/evm.d.ts +1 -0
- package/dist/types/ledger/clients/evm.d.ts.map +1 -1
- package/dist/types/ledger/index.d.ts +1 -1
- package/dist/types/trezor/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/ledger/clients/evm.ts +19 -7
package/package.json
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"@near-js/transactions": "~2.5.0",
|
|
23
23
|
"@scure/base": "2.2.0",
|
|
24
24
|
"@scure/bip32": "2.2.0",
|
|
25
|
-
"@swapkit/helpers": "^4.13.
|
|
26
|
-
"@swapkit/toolboxes": "^4.15.
|
|
25
|
+
"@swapkit/helpers": "^4.13.10",
|
|
26
|
+
"@swapkit/toolboxes": "^4.15.14",
|
|
27
27
|
"@swapkit/utxo-signer": "^2.1.3",
|
|
28
|
-
"@swapkit/wallet-core": "^4.3.
|
|
28
|
+
"@swapkit/wallet-core": "^4.3.1",
|
|
29
29
|
"@trezor/connect-web": "~9.7.3",
|
|
30
30
|
"cosmjs-types": "~0.10.1",
|
|
31
31
|
"ethers": "^6.14.0",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"type-check:go": "tsgo"
|
|
110
110
|
},
|
|
111
111
|
"type": "module",
|
|
112
|
-
"version": "4.9.
|
|
112
|
+
"version": "4.9.13"
|
|
113
113
|
}
|
|
@@ -17,11 +17,19 @@ import {
|
|
|
17
17
|
|
|
18
18
|
import { getLedgerTransport } from "../helpers/getLedgerTransport";
|
|
19
19
|
|
|
20
|
+
function parseLedgerSignatureV(v: number | string) {
|
|
21
|
+
if (typeof v === "number") return v;
|
|
22
|
+
|
|
23
|
+
const hex = v.startsWith("0x") ? v.slice(2) : v;
|
|
24
|
+
return Number.parseInt(hex || "0", 16);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
class EVMLedgerInterface extends AbstractSigner {
|
|
21
28
|
chainId: ChainId = ChainId.Ethereum;
|
|
22
29
|
derivationPath = "";
|
|
23
30
|
ledgerApp: InstanceType<typeof EthereumApp> | null = null;
|
|
24
31
|
ledgerTimeout = 50000;
|
|
32
|
+
private transport?: Transport;
|
|
25
33
|
private readonly injectedTransport?: Transport;
|
|
26
34
|
|
|
27
35
|
constructor({
|
|
@@ -44,19 +52,20 @@ class EVMLedgerInterface extends AbstractSigner {
|
|
|
44
52
|
chainId: this.chainId,
|
|
45
53
|
derivationPath: this.derivationPath,
|
|
46
54
|
provider,
|
|
47
|
-
transport: this.injectedTransport,
|
|
55
|
+
transport: this.transport ?? this.injectedTransport,
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
checkOrCreateTransportAndLedger = async () => {
|
|
51
|
-
if (this.ledgerApp) return;
|
|
52
59
|
await this.createTransportAndLedger();
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
createTransportAndLedger = async () => {
|
|
56
|
-
|
|
63
|
+
if (this.ledgerApp) return;
|
|
64
|
+
|
|
65
|
+
this.transport ||= this.injectedTransport ?? (await getLedgerTransport());
|
|
57
66
|
const EthereumApp = (await import("@ledgerhq/hw-app-eth")).default;
|
|
58
67
|
|
|
59
|
-
this.ledgerApp = new EthereumApp(transport);
|
|
68
|
+
this.ledgerApp = new EthereumApp(this.transport);
|
|
60
69
|
};
|
|
61
70
|
|
|
62
71
|
getAddress = async () => {
|
|
@@ -141,7 +150,9 @@ class EVMLedgerInterface extends AbstractSigner {
|
|
|
141
150
|
const { Transaction } = await import("ethers");
|
|
142
151
|
await this.createTransportAndLedger();
|
|
143
152
|
|
|
144
|
-
const
|
|
153
|
+
const nonce = tx.nonce ?? undefined;
|
|
154
|
+
const transactionCount =
|
|
155
|
+
nonce === undefined ? await this.provider?.getTransactionCount(tx.from || (await this.getAddress())) : undefined;
|
|
145
156
|
|
|
146
157
|
const baseTx = {
|
|
147
158
|
chainId: tx.chainId || this.chainId,
|
|
@@ -150,7 +161,7 @@ class EVMLedgerInterface extends AbstractSigner {
|
|
|
150
161
|
...(tx.gasPrice && { gasPrice: tx.gasPrice }),
|
|
151
162
|
...(!tx.gasPrice &&
|
|
152
163
|
tx.maxFeePerGas && { maxFeePerGas: tx.maxFeePerGas, maxPriorityFeePerGas: tx.maxPriorityFeePerGas }),
|
|
153
|
-
nonce:
|
|
164
|
+
nonce: nonce !== undefined ? Number(nonce.toString()) : transactionCount,
|
|
154
165
|
to: tx.to?.toString(),
|
|
155
166
|
type: tx.type && !Number.isNaN(tx.type) ? tx.type : tx.maxFeePerGas ? 2 : 0,
|
|
156
167
|
value: tx.value,
|
|
@@ -169,7 +180,8 @@ class EVMLedgerInterface extends AbstractSigner {
|
|
|
169
180
|
|
|
170
181
|
const { r, s, v } = signature;
|
|
171
182
|
|
|
172
|
-
return Transaction.from({ ...baseTx, signature: { r: `0x${r}`, s: `0x${s}`, v:
|
|
183
|
+
return Transaction.from({ ...baseTx, signature: { r: `0x${r}`, s: `0x${s}`, v: parseLedgerSignatureV(v) } })
|
|
184
|
+
.serialized;
|
|
173
185
|
};
|
|
174
186
|
}
|
|
175
187
|
|