/** * Step 2 — Device app lib (JS bindings) * For EVM/Chain 138 we use existing @ledgerhq/hw-app-eth. No new package needed. * Ensure chainId 138 is passed when building/signing transactions. * * Example usage in coin-module or live-common (signer/bridge): */ import Eth from "@ledgerhq/hw-app-eth"; const CHAIN_ID_138 = 138; // When getting address (path is BIP44 EVM: 44'/60'/0'/0/0) async function getAddress( transport: { send: (cla: number, ins: number, p1: number, p2: number, data?: Buffer) => Promise }, path: string, display?: boolean ) { const eth = new Eth(transport); const result = await eth.getAddress(path, display ?? false); return { address: result.address, publicKey: result.publicKey, path }; } // When signing a transaction, the serialized tx must include chainId 138 (EIP-155) // so the device shows "Defi Oracle Meta" and signs correctly. function buildTxWithChainId(tx: { chainId?: number; [k: string]: unknown }) { return { ...tx, chainId: tx.chainId ?? CHAIN_ID_138 }; } export { getAddress, buildTxWithChainId, CHAIN_ID_138 };