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

difftreelog

refactor extract evm string error

Yaroslav Bolyukin2021-07-20parent: #d367e15.patch.diff
in: master

2 files changed

modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
163 self.write_padleft(&u128::to_be_bytes(*value))163 self.write_padleft(&u128::to_be_bytes(*value))
164 }164 }
165165
166 /// This method writes u128, and exists only for convenience, because there is
167 /// no u256 support in rust
168 pub fn uint256(&mut self, value: &U256) {166 pub fn uint256(&mut self, value: &U256) {
169 let mut out = [0; 32];167 let mut out = [0; 32];
170 value.to_big_endian(&mut out);168 value.to_big_endian(&mut out);
260 fn abi_write(&self, _writer: &mut AbiWriter) {}258 fn abi_write(&self, _writer: &mut AbiWriter) {}
261}259}
262
263/// Error, which can be constructed from any ToString type
264/// Encoded to Abi as Error(string)
265#[derive(Debug)]
266pub struct StringError(String);
267
268impl<E> From<E> for StringError
269where
270 E: ToString,
271{
272 fn from(e: E) -> Self {
273 Self(e.to_string())
274 }
275}
276
277impl From<StringError> for AbiWriter {
278 fn from(v: StringError) -> Self {
279 let mut out = AbiWriter::new_call(crate::fn_selector!(Error(string)));
280 out.string(&v.0);
281 out
282 }
283}
284260
285#[macro_export]261#[macro_export]
286macro_rules! abi_decode {262macro_rules! abi_decode {
addedcrates/evm-coder/src/execution.rsdiffbeforeafterboth

no changes