git.delta.rocks / unique-network / refs/commits / cddd1b2a4dac

difftreelog

source

crates/evm-coder/src/events.rs1.4 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use ethereum::Log;18use primitive_types::{H160, H256};1920use crate::types::*;2122pub trait ToLog {23	fn to_log(&self, contract: H160) -> Log;24}2526pub trait ToTopic {27	fn to_topic(&self) -> H256;28}2930impl ToTopic for H256 {31	fn to_topic(&self) -> H256 {32		*self33	}34}3536impl ToTopic for uint256 {37	fn to_topic(&self) -> H256 {38		let mut out = [0u8; 32];39		self.to_big_endian(&mut out);40		H256(out)41	}42}4344impl ToTopic for address {45	fn to_topic(&self) -> H256 {46		let mut out = [0u8; 32];47		out[12..32].copy_from_slice(&self.0);48		H256(out)49	}50}5152impl ToTopic for uint32 {53	fn to_topic(&self) -> H256 {54		let mut out = [0u8; 32];55		out[28..32].copy_from_slice(&self.to_be_bytes());56		H256(out)57	}58}