Files
LedgerLive/step-07-wallet-api/validation.ethereum-chain138.ts

29 lines
989 B
TypeScript
Raw Normal View History

/**
* Step 7 Wallet API: validation (Zod) for Ethereum family with chainId 138
* Target: ledger-live wallet-api packages/core/src/families/ethereum/validation.ts
* (If Ledger adds Chain 138 to Ethereum family, ensure chainId 138 is allowed in schema.)
*
* Example: extend schemaRawEthereumTransaction to allow chainId 138.
*/
import { z } from "zod";
const CHAIN_ID_138 = 138;
export const schemaRawEthereumTransaction = z.object({
family: z.literal("ethereum"),
amount: z.string(),
recipient: z.string(),
gasPrice: z.string().optional(),
maxFeePerGas: z.string().optional(),
maxPriorityFeePerGas: z.string().optional(),
gasLimit: z.string().optional(),
data: z.string().optional(),
nonce: z.number().optional(),
chainId: z.number().refine((id) => id === 1 || id === CHAIN_ID_138, {
message: "chainId must be 1 (Ethereum) or 138 (Defi Oracle Meta Mainnet)",
}),
});
export type RawEthereumTransaction = z.infer<typeof schemaRawEthereumTransaction>;