Skip to content

Commit

Permalink
added to api
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 6, 2023
1 parent 10b2b31 commit e5385c5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/erc20_payment_lib/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,23 @@ impl PaymentRuntime {
pub fn network_name(&self, chain_id: i64) -> Option<&str> {
self.get_chain(chain_id).map(|chain| chain.network.as_str())
}
}

pub async fn verify_transaction(
&self,
chain_id: i64,
tx_hash: H256,
sender: Address,
receiver: Address,
amount: U256,
) -> Result<VerifyTransactionResult, PaymentError> {
let network_name = self.network_name(chain_id).ok_or(err_custom_create!(
"Chain {} not found in config file",
chain_id
))?;
let prov = self.get_web3_provider(network_name).await?;
verify_transaction(&prov, chain_id, tx_hash, sender, receiver, amount).await
}
}
pub struct VerifyTransactionResult {
pub verified: bool,
pub reason: Option<String>,
Expand Down

0 comments on commit e5385c5

Please sign in to comment.