difftreelog
Merge branch 'develop' into tests/generalization
in: master
33 files changed
Cargo.lockdiffbeforeafterboth232123212322[[package]]2322[[package]]2323name = "evm-coder"2323name = "evm-coder"2324version = "0.1.5"2324version = "0.1.6"2325dependencies = [2325dependencies = [2326 "ethereum 0.14.0",2326 "ethereum 0.14.0",2327 "evm-coder-procedural",2327 "evm-coder-procedural",crates/evm-coder/CHANGELOG.mddiffbeforeafterboth3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->6## [v0.1.6] - 2023-01-1278### Added9- Support Option<T> type.10### Removed11- Frontier dependency.126## [v0.1.5] - 2022-11-3013## [v0.1.5] - 2022-11-307148### Added15### Addedcrates/evm-coder/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "evm-coder"2name = "evm-coder"3version = "0.1.5"3version = "0.1.6"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth259impl_tuples! {A B C D E F G H I}259impl_tuples! {A B C D E F G H I}260impl_tuples! {A B C D E F G H I J}260impl_tuples! {A B C D E F G H I J}261262//----- impls for Option -----263impl<T: AbiType> AbiType for Option<T> {264 const SIGNATURE: SignatureUnit = <(bool, T)>::SIGNATURE;265266 fn is_dynamic() -> bool {267 <(bool, T)>::is_dynamic()268 }269270 fn size() -> usize {271 <(bool, T)>::size()272 }273}274275impl<T: AbiWrite + AbiType + Default> AbiWrite for Option<T> {276 fn abi_write(&self, writer: &mut AbiWriter) {277 match self {278 Some(value) => (true, value).abi_write(writer),279 None => (false, T::default()).abi_write(writer),280 }281 }282}283284impl<T> AbiRead for Option<T>285where286 Self: AbiType,287 T: AbiRead + AbiType,288{289 fn abi_read(reader: &mut AbiReader) -> Result<Self>290 where291 Self: Sized,292 {293 let (status, value) = <(bool, T)>::abi_read(reader)?;294 Ok(if status { Some(value) } else { None })295 }296}261297crates/evm-coder/src/abi/test.rsdiffbeforeafterboth539 assert_eq!(p2, 0x0b);539 assert_eq!(p2, 0x0b);540}540}541542#[test]543fn encode_decode_option_uint8_some() {544 test_impl::<Option<u8>>(545 0xdeadbeef,546 Some(44),547 &hex!(548 "549 deadbeef550 0000000000000000000000000000000000000000000000000000000000000001551 000000000000000000000000000000000000000000000000000000000000002c552 "553 ),554 );555}556557#[test]558fn encode_decode_option_uint8_none() {559 test_impl::<Option<u8>>(560 0xdeadbeef,561 None,562 &hex!(563 "564 deadbeef565 0000000000000000000000000000000000000000000000000000000000000000566 0000000000000000000000000000000000000000000000000000000000000000567 "568 ),569 );570}571572#[test]573fn encode_decode_option_string_some() {574 test_impl::<Option<String>>(575 0xdeadbeef,576 Some("some string".to_string()),577 &hex!(578 "579 deadbeef580 0000000000000000000000000000000000000000000000000000000000000020581 0000000000000000000000000000000000000000000000000000000000000001582 0000000000000000000000000000000000000000000000000000000000000040583 000000000000000000000000000000000000000000000000000000000000000b584 736f6d6520737472696e67000000000000000000000000000000000000000000585 "586 ),587 );588}589590#[test]591fn encode_decode_option_string_none() {592 test_impl::<Option<String>>(593 0xdeadbeef,594 None,595 &hex!(596 "597 deadbeef598 0000000000000000000000000000000000000000000000000000000000000020599 0000000000000000000000000000000000000000000000000000000000000000600 0000000000000000000000000000000000000000000000000000000000000040601 0000000000000000000000000000000000000000000000000000000000000000602 "603 ),604 );605}541606crates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth122impl_tuples! {A B C D E F G H I}122impl_tuples! {A B C D E F G H I}123impl_tuples! {A B C D E F G H I J}123impl_tuples! {A B C D E F G H I J}124125//----- impls for Option -----126impl<T: SolidityTypeName + 'static> SolidityTypeName for Option<T> {127 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {128 write!(writer, "{}", tc.collect_struct::<Self>())129 }130 fn is_simple() -> bool {131 false132 }133 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {134 write!(writer, "{}(", tc.collect_struct::<Self>())?;135 bool::solidity_default(writer, tc)?;136 write!(writer, ", ");137 T::solidity_default(writer, tc)?;138 write!(writer, ")")139 }140}141142impl<T: SolidityTypeName> super::SolidityStructTy for Option<T> {143 fn generate_solidity_interface(tc: &TypeCollector) -> String {144 let mut solidity_name = "Option".to_string();145 let mut generic_name = String::new();146 T::solidity_name(&mut generic_name, tc);147 solidity_name.push(148 generic_name149 .chars()150 .next()151 .expect("Generic name is empty")152 .to_ascii_uppercase(),153 );154 solidity_name.push_str(&generic_name[1..]);155156 let interface = super::SolidityStruct {157 docs: &[" Optional value"],158 name: solidity_name.as_str(),159 fields: (160 super::SolidityStructField::<bool> {161 docs: &[" Shows the status of accessibility of value"],162 name: "status",163 ty: ::core::marker::PhantomData,164 },165 super::SolidityStructField::<T> {166 docs: &[" Actual value if `status` is true"],167 name: "value",168 ty: ::core::marker::PhantomData,169 },170 ),171 };172173 let mut out = String::new();174 let _ = interface.format(&mut out, tc);175 tc.collect(out);176177 solidity_name.to_string()178 }179}124180crates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth456 Ok(())456 Ok(())457 }457 }458}458}459pub struct SolidityStruct<F> {459pub struct SolidityStruct<'a, F> {460 pub docs: &'static [&'static str],460 pub docs: &'a [&'a str],461 // pub generics:461 // pub generics:462 pub name: &'static str,462 pub name: &'a str,463 pub fields: F,463 pub fields: F,464}464}465impl<F> SolidityStruct<F>465impl<F> SolidityStruct<'_, F>466where466where467 F: SolidityItems,467 F: SolidityItems,468{468{pallets/common/src/erc.rsdiffbeforeafterboth284 fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {284 fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {285 let limits = &self.collection.limits;285 let limits = &self.collection.limits;286287 let convert_value_from_bool = |ob: Option<bool>| match ob {288 Some(b) => Some(b as u32),289 None => None,290 };286291287 Ok(vec![292 Ok(vec![288 eth::CollectionLimit::new(293 eth::CollectionLimit::new(297 .sponsored_data_rate_limit302 .sponsored_data_rate_limit298 .and_then(|limit| {303 .and_then(|limit| {299 if let SponsoringRateLimit::Blocks(blocks) = limit {304 if let SponsoringRateLimit::Blocks(blocks) = limit {300 Some(eth::CollectionLimit::new::<u32>(305 Some(eth::CollectionLimit::new(301 eth::CollectionLimitField::SponsoredDataRateLimit,306 eth::CollectionLimitField::SponsoredDataRateLimit,302 blocks,307 Some(blocks),303 ))308 ))304 } else {309 } else {305 None310 None306 }311 }307 })312 })308 .unwrap_or(eth::CollectionLimit::new::<u32>(313 .unwrap_or(eth::CollectionLimit::new(309 eth::CollectionLimitField::SponsoredDataRateLimit,314 eth::CollectionLimitField::SponsoredDataRateLimit,310 Default::default(),315 Default::default(),311 )),316 )),320 ),325 ),321 eth::CollectionLimit::new(326 eth::CollectionLimit::new(322 eth::CollectionLimitField::OwnerCanTransfer,327 eth::CollectionLimitField::OwnerCanTransfer,323 limits.owner_can_transfer,328 convert_value_from_bool(limits.owner_can_transfer),324 ),329 ),325 eth::CollectionLimit::new(330 eth::CollectionLimit::new(326 eth::CollectionLimitField::OwnerCanDestroy,331 eth::CollectionLimitField::OwnerCanDestroy,327 limits.owner_can_destroy,332 convert_value_from_bool(limits.owner_can_destroy),328 ),333 ),329 eth::CollectionLimit::new(334 eth::CollectionLimit::new(330 eth::CollectionLimitField::TransferEnabled,335 eth::CollectionLimitField::TransferEnabled,331 limits.transfers_enabled,336 convert_value_from_bool(limits.transfers_enabled),332 ),337 ),333 ])338 ])334 }339 }pallets/common/src/eth.rsdiffbeforeafterboth66 T::CrossAccountId::from_sub(account_id)66 T::CrossAccountId::from_sub(account_id)67}67}6869/// Ethereum representation of Optional value with uint256.70#[derive(Debug, Default, AbiCoder)]71pub struct OptionUint {72 status: bool,73 value: uint256,74}7576impl From<u32> for OptionUint {77 fn from(value: u32) -> Self {78 Self {79 status: true,80 value: uint256::from(value),81 }82 }83}8485impl From<Option<u32>> for OptionUint {86 fn from(value: Option<u32>) -> Self {87 match value {88 Some(value) => Self {89 status: true,90 value: value.into(),91 },92 None => Self {93 status: false,94 value: Default::default(),95 },96 }97 }98}99100impl From<bool> for OptionUint {101 fn from(value: bool) -> Self {102 Self {103 status: true,104 value: if value {105 uint256::from(1)106 } else {107 Default::default()108 },109 }110 }111}112113impl From<Option<bool>> for OptionUint {114 fn from(value: Option<bool>) -> Self {115 match value {116 Some(value) => Self::from(value),117 None => Self {118 status: false,119 value: Default::default(),120 },121 }122 }123}124125/// Ethereum representation of Optional value with CrossAddress.126#[derive(Debug, Default, AbiCoder)]127pub struct OptionCrossAddress {128 /// Whether or not this CrossAdress is valid and has meaning.129 pub status: bool,130 /// The underlying CrossAddress value. If the status is false, can be set to whatever.131 pub value: CrossAddress,132}13368134/// Cross account struct69/// Cross account struct135#[derive(Debug, Default, AbiCoder)]70#[derive(Debug, Default, AbiCoder)]252#[derive(Debug, Default, AbiCoder)]187#[derive(Debug, Default, AbiCoder)]253pub struct CollectionLimit {188pub struct CollectionLimit {254 field: CollectionLimitField,189 field: CollectionLimitField,255 value: OptionUint,190 value: Option<uint256>,256}191}257192258impl CollectionLimit {193impl CollectionLimit {259 /// Create [`CollectionLimit`] from field and value.194 /// Create [`CollectionLimit`] from field and value.260 pub fn new<T>(field: CollectionLimitField, value: T) -> Self195 pub fn new(field: CollectionLimitField, value: Option<u32>) -> Self {261 where262 OptionUint: From<T>,263 {264 Self {196 Self {265 field,197 field,266 value: value.into(),198 value: match value {199 Some(value) => Some(value.into()),200 None => None,201 },267 }202 }268 }203 }269 /// Whether the field contains a value.204 /// Whether the field contains a value.270 pub fn has_value(&self) -> bool {205 pub fn has_value(&self) -> bool {271 self.value.status206 self.value.is_some()272 }207 }273}208}274209275impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {210impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {276 type Error = evm_coder::execution::Error;211 type Error = evm_coder::execution::Error;277212278 fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {213 fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {279 let value = self.value.value.try_into().map_err(|error| {214 let value = self215 .value216 .ok_or::<Self::Error>("can't convert `None` value to boolean".into())?;217 let value = Some(value.try_into().map_err(|error| {280 Self::Error::Revert(format!(218 Self::Error::Revert(format!(281 "can't convert value to u32 \"{}\" because: \"{error}\"",219 "can't convert value to u32 \"{}\" because: \"{error}\"",282 self.value.value220 value283 ))221 ))284 })?;222 })?);285223286 let convert_value_to_bool = || match value {224 let convert_value_to_bool = || match value {287 0 => Ok(false),225 Some(value) => match value {226 0 => Ok(Some(false)),288 1 => Ok(true),227 1 => Ok(Some(true)),289 _ => {228 _ => {290 return Err(Self::Error::Revert(format!(229 return Err(Self::Error::Revert(format!(291 "can't convert value to boolean \"{value}\""230 "can't convert value to boolean \"{value}\""292 )))231 )))293 }232 }233 },234 None => Ok(None),294 };235 };295236296 let mut limits = up_data_structs::CollectionLimits::default();237 let mut limits = up_data_structs::CollectionLimits::default();297 match self.field {238 match self.field {298 CollectionLimitField::AccountTokenOwnership => {239 CollectionLimitField::AccountTokenOwnership => {299 limits.account_token_ownership_limit = Some(value);240 limits.account_token_ownership_limit = value;300 }241 }301 CollectionLimitField::SponsoredDataSize => {242 CollectionLimitField::SponsoredDataSize => {302 limits.sponsored_data_size = Some(value);243 limits.sponsored_data_size = value;303 }244 }304 CollectionLimitField::SponsoredDataRateLimit => {245 CollectionLimitField::SponsoredDataRateLimit => {305 limits.sponsored_data_rate_limit =246 limits.sponsored_data_rate_limit = match value {306 Some(up_data_structs::SponsoringRateLimit::Blocks(value));247 Some(value) => Some(up_data_structs::SponsoringRateLimit::Blocks(value)),248 None => None,249 };307 }250 }308 CollectionLimitField::TokenLimit => {251 CollectionLimitField::TokenLimit => {309 limits.token_limit = Some(value);252 limits.token_limit = value;310 }253 }311 CollectionLimitField::SponsorTransferTimeout => {254 CollectionLimitField::SponsorTransferTimeout => {312 limits.sponsor_transfer_timeout = Some(value);255 limits.sponsor_transfer_timeout = value;313 }256 }314 CollectionLimitField::SponsorApproveTimeout => {257 CollectionLimitField::SponsorApproveTimeout => {315 limits.sponsor_approve_timeout = Some(value);258 limits.sponsor_approve_timeout = value;316 }259 }317 CollectionLimitField::OwnerCanTransfer => {260 CollectionLimitField::OwnerCanTransfer => {318 limits.owner_can_transfer = Some(convert_value_to_bool()?);261 limits.owner_can_transfer = convert_value_to_bool()?;319 }262 }320 CollectionLimitField::OwnerCanDestroy => {263 CollectionLimitField::OwnerCanDestroy => {321 limits.owner_can_destroy = Some(convert_value_to_bool()?);264 limits.owner_can_destroy = convert_value_to_bool()?;322 }265 }323 CollectionLimitField::TransferEnabled => {266 CollectionLimitField::TransferEnabled => {324 limits.transfers_enabled = Some(convert_value_to_bool()?);267 limits.transfers_enabled = convert_value_to_bool()?;325 }268 }326 };269 };327 Ok(limits)270 Ok(limits)pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth175 ///175 ///176 /// @param contractAddress The contract for which a sponsor is requested.176 /// @param contractAddress The contract for which a sponsor is requested.177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.178 fn sponsor(&self, contract_address: address) -> Result<eth::OptionCrossAddress> {178 fn sponsor(&self, contract_address: address) -> Result<Option<eth::CrossAddress>> {179 Ok(match Pallet::<T>::get_sponsor(contract_address) {179 Ok(match Pallet::<T>::get_sponsor(contract_address) {180 Some(ref value) => eth::OptionCrossAddress {180 Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::<T>(value)),181 status: true,182 value: eth::CrossAddress::from_sub_cross_account::<T>(value),183 },184 None => eth::OptionCrossAddress {181 None => None,185 status: false,186 value: Default::default(),187 },188 })182 })189 }183 }190184pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth281 uint256 sub;281 uint256 sub;282}282}283283284/// Ethereum representation of Optional value with CrossAddress.284/// Optional value285struct OptionCrossAddress {285struct OptionCrossAddress {286 /// Whether or not this CrossAdress is valid and has meaning.286 /// Shows the status of accessibility of value287 bool status;287 bool status;288 /// The underlying CrossAddress value. If the status is false, can be set to whatever.288 /// Actual value if `status` is true289 CrossAddress value;289 CrossAddress value;290}290}291291pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth466/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.466/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.467struct CollectionLimit {467struct CollectionLimit {468 CollectionLimitField field;468 CollectionLimitField field;469 OptionUint value;469 OptionUint256 value;470}470}471471472/// Ethereum representation of Optional value with uint256.472/// Optional value473struct OptionUint {473struct OptionUint256 {474 /// Shows the status of accessibility of value474 bool status;475 bool status;476 /// Actual value if `status` is true475 uint256 value;477 uint256 value;476}478}477479pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.609struct CollectionLimit {609struct CollectionLimit {610 CollectionLimitField field;610 CollectionLimitField field;611 OptionUint value;611 OptionUint256 value;612}612}613613614/// Ethereum representation of Optional value with uint256.614/// Optional value615struct OptionUint {615struct OptionUint256 {616 /// Shows the status of accessibility of value616 bool status;617 bool status;618 /// Actual value if `status` is true617 uint256 value;619 uint256 value;618}620}619621pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.609struct CollectionLimit {609struct CollectionLimit {610 CollectionLimitField field;610 CollectionLimitField field;611 OptionUint value;611 OptionUint256 value;612}612}613613614/// Ethereum representation of Optional value with uint256.614/// Optional value615struct OptionUint {615struct OptionUint256 {616 /// Shows the status of accessibility of value616 bool status;617 bool status;618 /// Actual value if `status` is true617 uint256 value;619 uint256 value;618}620}619621runtime/common/identity.rsdiffbeforeafterboth24 transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},24 transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},25};25};2627#[cfg(feature = "collator-selection")]28use sp_runtime::transaction_validity::InvalidTransaction;292630#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]27#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]31pub struct DisableIdentityCalls;28pub struct DisableIdentityCalls;tests/src/eth/abi/fungible.jsondiffbeforeafterboth222 { "internalType": "bool", "name": "status", "type": "bool" },222 { "internalType": "bool", "name": "status", "type": "bool" },223 { "internalType": "uint256", "name": "value", "type": "uint256" }223 { "internalType": "uint256", "name": "value", "type": "uint256" }224 ],224 ],225 "internalType": "struct OptionUint",225 "internalType": "struct OptionUint256",226 "name": "value",226 "name": "value",227 "type": "tuple"227 "type": "tuple"228 }228 }508 { "internalType": "bool", "name": "status", "type": "bool" },508 { "internalType": "bool", "name": "status", "type": "bool" },509 { "internalType": "uint256", "name": "value", "type": "uint256" }509 { "internalType": "uint256", "name": "value", "type": "uint256" }510 ],510 ],511 "internalType": "struct OptionUint",511 "internalType": "struct OptionUint256",512 "name": "value",512 "name": "value",513 "type": "tuple"513 "type": "tuple"514 }514 }tests/src/eth/abi/fungibleDeprecated.jsondiffbeforeafterboth88 "outputs": [],88 "outputs": [],89 "stateMutability": "nonpayable",89 "stateMutability": "nonpayable",90 "type": "function"90 "type": "function"91 },91 }92 {93 "inputs": [94 { "internalType": "address", "name": "newOwner", "type": "address" }95 ],96 "name": "changeCollectionOwner",97 "outputs": [],98 "stateMutability": "nonpayable",99 "type": "function"100 }101]92]10293tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",50 "type": "event"50 "type": "event"51 },51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {52 {59 "anonymous": false,53 "anonymous": false,60 "inputs": [54 "inputs": [252 { "internalType": "bool", "name": "status", "type": "bool" },246 { "internalType": "bool", "name": "status", "type": "bool" },253 { "internalType": "uint256", "name": "value", "type": "uint256" }247 { "internalType": "uint256", "name": "value", "type": "uint256" }254 ],248 ],255 "internalType": "struct OptionUint",249 "internalType": "struct OptionUint256",256 "name": "value",250 "name": "value",257 "type": "tuple"251 "type": "tuple"258 }252 }422 "stateMutability": "view",416 "stateMutability": "view",423 "type": "function"417 "type": "function"424 },418 },425 {426 "inputs": [],427 "name": "finishMinting",428 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],429 "stateMutability": "nonpayable",430 "type": "function"431 },432 {419 {433 "inputs": [420 "inputs": [434 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }421 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }515 "stateMutability": "nonpayable",502 "stateMutability": "nonpayable",516 "type": "function"503 "type": "function"517 },504 },518 {519 "inputs": [],520 "name": "mintingFinished",521 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],522 "stateMutability": "view",523 "type": "function"524 },525 {505 {526 "inputs": [],506 "inputs": [],527 "name": "name",507 "name": "name",670 { "internalType": "bool", "name": "status", "type": "bool" },650 { "internalType": "bool", "name": "status", "type": "bool" },671 { "internalType": "uint256", "name": "value", "type": "uint256" }651 { "internalType": "uint256", "name": "value", "type": "uint256" }672 ],652 ],673 "internalType": "struct OptionUint",653 "internalType": "struct OptionUint256",674 "name": "value",654 "name": "value",675 "type": "tuple"655 "type": "tuple"676 }656 }tests/src/eth/abi/reFungible.jsondiffbeforeafterboth49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",50 "type": "event"50 "type": "event"51 },51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {52 {59 "anonymous": false,53 "anonymous": false,60 "inputs": [54 "inputs": [234 { "internalType": "bool", "name": "status", "type": "bool" },228 { "internalType": "bool", "name": "status", "type": "bool" },235 { "internalType": "uint256", "name": "value", "type": "uint256" }229 { "internalType": "uint256", "name": "value", "type": "uint256" }236 ],230 ],237 "internalType": "struct OptionUint",231 "internalType": "struct OptionUint256",238 "name": "value",232 "name": "value",239 "type": "tuple"233 "type": "tuple"240 }234 }404 "stateMutability": "view",398 "stateMutability": "view",405 "type": "function"399 "type": "function"406 },400 },407 {408 "inputs": [],409 "name": "finishMinting",410 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],411 "stateMutability": "nonpayable",412 "type": "function"413 },414 {401 {415 "inputs": [402 "inputs": [416 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }403 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }497 "stateMutability": "nonpayable",484 "stateMutability": "nonpayable",498 "type": "function"485 "type": "function"499 },486 },500 {501 "inputs": [],502 "name": "mintingFinished",503 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],504 "stateMutability": "view",505 "type": "function"506 },507 {487 {508 "inputs": [],488 "inputs": [],509 "name": "name",489 "name": "name",652 { "internalType": "bool", "name": "status", "type": "bool" },632 { "internalType": "bool", "name": "status", "type": "bool" },653 { "internalType": "uint256", "name": "value", "type": "uint256" }633 { "internalType": "uint256", "name": "value", "type": "uint256" }654 ],634 ],655 "internalType": "struct OptionUint",635 "internalType": "struct OptionUint256",656 "name": "value",636 "name": "value",657 "type": "tuple"637 "type": "tuple"658 }638 }tests/src/eth/abi/reFungibleDeprecated.jsondiffbeforeafterboth80 "stateMutability": "nonpayable",80 "stateMutability": "nonpayable",81 "type": "function"81 "type": "function"82 },82 },83 {84 "inputs": [85 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },86 { "internalType": "string", "name": "key", "type": "string" },87 { "internalType": "bytes", "name": "value", "type": "bytes" }88 ],89 "name": "setProperty",90 "outputs": [],91 "stateMutability": "nonpayable",92 "type": "function"93 },83 {94 {84 "inputs": [95 "inputs": [85 { "internalType": "address", "name": "newOwner", "type": "address" }96 { "internalType": "address", "name": "newOwner", "type": "address" }tests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth96 "stateMutability": "view",96 "stateMutability": "view",97 "type": "function"97 "type": "function"98 },98 },99 {100 "inputs": [101 { "internalType": "address", "name": "from", "type": "address" },102 { "internalType": "uint256", "name": "amount", "type": "uint256" }103 ],104 "name": "burnFrom",105 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],106 "stateMutability": "nonpayable",107 "type": "function"108 },109 {99 {110 "inputs": [100 "inputs": [111 {101 {tests/src/eth/abi/reFungibleTokenDeprecated.jsondiffbeforeafterbothno changes
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth181 Generous181 Generous182}182}183183184/// Ethereum representation of Optional value with CrossAddress.184/// Optional value185struct OptionCrossAddress {185struct OptionCrossAddress {186 /// Whether or not this CrossAdress is valid and has meaning.186 /// Shows the status of accessibility of value187 bool status;187 bool status;188 /// The underlying CrossAddress value. If the status is false, can be set to whatever.188 /// Actual value if `status` is true189 CrossAddress value;189 CrossAddress value;190}190}191191tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth308/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.308/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.309struct CollectionLimit {309struct CollectionLimit {310 CollectionLimitField field;310 CollectionLimitField field;311 OptionUint value;311 OptionUint256 value;312}312}313313314/// Ethereum representation of Optional value with uint256.314/// Optional value315struct OptionUint {315struct OptionUint256 {316 /// Shows the status of accessibility of value316 bool status;317 bool status;318 /// Actual value if `status` is true317 uint256 value;319 uint256 value;318}320}319321tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.409struct CollectionLimit {409struct CollectionLimit {410 CollectionLimitField field;410 CollectionLimitField field;411 OptionUint value;411 OptionUint256 value;412}412}413413414/// Ethereum representation of Optional value with uint256.414/// Optional value415struct OptionUint {415struct OptionUint256 {416 /// Shows the status of accessibility of value416 bool status;417 bool status;418 /// Actual value if `status` is true417 uint256 value;419 uint256 value;418}420}419421tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.409struct CollectionLimit {409struct CollectionLimit {410 CollectionLimitField field;410 CollectionLimitField field;411 OptionUint value;411 OptionUint256 value;412}412}413413414/// Ethereum representation of Optional value with uint256.414/// Optional value415struct OptionUint {415struct OptionUint256 {416 /// Shows the status of accessibility of value416 bool status;417 bool status;418 /// Actual value if `status` is true417 uint256 value;419 uint256 value;418}420}419421tests/src/eth/reFungible.test.tsdiffbeforeafterboth213 const address = helper.ethAddress.fromCollectionId(collection.collectionId);213 const address = helper.ethAddress.fromCollectionId(collection.collectionId);214 const contract = await helper.ethNativeContract.collection(address, 'rft');214 const contract = await helper.ethNativeContract.collection(address, 'rft');215215216 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner);216 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);217217218 {218 {219 await rftToken.methods.approve(operator, 15n).send({from: owner});219 await rftToken.methods.approve(operator, 15n).send({from: owner});tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth413 const result = await contract.methods.mint(caller).send();413 const result = await contract.methods.mint(caller).send();414 const tokenId = result.events.Transfer.returnValues.tokenId;414 const tokenId = result.events.Transfer.returnValues.tokenId;415 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);415 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);416 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);416 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller, true);417417418 await tokenContract.methods.repartition(2).send();418 await tokenContract.methods.repartition(2).send();419 await tokenContract.methods.transfer(receiver, 1).send();419 await tokenContract.methods.transfer(receiver, 1).send();tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth29import refungibleAbi from '../../abi/reFungible.json';29import refungibleAbi from '../../abi/reFungible.json';30import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';30import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';31import refungibleTokenAbi from '../../abi/reFungibleToken.json';31import refungibleTokenAbi from '../../abi/reFungibleToken.json';32import refungibleTokenDeprecatedAbi from '../../abi/reFungibleTokenDeprecated.json';32import contractHelpersAbi from '../../abi/contractHelpers.json';33import contractHelpersAbi from '../../abi/contractHelpers.json';33import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';34import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';34import {TCollectionMode} from '../../../util/playgrounds/types';35import {TCollectionMode} from '../../../util/playgrounds/types';187 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);188 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);188 }189 }189190190 async rftToken(address: string, caller?: string) {191 async rftToken(address: string, caller?: string, mergeDeprecated = false) {191 const web3 = this.helper.getWeb3();192 const web3 = this.helper.getWeb3();193 const abi = mergeDeprecated ? [...refungibleTokenAbi, ...refungibleTokenDeprecatedAbi] : refungibleTokenAbi;192 return unlimitedMoneyHack(new web3.eth.Contract(refungibleTokenAbi as any, address, {194 return unlimitedMoneyHack(new web3.eth.Contract(abi as any, address, {193 gas: this.helper.eth.DEFAULT_GAS,195 gas: this.helper.eth.DEFAULT_GAS,194 gasPrice: await this.getGasPrice(),196 gasPrice: await this.getGasPrice(),195 ...(caller ? {from: caller} : {}),197 ...(caller ? {from: caller} : {}),196 }));198 }));197 }199 }198200199 rftTokenById(collectionId: number, tokenId: number, caller?: string) {201 rftTokenById(collectionId: number, tokenId: number, caller?: string, mergeDeprecated = false) {200 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);202 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller, mergeDeprecated);201 }203 }202}204}203205