difftreelog
refac: rename caller -> Caller
in: master
11 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -354,7 +354,7 @@
fn is_caller(&self) -> bool {
if let Ok(ident) = self.plain() {
- return ident == "caller";
+ return ident == "Caller";
}
false
}
crates/evm-coder/src/lib.rsdiffbeforeafterboth--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -147,7 +147,7 @@
/// Makes function payable
pub type Value = U256;
/// Makes function caller-sensitive
- pub type caller = Address;
+ pub type Caller = Address;
//#endregion
/// Ethereum typed call message, similar to solidity
crates/evm-coder/tests/random.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/random.rs
+++ b/crates/evm-coder/tests/random.rs
@@ -64,7 +64,7 @@
unreachable!()
}
- fn caller_sensitive(&self, _caller: caller) -> Result<u8> {
+ fn caller_sensitive(&self, _caller: Caller) -> Result<u8> {
unreachable!()
}
fn payable(&mut self, _value: Value) -> Result<u8> {
crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/solidity_generation.rs
+++ b/crates/evm-coder/tests/solidity_generation.rs
@@ -28,19 +28,19 @@
fn balance_of(&self, _owner: Address) -> Result<U256> {
unreachable!()
}
- fn transfer(&mut self, _caller: caller, _to: Address, _value: U256) -> Result<bool> {
+ fn transfer(&mut self, _caller: Caller, _to: Address, _value: U256) -> Result<bool> {
unreachable!()
}
fn transfer_from(
&mut self,
- _caller: caller,
+ _caller: Caller,
_from: Address,
_to: Address,
_value: U256,
) -> Result<bool> {
unreachable!()
}
- fn approve(&mut self, _caller: caller, _spender: Address, _value: U256) -> Result<bool> {
+ fn approve(&mut self, _caller: Caller, _spender: Address, _value: U256) -> Result<bool> {
unreachable!()
}
fn allowance(&self, _owner: Address, _spender: Address) -> Result<U256> {
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -94,7 +94,7 @@
/// @param value Propery value.
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]
- fn set_collection_property(&mut self, caller: caller, key: String, value: Bytes) -> Result<()> {
+ fn set_collection_property(&mut self, caller: Caller, key: String, value: Bytes) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let key = <Vec<u8>>::from(key)
.try_into()
@@ -111,7 +111,7 @@
#[weight(<SelfWeightOf<T>>::set_collection_properties(properties.len() as u32))]
fn set_collection_properties(
&mut self,
- caller: caller,
+ caller: Caller,
properties: Vec<eth::Property>,
) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -130,7 +130,7 @@
/// @param key Property key.
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
- fn delete_collection_property(&mut self, caller: caller, key: String) -> Result<()> {
+ fn delete_collection_property(&mut self, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let key = <Vec<u8>>::from(key)
.try_into()
@@ -143,7 +143,7 @@
///
/// @param keys Properties keys.
#[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]
- fn delete_collection_properties(&mut self, caller: caller, keys: Vec<String>) -> Result<()> {
+ fn delete_collection_properties(&mut self, caller: Caller, keys: Vec<String>) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let keys = keys
.into_iter()
@@ -208,7 +208,7 @@
///
/// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
#[solidity(hide)]
- fn set_collection_sponsor(&mut self, caller: caller, sponsor: Address) -> Result<()> {
+ fn set_collection_sponsor(&mut self, caller: Caller, sponsor: Address) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -225,7 +225,7 @@
/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
fn set_collection_sponsor_cross(
&mut self,
- caller: caller,
+ caller: Caller,
sponsor: eth::CrossAddress,
) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
@@ -248,7 +248,7 @@
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
- fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<()> {
+ fn confirm_collection_sponsorship(&mut self, caller: Caller) -> Result<()> {
self.consume_store_writes(1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -257,7 +257,7 @@
}
/// Remove collection sponsor.
- fn remove_collection_sponsor(&mut self, caller: caller) -> Result<()> {
+ fn remove_collection_sponsor(&mut self, caller: Caller) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
self.remove_sponsor(&caller).map_err(dispatch_to_evm::<T>)
@@ -339,7 +339,7 @@
/// @dev Throws error if limit not found.
/// @param limit Some limit.
#[solidity(rename_selector = "setCollectionLimit")]
- fn set_collection_limit(&mut self, caller: caller, limit: eth::CollectionLimit) -> Result<()> {
+ fn set_collection_limit(&mut self, caller: Caller, limit: eth::CollectionLimit) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
if !limit.has_value() {
@@ -359,7 +359,7 @@
/// @param newAdmin Cross account administrator address.
fn add_collection_admin_cross(
&mut self,
- caller: caller,
+ caller: Caller,
new_admin: eth::CrossAddress,
) -> Result<()> {
self.consume_store_reads_and_writes(2, 2)?;
@@ -374,7 +374,7 @@
/// @param admin Cross account administrator address.
fn remove_collection_admin_cross(
&mut self,
- caller: caller,
+ caller: Caller,
admin: eth::CrossAddress,
) -> Result<()> {
self.consume_store_reads_and_writes(2, 2)?;
@@ -388,7 +388,7 @@
/// Add collection admin.
/// @param newAdmin Address of the added administrator.
#[solidity(hide)]
- fn add_collection_admin(&mut self, caller: caller, new_admin: Address) -> Result<()> {
+ fn add_collection_admin(&mut self, caller: Caller, new_admin: Address) -> Result<()> {
self.consume_store_reads_and_writes(2, 2)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -401,7 +401,7 @@
///
/// @param admin Address of the removed administrator.
#[solidity(hide)]
- fn remove_collection_admin(&mut self, caller: caller, admin: Address) -> Result<()> {
+ fn remove_collection_admin(&mut self, caller: Caller, admin: Address) -> Result<()> {
self.consume_store_reads_and_writes(2, 2)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -414,7 +414,7 @@
///
/// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
#[solidity(rename_selector = "setCollectionNesting")]
- fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<()> {
+ fn set_nesting_bool(&mut self, caller: Caller, enable: bool) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -435,7 +435,7 @@
#[solidity(rename_selector = "setCollectionNesting")]
fn set_nesting(
&mut self,
- caller: caller,
+ caller: Caller,
enable: bool,
collections: Vec<Address>,
) -> Result<()> {
@@ -503,7 +503,7 @@
}
/// Set the collection access method.
/// @param mode Access mode
- fn set_collection_access(&mut self, caller: caller, mode: eth::AccessMode) -> Result<()> {
+ fn set_collection_access(&mut self, caller: Caller, mode: eth::AccessMode) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -526,7 +526,7 @@
///
/// @param user Address of a trusted user.
#[solidity(hide)]
- fn add_to_collection_allow_list(&mut self, caller: caller, user: Address) -> Result<()> {
+ fn add_to_collection_allow_list(&mut self, caller: Caller, user: Address) -> Result<()> {
self.consume_store_writes(1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -540,7 +540,7 @@
/// @param user User cross account address.
fn add_to_collection_allow_list_cross(
&mut self,
- caller: caller,
+ caller: Caller,
user: eth::CrossAddress,
) -> Result<()> {
self.consume_store_writes(1)?;
@@ -555,7 +555,7 @@
///
/// @param user Address of a removed user.
#[solidity(hide)]
- fn remove_from_collection_allow_list(&mut self, caller: caller, user: Address) -> Result<()> {
+ fn remove_from_collection_allow_list(&mut self, caller: Caller, user: Address) -> Result<()> {
self.consume_store_writes(1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -569,7 +569,7 @@
/// @param user User cross account address.
fn remove_from_collection_allow_list_cross(
&mut self,
- caller: caller,
+ caller: Caller,
user: eth::CrossAddress,
) -> Result<()> {
self.consume_store_writes(1)?;
@@ -583,7 +583,7 @@
/// Switch permission for minting.
///
/// @param mode Enable if "true".
- fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<()> {
+ fn set_collection_mint_mode(&mut self, caller: Caller, mode: bool) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -640,7 +640,7 @@
/// @dev Owner can be changed only by current owner
/// @param newOwner new owner account
#[solidity(hide, rename_selector = "changeCollectionOwner")]
- fn set_owner(&mut self, caller: caller, new_owner: Address) -> Result<()> {
+ fn set_owner(&mut self, caller: Caller, new_owner: Address) -> Result<()> {
self.consume_store_writes(1)?;
let caller = T::CrossAccountId::from_eth(caller);
@@ -666,7 +666,7 @@
/// @param newOwner new owner cross account
fn change_collection_owner_cross(
&mut self,
- caller: caller,
+ caller: Caller,
new_owner: eth::CrossAddress,
) -> Result<()> {
self.consume_store_writes(1)?;
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -105,7 +105,7 @@
/// @param sponsor User address who set as pending sponsor.
fn set_sponsor(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
sponsor: Address,
) -> Result<()> {
@@ -125,7 +125,7 @@
/// Set contract as self sponsored.
///
/// @param contractAddress Contract for which a self sponsoring is being enabled.
- fn self_sponsored_enable(&mut self, caller: caller, contract_address: Address) -> Result<()> {
+ fn self_sponsored_enable(&mut self, caller: Caller, contract_address: Address) -> Result<()> {
self.recorder().consume_sload()?;
self.recorder().consume_sstore()?;
@@ -146,7 +146,7 @@
/// Remove sponsor.
///
/// @param contractAddress Contract for which a sponsorship is being removed.
- fn remove_sponsor(&mut self, caller: caller, contract_address: Address) -> Result<()> {
+ fn remove_sponsor(&mut self, caller: Caller, contract_address: Address) -> Result<()> {
self.recorder().consume_sload()?;
self.recorder().consume_sstore()?;
@@ -161,7 +161,7 @@
/// @dev Caller must be same that set via [`setSponsor`].
///
/// @param contractAddress Сontract for which need to confirm sponsorship.
- fn confirm_sponsorship(&mut self, caller: caller, contract_address: Address) -> Result<()> {
+ fn confirm_sponsorship(&mut self, caller: Caller, contract_address: Address) -> Result<()> {
self.recorder().consume_sload()?;
self.recorder().consume_sstore()?;
@@ -207,7 +207,7 @@
fn set_sponsoring_mode(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
mode: SponsoringModeT,
) -> Result<()> {
@@ -239,7 +239,7 @@
/// @dev Only contract owner can change this setting
fn set_sponsoring_rate_limit(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
rate_limit: u32,
) -> Result<()> {
@@ -259,7 +259,7 @@
/// @dev Only contract owner can change this setting
fn set_sponsoring_fee_limit(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
fee_limit: U256,
) -> Result<()> {
@@ -300,7 +300,7 @@
/// @dev Only contract owner can change this setting
fn toggle_allowed(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
user: Address,
is_allowed: bool,
@@ -329,7 +329,7 @@
/// @param enabled Should allowlist access to be enabled?
fn toggle_allowlist(
&mut self,
- caller: caller,
+ caller: Caller,
contract_address: Address,
enabled: bool,
) -> Result<()> {
pallets/fungible/src/erc.rsdiffbeforeafterboth1// 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/>.1617//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::{23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,24 weight,25};26use up_data_structs::CollectionMode;27use pallet_common::{28 CollectionHandle,29 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},30};31use sp_std::vec::Vec;32use pallet_evm::{account::CrossAccountId, PrecompileHandle};33use pallet_evm_coder_substrate::{call, dispatch_to_evm};34use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};35use sp_core::{U256, Get};3637use crate::{38 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,39 weights::WeightInfo,40};4142#[derive(ToLog)]43pub enum ERC20Events {44 Transfer {45 #[indexed]46 from: Address,47 #[indexed]48 to: Address,49 value: U256,50 },51 Approval {52 #[indexed]53 owner: Address,54 #[indexed]55 spender: Address,56 value: U256,57 },58}5960#[solidity_interface(name = ERC20, events(ERC20Events))]61impl<T: Config> FungibleHandle<T> {62 fn name(&self) -> Result<String> {63 Ok(decode_utf16(self.name.iter().copied())64 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))65 .collect::<String>())66 }67 fn symbol(&self) -> Result<String> {68 Ok(String::from_utf8_lossy(&self.token_prefix).into())69 }70 fn total_supply(&self) -> Result<U256> {71 self.consume_store_reads(1)?;72 Ok(<TotalSupply<T>>::get(self.id).into())73 }7475 fn decimals(&self) -> Result<u8> {76 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {77 *decimals78 } else {79 unreachable!()80 })81 }82 fn balance_of(&self, owner: Address) -> Result<U256> {83 self.consume_store_reads(1)?;84 let owner = T::CrossAccountId::from_eth(owner);85 let balance = <Balance<T>>::get((self.id, owner));86 Ok(balance.into())87 }88 #[weight(<SelfWeightOf<T>>::transfer())]89 fn transfer(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {90 let caller = T::CrossAccountId::from_eth(caller);91 let to = T::CrossAccountId::from_eth(to);92 let amount = amount.try_into().map_err(|_| "amount overflow")?;93 let budget = self94 .recorder95 .weight_calls_budget(<StructureWeight<T>>::find_parent());9697 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;98 Ok(true)99 }100101 #[weight(<SelfWeightOf<T>>::transfer_from())]102 fn transfer_from(103 &mut self,104 caller: caller,105 from: Address,106 to: Address,107 amount: U256,108 ) -> Result<bool> {109 let caller = T::CrossAccountId::from_eth(caller);110 let from = T::CrossAccountId::from_eth(from);111 let to = T::CrossAccountId::from_eth(to);112 let amount = amount.try_into().map_err(|_| "amount overflow")?;113 let budget = self114 .recorder115 .weight_calls_budget(<StructureWeight<T>>::find_parent());116117 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)118 .map_err(dispatch_to_evm::<T>)?;119 Ok(true)120 }121 #[weight(<SelfWeightOf<T>>::approve())]122 fn approve(&mut self, caller: caller, spender: Address, amount: U256) -> Result<bool> {123 let caller = T::CrossAccountId::from_eth(caller);124 let spender = T::CrossAccountId::from_eth(spender);125 let amount = amount.try_into().map_err(|_| "amount overflow")?;126127 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)128 .map_err(dispatch_to_evm::<T>)?;129 Ok(true)130 }131 fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {132 self.consume_store_reads(1)?;133 let owner = T::CrossAccountId::from_eth(owner);134 let spender = T::CrossAccountId::from_eth(spender);135136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())137 }138139 /// @notice Returns collection helper contract address140 fn collection_helper_address(&self) -> Result<Address> {141 Ok(T::ContractAddress::get())142 }143}144145#[solidity_interface(name = ERC20Mintable)]146impl<T: Config> FungibleHandle<T> {147 /// Mint tokens for `to` account.148 /// @param to account that will receive minted tokens149 /// @param amount amount of tokens to mint150 #[weight(<SelfWeightOf<T>>::create_item())]151 fn mint(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {152 let caller = T::CrossAccountId::from_eth(caller);153 let to = T::CrossAccountId::from_eth(to);154 let amount = amount.try_into().map_err(|_| "amount overflow")?;155 let budget = self156 .recorder157 .weight_calls_budget(<StructureWeight<T>>::find_parent());158 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)159 .map_err(dispatch_to_evm::<T>)?;160 Ok(true)161 }162}163164#[solidity_interface(name = ERC20UniqueExtensions)]165impl<T: Config> FungibleHandle<T>166where167 T::AccountId: From<[u8; 32]>,168{169 /// @notice A description for the collection.170 fn description(&self) -> Result<String> {171 Ok(decode_utf16(self.description.iter().copied())172 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))173 .collect::<String>())174 }175176 #[weight(<SelfWeightOf<T>>::create_item())]177 fn mint_cross(178 &mut self,179 caller: caller,180 to: pallet_common::eth::CrossAddress,181 amount: U256,182 ) -> Result<bool> {183 let caller = T::CrossAccountId::from_eth(caller);184 let to = to.into_sub_cross_account::<T>()?;185 let amount = amount.try_into().map_err(|_| "amount overflow")?;186 let budget = self187 .recorder188 .weight_calls_budget(<StructureWeight<T>>::find_parent());189 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)190 .map_err(dispatch_to_evm::<T>)?;191 Ok(true)192 }193194 #[weight(<SelfWeightOf<T>>::approve())]195 fn approve_cross(196 &mut self,197 caller: caller,198 spender: pallet_common::eth::CrossAddress,199 amount: U256,200 ) -> Result<bool> {201 let caller = T::CrossAccountId::from_eth(caller);202 let spender = spender.into_sub_cross_account::<T>()?;203 let amount = amount.try_into().map_err(|_| "amount overflow")?;204205 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)206 .map_err(dispatch_to_evm::<T>)?;207 Ok(true)208 }209210 /// Burn tokens from account211 /// @dev Function that burns an `amount` of the tokens of a given account,212 /// deducting from the sender's allowance for said account.213 /// @param from The account whose tokens will be burnt.214 /// @param amount The amount that will be burnt.215 #[solidity(hide)]216 #[weight(<SelfWeightOf<T>>::burn_from())]217 fn burn_from(&mut self, caller: caller, from: Address, amount: U256) -> Result<bool> {218 let caller = T::CrossAccountId::from_eth(caller);219 let from = T::CrossAccountId::from_eth(from);220 let amount = amount.try_into().map_err(|_| "amount overflow")?;221 let budget = self222 .recorder223 .weight_calls_budget(<StructureWeight<T>>::find_parent());224225 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)226 .map_err(dispatch_to_evm::<T>)?;227 Ok(true)228 }229230 /// Burn tokens from account231 /// @dev Function that burns an `amount` of the tokens of a given account,232 /// deducting from the sender's allowance for said account.233 /// @param from The account whose tokens will be burnt.234 /// @param amount The amount that will be burnt.235 #[weight(<SelfWeightOf<T>>::burn_from())]236 fn burn_from_cross(237 &mut self,238 caller: caller,239 from: pallet_common::eth::CrossAddress,240 amount: U256,241 ) -> Result<bool> {242 let caller = T::CrossAccountId::from_eth(caller);243 let from = from.into_sub_cross_account::<T>()?;244 let amount = amount.try_into().map_err(|_| "amount overflow")?;245 let budget = self246 .recorder247 .weight_calls_budget(<StructureWeight<T>>::find_parent());248249 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)250 .map_err(dispatch_to_evm::<T>)?;251 Ok(true)252 }253254 /// Mint tokens for multiple accounts.255 /// @param amounts array of pairs of account address and amount256 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]257 fn mint_bulk(&mut self, caller: caller, amounts: Vec<(Address, U256)>) -> Result<bool> {258 let caller = T::CrossAccountId::from_eth(caller);259 let budget = self260 .recorder261 .weight_calls_budget(<StructureWeight<T>>::find_parent());262 let amounts = amounts263 .into_iter()264 .map(|(to, amount)| {265 Ok((266 T::CrossAccountId::from_eth(to),267 amount.try_into().map_err(|_| "amount overflow")?,268 ))269 })270 .collect::<Result<_>>()?;271272 <Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)273 .map_err(dispatch_to_evm::<T>)?;274 Ok(true)275 }276277 #[weight(<SelfWeightOf<T>>::transfer())]278 fn transfer_cross(279 &mut self,280 caller: caller,281 to: pallet_common::eth::CrossAddress,282 amount: U256,283 ) -> Result<bool> {284 let caller = T::CrossAccountId::from_eth(caller);285 let to = to.into_sub_cross_account::<T>()?;286 let amount = amount.try_into().map_err(|_| "amount overflow")?;287 let budget = self288 .recorder289 .weight_calls_budget(<StructureWeight<T>>::find_parent());290291 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;292 Ok(true)293 }294295 #[weight(<SelfWeightOf<T>>::transfer_from())]296 fn transfer_from_cross(297 &mut self,298 caller: caller,299 from: pallet_common::eth::CrossAddress,300 to: pallet_common::eth::CrossAddress,301 amount: U256,302 ) -> Result<bool> {303 let caller = T::CrossAccountId::from_eth(caller);304 let from = from.into_sub_cross_account::<T>()?;305 let to = to.into_sub_cross_account::<T>()?;306 let amount = amount.try_into().map_err(|_| "amount overflow")?;307 let budget = self308 .recorder309 .weight_calls_budget(<StructureWeight<T>>::find_parent());310311 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)312 .map_err(dispatch_to_evm::<T>)?;313 Ok(true)314 }315}316317#[solidity_interface(318 name = UniqueFungible,319 is(320 ERC20,321 ERC20Mintable,322 ERC20UniqueExtensions,323 Collection(via(common_mut returns CollectionHandle<T>)),324 )325)]326impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}327328generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);329generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);330331impl<T: Config> CommonEvmHandler for FungibleHandle<T>332where333 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,334{335 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");336337 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {338 call::<T, UniqueFungibleCall<T>, _, _>(handle, self)339 }340}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/>.1617//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::{23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,24 weight,25};26use up_data_structs::CollectionMode;27use pallet_common::{28 CollectionHandle,29 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},30};31use sp_std::vec::Vec;32use pallet_evm::{account::CrossAccountId, PrecompileHandle};33use pallet_evm_coder_substrate::{call, dispatch_to_evm};34use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};35use sp_core::{U256, Get};3637use crate::{38 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,39 weights::WeightInfo,40};4142#[derive(ToLog)]43pub enum ERC20Events {44 Transfer {45 #[indexed]46 from: Address,47 #[indexed]48 to: Address,49 value: U256,50 },51 Approval {52 #[indexed]53 owner: Address,54 #[indexed]55 spender: Address,56 value: U256,57 },58}5960#[solidity_interface(name = ERC20, events(ERC20Events))]61impl<T: Config> FungibleHandle<T> {62 fn name(&self) -> Result<String> {63 Ok(decode_utf16(self.name.iter().copied())64 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))65 .collect::<String>())66 }67 fn symbol(&self) -> Result<String> {68 Ok(String::from_utf8_lossy(&self.token_prefix).into())69 }70 fn total_supply(&self) -> Result<U256> {71 self.consume_store_reads(1)?;72 Ok(<TotalSupply<T>>::get(self.id).into())73 }7475 fn decimals(&self) -> Result<u8> {76 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {77 *decimals78 } else {79 unreachable!()80 })81 }82 fn balance_of(&self, owner: Address) -> Result<U256> {83 self.consume_store_reads(1)?;84 let owner = T::CrossAccountId::from_eth(owner);85 let balance = <Balance<T>>::get((self.id, owner));86 Ok(balance.into())87 }88 #[weight(<SelfWeightOf<T>>::transfer())]89 fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {90 let caller = T::CrossAccountId::from_eth(caller);91 let to = T::CrossAccountId::from_eth(to);92 let amount = amount.try_into().map_err(|_| "amount overflow")?;93 let budget = self94 .recorder95 .weight_calls_budget(<StructureWeight<T>>::find_parent());9697 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;98 Ok(true)99 }100101 #[weight(<SelfWeightOf<T>>::transfer_from())]102 fn transfer_from(103 &mut self,104 caller: Caller,105 from: Address,106 to: Address,107 amount: U256,108 ) -> Result<bool> {109 let caller = T::CrossAccountId::from_eth(caller);110 let from = T::CrossAccountId::from_eth(from);111 let to = T::CrossAccountId::from_eth(to);112 let amount = amount.try_into().map_err(|_| "amount overflow")?;113 let budget = self114 .recorder115 .weight_calls_budget(<StructureWeight<T>>::find_parent());116117 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)118 .map_err(dispatch_to_evm::<T>)?;119 Ok(true)120 }121 #[weight(<SelfWeightOf<T>>::approve())]122 fn approve(&mut self, caller: Caller, spender: Address, amount: U256) -> Result<bool> {123 let caller = T::CrossAccountId::from_eth(caller);124 let spender = T::CrossAccountId::from_eth(spender);125 let amount = amount.try_into().map_err(|_| "amount overflow")?;126127 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)128 .map_err(dispatch_to_evm::<T>)?;129 Ok(true)130 }131 fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {132 self.consume_store_reads(1)?;133 let owner = T::CrossAccountId::from_eth(owner);134 let spender = T::CrossAccountId::from_eth(spender);135136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())137 }138139 /// @notice Returns collection helper contract address140 fn collection_helper_address(&self) -> Result<Address> {141 Ok(T::ContractAddress::get())142 }143}144145#[solidity_interface(name = ERC20Mintable)]146impl<T: Config> FungibleHandle<T> {147 /// Mint tokens for `to` account.148 /// @param to account that will receive minted tokens149 /// @param amount amount of tokens to mint150 #[weight(<SelfWeightOf<T>>::create_item())]151 fn mint(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {152 let caller = T::CrossAccountId::from_eth(caller);153 let to = T::CrossAccountId::from_eth(to);154 let amount = amount.try_into().map_err(|_| "amount overflow")?;155 let budget = self156 .recorder157 .weight_calls_budget(<StructureWeight<T>>::find_parent());158 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)159 .map_err(dispatch_to_evm::<T>)?;160 Ok(true)161 }162}163164#[solidity_interface(name = ERC20UniqueExtensions)]165impl<T: Config> FungibleHandle<T>166where167 T::AccountId: From<[u8; 32]>,168{169 /// @notice A description for the collection.170 fn description(&self) -> Result<String> {171 Ok(decode_utf16(self.description.iter().copied())172 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))173 .collect::<String>())174 }175176 #[weight(<SelfWeightOf<T>>::create_item())]177 fn mint_cross(178 &mut self,179 caller: Caller,180 to: pallet_common::eth::CrossAddress,181 amount: U256,182 ) -> Result<bool> {183 let caller = T::CrossAccountId::from_eth(caller);184 let to = to.into_sub_cross_account::<T>()?;185 let amount = amount.try_into().map_err(|_| "amount overflow")?;186 let budget = self187 .recorder188 .weight_calls_budget(<StructureWeight<T>>::find_parent());189 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)190 .map_err(dispatch_to_evm::<T>)?;191 Ok(true)192 }193194 #[weight(<SelfWeightOf<T>>::approve())]195 fn approve_cross(196 &mut self,197 caller: Caller,198 spender: pallet_common::eth::CrossAddress,199 amount: U256,200 ) -> Result<bool> {201 let caller = T::CrossAccountId::from_eth(caller);202 let spender = spender.into_sub_cross_account::<T>()?;203 let amount = amount.try_into().map_err(|_| "amount overflow")?;204205 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)206 .map_err(dispatch_to_evm::<T>)?;207 Ok(true)208 }209210 /// Burn tokens from account211 /// @dev Function that burns an `amount` of the tokens of a given account,212 /// deducting from the sender's allowance for said account.213 /// @param from The account whose tokens will be burnt.214 /// @param amount The amount that will be burnt.215 #[solidity(hide)]216 #[weight(<SelfWeightOf<T>>::burn_from())]217 fn burn_from(&mut self, caller: Caller, from: Address, amount: U256) -> Result<bool> {218 let caller = T::CrossAccountId::from_eth(caller);219 let from = T::CrossAccountId::from_eth(from);220 let amount = amount.try_into().map_err(|_| "amount overflow")?;221 let budget = self222 .recorder223 .weight_calls_budget(<StructureWeight<T>>::find_parent());224225 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)226 .map_err(dispatch_to_evm::<T>)?;227 Ok(true)228 }229230 /// Burn tokens from account231 /// @dev Function that burns an `amount` of the tokens of a given account,232 /// deducting from the sender's allowance for said account.233 /// @param from The account whose tokens will be burnt.234 /// @param amount The amount that will be burnt.235 #[weight(<SelfWeightOf<T>>::burn_from())]236 fn burn_from_cross(237 &mut self,238 caller: Caller,239 from: pallet_common::eth::CrossAddress,240 amount: U256,241 ) -> Result<bool> {242 let caller = T::CrossAccountId::from_eth(caller);243 let from = from.into_sub_cross_account::<T>()?;244 let amount = amount.try_into().map_err(|_| "amount overflow")?;245 let budget = self246 .recorder247 .weight_calls_budget(<StructureWeight<T>>::find_parent());248249 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)250 .map_err(dispatch_to_evm::<T>)?;251 Ok(true)252 }253254 /// Mint tokens for multiple accounts.255 /// @param amounts array of pairs of account address and amount256 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]257 fn mint_bulk(&mut self, caller: Caller, amounts: Vec<(Address, U256)>) -> Result<bool> {258 let caller = T::CrossAccountId::from_eth(caller);259 let budget = self260 .recorder261 .weight_calls_budget(<StructureWeight<T>>::find_parent());262 let amounts = amounts263 .into_iter()264 .map(|(to, amount)| {265 Ok((266 T::CrossAccountId::from_eth(to),267 amount.try_into().map_err(|_| "amount overflow")?,268 ))269 })270 .collect::<Result<_>>()?;271272 <Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)273 .map_err(dispatch_to_evm::<T>)?;274 Ok(true)275 }276277 #[weight(<SelfWeightOf<T>>::transfer())]278 fn transfer_cross(279 &mut self,280 caller: Caller,281 to: pallet_common::eth::CrossAddress,282 amount: U256,283 ) -> Result<bool> {284 let caller = T::CrossAccountId::from_eth(caller);285 let to = to.into_sub_cross_account::<T>()?;286 let amount = amount.try_into().map_err(|_| "amount overflow")?;287 let budget = self288 .recorder289 .weight_calls_budget(<StructureWeight<T>>::find_parent());290291 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;292 Ok(true)293 }294295 #[weight(<SelfWeightOf<T>>::transfer_from())]296 fn transfer_from_cross(297 &mut self,298 caller: Caller,299 from: pallet_common::eth::CrossAddress,300 to: pallet_common::eth::CrossAddress,301 amount: U256,302 ) -> Result<bool> {303 let caller = T::CrossAccountId::from_eth(caller);304 let from = from.into_sub_cross_account::<T>()?;305 let to = to.into_sub_cross_account::<T>()?;306 let amount = amount.try_into().map_err(|_| "amount overflow")?;307 let budget = self308 .recorder309 .weight_calls_budget(<StructureWeight<T>>::find_parent());310311 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)312 .map_err(dispatch_to_evm::<T>)?;313 Ok(true)314 }315}316317#[solidity_interface(318 name = UniqueFungible,319 is(320 ERC20,321 ERC20Mintable,322 ERC20UniqueExtensions,323 Collection(via(common_mut returns CollectionHandle<T>)),324 )325)]326impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}327328generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);329generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);330331impl<T: Config> CommonEvmHandler for FungibleHandle<T>332where333 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,334{335 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");336337 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {338 call::<T, UniqueFungibleCall<T>, _, _>(handle, self)339 }340}pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -63,7 +63,7 @@
#[solidity(hide)]
fn set_token_property_permission(
&mut self,
- caller: caller,
+ caller: Caller,
key: String,
is_mutable: bool,
collection_admin: bool,
@@ -93,7 +93,7 @@
#[weight(<SelfWeightOf<T>>::set_token_property_permissions(permissions.len() as u32))]
fn set_token_property_permissions(
&mut self,
- caller: caller,
+ caller: Caller,
permissions: Vec<eth::TokenPropertyPermission>,
) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -121,7 +121,7 @@
#[weight(<SelfWeightOf<T>>::set_token_properties(1))]
fn set_property(
&mut self,
- caller: caller,
+ caller: Caller,
token_id: U256,
key: String,
value: Bytes,
@@ -154,7 +154,7 @@
#[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
- caller: caller,
+ caller: Caller,
token_id: U256,
properties: Vec<eth::Property>,
) -> Result<()> {
@@ -187,7 +187,7 @@
/// @param key Property key.
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
- fn delete_property(&mut self, token_id: U256, caller: caller, key: String) -> Result<()> {
+ fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
let key = <Vec<u8>>::from(key)
@@ -210,7 +210,7 @@
fn delete_properties(
&mut self,
token_id: U256,
- caller: caller,
+ caller: Caller,
keys: Vec<String>,
) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -445,7 +445,7 @@
#[weight(<SelfWeightOf<T>>::transfer_from())]
fn transfer_from(
&mut self,
- caller: caller,
+ caller: Caller,
from: Address,
to: Address,
token_id: U256,
@@ -470,7 +470,7 @@
/// @param approved The new approved NFT controller
/// @param tokenId The NFT to approve
#[weight(<SelfWeightOf<T>>::approve())]
- fn approve(&mut self, caller: caller, approved: Address, token_id: U256) -> Result<()> {
+ fn approve(&mut self, caller: Caller, approved: Address, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let approved = T::CrossAccountId::from_eth(approved);
let token = token_id.try_into()?;
@@ -487,7 +487,7 @@
#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]
fn set_approval_for_all(
&mut self,
- caller: caller,
+ caller: Caller,
operator: Address,
approved: bool,
) -> Result<()> {
@@ -523,7 +523,7 @@
/// operator of the current owner.
/// @param tokenId The NFT to approve
#[weight(<SelfWeightOf<T>>::burn_item())]
- fn burn(&mut self, caller: caller, token_id: U256) -> Result<()> {
+ fn burn(&mut self, caller: Caller, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token = token_id.try_into()?;
@@ -539,7 +539,7 @@
/// @param to The new owner
/// @return uint256 The id of the newly minted token
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint(&mut self, caller: caller, to: Address) -> Result<U256> {
+ fn mint(&mut self, caller: Caller, to: Address) -> Result<U256> {
let token_id: U256 = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?
@@ -555,7 +555,7 @@
/// @param tokenId ID of the minted NFT
#[solidity(hide, rename_selector = "mint")]
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint_check_id(&mut self, caller: caller, to: Address, token_id: U256) -> Result<bool> {
+ fn mint_check_id(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
@@ -593,7 +593,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_with_token_uri(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
token_uri: String,
) -> Result<U256> {
@@ -615,7 +615,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_with_token_uri_check_id(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
token_id: U256,
token_uri: String,
@@ -765,7 +765,7 @@
#[weight(<SelfWeightOf<T>>::approve())]
fn approve_cross(
&mut self,
- caller: caller,
+ caller: Caller,
approved: eth::CrossAddress,
token_id: U256,
) -> Result<()> {
@@ -784,7 +784,7 @@
/// @param to The new owner
/// @param tokenId The NFT to transfer
#[weight(<SelfWeightOf<T>>::transfer())]
- fn transfer(&mut self, caller: caller, to: Address, token_id: U256) -> Result<()> {
+ fn transfer(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
@@ -804,7 +804,7 @@
#[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_cross(
&mut self,
- caller: caller,
+ caller: Caller,
to: eth::CrossAddress,
token_id: U256,
) -> Result<()> {
@@ -828,7 +828,7 @@
#[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: eth::CrossAddress,
to: eth::CrossAddress,
token_id: U256,
@@ -853,7 +853,7 @@
/// @param tokenId The NFT to transfer
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::burn_from())]
- fn burn_from(&mut self, caller: caller, from: Address, token_id: U256) -> Result<()> {
+ fn burn_from(&mut self, caller: Caller, from: Address, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
@@ -875,7 +875,7 @@
#[weight(<SelfWeightOf<T>>::burn_from())]
fn burn_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: eth::CrossAddress,
token_id: U256,
) -> Result<()> {
@@ -907,7 +907,7 @@
/// @param tokenIds IDs of the minted NFTs
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]
- fn mint_bulk(&mut self, caller: caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {
+ fn mint_bulk(&mut self, caller: Caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let mut expected_index = <TokensMinted<T>>::get(self.id)
@@ -946,7 +946,7 @@
#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
fn mint_bulk_with_token_uri(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
tokens: Vec<(U256, String)>,
) -> Result<bool> {
@@ -997,7 +997,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_cross(
&mut self,
- caller: caller,
+ caller: Caller,
to: eth::CrossAddress,
properties: Vec<eth::Property>,
) -> Result<U256> {
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -66,7 +66,7 @@
#[solidity(hide)]
fn set_token_property_permission(
&mut self,
- caller: caller,
+ caller: Caller,
key: String,
is_mutable: bool,
collection_admin: bool,
@@ -96,7 +96,7 @@
#[weight(<SelfWeightOf<T>>::set_token_property_permissions(permissions.len() as u32))]
fn set_token_property_permissions(
&mut self,
- caller: caller,
+ caller: Caller,
permissions: Vec<eth::TokenPropertyPermission>,
) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -124,7 +124,7 @@
#[weight(<SelfWeightOf<T>>::set_token_properties(1))]
fn set_property(
&mut self,
- caller: caller,
+ caller: Caller,
token_id: U256,
key: String,
value: Bytes,
@@ -157,7 +157,7 @@
#[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
- caller: caller,
+ caller: Caller,
token_id: U256,
properties: Vec<eth::Property>,
) -> Result<()> {
@@ -190,7 +190,7 @@
/// @param key Property key.
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
- fn delete_property(&mut self, token_id: U256, caller: caller, key: String) -> Result<()> {
+ fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
let key = <Vec<u8>>::from(key)
@@ -213,7 +213,7 @@
fn delete_properties(
&mut self,
token_id: U256,
- caller: caller,
+ caller: Caller,
keys: Vec<String>,
) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -449,7 +449,7 @@
#[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]
fn transfer_from(
&mut self,
- caller: caller,
+ caller: Caller,
from: Address,
to: Address,
token_id: U256,
@@ -472,7 +472,7 @@
}
/// @dev Not implemented
- fn approve(&mut self, _caller: caller, _approved: Address, _token_id: U256) -> Result<()> {
+ fn approve(&mut self, _caller: Caller, _approved: Address, _token_id: U256) -> Result<()> {
Err("not implemented".into())
}
@@ -483,7 +483,7 @@
#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]
fn set_approval_for_all(
&mut self,
- caller: caller,
+ caller: Caller,
operator: Address,
approved: bool,
) -> Result<()> {
@@ -551,7 +551,7 @@
/// operator of the current owner.
/// @param tokenId The RFT to approve
#[weight(<SelfWeightOf<T>>::burn_item_fully())]
- fn burn(&mut self, caller: caller, token_id: U256) -> Result<()> {
+ fn burn(&mut self, caller: Caller, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token = token_id.try_into()?;
@@ -570,7 +570,7 @@
/// @param to The new owner
/// @return uint256 The id of the newly minted token
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint(&mut self, caller: caller, to: Address) -> Result<U256> {
+ fn mint(&mut self, caller: Caller, to: Address) -> Result<U256> {
let token_id: U256 = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?
@@ -586,7 +586,7 @@
/// @param tokenId ID of the minted RFT
#[solidity(hide, rename_selector = "mint")]
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint_check_id(&mut self, caller: caller, to: Address, token_id: U256) -> Result<bool> {
+ fn mint_check_id(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
@@ -629,7 +629,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_with_token_uri(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
token_uri: String,
) -> Result<U256> {
@@ -651,7 +651,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_with_token_uri_check_id(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
token_id: U256,
token_uri: String,
@@ -800,7 +800,7 @@
/// @param to The new owner
/// @param tokenId The RFT to transfer
#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]
- fn transfer(&mut self, caller: caller, to: Address, token_id: U256) -> Result<()> {
+ fn transfer(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
@@ -825,7 +825,7 @@
#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]
fn transfer_cross(
&mut self,
- caller: caller,
+ caller: Caller,
to: eth::CrossAddress,
token_id: U256,
) -> Result<()> {
@@ -853,7 +853,7 @@
#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]
fn transfer_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: eth::CrossAddress,
to: eth::CrossAddress,
token_id: U256,
@@ -883,7 +883,7 @@
/// @param tokenId The RFT to transfer
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::burn_from())]
- fn burn_from(&mut self, caller: caller, from: Address, token_id: U256) -> Result<()> {
+ fn burn_from(&mut self, caller: Caller, from: Address, token_id: U256) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
@@ -909,7 +909,7 @@
#[weight(<SelfWeightOf<T>>::burn_from())]
fn burn_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: eth::CrossAddress,
token_id: U256,
) -> Result<()> {
@@ -944,7 +944,7 @@
/// @param tokenIds IDs of the minted RFTs
#[solidity(hide)]
#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]
- fn mint_bulk(&mut self, caller: caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {
+ fn mint_bulk(&mut self, caller: Caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let mut expected_index = <TokensMinted<T>>::get(self.id)
@@ -989,7 +989,7 @@
#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
fn mint_bulk_with_token_uri(
&mut self,
- caller: caller,
+ caller: Caller,
to: Address,
tokens: Vec<(U256, String)>,
) -> Result<bool> {
@@ -1046,7 +1046,7 @@
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_cross(
&mut self,
- caller: caller,
+ caller: Caller,
to: eth::CrossAddress,
properties: Vec<eth::Property>,
) -> Result<U256> {
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -129,7 +129,7 @@
/// @param to The address to transfer to.
/// @param amount The amount to be transferred.
#[weight(<CommonWeights<T>>::transfer())]
- fn transfer(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {
+ fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -149,7 +149,7 @@
#[weight(<CommonWeights<T>>::transfer_from())]
fn transfer_from(
&mut self,
- caller: caller,
+ caller: Caller,
from: Address,
to: Address,
amount: U256,
@@ -175,7 +175,7 @@
/// @param spender The address which will spend the funds.
/// @param amount The amount of tokens to be spent.
#[weight(<SelfWeightOf<T>>::approve())]
- fn approve(&mut self, caller: caller, spender: Address, amount: U256) -> Result<bool> {
+ fn approve(&mut self, caller: Caller, spender: Address, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let spender = T::CrossAccountId::from_eth(spender);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -209,7 +209,7 @@
/// @param amount The amount that will be burnt.
#[weight(<SelfWeightOf<T>>::burn_from())]
#[solidity(hide)]
- fn burn_from(&mut self, caller: caller, from: Address, amount: U256) -> Result<bool> {
+ fn burn_from(&mut self, caller: Caller, from: Address, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -229,7 +229,7 @@
#[weight(<SelfWeightOf<T>>::burn_from())]
fn burn_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: pallet_common::eth::CrossAddress,
amount: U256,
) -> Result<bool> {
@@ -255,7 +255,7 @@
#[weight(<SelfWeightOf<T>>::approve())]
fn approve_cross(
&mut self,
- caller: caller,
+ caller: Caller,
spender: pallet_common::eth::CrossAddress,
amount: U256,
) -> Result<bool> {
@@ -271,7 +271,7 @@
/// Throws if `msg.sender` doesn't owns all of the tokens.
/// @param amount New total amount of the tokens.
#[weight(<SelfWeightOf<T>>::repartition_item())]
- fn repartition(&mut self, caller: caller, amount: U256) -> Result<bool> {
+ fn repartition(&mut self, caller: Caller, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -285,7 +285,7 @@
#[weight(<CommonWeights<T>>::transfer())]
fn transfer_cross(
&mut self,
- caller: caller,
+ caller: Caller,
to: pallet_common::eth::CrossAddress,
amount: U256,
) -> Result<bool> {
@@ -308,7 +308,7 @@
#[weight(<CommonWeights<T>>::transfer_from())]
fn transfer_from_cross(
&mut self,
- caller: caller,
+ caller: Caller,
from: pallet_common::eth::CrossAddress,
to: pallet_common::eth::CrossAddress,
amount: U256,
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -56,7 +56,7 @@
}
fn convert_data<T: Config>(
- caller: caller,
+ caller: Caller,
name: String,
description: String,
token_prefix: String,
@@ -87,7 +87,7 @@
#[inline(always)]
fn create_collection_internal<T: Config>(
- caller: caller,
+ caller: Caller,
value: Value,
name: String,
collection_mode: CollectionMode,
@@ -149,7 +149,7 @@
#[solidity(rename_selector = "createNFTCollection")]
fn create_nft_collection(
&mut self,
- caller: caller,
+ caller: Caller,
value: Value,
name: String,
description: String,
@@ -188,7 +188,7 @@
#[solidity(hide)]
fn create_nonfungible_collection(
&mut self,
- caller: caller,
+ caller: Caller,
value: Value,
name: String,
description: String,
@@ -208,7 +208,7 @@
#[solidity(rename_selector = "createRFTCollection")]
fn create_rft_collection(
&mut self,
- caller: caller,
+ caller: Caller,
value: Value,
name: String,
description: String,
@@ -228,7 +228,7 @@
#[solidity(rename_selector = "createFTCollection")]
fn create_fungible_collection(
&mut self,
- caller: caller,
+ caller: Caller,
value: Value,
name: String,
decimals: u8,
@@ -248,7 +248,7 @@
#[solidity(rename_selector = "makeCollectionERC721MetadataCompatible")]
fn make_collection_metadata_compatible(
&mut self,
- caller: caller,
+ caller: Caller,
collection: Address,
base_uri: String,
) -> Result<()> {
@@ -334,7 +334,7 @@
}
#[weight(<SelfWeightOf<T>>::destroy_collection())]
- fn destroy_collection(&mut self, caller: caller, collection_address: Address) -> Result<()> {
+ fn destroy_collection(&mut self, caller: Caller, collection_address: Address) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)
@@ -346,7 +346,7 @@
/// Check if a collection exists
/// @param collectionAddress Address of the collection in question
/// @return bool Does the collection exist?
- fn is_collection_exist(&self, _caller: caller, collection_address: Address) -> Result<bool> {
+ fn is_collection_exist(&self, _caller: Caller, collection_address: Address) -> Result<bool> {
if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {
let collection_id = id;
return Ok(<CollectionById<T>>::contains_key(collection_id));