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

difftreelog

name anonymous tuples

Trubnikov Sergey2023-02-01parent: #55aed0d.patch.diff
in: master

15 files changed

modifiedpallets/common/src/eth.rsdiffbeforeafterboth
20use sp_std::{vec, vec::Vec};20use sp_std::{vec, vec::Vec};
21use evm_coder::{AbiCoder, types::Address};21use evm_coder::{
22 AbiCoder,
23 types::{Address, String},
24};
22pub use pallet_evm::{Config, account::CrossAccountId};25pub use pallet_evm::{Config, account::CrossAccountId};
23use sp_core::{H160, U256};26use sp_core::{H160, U256};
390 }393 }
391}394}
395
396/// Data for creation token with uri.
397#[derive(Debug, AbiCoder)]
398pub struct TokenUri {
399 /// Id of new token.
400 pub id: U256,
401
402 /// Uri of new token.
403 pub uri: String,
404}
392405
393/// Nested collections.406/// Nested collections.
394#[derive(Debug, Default, AbiCoder)]407#[derive(Debug, Default, AbiCoder)]
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is disaddress: tod in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
19extern crate alloc;19extern crate alloc;
20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
21use core::convert::TryInto;21use core::convert::TryInto;
22use evm_coder::AbiCoder;
22use evm_coder::{23use evm_coder::{
23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,24 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
24 weight,25 weight,
57 },58 },
58}59}
60
61#[derive(AbiCoder, Debug)]
62pub struct AmountForAddress {
63 to: Address,
64 amount: U256,
65}
5966
60#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]67#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]
61impl<T: Config> FungibleHandle<T> {68impl<T: Config> FungibleHandle<T> {
264 /// Mint tokens for multiple accounts.271 /// Mint tokens for multiple accounts.
265 /// @param amounts array of pairs of account address and amount272 /// @param amounts array of pairs of account address and amount
266 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]273 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]
267 fn mint_bulk(&mut self, caller: Caller, amounts: Vec<(Address, U256)>) -> Result<bool> {274 fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {
268 let caller = T::CrossAccountId::from_eth(caller);275 let caller = T::CrossAccountId::from_eth(caller);
269 let budget = self276 let budget = self
270 .recorder277 .recorder
271 .weight_calls_budget(<StructureWeight<T>>::find_parent());278 .weight_calls_budget(<StructureWeight<T>>::find_parent());
272 let amounts = amounts279 let amounts = amounts
273 .into_iter()280 .into_iter()
274 .map(|(to, amount)| {281 .map(|AmountForAddress { to, amount }| {
275 Ok((282 Ok((
276 T::CrossAccountId::from_eth(to),283 T::CrossAccountId::from_eth(to),
277 amount.try_into().map_err(|_| "amount overflow")?,284 amount.try_into().map_err(|_| "amount overflow")?,
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
590 /// @param amounts array of pairs of account address and amount590 /// @param amounts array of pairs of account address and amount
591 /// @dev EVM selector for this function is: 0x1acf2d55,591 /// @dev EVM selector for this function is: 0x1acf2d55,
592 /// or in textual repr: mintBulk((address,uint256)[])592 /// or in textual repr: mintBulk((address,uint256)[])
593 function mintBulk(Tuple11[] memory amounts) public returns (bool) {593 function mintBulk(AmountForAddress[] memory amounts) public returns (bool) {
594 require(false, stub_error);594 require(false, stub_error);
595 amounts;595 amounts;
596 dummy = 0;596 dummy = 0;
632 }632 }
633}633}
634634
635/// @dev anonymous struct
636struct Tuple11 {635struct AmountForAddress {
637 address field_0;636 address to;
638 uint256 field_1;637 uint256 amount;
639}638}
640639
641/// @dev the ERC-165 identifier for this interface is 0x40c10f19640/// @dev the ERC-165 identifier for this interface is 0x40c10f19
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
38use pallet_common::{38use pallet_common::{
39 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,39 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
40 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},40 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
41 eth,41 eth::{self, TokenUri},
42};42};
43use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm::{account::CrossAccountId, PrecompileHandle};
44use pallet_evm_coder_substrate::call;44use pallet_evm_coder_substrate::call;
948 &mut self,948 &mut self,
949 caller: Caller,949 caller: Caller,
950 to: Address,950 to: Address,
951 tokens: Vec<(U256, String)>,951 tokens: Vec<TokenUri>,
952 ) -> Result<bool> {952 ) -> Result<bool> {
953 let key = key::url();953 let key = key::url();
954 let caller = T::CrossAccountId::from_eth(caller);954 let caller = T::CrossAccountId::from_eth(caller);
961 .weight_calls_budget(<StructureWeight<T>>::find_parent());961 .weight_calls_budget(<StructureWeight<T>>::find_parent());
962962
963 let mut data = Vec::with_capacity(tokens.len());963 let mut data = Vec::with_capacity(tokens.len());
964 for (id, token_uri) in tokens {964 for TokenUri { id, uri } in tokens {
965 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;965 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
966 if id != expected_index {966 if id != expected_index {
967 return Err("item id should be next".into());967 return Err("item id should be next".into());
972 properties972 properties
973 .try_push(Property {973 .try_push(Property {
974 key: key.clone(),974 key: key.clone(),
975 value: token_uri975 value: uri
976 .into_bytes()976 .into_bytes()
977 .try_into()977 .try_into()
978 .map_err(|_| "token uri is too long")?,978 .map_err(|_| "token uri is too long")?,
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
949 // /// @param tokens array of pairs of token ID and token URI for minted tokens949 // /// @param tokens array of pairs of token ID and token URI for minted tokens
950 // /// @dev EVM selector for this function is: 0x36543006,950 // /// @dev EVM selector for this function is: 0x36543006,
951 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])951 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
952 // function mintBulkWithTokenURI(address to, Tuple15[] memory tokens) public returns (bool) {952 // function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) public returns (bool) {
953 // require(false, stub_error);953 // require(false, stub_error);
954 // to;954 // to;
955 // tokens;955 // tokens;
981 }981 }
982}982}
983983
984/// @dev anonymous struct984/// Data for creation token with uri.
985struct Tuple15 {985struct TokenUri {
986 /// Id of new token.
986 uint256 field_0;987 uint256 id;
988 /// Uri of new token.
987 string field_1;989 string uri;
988}990}
989991
990/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension992/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
34 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,34 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
35 Error as CommonError,35 Error as CommonError,
36 erc::{CommonEvmHandler, CollectionCall, static_property::key},36 erc::{CommonEvmHandler, CollectionCall, static_property::key},
37 eth,37 eth::{self, TokenUri},
38};38};
39use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};
40use pallet_evm_coder_substrate::{call, dispatch_to_evm};40use pallet_evm_coder_substrate::{call, dispatch_to_evm};
999 &mut self,999 &mut self,
1000 caller: Caller,1000 caller: Caller,
1001 to: Address,1001 to: Address,
1002 tokens: Vec<(U256, String)>,1002 tokens: Vec<TokenUri>,
1003 ) -> Result<bool> {1003 ) -> Result<bool> {
1004 let key = key::url();1004 let key = key::url();
1005 let caller = T::CrossAccountId::from_eth(caller);1005 let caller = T::CrossAccountId::from_eth(caller);
1017 .collect::<BTreeMap<_, _>>()1017 .collect::<BTreeMap<_, _>>()
1018 .try_into()1018 .try_into()
1019 .unwrap();1019 .unwrap();
1020 for (id, token_uri) in tokens {1020 for TokenUri { id, uri } in tokens {
1021 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;1021 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
1022 if id != expected_index {1022 if id != expected_index {
1023 return Err("item id should be next".into());1023 return Err("item id should be next".into());
1028 properties1028 properties
1029 .try_push(Property {1029 .try_push(Property {
1030 key: key.clone(),1030 key: key.clone(),
1031 value: token_uri1031 value: uri
1032 .into_bytes()1032 .into_bytes()
1033 .try_into()1033 .try_into()
1034 .map_err(|_| "token uri is too long")?,1034 .map_err(|_| "token uri is too long")?,
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
938 // /// @param tokens array of pairs of token ID and token URI for minted tokens938 // /// @param tokens array of pairs of token ID and token URI for minted tokens
939 // /// @dev EVM selector for this function is: 0x36543006,939 // /// @dev EVM selector for this function is: 0x36543006,
940 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])940 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
941 // function mintBulkWithTokenURI(address to, Tuple14[] memory tokens) public returns (bool) {941 // function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) public returns (bool) {
942 // require(false, stub_error);942 // require(false, stub_error);
943 // to;943 // to;
944 // tokens;944 // tokens;
982 }982 }
983}983}
984984
985/// @dev anonymous struct985/// Data for creation token with uri.
986struct Tuple14 {986struct TokenUri {
987 /// Id of new token.
987 uint256 field_0;988 uint256 id;
989 /// Uri of new token.
988 string field_1;990 string uri;
989}991}
990992
991/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension993/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
434 "inputs": [434 "inputs": [
435 {435 {
436 "components": [436 "components": [
437 { "internalType": "address", "name": "field_0", "type": "address" },437 { "internalType": "address", "name": "to", "type": "address" },
438 { "internalType": "uint256", "name": "field_1", "type": "uint256" }438 { "internalType": "uint256", "name": "amount", "type": "uint256" }
439 ],439 ],
440 "internalType": "struct Tuple11[]",440 "internalType": "struct AmountForAddress[]",
441 "name": "amounts",441 "name": "amounts",
442 "type": "tuple[]"442 "type": "tuple[]"
443 }443 }
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
398 /// @param amounts array of pairs of account address and amount398 /// @param amounts array of pairs of account address and amount
399 /// @dev EVM selector for this function is: 0x1acf2d55,399 /// @dev EVM selector for this function is: 0x1acf2d55,
400 /// or in textual repr: mintBulk((address,uint256)[])400 /// or in textual repr: mintBulk((address,uint256)[])
401 function mintBulk(Tuple11[] memory amounts) external returns (bool);401 function mintBulk(AmountForAddress[] memory amounts) external returns (bool);
402402
403 /// @dev EVM selector for this function is: 0x2ada85ff,403 /// @dev EVM selector for this function is: 0x2ada85ff,
404 /// or in textual repr: transferCross((address,uint256),uint256)404 /// or in textual repr: transferCross((address,uint256),uint256)
418 function collectionHelperAddress() external view returns (address);418 function collectionHelperAddress() external view returns (address);
419}419}
420420
421/// @dev anonymous struct
422struct Tuple11 {421struct AmountForAddress {
423 address field_0;422 address to;
424 uint256 field_1;423 uint256 amount;
425}424}
426425
427/// @dev the ERC-165 identifier for this interface is 0x40c10f19426/// @dev the ERC-165 identifier for this interface is 0x40c10f19
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
644 // /// @param tokens array of pairs of token ID and token URI for minted tokens644 // /// @param tokens array of pairs of token ID and token URI for minted tokens
645 // /// @dev EVM selector for this function is: 0x36543006,645 // /// @dev EVM selector for this function is: 0x36543006,
646 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])646 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
647 // function mintBulkWithTokenURI(address to, Tuple13[] memory tokens) external returns (bool);647 // function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) external returns (bool);
648648
649 /// @notice Function to mint a token.649 /// @notice Function to mint a token.
650 /// @param to The new owner crossAccountId650 /// @param to The new owner crossAccountId
660 function collectionHelperAddress() external view returns (address);660 function collectionHelperAddress() external view returns (address);
661}661}
662662
663/// @dev anonymous struct663/// Data for creation token with uri.
664struct Tuple13 {664struct TokenUri {
665 /// Id of new token.
665 uint256 field_0;666 uint256 id;
667 /// Uri of new token.
666 string field_1;668 string uri;
667}669}
668670
669/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension671/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
638 // /// @param tokens array of pairs of token ID and token URI for minted tokens638 // /// @param tokens array of pairs of token ID and token URI for minted tokens
639 // /// @dev EVM selector for this function is: 0x36543006,639 // /// @dev EVM selector for this function is: 0x36543006,
640 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])640 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
641 // function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);641 // function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) external returns (bool);
642642
643 /// @notice Function to mint a token.643 /// @notice Function to mint a token.
644 /// @param to The new owner crossAccountId644 /// @param to The new owner crossAccountId
661 function collectionHelperAddress() external view returns (address);661 function collectionHelperAddress() external view returns (address);
662}662}
663663
664/// @dev anonymous struct664/// Data for creation token with uri.
665struct Tuple12 {665struct TokenUri {
666 /// Id of new token.
666 uint256 field_0;667 uint256 id;
668 /// Uri of new token.
667 string field_1;669 string uri;
668}670}
669671
670/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension672/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedtests/src/eth/proxy/UniqueNFTProxy.soldiffbeforeafterboth
168 return proxied.mintBulk(to, tokenIds);168 return proxied.mintBulk(to, tokenIds);
169 }169 }
170170
171 function mintBulkWithTokenURI(address to, Tuple6[] memory tokens)171 function mintBulkWithTokenURI(address to, TokenUri[] memory tokens)
172 external172 external
173 override173 override
174 returns (bool)174 returns (bool)