Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Marketplace mock Land contracts and test #1577

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
940c9a0
add: bundle as AssetType
atkinsonholly May 8, 2024
c79d1c4
fix: temp fix bundle any type
atkinsonholly May 8, 2024
d0e52b5
fix: typo in error TransferManager
atkinsonholly May 8, 2024
df9a0f7
add: note on bundle asset value
atkinsonholly May 8, 2024
8f9343f
add: whitelist validation added for bundles
atkinsonholly May 9, 2024
340240e
fix: whitelist validation added for bundles
atkinsonholly May 9, 2024
28a797c
add: bundle tests for fill and partial fill
atkinsonholly May 22, 2024
09dcf9d
add: test for ERC721 scenario + Bundle ERC20 reverse
atkinsonholly May 23, 2024
343f908
add: WIP add QUADS so marketplace can batch transfer LANDs
atkinsonholly May 23, 2024
37cb523
fix: yarn.lock
atkinsonholly May 23, 2024
001ddf0
add: quad struct added to bundle
atkinsonholly May 29, 2024
f0c9d3a
fix: format
atkinsonholly May 29, 2024
8a40524
add: hardhat config updated for land package compiler version
atkinsonholly Jun 17, 2024
7c5e52d
add: mock land contracts for testing Bundles with Quads
atkinsonholly Jun 17, 2024
617f045
add: Bundles working with Quads
atkinsonholly Jun 17, 2024
5948325
add: update OZ contracts version to 5.0.2 to align with packages/land
atkinsonholly Jun 25, 2024
42f9f36
fix: update mocks for OZ contracts v5.0.2 and fix failing tests
atkinsonholly Jun 25, 2024
f1e6e50
fix: format
atkinsonholly Jun 25, 2024
56acf4b
add: update hardhat.config incl mocha object
atkinsonholly Jun 25, 2024
adc8af6
Marketplace fee whitelists
wojciech-turek Jul 2, 2024
d4d988f
Update documentation
wojciech-turek Jul 2, 2024
f15020a
feat: added Bundle price distribution
capedcrusader21 Jul 12, 2024
ea30199
feat: royalty distribution for quad
capedcrusader21 Jul 18, 2024
1ade4c6
fix: royalty distribution for bundle
capedcrusader21 Aug 5, 2024
0082e5c
feat: added test with royalty on bundle
capedcrusader21 Aug 5, 2024
b028fc4
fix: Marketplace contracts
capedcrusader21 Aug 14, 2024
1d5d555
fix: access control tests
capedcrusader21 Aug 14, 2024
961a996
feat: updated doc with Bundle info
capedcrusader21 Aug 14, 2024
e49d7cd
refactor: remove redundant import
capedcrusader21 Aug 15, 2024
ba5ed01
feat: added upgrade scripts for marketplace contracts
capedcrusader21 Aug 16, 2024
8c32cb9
refactor: removed external call to fetch grid size
capedcrusader21 Aug 16, 2024
af4ef09
refactor: lint fix
capedcrusader21 Aug 16, 2024
3cb3598
fix: updated deploy dependencies
capedcrusader21 Aug 16, 2024
5f87d24
refactor: dependency and lint update
capedcrusader21 Aug 16, 2024
1eec4e1
refactor: add sand dependency to order validator
capedcrusader21 Aug 16, 2024
fec0b6d
Update deployment scripts
wojciech-turek Aug 16, 2024
8417602
Rm debug logs
wojciech-turek Aug 16, 2024
98841ea
Refactor: Remove duplicate interface check
capedcrusader21 Aug 16, 2024
272df17
Revert to oz contract 4.9.2 to fix storage issue
wojciech-turek Aug 16, 2024
af43c45
Merge branch 'fix/marketplace-bundle' of github.com-personal:thesandb…
wojciech-turek Aug 16, 2024
da3c326
Fix import in mock contract
wojciech-turek Aug 16, 2024
1443dc7
Merge pull request #1573 from thesandboxgame/fix/marketplace-bundle
wojciech-turek Aug 16, 2024
aef3433
feat: mock land contracts
capedcrusader21 Aug 22, 2024
1c77688
fix: test cases
capedcrusader21 Aug 22, 2024
aee0eae
fix: updated LibOrder in asset
capedcrusader21 Aug 28, 2024
9e4e17b
fix: failing AssetCreate tests
capedcrusader21 Aug 28, 2024
7d7ce31
fix: mock land contracts in marketplace
capedcrusader21 Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/asset/contracts/libraries/LibOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {LibMath} from "./LibMath.sol";
library LibOrder {
bytes32 internal constant ORDER_TYPEHASH =
keccak256(
"Order(address maker,Asset makeAsset,address taker,Asset takeAsset,uint256 salt,uint256 start,uint256 end)Asset(AssetType assetType,uint256 value)AssetType(uint256 assetClass,bytes data)"
"Order(address maker,Asset makeAsset,address taker,Asset takeAsset,address makeRecipient,uint256 salt,uint256 start,uint256 end)Asset(AssetType assetType,uint256 value)AssetType(uint256 assetClass,bytes data)"
);

/// @dev Represents the structure of an order.
Expand All @@ -20,6 +20,7 @@ library LibOrder {
LibAsset.Asset makeAsset; // Asset the maker is providing.
address taker; // Address of the taker.
LibAsset.Asset takeAsset; // Asset the taker is providing.
address makeRecipient; // recipient address for maker.
uint256 salt; // Random number to ensure unique order hash.
uint256 start; // Timestamp when the order becomes valid.
uint256 end; // Timestamp when the order expires.
Expand All @@ -39,6 +40,7 @@ library LibOrder {
keccak256(
abi.encode(
order.maker,
order.makeRecipient,
LibAsset.hash(order.makeAsset.assetType),
LibAsset.hash(order.takeAsset.assetType),
order.salt
Expand All @@ -59,6 +61,7 @@ library LibOrder {
LibAsset.hash(order.makeAsset),
order.taker,
LibAsset.hash(order.takeAsset),
order.makeRecipient,
order.salt,
order.start,
order.end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await deploy('RoyaltiesRegistry', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol:RoyaltiesRegistry',
'@sandbox-smart-contracts/marketplace@1.0.1/contracts/RoyaltiesRegistry.sol:RoyaltiesRegistry',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await deploy('OrderValidator', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol:OrderValidator',
'@sandbox-smart-contracts/marketplace@1.0.1/contracts/OrderValidator.sol:OrderValidator',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ const func: DeployFunction = async function (
const TSB_ROLE = await read('OrderValidator', 'TSB_ROLE');
const PARTNER_ROLE = await read('OrderValidator', 'PARTNER_ROLE');

const SandContract = await deployments.get('PolygonSand');
let SandContract;
if (hre.network.name === 'polygon') {
SandContract = await deployments.get('PolygonSand');
} else {
SandContract = await deployments.get('Sand');
}
const AssetContract = await deployments.get('Asset');

const addressesToGrant = [];
Expand Down Expand Up @@ -110,5 +115,6 @@ func.tags = [
func.dependencies = [
'OrderValidator_deploy',
'PolygonSand_deploy',
'Sand_deploy',
'Asset_deploy',
];
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

await deploy('Exchange', {
from: deployer,
contract: `@sandbox-smart-contracts/marketplace/contracts/Exchange.sol:Exchange`,
contract: `@sandbox-smart-contracts/marketplace@1.0.1/contracts/Exchange.sol:Exchange`,
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DEPLOY_TAGS} from '../../hardhat.config';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy, catchUnknownSigner} = deployments;
const {deployer, upgradeAdmin} = await getNamedAccounts();
await catchUnknownSigner(
deploy('RoyaltiesRegistry', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol:RoyaltiesRegistry',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
upgradeIndex: 1,
},
log: true,
})
);
};

export default func;
func.tags = [
'RoyaltiesRegistry',
'RoyaltiesRegistry',
'RoyaltiesRegistryV2_deploy',
DEPLOY_TAGS.L1,
DEPLOY_TAGS.L1_PROD,
DEPLOY_TAGS.L1_TEST,
DEPLOY_TAGS.L2,
DEPLOY_TAGS.L2_PROD,
DEPLOY_TAGS.L2_TEST,
];
func.dependencies = ['RoyaltiesRegistry_deploy'];
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DEPLOY_TAGS} from '../../hardhat.config';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy, catchUnknownSigner} = deployments;
const {deployer, upgradeAdmin} = await getNamedAccounts();
await catchUnknownSigner(
deploy('OrderValidator', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol:OrderValidator',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
upgradeIndex: 1,
},
log: true,
})
);
};

export default func;
func.tags = [
'OrderValidator',
'OrderValidator',
'OrderValidatorV2_deploy',
DEPLOY_TAGS.L1,
DEPLOY_TAGS.L1_PROD,
DEPLOY_TAGS.L1_TEST,
DEPLOY_TAGS.L2,
DEPLOY_TAGS.L2_PROD,
DEPLOY_TAGS.L2_TEST,
];
func.dependencies = ['OrderValidator_deploy'];
35 changes: 35 additions & 0 deletions packages/deploy/deploy/500_marketplace/507_upgrade_exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DEPLOY_TAGS} from '../../hardhat.config';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy, catchUnknownSigner} = deployments;
const {deployer, upgradeAdmin} = await getNamedAccounts();
await catchUnknownSigner(
deploy('Exchange', {
from: deployer,
contract: `@sandbox-smart-contracts/marketplace/contracts/Exchange.sol:Exchange`,
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
upgradeIndex: 1,
},
log: true,
})
);
};

