difftreelog
chore fix code review requests
in: master
2 files changed
runtime/common/ethereum/sponsoring/refungible.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//! Implements EVM sponsoring logic via TransactionValidityHack1819use core::convert::TryInto;20use pallet_common::CollectionHandle;21use pallet_evm::account::CrossAccountId;22use pallet_fungible::Config as FungibleConfig;23use pallet_refungible::Config as RefungibleConfig;24use pallet_nonfungible::Config as NonfungibleConfig;25use pallet_unique::Config as UniqueConfig;26use up_data_structs::{CreateItemData, CreateNftData, TokenId};2728use super::common;29use crate::runtime_common::sponsoring::*;3031use pallet_refungible::{32 erc::{33 ERC721BurnableCall, ERC721Call, ERC721EnumerableCall, ERC721MetadataCall,34 ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, TokenPropertiesCall,35 UniqueRefungibleCall,36 },37 erc_token::{38 ERC1633Call, ERC20Call, ERC20UniqueExtensionsCall, RefungibleTokenHandle,39 UniqueRefungibleTokenCall,40 },41};4243pub fn call_sponsor<T>(44 call: UniqueRefungibleCall<T>,45 collection: CollectionHandle<T>,46 who: &T::CrossAccountId,47) -> Option<()>48where49 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,50{51 use UniqueRefungibleCall::*;5253 match call {54 // Readonly55 ERC165Call(_, _) => None,5657 ERC721Enumerable(call) => erc721::enumerable_call_sponsor(call, collection, who),58 ERC721Burnable(call) => erc721::burnable_call_sponsor(call, collection, who),59 ERC721Metadata(call) => erc721::metadata_call_sponsor(call, collection, who),60 Collection(call) => common::collection_call_sponsor(call, collection, who),61 ERC721(call) => erc721::call_sponsor(call, collection, who),62 ERC721UniqueExtensions(call) => {63 erc721::unique_extensions_call_sponsor(call, collection, who)64 }65 ERC721UniqueMintable(call) => erc721::unique_mintable_call_sponsor(call, collection, who),66 TokenProperties(call) => token_properties_call_sponsor(call, collection, who),67 }68}6970pub fn token_properties_call_sponsor<T>(71 call: TokenPropertiesCall<T>,72 collection: CollectionHandle<T>,73 who: &T::CrossAccountId,74) -> Option<()>75where76 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,77{78 use TokenPropertiesCall::*;7980 match call {81 // Readonly82 ERC165Call(_, _) | Property { .. } | TokenPropertyPermissions => None,8384 // Not sponsored85 SetTokenPropertyPermission { .. }86 | SetTokenPropertyPermissions { .. }87 | SetProperties { .. }88 | DeleteProperty { .. }89 | DeleteProperties { .. } => None,9091 SetProperty {92 token_id,93 key,94 value,95 ..96 } => {97 let token_id = TokenId::try_from(token_id).ok()?;98 withdraw_set_token_property::<T>(&collection, &who, &token_id, key.len() + value.len())99 }100 }101}102103pub fn token_call_sponsor<T>(104 call: UniqueRefungibleTokenCall<T>,105 token: RefungibleTokenHandle<T>,106 who: &T::CrossAccountId,107) -> Option<()>108where109 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,110{111 use UniqueRefungibleTokenCall::*;112113 match call {114 // Readonly115 ERC165Call(_, _) => None,116117 ERC20(call) => erc20::call_sponsor(call, token, who),118 ERC20UniqueExtensions(call) => erc20::unique_extensions_call_sponsor(call, token, who),119 ERC1633(call) => erc1633::call_sponsor(call, token, who),120 }121}122123mod erc721 {124 use super::*;125126 pub fn call_sponsor<T>(127 call: ERC721Call<T>,128 collection: CollectionHandle<T>,129 _who: &T::CrossAccountId,130 ) -> Option<()>131 where132 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,133 {134 use ERC721Call::*;135136 match call {137 // Readonly138 ERC165Call(_, _)139 | BalanceOf { .. }140 | OwnerOf { .. }141 | GetApproved { .. }142 | IsApprovedForAll { .. }143 | CollectionHelperAddress => None,144145 // Not sponsored146 SafeTransferFromWithData { .. }147 | SafeTransferFrom { .. }148 | SetApprovalForAll { .. } => None,149150 TransferFrom { token_id, from, .. } => {151 let token_id = TokenId::try_from(token_id).ok()?;152 let from = T::CrossAccountId::from_eth(from);153 withdraw_transfer::<T>(&collection, &from, &token_id)154 }155156 // Not supported157 Approve { .. } => None,158 }159 }160161 pub fn enumerable_call_sponsor<T>(162 call: ERC721EnumerableCall<T>,163 _collection: CollectionHandle<T>,164 _who: &T::CrossAccountId,165 ) -> Option<()>166 where167 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,168 {169 use ERC721EnumerableCall::*;170171 match call {172 // Readonly173 ERC165Call(_, _) | TokenByIndex { .. } | TokenOfOwnerByIndex { .. } | TotalSupply => {174 None175 }176 }177 }178179 pub fn burnable_call_sponsor<T>(180 call: ERC721BurnableCall<T>,181 _collection: CollectionHandle<T>,182 _who: &T::CrossAccountId,183 ) -> Option<()>184 where185 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,186 {187 use ERC721BurnableCall::*;188189 match call {190 // Readonly191 ERC165Call(_, _) => None,192193 // Not sponsored194 Burn { .. } => None,195 }196 }197198 pub fn metadata_call_sponsor<T>(199 call: ERC721MetadataCall<T>,200 _collection: CollectionHandle<T>,201 _who: &T::CrossAccountId,202 ) -> Option<()>203 where204 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,205 {206 use ERC721MetadataCall::*;207208 match call {209 // Readonly210 ERC165Call(_, _) | NameProxy | SymbolProxy | TokenUri { .. } => None,211 }212 }213214 pub fn unique_extensions_call_sponsor<T>(215 call: ERC721UniqueExtensionsCall<T>,216 collection: CollectionHandle<T>,217 who: &T::CrossAccountId,218 ) -> Option<()>219 where220 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,221 {222 use ERC721UniqueExtensionsCall::*;223224 match call {225 // Readonly226 ERC165Call(_, _)227 | Name228 | Symbol229 | Description230 | CrossOwnerOf { .. }231 | Properties { .. }232 | NextTokenId233 | TokenContractAddress { .. } => None,234235 // Not sponsored236 BurnFrom { .. } | BurnFromCross { .. } => None,237238 MintCross { .. } | MintBulk { .. } | MintBulkWithTokenUri { .. } => {239 withdraw_create_item::<T>(240 &collection,241 &who,242 &CreateItemData::NFT(CreateNftData::default()),243 )244 }245246 TransferCross { token_id, .. }247 | TransferFromCross { token_id, .. }248 | Transfer { token_id, .. } => {249 let token_id = TokenId::try_from(token_id).ok()?;250 withdraw_transfer::<T>(&collection, &who, &token_id)251 }252 }253 }254255 pub fn unique_mintable_call_sponsor<T>(256 call: ERC721UniqueMintableCall<T>,257 collection: CollectionHandle<T>,258 who: &T::CrossAccountId,259 ) -> Option<()>260 where261 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,262 {263 use ERC721UniqueMintableCall::*;264265 match call {266 // Readonly267 ERC165Call(_, _) | MintingFinished => None,268269 // Not sponsored270 FinishMinting => None,271272 Mint { .. }273 | MintCheckId { .. }274 | MintWithTokenUri { .. }275 | MintWithTokenUriCheckId { .. } => withdraw_create_item::<T>(276 &collection,277 &who,278 &CreateItemData::NFT(CreateNftData::default()),279 ),280 }281 }282}283284mod erc20 {285 use super::*;286287 pub fn call_sponsor<T>(288 call: ERC20Call<T>,289 token: RefungibleTokenHandle<T>,290 who: &T::CrossAccountId,291 ) -> Option<()>292 where293 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,294 {295 use ERC20Call::*;296297 match call {298 // Readonly299 ERC165Call(_, _)300 | Name301 | Symbol302 | TotalSupply303 | Decimals304 | BalanceOf { .. }305 | Allowance { .. } => None,306307 Transfer { .. } => {308 let RefungibleTokenHandle(handle, token_id) = token;309 let token_id = token_id.try_into().ok()?;310 withdraw_transfer::<T>(&handle, &who, &token_id)311 }312 TransferFrom { from, .. } => {313 let RefungibleTokenHandle(handle, token_id) = token;314 let token_id = token_id.try_into().ok()?;315 let from = T::CrossAccountId::from_eth(from);316 withdraw_transfer::<T>(&handle, &from, &token_id)317 }318 Approve { .. } => {319 let RefungibleTokenHandle(handle, token_id) = token;320 let token_id = token_id.try_into().ok()?;321 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)322 }323 }324 }325326 pub fn unique_extensions_call_sponsor<T>(327 call: ERC20UniqueExtensionsCall<T>,328 token: RefungibleTokenHandle<T>,329 who: &T::CrossAccountId,330 ) -> Option<()>331 where332 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,333 {334 use ERC20UniqueExtensionsCall::*;335336 match call {337 // Readonly338 ERC165Call(_, _) => None,339340 // Not sponsored341 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,342343 TransferCross { .. } | TransferFromCross { .. } => {344 let RefungibleTokenHandle(handle, token_id) = token;345 let token_id = token_id.try_into().ok()?;346 withdraw_transfer::<T>(&handle, &who, &token_id)347 }348349 ApproveCross { .. } => {350 let RefungibleTokenHandle(handle, token_id) = token;351 let token_id = token_id.try_into().ok()?;352 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)353 }354 }355 }356}357358mod erc1633 {359 use super::*;360361 pub fn call_sponsor<T>(362 call: ERC1633Call<T>,363 _token: RefungibleTokenHandle<T>,364 _who: &T::CrossAccountId,365 ) -> Option<()>366 where367 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,368 {369 use ERC1633Call::*;370371 match call {372 // Readonly373 ERC165Call(_, _) | ParentToken | ParentTokenId => None,374 }375 }376}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//! Implements EVM sponsoring logic via TransactionValidityHack1819use core::convert::TryInto;20use pallet_common::CollectionHandle;21use pallet_evm::account::CrossAccountId;22use pallet_fungible::Config as FungibleConfig;23use pallet_refungible::Config as RefungibleConfig;24use pallet_nonfungible::Config as NonfungibleConfig;25use pallet_unique::Config as UniqueConfig;26use up_data_structs::{CreateItemData, CreateNftData, TokenId};2728use super::common;29use crate::runtime_common::sponsoring::*;3031use pallet_refungible::{32 erc::{33 ERC721BurnableCall, ERC721Call, ERC721EnumerableCall, ERC721MetadataCall,34 ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, TokenPropertiesCall,35 UniqueRefungibleCall,36 },37 erc_token::{38 ERC1633Call, ERC20Call, ERC20UniqueExtensionsCall, RefungibleTokenHandle,39 UniqueRefungibleTokenCall,40 },41};4243pub fn call_sponsor<T>(44 call: UniqueRefungibleCall<T>,45 collection: CollectionHandle<T>,46 who: &T::CrossAccountId,47) -> Option<()>48where49 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,50{51 use UniqueRefungibleCall::*;5253 match call {54 // Readonly55 ERC165Call(_, _) => None,5657 ERC721Enumerable(call) => erc721::enumerable_call_sponsor(call, collection, who),58 ERC721Burnable(call) => erc721::burnable_call_sponsor(call, collection, who),59 ERC721Metadata(call) => erc721::metadata_call_sponsor(call, collection, who),60 Collection(call) => common::collection_call_sponsor(call, collection, who),61 ERC721(call) => erc721::call_sponsor(call, collection, who),62 ERC721UniqueExtensions(call) => {63 erc721::unique_extensions_call_sponsor(call, collection, who)64 }65 ERC721UniqueMintable(call) => erc721::unique_mintable_call_sponsor(call, collection, who),66 TokenProperties(call) => token_properties_call_sponsor(call, collection, who),67 }68}6970pub fn token_properties_call_sponsor<T>(71 call: TokenPropertiesCall<T>,72 collection: CollectionHandle<T>,73 who: &T::CrossAccountId,74) -> Option<()>75where76 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,77{78 use TokenPropertiesCall::*;7980 match call {81 // Readonly82 ERC165Call(_, _) | Property { .. } | TokenPropertyPermissions => None,8384 // Not sponsored85 SetTokenPropertyPermission { .. }86 | SetTokenPropertyPermissions { .. }87 | SetProperties { .. }88 | DeleteProperty { .. }89 | DeleteProperties { .. } => None,9091 SetProperty {92 token_id,93 key,94 value,95 ..96 } => {97 let token_id = TokenId::try_from(token_id).ok()?;98 withdraw_set_token_property::<T>(&collection, &who, &token_id, key.len() + value.len())99 }100 }101}102103pub fn token_call_sponsor<T>(104 call: UniqueRefungibleTokenCall<T>,105 token: RefungibleTokenHandle<T>,106 who: &T::CrossAccountId,107) -> Option<()>108where109 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,110{111 use UniqueRefungibleTokenCall::*;112113 match call {114 // Readonly115 ERC165Call(_, _) => None,116117 ERC20(call) => erc20::call_sponsor(call, token, who),118 ERC20UniqueExtensions(call) => erc20::unique_extensions_call_sponsor(call, token, who),119 ERC1633(call) => erc1633::call_sponsor(call, token, who),120 }121}122123mod erc721 {124 use super::*;125126 pub fn call_sponsor<T>(127 call: ERC721Call<T>,128 collection: CollectionHandle<T>,129 _who: &T::CrossAccountId,130 ) -> Option<()>131 where132 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,133 {134 use ERC721Call::*;135136 match call {137 // Readonly138 ERC165Call(_, _)139 | BalanceOf { .. }140 | OwnerOf { .. }141 | GetApproved { .. }142 | IsApprovedForAll { .. }143 | CollectionHelperAddress => None,144145 // Not sponsored146 SafeTransferFromWithData { .. }147 | SafeTransferFrom { .. }148 | SetApprovalForAll { .. } => None,149150 TransferFrom { token_id, from, .. } => {151 let token_id = TokenId::try_from(token_id).ok()?;152 let from = T::CrossAccountId::from_eth(from);153 withdraw_transfer::<T>(&collection, &from, &token_id)154 }155156 // Not supported157 Approve { .. } => None,158 }159 }160161 pub fn enumerable_call_sponsor<T>(162 call: ERC721EnumerableCall<T>,163 _collection: CollectionHandle<T>,164 _who: &T::CrossAccountId,165 ) -> Option<()>166 where167 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,168 {169 use ERC721EnumerableCall::*;170171 match call {172 // Readonly173 ERC165Call(_, _) | TokenByIndex { .. } | TokenOfOwnerByIndex { .. } | TotalSupply => {174 None175 }176 }177 }178179 pub fn burnable_call_sponsor<T>(180 call: ERC721BurnableCall<T>,181 _collection: CollectionHandle<T>,182 _who: &T::CrossAccountId,183 ) -> Option<()>184 where185 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,186 {187 use ERC721BurnableCall::*;188189 match call {190 // Readonly191 ERC165Call(_, _) => None,192193 // Not sponsored194 Burn { .. } => None,195 }196 }197198 pub fn metadata_call_sponsor<T>(199 call: ERC721MetadataCall<T>,200 _collection: CollectionHandle<T>,201 _who: &T::CrossAccountId,202 ) -> Option<()>203 where204 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,205 {206 use ERC721MetadataCall::*;207208 match call {209 // Readonly210 ERC165Call(_, _) | NameProxy | SymbolProxy | TokenUri { .. } => None,211 }212 }213214 pub fn unique_extensions_call_sponsor<T>(215 call: ERC721UniqueExtensionsCall<T>,216 collection: CollectionHandle<T>,217 who: &T::CrossAccountId,218 ) -> Option<()>219 where220 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,221 {222 use ERC721UniqueExtensionsCall::*;223224 match call {225 // Readonly226 ERC165Call(_, _)227 | Name228 | Symbol229 | Description230 | CrossOwnerOf { .. }231 | Properties { .. }232 | NextTokenId233 | TokenContractAddress { .. } => None,234235 // Not sponsored236 BurnFrom { .. } | BurnFromCross { .. } | MintBulk { .. } | MintBulkWithTokenUri { .. } => None,237238 MintCross { .. } => {239 withdraw_create_item::<T>(240 &collection,241 &who,242 &CreateItemData::NFT(CreateNftData::default()),243 )244 }245246 TransferCross { token_id, .. }247 | TransferFromCross { token_id, .. }248 | Transfer { token_id, .. } => {249 let token_id = TokenId::try_from(token_id).ok()?;250 withdraw_transfer::<T>(&collection, &who, &token_id)251 }252 }253 }254255 pub fn unique_mintable_call_sponsor<T>(256 call: ERC721UniqueMintableCall<T>,257 collection: CollectionHandle<T>,258 who: &T::CrossAccountId,259 ) -> Option<()>260 where261 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,262 {263 use ERC721UniqueMintableCall::*;264265 match call {266 // Readonly267 ERC165Call(_, _) | MintingFinished => None,268269 // Not sponsored270 FinishMinting => None,271272 Mint { .. }273 | MintCheckId { .. }274 | MintWithTokenUri { .. }275 | MintWithTokenUriCheckId { .. } => withdraw_create_item::<T>(276 &collection,277 &who,278 &CreateItemData::NFT(CreateNftData::default()),279 ),280 }281 }282}283284mod erc20 {285 use super::*;286287 pub fn call_sponsor<T>(288 call: ERC20Call<T>,289 token: RefungibleTokenHandle<T>,290 who: &T::CrossAccountId,291 ) -> Option<()>292 where293 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,294 {295 use ERC20Call::*;296297 match call {298 // Readonly299 ERC165Call(_, _)300 | Name301 | Symbol302 | TotalSupply303 | Decimals304 | BalanceOf { .. }305 | Allowance { .. } => None,306307 Transfer { .. } => {308 let RefungibleTokenHandle(handle, token_id) = token;309 let token_id = token_id.try_into().ok()?;310 withdraw_transfer::<T>(&handle, &who, &token_id)311 }312 TransferFrom { from, .. } => {313 let RefungibleTokenHandle(handle, token_id) = token;314 let token_id = token_id.try_into().ok()?;315 let from = T::CrossAccountId::from_eth(from);316 withdraw_transfer::<T>(&handle, &from, &token_id)317 }318 Approve { .. } => {319 let RefungibleTokenHandle(handle, token_id) = token;320 let token_id = token_id.try_into().ok()?;321 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)322 }323 }324 }325326 pub fn unique_extensions_call_sponsor<T>(327 call: ERC20UniqueExtensionsCall<T>,328 token: RefungibleTokenHandle<T>,329 who: &T::CrossAccountId,330 ) -> Option<()>331 where332 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,333 {334 use ERC20UniqueExtensionsCall::*;335336 match call {337 // Readonly338 ERC165Call(_, _) => None,339340 // Not sponsored341 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,342343 TransferCross { .. } | TransferFromCross { .. } => {344 let RefungibleTokenHandle(handle, token_id) = token;345 let token_id = token_id.try_into().ok()?;346 withdraw_transfer::<T>(&handle, &who, &token_id)347 }348349 ApproveCross { .. } => {350 let RefungibleTokenHandle(handle, token_id) = token;351 let token_id = token_id.try_into().ok()?;352 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)353 }354 }355 }356}357358mod erc1633 {359 use super::*;360361 pub fn call_sponsor<T>(362 call: ERC1633Call<T>,363 _token: RefungibleTokenHandle<T>,364 _who: &T::CrossAccountId,365 ) -> Option<()>366 where367 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,368 {369 use ERC1633Call::*;370371 match call {372 // Readonly373 ERC165Call(_, _) | ParentToken | ParentTokenId => None,374 }375 }376}tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -16,7 +16,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets, requirePalletsOrSkip, usingPlaygrounds} from '../util/index';
-import { CrossAccountId } from '../util/playgrounds/unique';
import {itEth, expect} from './util';
describe('evm nft collection sponsoring', () => {
@@ -102,14 +101,14 @@
expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
- let sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
- expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
+ let sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});
+ expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorStruct.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
- sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
- expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');
+ sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});
+ expect(sponsorStruct.eth).to.be.eq('0x0000000000000000000000000000000000000000');
}));
[
@@ -337,8 +336,6 @@
[
'mintCross',
'mintWithTokenURI',
- 'mintBulk',
- 'mintBulkWithTokenUri',
].map(testCase =>
itEth(`[${testCase}] sponsors mint transactions`, async ({helper}) => {
const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}, tokenPropertyPermissions: [
@@ -364,21 +361,12 @@
let mintingResult;
let tokenId;
- const nextTokenId = await contract.methods.nextTokenId().call();
switch (testCase) {
case 'mintCross':
mintingResult = await contract.methods.mintCross(minterCross, []).send();
break;
case 'mintWithTokenURI':
mintingResult = await contract.methods.mintWithTokenURI(minter, 'Test URI').send();
- tokenId = mintingResult.events.Transfer.returnValues.tokenId;
- expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
- break;
- case 'mintBulk':
- mintingResult = await contract.methods.mintBulk(minter, [nextTokenId]).send();
- break;
- case 'mintBulkWithTokenUri':
- mintingResult = await contract.methods.mintBulkWithTokenURI(minter, [[nextTokenId, 'Test URI']]).send();
tokenId = mintingResult.events.Transfer.returnValues.tokenId;
expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
break;
@@ -419,8 +407,8 @@
await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
- const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
- expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');
+ const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});
+ expect(sponsorStruct.eth).to.be.eq('0x0000000000000000000000000000000000000000');
}));
[
@@ -524,9 +512,9 @@
collectionData = (await collectionSub.getData())!;
expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;
- const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
+ const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});
const sponsorSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.ethToSubstrate(sponsor));
- const actualSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub)));
+ const actualSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorStruct.sub)));
expect(actualSubAddress).to.be.equal(sponsorSubAddress);
const user = helper.eth.createAccount();
@@ -580,8 +568,8 @@
collectionData = (await collectionSub.getData())!;
expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(sponsor.address);
expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;
- const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
- expect(BigInt(sponsorTuple.sub)).to.be.equal(BigInt('0x' + Buffer.from(sponsor.addressRaw).toString('hex')));
+ const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});
+ expect(BigInt(sponsorStruct.sub)).to.be.equal(BigInt('0x' + Buffer.from(sponsor.addressRaw).toString('hex')));
const user = helper.eth.createAccount();
const userCross = helper.ethCrossAccount.fromAddress(user);