diff --git a/provider/src/response.rs b/provider/src/response.rs index a339ca32..0aebfa2d 100644 --- a/provider/src/response.rs +++ b/provider/src/response.rs @@ -281,3 +281,77 @@ pub struct ZkLinkTxHistory { pub tx_receipt: TxReceiptResp, pub created_at: DateTime, } + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct EthPropertyResp { + gateways: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct GateWayInfo { + chain_id: ChainId, + l1_gateway_contract: ZkLinkAddress, + l2_gateway_contract: ZkLinkAddress, + tokens: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct TokenInfo { + token_id: TokenId, + token_address: ZkLinkAddress, + decimal: u8, +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_rpc_response() { + let s = r#" { + "gateways": [ + { + "chainId": 5, + "l1GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "l2GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "tokens": [ + { + "tokenId": 1, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff", + "decimal": 6 + }, + { + "tokenId": 3, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff", + "decimal": 7 + } + ] + }, + { + "chainId": 7, + "l1GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "l2GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "tokens": [ + { + "tokenId": 1, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff", + "decimal": 6 + }, + { + "tokenId": 3, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff", + "decimal": 6 + } + ] + } + ] +} + "#; + let resp: Result = serde_json::from_str(s); + println!("{:?}", resp); + assert!(resp.is_ok()); + } +} diff --git a/provider/src/rpc.rs b/provider/src/rpc.rs index 5a769182..f9d857df 100644 --- a/provider/src/rpc.rs +++ b/provider/src/rpc.rs @@ -97,6 +97,9 @@ pub trait ZkLinkRpc { #[method(name = "getChangePubkeyChainId")] async fn get_change_pubkey_chain_id(&self) -> RpcResult; + #[method(name = "getEthProperty")] + async fn get_eth_property(&self) -> RpcResult; + #[method(name = "pullForwardTxs")] async fn pull_forward_txs( &self,