Skip to content

Commit

Permalink
get_event in Ref
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaplas committed Nov 8, 2023
1 parent 20d61b8 commit 3bf87af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples2/src/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ mod __erc20_test_parts {
use crate::erc20::Erc20;
use odra2::prelude::*;
use odra2::types::casper_types::EntryPoints;
use odra2::types::{runtime_args, Address, Bytes, RuntimeArgs, ToBytes, U256, U512};
use odra2::types::{runtime_args, Address, Bytes, RuntimeArgs, ToBytes, U256, U512, FromBytes};
use odra2::{CallDef, ContractEnv, EntryPointsCaller, HostEnv};
use odra2::casper_event_standard::EventInstance;
use odra2::event::EventError;

pub struct Erc20ContractRef {
pub address: Address,
Expand Down Expand Up @@ -446,6 +448,10 @@ mod __erc20_test_parts {
)
)
}

pub fn get_event<T: FromBytes + EventInstance>(&self, index: i32) -> Result<T, EventError> {
self.env.get_event(&self.address, index)
}
}

pub struct Erc20Deployer;
Expand Down Expand Up @@ -580,7 +586,7 @@ mod tests {
assert_eq!(env.balance_of(&alice), current_balance + U512::from(100));

// Test events
let event: Transfer = env.get_event(&erc20.address, 0).unwrap();
let event: Transfer = erc20.get_event(0).unwrap();
assert_eq!(event.from, Some(alice));
assert_eq!(event.to, Some(bob));
assert_eq!(event.amount, 10.into());
Expand Down

0 comments on commit 3bf87af

Please sign in to comment.