difftreelog
feat update MarketV2 contract
in: master
3 files changed
tests/src/eth/marketplace-v2/Market.soldiffbeforeafterboth4import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";4import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";5import "@openzeppelin/contracts/token/ERC721/IERC721.sol";5import "@openzeppelin/contracts/token/ERC721/IERC721.sol";6import { UniqueNFT, CrossAddress } from "@unique-nft/solidity-interfaces/contracts/UniqueNFT.sol";6import { UniqueNFT, CrossAddress } from "@unique-nft/solidity-interfaces/contracts/UniqueNFT.sol";7import { UniqueFungible, CrossAddress as CrossAddressF } from "@unique-nft/solidity-interfaces/contracts/UniqueFungible.sol";7import "@unique-nft/solidity-interfaces/contracts/CollectionHelpers.sol";8import "@unique-nft/solidity-interfaces/contracts/CollectionHelpers.sol";8import "./royalty/UniqueRoyaltyHelper.sol";9import "./royalty/UniqueRoyaltyHelper.sol";91020 }21 }212222 uint32 public constant version = 0;23 uint32 public constant version = 0;24 uint32 public constant buildVersion = 1;23 bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd;25 bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd;24 bytes4 private constant InterfaceId_ERC165 = 0x5755c3f2;26 bytes4 private constant InterfaceId_ERC165 = 0x5755c3f2;25 CollectionHelpers private constant collectionHelpers =27 CollectionHelpers private constant collectionHelpers =251253252 IERC721 erc721 = getErc721(collectionId);254 IERC721 erc721 = getErc721(collectionId);253255254 if (erc721.getApproved(tokenId) != selfAddress) {256 if (erc721.getApproved(tokenId) != selfAddress || erc721.ownerOf(tokenId) != getAddressFromCrossAccount(order.seller)) {255 uint32 amount = order.amount;257 uint32 amount = order.amount;256 order.amount = 0;258 order.amount = 0;257 emit TokenRevoke(version, order, amount);259 emit TokenRevoke(version, order, amount);262 }264 }263 }265 }266267 function getAddressFromCrossAccount(CrossAddress memory account) private pure returns (address) {268 if (account.eth != address(0)) {269 return account.eth;270 } else {271 return address(uint160(account.sub >> 96));272 }273 }274275 function revokeAdmin(uint32 collectionId, uint32 tokenId) public onlyAdmin {276 Order memory order = orders[collectionId][tokenId];277 if (order.price == 0) {278 revert OrderNotFound();279 }280281 uint32 amount = order.amount;282 order.amount = 0;283 emit TokenRevoke(version, order, amount);284285 delete orders[collectionId][tokenId];286 }264287265 // ################################################################288 // ################################################################266 // Buy a token #289 // Buy a token #329 }352 }330353331 function sendMoney(CrossAddress memory to, uint256 money) private {354 function sendMoney(CrossAddress memory to, uint256 money) private {332 address payable eth;355 address collectionAddress = collectionHelpers.collectionAddress(0);356333 if (to.eth != address(0)) {357 UniqueFungible fungible = UniqueFungible(collectionAddress);358334 eth = payable(to.eth);359 CrossAddressF memory fromF = CrossAddressF(selfAddress, 0);335 } else {336 eth = payable(address(uint160(to.sub >> 96)));360 CrossAddressF memory toF = CrossAddressF(to.eth, to.sub);337 }361338 eth.transfer(money);362 fungible.transferFromCross(fromF, toF, money);339 }363 }340364341 function sendRoyalties(address collection, uint tokenId, uint sellPrice) private returns (uint256, RoyaltyAmount[] memory) {365 function sendRoyalties(address collection, uint tokenId, uint sellPrice) private returns (uint256, RoyaltyAmount[] memory) {tests/src/eth/marketplace-v2/marketplace.test.tsdiffbeforeafterboth--- a/tests/src/eth/marketplace-v2/marketplace.test.ts
+++ b/tests/src/eth/marketplace-v2/marketplace.test.ts
@@ -43,6 +43,10 @@
fsPath: `${dirname}/../api/UniqueNFT.sol`,
},
{
+ solPath: '@unique-nft/solidity-interfaces/contracts/UniqueFungible.sol',
+ fsPath: `${dirname}/../api/UniqueFungible.sol`,
+ },
+ {
solPath: '@openzeppelin/contracts/utils/introspection/IERC165.sol',
fsPath: `${dirname}/../../../node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol`,
},
@@ -125,7 +129,6 @@
const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', marketOwner);
const [seller] = await helper.arrange.createAccounts([600n], donor);
- const sellerMirror = helper.address.substrateToEth(seller.address);
const sellerCross = helper.ethCrossAccount.fromKeyringPair(seller);
const result = await collection.methods.mintCross(sellerCross, []).send();
const tokenId = result.events.Transfer.returnValues.tokenId;
@@ -140,10 +143,9 @@
const buyerMirror = helper.address.substrateToEth(buyer.address);
const buyerCross = helper.ethCrossAccount.fromKeyringPair(buyer);
await helper.eth.transferBalanceFromSubstrate(donor, buyerMirror, 1n);
- //TODO: change balance check to helper.balance.getSubstrate when implementation of sendMoney will be fixed in contract
- const sellerBalance = BigInt(await web3.eth.getBalance(sellerMirror));
+ const sellerBalance = BigInt(await helper.balance.getSubstrate(seller.address));
await helper.eth.sendEVM(buyer, market.options.address, market.methods.buy(collectionId, tokenId, 1, buyerCross).encodeABI(), PRICE.toString());
- const sellerBalanceAfterBuy = BigInt(await web3.eth.getBalance(sellerMirror));
+ const sellerBalanceAfterBuy = BigInt(await helper.balance.getSubstrate(seller.address));
ownerCross = await collection.methods.ownerOfCross(tokenId).call();
expect(ownerCross.eth).to.be.eq(buyerCross.eth);
expect(substrateAddressToHex(ownerCross.sub, web3)).to.be.eq(substrateAddressToHex(buyerCross.sub, web3));
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -561,10 +561,10 @@
itEth.ifWithPallets(`[${testCase.mode}] Can't be multiple set/read for non-existent token`, testCase.requiredPallets, async({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
- const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
+ const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
+ const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {tokenOwner: true,
collectionAdmin: true,
- mutable: true}}; });
+ mutable: true}}));
const collection = await helper[testCase.mode].mintCollection(alice, {
tokenPrefix: 'ethp',