Add full Chain 138 integration: 8 steps, chain spec, app-ethereum config, docs
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
5
step-02-device-app-lib/README.md
Normal file
5
step-02-device-app-lib/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Step 2 — Device app lib
|
||||
|
||||
- **EVM/Chain 138:** Use existing `@ledgerhq/hw-app-eth`; no new device app lib. Ensure `chainId: 138` in transaction building/signing.
|
||||
- **app-ethereum (C):** If upstream Ledger app-ethereum does not list Chain 138, add the line from `network-entry-chain138.c` to `src/network.c`. Our fork already has it at `pr-workspace/app-ethereum/src/network.c` line 42.
|
||||
- **Icons:** If Ledger requires a network icon, use their icon process (see Device App Kit docs). Chain 138 can share the generic Ethereum-style icon until a custom one is added.
|
||||
30
step-02-device-app-lib/hw-app-eth-usage.ts
Normal file
30
step-02-device-app-lib/hw-app-eth-usage.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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<Buffer> },
|
||||
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 };
|
||||
12
step-02-device-app-lib/network-entry-chain138.c
Normal file
12
step-02-device-app-lib/network-entry-chain138.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Step 2 — Device app lib (app-ethereum network entry)
|
||||
* Target: LedgerHQ/app-ethereum src/network.c
|
||||
*
|
||||
* Our fork already has Chain 138 at line 42. This snippet is for upstream Ledger
|
||||
* app-ethereum if they don't yet list Chain 138. Add one line to NETWORK_MAPPING[].
|
||||
*
|
||||
* Format: {.chain_id = 138, .name = "Defi Oracle Meta", .ticker = "ETH"},
|
||||
*/
|
||||
|
||||
/* Insert in src/network.c inside NETWORK_MAPPING[], e.g. after Polygon (137): */
|
||||
{.chain_id = 138, .name = "Defi Oracle Meta", .ticker = "ETH"},
|
||||
Reference in New Issue
Block a user