export default func;
func.tags = [
'Exchange',
'Exchange',
'ExchangeV2_deploy',
DEPLOY_TAGS.L1,
DEPLOY_TAGS.L1_PROD,
DEPLOY_TAGS.L1_TEST,
DEPLOY_TAGS.L2,
DEPLOY_TAGS.L2_PROD,
DEPLOY_TAGS.L2_TEST,
];
func.dependencies = ['Exchange_deploy'];
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ const func: DeployFunction = async function (

const ERC1776_OPERATOR_ROLE = await read('Exchange', 'ERC1776_OPERATOR_ROLE');
const EXCHANGE_ADMIN_ROLE = await read('Exchange', 'EXCHANGE_ADMIN_ROLE');
const sandContract = await deployments.get('PolygonSand');

let sandContract;
let landContract;
if (hre.network.name === 'polygon') {
sandContract = await deployments.get('PolygonSand');
landContract = await deployments.get('PolygonLand');
} else {
sandContract = await deployments.get('Sand');
landContract = await deployments.get('Land');
}

const hasERC1776OperatorRole = await read(
'Exchange',
Expand Down Expand Up @@ -48,6 +57,18 @@ const func: DeployFunction = async function (
)
);
}

const currentLand = await read('Exchange', 'landContract');
if (currentLand != landContract.address) {
await catchUnknownSigner(
execute(
'Exchange',
{from: sandAdmin, log: true},
'setLandContract',
landContract.address
)
);
}
};

