@faremeter/wallet-ledger 0.7.0 → 0.9.0
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/src/evm.d.ts +2 -1
- package/dist/src/evm.d.ts.map +1 -1
- package/dist/src/evm.js +5 -33
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/evm.ts +5 -42
- package/src/types.ts +2 -1
package/package.json
CHANGED
package/src/evm.ts
CHANGED
|
@@ -9,53 +9,16 @@ import {
|
|
|
9
9
|
hashDomain,
|
|
10
10
|
hashStruct,
|
|
11
11
|
} from "viem";
|
|
12
|
-
import { baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
13
12
|
import Eth from "@ledgerhq/hw-app-eth/lib-es/Eth";
|
|
14
13
|
import { type } from "arktype";
|
|
15
14
|
import { createTransport } from "./transport";
|
|
16
15
|
import type { LedgerEvmWallet, UserInterface } from "./types";
|
|
17
16
|
|
|
18
|
-
interface NetworkConfig {
|
|
19
|
-
chain: Chain;
|
|
20
|
-
rpcUrl: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const NETWORK_CONFIGS = new Map<string, NetworkConfig>([
|
|
24
|
-
[
|
|
25
|
-
"base-sepolia",
|
|
26
|
-
{
|
|
27
|
-
chain: baseSepolia,
|
|
28
|
-
rpcUrl: "https://sepolia.base.org",
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
"ethereum",
|
|
33
|
-
{
|
|
34
|
-
chain: mainnet,
|
|
35
|
-
rpcUrl: "https://ethereum-rpc.publicnode.com",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
[
|
|
39
|
-
"sepolia",
|
|
40
|
-
{
|
|
41
|
-
chain: sepolia,
|
|
42
|
-
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
17
|
export async function createLedgerEvmWallet(
|
|
48
18
|
ui: UserInterface,
|
|
49
|
-
|
|
19
|
+
chain: Chain,
|
|
50
20
|
derivationPath: string,
|
|
51
21
|
): Promise<LedgerEvmWallet> {
|
|
52
|
-
const config = NETWORK_CONFIGS.get(network);
|
|
53
|
-
if (!config) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Unsupported network: ${network}. Supported networks: ${Array.from(NETWORK_CONFIGS.keys()).join(", ")}`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
22
|
const transport = await createTransport();
|
|
60
23
|
const eth = new Eth(transport);
|
|
61
24
|
|
|
@@ -106,7 +69,7 @@ export async function createLedgerEvmWallet(
|
|
|
106
69
|
gasPrice: toHex(transaction.gasPrice),
|
|
107
70
|
maxFeePerGas: toHex(transaction.maxFeePerGas),
|
|
108
71
|
maxPriorityFeePerGas: toHex(transaction.maxPriorityFeePerGas),
|
|
109
|
-
chainId:
|
|
72
|
+
chainId: chain.id,
|
|
110
73
|
};
|
|
111
74
|
|
|
112
75
|
const result = await eth.signTransaction(
|
|
@@ -193,12 +156,12 @@ export async function createLedgerEvmWallet(
|
|
|
193
156
|
|
|
194
157
|
const client = createWalletClient({
|
|
195
158
|
account: ledgerAccount,
|
|
196
|
-
chain:
|
|
197
|
-
transport: http(
|
|
159
|
+
chain: chain,
|
|
160
|
+
transport: http(chain.rpcUrls.default.http[0]),
|
|
198
161
|
});
|
|
199
162
|
|
|
200
163
|
return {
|
|
201
|
-
|
|
164
|
+
chain,
|
|
202
165
|
address: formattedAddress,
|
|
203
166
|
client,
|
|
204
167
|
signTransaction: async (tx: TransactionSerializable) => {
|
package/src/types.ts
CHANGED
|
@@ -3,12 +3,13 @@ import type {
|
|
|
3
3
|
WalletClient,
|
|
4
4
|
TransactionSerializable,
|
|
5
5
|
TypedDataDefinition,
|
|
6
|
+
Chain,
|
|
6
7
|
} from "viem";
|
|
7
8
|
import type { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
8
9
|
import type Transport from "@ledgerhq/hw-transport";
|
|
9
10
|
|
|
10
11
|
export interface LedgerEvmWallet {
|
|
11
|
-
|
|
12
|
+
chain: Chain;
|
|
12
13
|
address: Hex;
|
|
13
14
|
client: WalletClient;
|
|
14
15
|
signTransaction: (tx: TransactionSerializable) => Promise<Hex>;
|