Skip to content

Commit

Permalink
Add 429 error response when fetching the eth proofs. (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSasaPrsic authored Apr 26, 2024
1 parent 5825b07 commit 2fb1602
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AVAIL_CLIENT_URL=https://couscous-devnet.avail.tools/api
AVAIL_CLIENT_URL=https://rpc-hex-devnet.avail.tools/api
SUCCINCT_URL=https://beaconapi.succinct.xyz/api/integrations/vectorx
AVAIL_CHAIN_NAME=couscous
AVAIL_CHAIN_NAME=hex
CONTRACT_CHAIN_ID=11155111
VECTORX_CONTRACT_ADDRESS=0xD528DdCd659D380DFDe96c8fa3e03BaAa03cb51A
BRIDGE_CONTRACT_ADDRESS=0x75545225C83B985f3A517bF61f316266057bb13b
VECTORX_CONTRACT_ADDRESS=0xbc281367e1F2dB1c3e92255AA2F040B1c642ec75
BRIDGE_CONTRACT_ADDRESS=0x1369a4c9391cf90d393b40faead521b0f7019dc5
ETHEREUM_CLIENT_URL=https://ethereum-sepolia.publicnode.com
BEACONCHAIN_URL=https://sepolia.beaconcha.in/api/v1/slot
HOST=0.0.0.0
Expand Down
18 changes: 13 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,19 @@ async fn get_avl_proof(
),
Err(err) => {
tracing::error!("❌ Cannot get account and storage proofs: {:?}", err);
(
StatusCode::INTERNAL_SERVER_ERROR,
[("Cache-Control", "max-age=300, must-revalidate")],
Json(json!({ "error": err.to_string()})),
)
if err.to_string().ends_with("status code: 429") {
(
StatusCode::TOO_MANY_REQUESTS,
[("Cache-Control", "max-age=300, must-revalidate")],
Json(json!({ "error": err.to_string()})),
)
} else {
(
StatusCode::INTERNAL_SERVER_ERROR,
[("Cache-Control", "max-age=300, must-revalidate")],
Json(json!({ "error": err.to_string()})),
)
}
}
}
}
Expand Down

0 comments on commit 2fb1602

Please sign in to comment.