use ethers::contract::abigen;
use ethers::providers::{Http, Provider};
use ethers::types::{Address, U256};
use std::sync::Arc;
abigen!(
NeoXBridgeEVM,
r#"[
function withdraw(address token, uint256 amount, string memory destination) public payable
function getFee(address token) public view returns (uint256)
]"#
);
pub struct NeoXBridgeContractEVM {
contract: NeoXBridgeEVM<Provider<Http>>,
}
impl NeoXBridgeContractEVM {
pub const CONTRACT_ADDRESS: &'static str = "0x0000000000000000000000000000000000000000";
pub fn new(address: Address, provider: Arc<Provider<Http>>) -> Self {
let contract = NeoXBridgeEVM::new(address, provider);
Self { contract }
}
pub fn default_bridge(provider: Arc<Provider<Http>>) -> Self {
let address: Address = Self::CONTRACT_ADDRESS.parse().unwrap_or_default();
Self::new(address, provider)
}
pub fn withdraw(&self, token: Address, amount: U256, destination_n3_address: String) -> ethers::contract::ContractCall<Provider<Http>, ()> {
self.contract.withdraw(token, amount, destination_n3_address)
}
pub async fn get_fee(&self, token: Address) -> Result<U256, ethers::contract::ContractError<Provider<Http>>> {
self.contract.get_fee(token).call().await
}
}