diff --git a/provider/src/response.rs b/provider/src/response.rs index a339ca32..892410d9 100644 --- a/provider/src/response.rs +++ b/provider/src/response.rs @@ -281,3 +281,74 @@ pub struct ZkLinkTxHistory { pub tx_receipt: TxReceiptResp, pub created_at: DateTime, } + + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct GetWayListResponse { + gateways: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct GetWayInfo { + 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, +} + +#[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" + }, + { + "tokenId": 3, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff" + } + ] + }, + { + "chainId": 7, + "l1GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "l2GatewayContract": "0xffffffffffffffffffffffffffffffffffffffff", + "tokens": [ + { + "tokenId": 1, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff" + }, + { + "tokenId": 3, + "tokenAddress":"0xffffffffffffffffffffffffffffffffffffffff" + } + ] + } + ] +} + "#; + 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 6e723114..f45c2010 100644 --- a/provider/src/rpc.rs +++ b/provider/src/rpc.rs @@ -94,6 +94,11 @@ pub trait ZkLinkRpc { max_txs: u32, ) -> RpcResult>; + #[method(name = "getGetwayList")] + async fn query_getway_list( + &self, + ) -> RpcResult; + #[method(name = "pullForwardTxs")] async fn pull_forward_txs( &self,