export default func;
Expand All @@ -61,4 +82,13 @@ func.tags = [
DEPLOY_TAGS.L2_PROD,
DEPLOY_TAGS.L2_TEST,
];
func.dependencies = ['Exchange_deploy', 'PolygonSand_deploy'];
func.dependencies = [
'Exchange_deploy',
'Sand_deploy',
'Land_deploy',
'PolygonSand_deploy',
'PolygonLand_deploy',
'PolygonLandV2_deploy',
'LandV4_deploy',
'ExchangeV2_deploy',
];
7 changes: 7 additions & 0 deletions packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ const importedPackages = {
],
'@sandbox-smart-contracts/giveaway': 'contracts/SignedMultiGiveaway.sol',
'@sandbox-smart-contracts/faucets': 'contracts/FaucetsERC1155.sol',
'@sandbox-smart-contracts/[email protected]': [
'contracts/RoyaltiesRegistry.sol',
'contracts/OrderValidator.sol',
'contracts/Exchange.sol',
'contracts/TransferManager.sol',
],
'@sandbox-smart-contracts/marketplace': [
'contracts/RoyaltiesRegistry.sol',
'contracts/OrderValidator.sol',
'contracts/Exchange.sol',
'contracts/TransferManager.sol',
],
'@sandbox-smart-contracts/dependency-operator-filter': [
'contracts/OperatorFilterSubscription.sol',
Expand Down
3 changes: 2 additions & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"@sandbox-smart-contracts/faucets": "0.0.1",
"@sandbox-smart-contracts/giveaway": "0.0.3",
"@sandbox-smart-contracts/land": "1.0.0-rc.1",
"@sandbox-smart-contracts/marketplace": "1.0.1",
"@sandbox-smart-contracts/marketplace": "1.0.2",
"@sandbox-smart-contracts/[email protected]": "npm:@sandbox-smart-contracts/[email protected]",
"@sandbox-smart-contracts/oft-sand": "0.0.1"
},
"files": [
Expand Down
11 changes: 11 additions & 0 deletions packages/deploy/test/asset/assetCreateFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const setupAssetCreateTests = deployments.createFixture(

const {
assetAdmin,
sandAdmin,
backendAuthWallet,
assetPauser,
treasury,
Expand Down Expand Up @@ -46,6 +47,9 @@ const setupAssetCreateTests = deployments.createFixture(
lazyMintingCatSeller
);

const OrderValidatorAsAdmin = OrderValidatorContract.connect(
await ethers.provider.getSigner(sandAdmin)
);
const CatalystContractAsAdmin = CatalystContract.connect(
await ethers.provider.getSigner(catalystMinter)
);
Expand Down Expand Up @@ -78,6 +82,13 @@ const setupAssetCreateTests = deployments.createFixture(
const createBatchLazyMintSignature = (data: LazyMintBatchData) =>
createMultipleLazyMintSignature(data, AssetCreateContract, network);

const ERC20_ROLE = await OrderValidatorContract.ERC20_ROLE();
await OrderValidatorAsAdmin.grantRole(
ERC20_ROLE,
await SandContract.getAddress()
);
await OrderValidatorAsAdmin.disableWhitelists();

return {
AssetContract,
AssetCreateContract,
Expand Down
6 changes: 5 additions & 1 deletion packages/deploy/utils/lazyMinting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Order = {
makeAsset: Asset;
taker: string;
takeAsset: Asset;
makeRecipient: string;
salt: Numeric;
start: Numeric;
end: Numeric;
Expand Down Expand Up @@ -115,6 +116,7 @@ export async function signOrder(
{name: 'makeAsset', type: 'Asset'},
{name: 'taker', type: 'address'},
{name: 'takeAsset', type: 'Asset'},
{name: 'makeRecipient', type: 'address'},
{name: 'salt', type: 'uint256'},
{name: 'start', type: 'uint256'},
{name: 'end', type: 'uint256'},
Expand All @@ -131,13 +133,15 @@ export const OrderDefault = async (
takeAsset: Asset,
salt: Numeric,
start: Numeric,
end: Numeric
end: Numeric,
makeRecipient?: Address
): Promise<Order> => ({
maker: await maker.getAddress(),
makeAsset,
taker:
taker === ZeroAddress ? ZeroAddress : await (taker as Signer).getAddress(),
takeAsset,
makeRecipient: makeRecipient || (await maker.getAddress()), // Use makerAddress if makeRecipient is not provided
salt,
start,
end,
Expand Down
2 changes: 1 addition & 1 deletion packages/marketplace/.solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
grep: '@skip-on-coverage', // Find everything with this tag
invert: true, // Run the grep's inverse set.
},
skipFiles: ['/mock'],
skipFiles: ['/mocks'],
};
1 change: 1 addition & 0 deletions packages/marketplace/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mocks
Loading
Loading