@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/dist/src/evm.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Chain } from "viem";
|
|
1
2
|
import type { LedgerEvmWallet, UserInterface } from "./types.js";
|
|
2
|
-
export declare function createLedgerEvmWallet(ui: UserInterface,
|
|
3
|
+
export declare function createLedgerEvmWallet(ui: UserInterface, chain: Chain, derivationPath: string): Promise<LedgerEvmWallet>;
|
|
3
4
|
//# sourceMappingURL=evm.d.ts.map
|
package/dist/src/evm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/evm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,KAAK,EAMX,MAAM,MAAM,CAAC;AAId,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CA4J1B"}
|
package/dist/src/evm.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
import { createWalletClient, http, hashDomain, hashStruct, } from "viem";
|
|
2
|
-
import { baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
3
2
|
import Eth from "@ledgerhq/hw-app-eth/lib-es/Eth.js";
|
|
4
3
|
import { type } from "arktype";
|
|
5
4
|
import { createTransport } from "./transport.js";
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
"base-sepolia",
|
|
9
|
-
{
|
|
10
|
-
chain: baseSepolia,
|
|
11
|
-
rpcUrl: "https://sepolia.base.org",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
[
|
|
15
|
-
"ethereum",
|
|
16
|
-
{
|
|
17
|
-
chain: mainnet,
|
|
18
|
-
rpcUrl: "https://ethereum-rpc.publicnode.com",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
[
|
|
22
|
-
"sepolia",
|
|
23
|
-
{
|
|
24
|
-
chain: sepolia,
|
|
25
|
-
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
]);
|
|
29
|
-
export async function createLedgerEvmWallet(ui, network, derivationPath) {
|
|
30
|
-
const config = NETWORK_CONFIGS.get(network);
|
|
31
|
-
if (!config) {
|
|
32
|
-
throw new Error(`Unsupported network: ${network}. Supported networks: ${Array.from(NETWORK_CONFIGS.keys()).join(", ")}`);
|
|
33
|
-
}
|
|
5
|
+
export async function createLedgerEvmWallet(ui, chain, derivationPath) {
|
|
34
6
|
const transport = await createTransport();
|
|
35
7
|
const eth = new Eth(transport);
|
|
36
8
|
const { address } = await eth.getAddress(derivationPath);
|
|
@@ -70,7 +42,7 @@ export async function createLedgerEvmWallet(ui, network, derivationPath) {
|
|
|
70
42
|
gasPrice: toHex(transaction.gasPrice),
|
|
71
43
|
maxFeePerGas: toHex(transaction.maxFeePerGas),
|
|
72
44
|
maxPriorityFeePerGas: toHex(transaction.maxPriorityFeePerGas),
|
|
73
|
-
chainId:
|
|
45
|
+
chainId: chain.id,
|
|
74
46
|
};
|
|
75
47
|
const result = await eth.signTransaction(derivationPath, JSON.stringify(tx));
|
|
76
48
|
const signature = `0x${result.r}${result.s}${result.v}`;
|
|
@@ -134,11 +106,11 @@ export async function createLedgerEvmWallet(ui, network, derivationPath) {
|
|
|
134
106
|
};
|
|
135
107
|
const client = createWalletClient({
|
|
136
108
|
account: ledgerAccount,
|
|
137
|
-
chain:
|
|
138
|
-
transport: http(
|
|
109
|
+
chain: chain,
|
|
110
|
+
transport: http(chain.rpcUrls.default.http[0]),
|
|
139
111
|
});
|
|
140
112
|
return {
|
|
141
|
-
|
|
113
|
+
chain,
|
|
142
114
|
address: formattedAddress,
|
|
143
115
|
client,
|
|
144
116
|
signTransaction: async (tx) => {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Hex, WalletClient, TransactionSerializable, TypedDataDefinition } from "viem";
|
|
1
|
+
import type { Hex, WalletClient, TransactionSerializable, TypedDataDefinition, Chain } from "viem";
|
|
2
2
|
import type { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
3
3
|
import type Transport from "@ledgerhq/hw-transport";
|
|
4
4
|
export interface LedgerEvmWallet {
|
|
5
|
-
|
|
5
|
+
chain: Chain;
|
|
6
6
|
address: Hex;
|
|
7
7
|
client: WalletClient;
|
|
8
8
|
signTransaction: (tx: TransactionSerializable) => Promise<Hex>;
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,EACN,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,SAAS,MAAM,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