Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bridge API

The bridge API is a REST API for fetching proofs from Avail's Kate RPC and Merkle proof service API to submit on Ethereum or
The bridge API is a REST API for fetching proofs from Avail's Bridge RPC and Merkle proof service API to submit on Ethereum or
any off-chain proof verification.

## Deploying the bridge API
Expand Down Expand Up @@ -293,7 +293,7 @@ RUSTFLAGS="-C target-cpu=native" cargo run --profile maxperf
"0xf871a08eccb5e838d7d0699e06d85c472bb097d8012c44d790e5d15c5b8465c7abb88180a02581c4c4535083ecd9ea1a314216bbe948f27bccb2e997c7796a9eec8f4c3df0a0c453ceda114a9775f135a7a2687f75e753c6f814789528fb73bb8cb5dec7eac680808080808080808080808080",
"0xf8429f31265685397ec9fa17535b5603e86e2b01a583b71373e1b2cbfac2a5bff58fa1a0eb70a047920b4aa1f3a418b52e455694d4e1a2362fd7fbcf16fe53d798311beb"
]
}
}
```

### Get bridge transactions
Expand Down Expand Up @@ -360,6 +360,6 @@ RUSTFLAGS="-C target-cpu=native" cargo run --profile maxperf
}
```

### Examples of using bridge api
### Examples of using bridge api

* We have prepared a set of examples written in Rust and Typescript to help you understand how to use bridge api. You can explore these examples by visiting our [code examples repository](https://github.com/availproject/avail-bridge-examples).
24 changes: 12 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ async fn get_eth_proof(
cloned_state
.avail_client
.request(
"kate_queryDataProof",
"bridge_queryDataProof",
rpc_params![index_struct.index, &block_hash],
)
.await
Expand All @@ -334,19 +334,19 @@ async fn get_eth_proof(
});
let (data_proof, merkle_proof_response) =
join!(data_proof_response_fut, mekrle_proof_response_fut);
let data_proof_res: KateQueryDataProofResponse = data_proof
let data_proof_res: BridgeQueryDataProofResponse = data_proof
.map_err(|e| {
tracing::error!("❌ Failed to fetch the kate query data. Error: {e:#}");
tracing::error!("❌ Failed to fetch the bridge query data proof. Error: {e:#}");
ErrorResponse::with_status_and_headers(
anyhow::anyhow!("Something went wrong."),
StatusCode::INTERNAL_SERVER_ERROR,
&[("Cache-Control", "public, max-age=60, must-revalidate")],
)
})?
.map_err(|e| {
tracing::error!("❌ Failed to get the kate query data. Error: {e:#}");
tracing::error!("❌ Failed to get the bridge query data proof. Error: {e:#}");
ErrorResponse::with_status_and_headers(
anyhow::anyhow!("Failed to get the kate query data."),
anyhow::anyhow!("Failed to get the bridge query data proof."),
StatusCode::BAD_REQUEST,
&[("Cache-Control", "public, max-age=60, must-revalidate")],
)
Expand Down Expand Up @@ -679,7 +679,7 @@ async fn get_proof(
}
}

let data_proof_response_fut = spawn_kate_proof(state.clone(), index, block_hash);
let data_proof_response_fut = spawn_data_proof(state.clone(), index, block_hash);
let merkle_proof_range_fut = spawn_merkle_proof_range_fetch(state.clone(), block_hash);
let (data_proof, range_response) = join!(data_proof_response_fut, merkle_proof_range_fut);

Expand All @@ -697,9 +697,9 @@ async fn get_proof(
|| err_str.contains("Cannot fetch tx data")
|| err_str.contains("is not finalized");
if is_warn {
tracing::warn!("Cannot get kate data proof response: {:?}", e);
tracing::warn!("Cannot get bridge data proof response: {:?}", e);
} else {
tracing::error!("Cannot get kate data proof response: {:?}", e);
tracing::error!("Cannot get bridge data proof response: {:?}", e);
}
ErrorResponse::with_status_and_headers(
anyhow!("error: {e:#}"),
Expand Down Expand Up @@ -771,16 +771,16 @@ async fn get_proof(
.into_response())
}

// spawn_kate_proof fetch queryDataProof from Avail chain
fn spawn_kate_proof(
// spawn_data_proof fetches queryDataProof from Avail chain.
fn spawn_data_proof(
state: Arc<AppState>,
index: u32,
block_hash: B256,
) -> JoinHandle<Result<KateQueryDataProofResponse, ClientError>> {
) -> JoinHandle<Result<BridgeQueryDataProofResponse, ClientError>> {
tokio::spawn(async move {
state
.avail_client
.request("kate_queryDataProof", rpc_params![index, &block_hash])
.request("bridge_queryDataProof", rpc_params![index, &block_hash])
.await
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub struct ProofQueryStruct {

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KateQueryDataProofResponse {
pub struct BridgeQueryDataProofResponse {
pub data_proof: DataProof,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<AddressedMessage>,
Expand Down Expand Up @@ -209,7 +209,7 @@ pub struct AggregatedResponse {
impl AggregatedResponse {
pub fn new(
range_data: MerkleProofData,
data_proof_res: KateQueryDataProofResponse,
data_proof_res: BridgeQueryDataProofResponse,
hash: B256,
) -> Self {
AggregatedResponse {
Expand Down
Loading