import { hexToBigInt } from '../encoding/fromHex.js' import type { ErrorType } from '../errors/utils.js' import type { Proof, RpcProof } from '../types/proof.js' export type FromRpcProofErrorType = ErrorType function fromRpcStorageProof(storageProof: RpcProof['storageProof']) { return (storageProof || []).map((proof) => ({ ...proof, value: BigInt(proof.value), })) } export function fromRpcProof(proof: RpcProof): Proof { return { ...proof, balance: proof.balance ? BigInt(proof.balance) : undefined, nonce: proof.nonce ? hexToBigInt(proof.nonce) : undefined, storageProof: proof.storageProof ? fromRpcStorageProof(proof.storageProof) : undefined, } }