From 3bf87afa6563e274fa3603b4feed8909b176183c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Wed, 8 Nov 2023 11:17:07 +0100 Subject: [PATCH] get_event in Ref --- examples2/src/erc20.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples2/src/erc20.rs b/examples2/src/erc20.rs index b2546b5b..15625a5b 100644 --- a/examples2/src/erc20.rs +++ b/examples2/src/erc20.rs @@ -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, @@ -446,6 +448,10 @@ mod __erc20_test_parts { ) ) } + + pub fn get_event(&self, index: i32) -> Result { + self.env.get_event(&self.address, index) + } } pub struct Erc20Deployer; @@ -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());