difftreelog
style reformat code
in: master
3 files changed
pallets/nft/Cargo.tomldiffbeforeafterboth1[package]2authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']3description = 'FRAME pallet nft'4edition = '2018'5homepage = 'https://substrate.io'6license = 'Unlicense'7name = 'pallet-nft'8repository = 'https://github.com/substrate-developer-hub/nft/'9version = '3.0.0'1011[package.metadata.docs.rs]12targets = ['x86_64-unknown-linux-gnu']1314# alias "parity-scale-code" to "codec"15[dependencies.codec]16default-features = false17features = ['derive']18package = 'parity-scale-codec'19version = '2.0.0'2021[dependencies]22serde = { default-features = false, version = "1.0.119", features = ["derive"] }23frame-support = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }24frame-system = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }25pallet-balances = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }26pallet-evm = { default-features = false, version = "3.0.1-dev", git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }27pallet-ethereum = { default-features = false, version = "1.0.1-dev", git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }28pallet-timestamp = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }29pallet-randomness-collective-flip = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }30sp-std = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }31frame-benchmarking = { default-features = false, version = '3.0.0', optional = true, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }32fp-evm = { default-features = false, version = '1.0.1-dev', git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }33sp-core = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }34sp-io = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }35sp-api = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }36sp-runtime = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }37pallet-contracts = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }38pallet-transaction-payment = { default-features = false, version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" }3940ethereum-tx-sign = { version = "3.0.4", optional = true }41ethereum = { default-features = false, version = "0.7.1" }42rlp = { default-features = false, version = "0.5.0" }4344evm-coder = { default-features = false, path = "../../crates/evm-coder" }45primitive-types = { version = "0.9.0", default-features = false }4647hex-literal = "0.3.1"4849[features]50default = ['std']51std = [52 'codec/std',53 'serde/std',54 'frame-support/std',55 'frame-system/std',56 'pallet-balances/std',57 'pallet-evm/std',58 'pallet-timestamp/std',59 'pallet-contracts/std',60 'pallet-randomness-collective-flip/std',61 'pallet-transaction-payment/std',62 'fp-evm/std',63 'sp-std/std',64 'sp-runtime/std',65 'frame-benchmarking/std',66 'ethereum/std',67 'rlp/std',6869 'ethereum-tx-sign',70 'primitive-types/std',71 'evm-coder/std',72]73runtime-benchmarks = ["frame-benchmarking"]1[package]2authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']3description = 'FRAME pallet nft'4edition = '2018'5homepage = 'https://substrate.io'6license = 'Unlicense'7name = 'pallet-nft'8repository = 'https://github.com/substrate-developer-hub/nft/'9version = '3.0.0'1011[package.metadata.docs.rs]12targets = ['x86_64-unknown-linux-gnu']1314# alias "parity-scale-code" to "codec"15[dependencies.codec]16default-features = false17features = ['derive']18package = 'parity-scale-codec'19version = '2.0.0'2021[dependencies]22serde = { default-features = false, version = "1.0.119", features = ["derive"] }23frame-support = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }24frame-system = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }25pallet-balances = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }26pallet-evm = { default-features = false, version = "3.0.1-dev", git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }27pallet-ethereum = { default-features = false, version = "1.0.1-dev", git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }28pallet-timestamp = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }29pallet-randomness-collective-flip = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }30sp-std = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }31frame-benchmarking = { default-features = false, version = '3.0.0', optional = true, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }32fp-evm = { default-features = false, version = '1.0.1-dev', git = "https://github.com/usetech-llc/frontier.git", branch = "injected-transactions" }33sp-core = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }34sp-io = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }35sp-api = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }36sp-runtime = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }37pallet-contracts = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }38pallet-transaction-payment = { default-features = false, version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" }3940ethereum-tx-sign = { version = "3.0.4", optional = true }41ethereum = { default-features = false, version = "0.7.1" }42rlp = { default-features = false, version = "0.5.0" }4344evm-coder = { default-features = false, path = "../../crates/evm-coder" }45primitive-types = { version = "0.9.0", default-features = false, features = ["serde_no_std"] }4647hex-literal = "0.3.1"4849[features]50default = ['std']51std = [52 'codec/std',53 'serde/std',54 'frame-support/std',55 'frame-system/std',56 'pallet-balances/std',57 'pallet-evm/std',58 'pallet-timestamp/std',59 'pallet-contracts/std',60 'pallet-randomness-collective-flip/std',61 'pallet-transaction-payment/std',62 'fp-evm/std',63 'sp-std/std',64 'sp-runtime/std',65 'frame-benchmarking/std',66 'ethereum/std',67 'rlp/std',6869 'ethereum-tx-sign',70 'primitive-types/std',71 'evm-coder/std',72]73runtime-benchmarks = ["frame-benchmarking"]pallets/nft/src/eth/account.rsdiffbeforeafterboth--- 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;
pallets/nft/src/eth/mod.rsdiffbeforeafterboth--- 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<T: Config>(core::marker::PhantomData<T>);
// 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<CollectionId> {
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::<ethereum::Transaction>(&signed).expect("transaction is just created, it can't be broken")
+ rlp::decode::<ethereum::Transaction>(&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
+}