Skip to content

Commit 0d34144

Browse files
committed
fix: fmt
1 parent 7edef68 commit 0d34144

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@ cargo run -- account-balance --interval 2.0 -c polygon -a 0x75be52afd54a13b6c984
7171

7272
# Example attestation
7373

74-
http://127.0.0.1:8080/erc20/api/attestation/sepolia/0x1d542735c2be213e64e3eff427efad256d27ac1dc9fabb6e5507d2e89cdd1717
74+
75+
http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xeb9b088871155d0ae32f382de5a42d0a64e946f512b722698f4ae6b32164f92d
76+
http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xc8b0ceee393cdcf313945d20b3bd45a01b0ccf2484309b669da2d4da9266b4d5

crates/erc20_payment_lib/config-payments.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ currency-symbol = "ETH"
138138
priority-fee = 0.000001
139139
max-fee-per-gas = 20.0
140140
transaction-timeout = 100
141-
attestation-contract = { address = "0x357458739f90461b99789350868cd7cf330dd7ee" }
141+
attestation-contract = { address = "0x4200000000000000000000000000000000000021" }
142142
schema-registry-contract = { address = "0x4200000000000000000000000000000000000020" }
143143
token = { address = "0x1200000000000000000000000000000000000021", symbol = "GLM" }
144144
confirmation-blocks = 0

crates/erc20_payment_lib/src/eth.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub async fn get_schema_details(
148148
))?;
149149

150150
let decoded = decoded[0].clone().into_tuple().unwrap();
151-
log::info!("Decoded attestation: {:?}", decoded);
151+
log::info!("Decoded attestation schema: {:?}", decoded);
152152
let schema = AttestationSchema {
153153
uid: H256::from_slice(decoded[0].clone().into_fixed_bytes().unwrap().as_slice()),
154154
resolver: decoded[1].clone().into_address().unwrap(),
@@ -177,7 +177,7 @@ pub async fn get_attestation_details(
177177
web3: Arc<Web3RpcPool>,
178178
uid: H256,
179179
eas_contract_address: Address,
180-
) -> Result<Attestation, PaymentError> {
180+
) -> Result<Option<Attestation>, PaymentError> {
181181
let res = web3
182182
.eth_call(
183183
CallRequest {
@@ -214,6 +214,9 @@ pub async fn get_attestation_details(
214214
))?;
215215

216216
let decoded = decoded[0].clone().into_tuple().unwrap();
217+
if decoded[0] == ethabi::Token::FixedBytes(vec![0; 32]) {
218+
return Ok(None);
219+
}
217220
log::info!("Decoded attestation: {:?}", decoded);
218221
let attestation = Attestation {
219222
uid: H256::from_slice(decoded[0].clone().into_fixed_bytes().unwrap().as_slice()),
@@ -229,7 +232,7 @@ pub async fn get_attestation_details(
229232
data: Bytes::from(decoded[9].clone().into_bytes().unwrap()),
230233
};
231234

232-
Ok(attestation)
235+
Ok(Some(attestation))
233236
}
234237

235238
pub async fn get_deposit_details(

crates/erc20_payment_lib/src/server/web.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,13 @@ pub async fn check_attestation(
13031303
log::info!("Querying attestation contract: {:#x}", contract.address);
13041304

13051305
let attestation = match get_attestation_details(web3.clone(), uid, contract.address).await {
1306-
Ok(attestation) => attestation,
1306+
Ok(Some(attestation)) => attestation,
1307+
Ok(None) => {
1308+
return Err(ErrorBadRequest(format!(
1309+
"Attestation with uid: {:#x} not found on chain {}",
1310+
uid, chain_name
1311+
)));
1312+
}
13071313
Err(e) => {
13081314
log::error!("Failed to get attestation details: {}", e);
13091315
return Err(ErrorBadRequest(format!(
@@ -1343,17 +1349,13 @@ pub async fn check_attestation(
13431349
)))?
13441350
);
13451351

1346-
let items = attestation_schema
1347-
.schema
1348-
.split(",")
1349-
.into_iter()
1350-
.collect::<Vec<&str>>();
1352+
let items = attestation_schema.schema.split(',').collect::<Vec<&str>>();
13511353
log::debug!("There are {} items in the schema", items.len());
13521354
let mut param_types = Vec::new();
13531355
let mut param_names = Vec::new();
13541356

13551357
for item in items {
1356-
let items2 = item.trim().split(" ").into_iter().collect::<Vec<&str>>();
1358+
let items2 = item.trim().split(' ').collect::<Vec<&str>>();
13571359
if items2.len() != 2 {
13581360
log::error!("Invalid item in schema: {}", item);
13591361
return Err(ErrorBadRequest(format!("Invalid item in schema: {}", item)));
@@ -1385,13 +1387,13 @@ pub async fn check_attestation(
13851387
});
13861388
}
13871389

1388-
return Ok(web::Json(AttestationCheckResult {
1390+
Ok(web::Json(AttestationCheckResult {
13891391
chain_id: chain.chain_id as u64,
13901392
chain: chain_name.to_string(),
13911393
attestation,
13921394
schema: attestation_schema,
13931395
params: decoded_items,
1394-
}));
1396+
}))
13951397
}
13961398

13971399
pub fn runtime_web_scope(

src/actions/attestation/check.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ pub async fn check_attestation_local(
7373
log::info!("Querying attestation contract: {:#x}", contract.address);
7474

7575
let attestation = match get_attestation_details(web3.clone(), uid, contract.address).await {
76-
Ok(attestation) => attestation,
76+
Ok(Some(attestation)) => attestation,
77+
Ok(None) => {
78+
return Err(err_custom_create!(
79+
"Attestation with uid: {:#x} not found on chain {}",
80+
uid,
81+
options.chain_name
82+
));
83+
}
7784
Err(e) => {
7885
log::error!("Failed to get attestation details: {}", e);
7986
return Err(err_custom_create!(

0 commit comments

Comments
 (0)