Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::deposit_event::*;
use crate::engine::Engine;
use crate::json::parse_json;
use crate::prelude::*;
use crate::prover::validate_eth_address;
use crate::prover::{validate_eth_address, Proof};
use crate::storage::{self, EthConnectorStorageId, KeyPrefix};
#[cfg(feature = "log")]
use alloc::format;
Expand Down Expand Up @@ -181,7 +181,6 @@ impl EthConnectorContract {
pub fn deposit(&self) {
self.assert_not_paused(PAUSE_DEPOSIT);

use crate::prover::Proof;
#[cfg(feature = "log")]
sdk::log("[Deposit tokens]");

Expand Down Expand Up @@ -643,6 +642,11 @@ impl EthConnectorContract {
sdk::storage_has_key(&self.used_event_key(key))
}

/// Checks whether the provided proof was already used
pub fn is_used_proof(&self, proof: Proof) -> bool {
self.check_used_event(&proof.get_key())
}

/// Get Eth connector paused flags
pub fn get_paused_flags(&self) -> PausedMask {
self.get_paused()
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ mod contract {
#[cfg(feature = "evm_bully")]
use crate::parameters::{BeginBlockArgs, BeginChainArgs};
use crate::parameters::{
ExpectUtf8, FunctionCallArgs, GetStorageAtArgs, InitCallArgs, NewCallArgs,
PauseEthConnectorCallArgs, SetContractDataCallArgs, TransferCallCallArgs, ViewCallArgs,
ExpectUtf8, FunctionCallArgs, GetStorageAtArgs, InitCallArgs, IsUsedProofCallArgs,
NewCallArgs, PauseEthConnectorCallArgs, SetContractDataCallArgs, TransferCallCallArgs,
ViewCallArgs,
};
use crate::prelude::{Address, H256, U256};
use crate::sdk;
Expand Down Expand Up @@ -401,6 +402,15 @@ mod contract {
EthConnectorContract::get_instance().finish_deposit_near();
}

#[no_mangle]
pub extern "C" fn is_used_proof() {
let args = IsUsedProofCallArgs::try_from_slice(&sdk::read_input()).expect(ERR_FAILED_PARSE);
Comment thread
sept-en marked this conversation as resolved.

let is_used_proof = EthConnectorContract::get_instance().is_used_proof(args.proof);
let res = is_used_proof.try_to_vec().unwrap();
sdk::return_output(&res[..]);
}

#[no_mangle]
pub extern "C" fn ft_total_supply() {
EthConnectorContract::get_instance().ft_total_supply();
Expand Down
8 changes: 8 additions & 0 deletions src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ pub struct DepositCallArgs {
pub relayer_eth_account: Option<EthAddress>,
}

/// Eth-connector isUsedProof arguments
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct IsUsedProofCallArgs {
/// Proof data
pub proof: Proof,
}

Comment thread
sept-en marked this conversation as resolved.
/// withdraw result for eth-connector
#[cfg(feature = "engine")]
#[derive(BorshSerialize)]
Expand Down
Loading