From 35f0b49c19be1a3dd168a86ba203847a73749a40 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 02 Jun 2021 19:23:49 +0000 Subject: [PATCH] style: reformat code --- --- a/pallets/nft/Cargo.toml +++ b/pallets/nft/Cargo.toml @@ -42,7 +42,7 @@ rlp = { default-features = false, version = "0.5.0" } evm-coder = { default-features = false, path = "../../crates/evm-coder" } -primitive-types = { version = "0.9.0", default-features = false } +primitive-types = { version = "0.9.0", default-features = false, features = ["serde_no_std"] } hex-literal = "0.3.1" --- a/pallets/nft/src/eth/account.rs +++ b/pallets/nft/src/eth/account.rs @@ -1,6 +1,7 @@ use crate::Config; use codec::{Encode, EncodeLike, Decode}; -use sp_core::{H160, H256, crypto::AccountId32}; +use sp_core::crypto::AccountId32; +use primitive_types::H160; use core::cmp::Ordering; use serde::{Serialize, Deserialize}; use pallet_evm::AddressMapping; --- a/pallets/nft/src/eth/mod.rs +++ b/pallets/nft/src/eth/mod.rs @@ -1,25 +1,31 @@ pub mod account; -use account::CrossAccountId; -pub mod abi; -use abi::{AbiReader, AbiWriter}; +pub mod erc; +mod erc_impl; pub mod log; +pub mod sponsoring; +use evm_coder::abi::AbiWriter; +use evm_coder::abi::StringError; +use sp_std::prelude::*; use sp_std::borrow::ToOwned; use sp_std::vec::Vec; -use sp_std::convert::TryInto; -use codec::{Decode, Encode}; -use pallet_evm::{AddressMapping, PrecompileLog, PrecompileOutput, ExitReason, ExitRevert, ExitSucceed}; -use sp_core::{H160, H256}; -use frame_support::storage::{StorageMap, StorageDoubleMap}; +use pallet_evm::{PrecompileOutput, ExitReason, ExitRevert, ExitSucceed}; +use sp_core::{H160, U256}; +use frame_support::storage::StorageMap; + +use crate::{Config, CollectionById, CollectionHandle, CollectionId, CollectionMode}; -use crate::{Allowances, NftItemList, Module, Balance, Config, CollectionById, CollectionHandle, CollectionId, CollectionMode}; +use erc::{UniqueFungible, UniqueFungibleCall, UniqueNFT, UniqueNFTCall}; +use evm_coder::{types::*, abi::AbiReader}; pub struct NftErcSupport(core::marker::PhantomData); // 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection // TODO: Unhardcode prefix -const ETH_ACCOUNT_PREFIX: [u8; 16] = [0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e]; +const ETH_ACCOUNT_PREFIX: [u8; 16] = [ + 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e, +]; fn map_eth_to_id(eth: &H160) -> Option { if ð[0..16] != ETH_ACCOUNT_PREFIX { @@ -113,7 +119,8 @@ CollectionMode::Fungible(_) => include_bytes!("stubs/ERC20.bin") as &[u8], CollectionMode::ReFungible => include_bytes!("stubs/ERC1633.bin") as &[u8], CollectionMode::Invalid => include_bytes!("stubs/Invalid.bin") as &[u8], - }.to_owned() + } + .to_owned() }) } fn call( @@ -162,17 +169,20 @@ gas: 0.into(), // zero selector, this transaction always have same sender, so all data should be acquired from logs data: Vec::from([0, 0, 0, 0]), - }.sign( + } + .sign( // TODO: move to pallet config // 0xF70631E55faff9f3FD3681545aa6c724226a3853 // 9dbaef9b3ebc00e53f67c6a77bcfbf2c4f2aebe4d70d94af4f2df01744b7a91a - &hex_literal::hex!("9dbaef9b3ebc00e53f67c6a77bcfbf2c4f2aebe4d70d94af4f2df01744b7a91a").into(), - &chain_id + &hex_literal::hex!("9dbaef9b3ebc00e53f67c6a77bcfbf2c4f2aebe4d70d94af4f2df01744b7a91a") + .into(), + &chain_id, ); - rlp::decode::(&signed).expect("transaction is just created, it can't be broken") + rlp::decode::(&signed) + .expect("transaction is just created, it can't be broken") } #[cfg(not(feature = "std"))] { panic!("transaction generation not yet supported by wasm runtime") } -} \ No newline at end of file +} -- gitstuff