diff --git a/README.md b/README.md index 6ad5d8e0..d040697b 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,6 @@ cargo run -- account-balance --interval 2.0 -c polygon -a 0x75be52afd54a13b6c984 # Example attestation -http://127.0.0.1:8080/erc20/api/attestation/sepolia/0x1d542735c2be213e64e3eff427efad256d27ac1dc9fabb6e5507d2e89cdd1717 \ No newline at end of file + +http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xeb9b088871155d0ae32f382de5a42d0a64e946f512b722698f4ae6b32164f92d +http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xc8b0ceee393cdcf313945d20b3bd45a01b0ccf2484309b669da2d4da9266b4d5 diff --git a/crates/erc20_payment_lib/config-payments.toml b/crates/erc20_payment_lib/config-payments.toml index 97c04286..2279a0a0 100644 --- a/crates/erc20_payment_lib/config-payments.toml +++ b/crates/erc20_payment_lib/config-payments.toml @@ -138,7 +138,7 @@ currency-symbol = "ETH" priority-fee = 0.000001 max-fee-per-gas = 20.0 transaction-timeout = 100 -attestation-contract = { address = "0x357458739f90461b99789350868cd7cf330dd7ee" } +attestation-contract = { address = "0x4200000000000000000000000000000000000021" } schema-registry-contract = { address = "0x4200000000000000000000000000000000000020" } token = { address = "0x1200000000000000000000000000000000000021", symbol = "GLM" } confirmation-blocks = 0 diff --git a/crates/erc20_payment_lib/src/eth.rs b/crates/erc20_payment_lib/src/eth.rs index d32c678f..ad5c4d29 100644 --- a/crates/erc20_payment_lib/src/eth.rs +++ b/crates/erc20_payment_lib/src/eth.rs @@ -148,7 +148,7 @@ pub async fn get_schema_details( ))?; let decoded = decoded[0].clone().into_tuple().unwrap(); - log::info!("Decoded attestation: {:?}", decoded); + log::info!("Decoded attestation schema: {:?}", decoded); let schema = AttestationSchema { uid: H256::from_slice(decoded[0].clone().into_fixed_bytes().unwrap().as_slice()), resolver: decoded[1].clone().into_address().unwrap(), @@ -177,7 +177,7 @@ pub async fn get_attestation_details( web3: Arc, uid: H256, eas_contract_address: Address, -) -> Result { +) -> Result, PaymentError> { let res = web3 .eth_call( CallRequest { @@ -214,6 +214,9 @@ pub async fn get_attestation_details( ))?; let decoded = decoded[0].clone().into_tuple().unwrap(); + if decoded[0] == ethabi::Token::FixedBytes(vec![0; 32]) { + return Ok(None); + } log::info!("Decoded attestation: {:?}", decoded); let attestation = Attestation { uid: H256::from_slice(decoded[0].clone().into_fixed_bytes().unwrap().as_slice()), @@ -229,7 +232,7 @@ pub async fn get_attestation_details( data: Bytes::from(decoded[9].clone().into_bytes().unwrap()), }; - Ok(attestation) + Ok(Some(attestation)) } pub async fn get_deposit_details( diff --git a/crates/erc20_payment_lib/src/server/web.rs b/crates/erc20_payment_lib/src/server/web.rs index 7427a77b..b441a89b 100644 --- a/crates/erc20_payment_lib/src/server/web.rs +++ b/crates/erc20_payment_lib/src/server/web.rs @@ -1303,7 +1303,13 @@ pub async fn check_attestation( log::info!("Querying attestation contract: {:#x}", contract.address); let attestation = match get_attestation_details(web3.clone(), uid, contract.address).await { - Ok(attestation) => attestation, + Ok(Some(attestation)) => attestation, + Ok(None) => { + return Err(ErrorBadRequest(format!( + "Attestation with uid: {:#x} not found on chain {}", + uid, chain_name + ))); + } Err(e) => { log::error!("Failed to get attestation details: {}", e); return Err(ErrorBadRequest(format!( @@ -1343,17 +1349,13 @@ pub async fn check_attestation( )))? ); - let items = attestation_schema - .schema - .split(",") - .into_iter() - .collect::>(); + let items = attestation_schema.schema.split(',').collect::>(); log::debug!("There are {} items in the schema", items.len()); let mut param_types = Vec::new(); let mut param_names = Vec::new(); for item in items { - let items2 = item.trim().split(" ").into_iter().collect::>(); + let items2 = item.trim().split(' ').collect::>(); if items2.len() != 2 { log::error!("Invalid item in schema: {}", item); return Err(ErrorBadRequest(format!("Invalid item in schema: {}", item))); @@ -1385,13 +1387,13 @@ pub async fn check_attestation( }); } - return Ok(web::Json(AttestationCheckResult { + Ok(web::Json(AttestationCheckResult { chain_id: chain.chain_id as u64, chain: chain_name.to_string(), attestation, schema: attestation_schema, params: decoded_items, - })); + })) } pub fn runtime_web_scope( diff --git a/src/actions/attestation/check.rs b/src/actions/attestation/check.rs index cb64afcb..16d6e5af 100644 --- a/src/actions/attestation/check.rs +++ b/src/actions/attestation/check.rs @@ -73,7 +73,14 @@ pub async fn check_attestation_local( log::info!("Querying attestation contract: {:#x}", contract.address); let attestation = match get_attestation_details(web3.clone(), uid, contract.address).await { - Ok(attestation) => attestation, + Ok(Some(attestation)) => attestation, + Ok(None) => { + return Err(err_custom_create!( + "Attestation with uid: {:#x} not found on chain {}", + uid, + options.chain_name + )); + } Err(e) => { log::error!("Failed to get attestation details: {}", e); return Err(err_custom_create!(