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:
45
step-07-wallet-api/serializer.ethereum-chain138.ts
Normal file
45
step-07-wallet-api/serializer.ethereum-chain138.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Step 7 — Wallet API: serialize/deserialize for JSON-RPC
|
||||
* Target: wallet-api packages/core/src/families/ethereum/serializer.ts
|
||||
*
|
||||
* Ethereum family already has serialization; ensure chainId is preserved.
|
||||
* When adding a new family, implement serializeTransaction/deserializeTransaction
|
||||
* for the new type and add to the union in packages/core/src/families/serializer.ts.
|
||||
*/
|
||||
|
||||
import type { RawEthereumTransaction } from "./types.ethereum-chain138";
|
||||
import type { EthereumTransaction } from "./types.ethereum-chain138";
|
||||
|
||||
export function serializeEthereumTransaction(
|
||||
tx: EthereumTransaction
|
||||
): RawEthereumTransaction {
|
||||
return {
|
||||
family: "ethereum",
|
||||
amount: tx.amount,
|
||||
recipient: tx.recipient,
|
||||
gasPrice: tx.gasPrice,
|
||||
maxFeePerGas: tx.maxFeePerGas,
|
||||
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
|
||||
gasLimit: tx.gasLimit,
|
||||
data: tx.data,
|
||||
nonce: tx.nonce,
|
||||
chainId: tx.chainId,
|
||||
};
|
||||
}
|
||||
|
||||
export function deserializeEthereumTransaction(
|
||||
raw: RawEthereumTransaction
|
||||
): EthereumTransaction {
|
||||
return {
|
||||
family: "ethereum",
|
||||
amount: raw.amount,
|
||||
recipient: raw.recipient,
|
||||
gasPrice: raw.gasPrice,
|
||||
maxFeePerGas: raw.maxFeePerGas,
|
||||
maxPriorityFeePerGas: raw.maxPriorityFeePerGas,
|
||||
gasLimit: raw.gasLimit,
|
||||
data: raw.data,
|
||||
nonce: raw.nonce,
|
||||
chainId: raw.chainId,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user