Skip to content

Commit

Permalink
feat: added hardhat deployment scripts for marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
capedcrusader21 committed Sep 13, 2023
1 parent ae66e6b commit 245dee7
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 11 deletions.
27 changes: 27 additions & 0 deletions packages/deploy/deploy/marketplace/00_deploy_royalties_registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer, upgradeAdmin} = await getNamedAccounts();

await deploy('RoyaltiesRegistry', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/src/royalties-registry/RoyaltiesRegistry.sol:RoyaltiesRegistry',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
execute: {
methodName: '__RoyaltiesRegistry_init',
args: [],
},
upgradeIndex: 0,
},
log: true,
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['RoyaltiesRegistry', 'RoyaltiesRegistry_deploy'];
27 changes: 27 additions & 0 deletions packages/deploy/deploy/marketplace/01_deploy_order_validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer, upgradeAdmin} = await getNamedAccounts();

await deploy('OrderValidator', {
from: deployer,
contract:
'@sandbox-smart-contracts/marketplace/src/exchange/OrderValidator.sol:OrderValidator',
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
execute: {
methodName: '__OrderValidator_init_unchained',
args: [false, false, true, false],
},
upgradeIndex: 0,
},
log: true,
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['OrderValidator', 'OrderValidator_deploy'];
55 changes: 55 additions & 0 deletions packages/deploy/deploy/marketplace/02_deploy_exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer, upgradeAdmin, exchangeFeeRecipient} =
await getNamedAccounts();

let TRUSTED_FORWARDER = await deployments.getOrNull('TRUSTED_FORWARDER');
if (!TRUSTED_FORWARDER) {
TRUSTED_FORWARDER = await deploy('TRUSTED_FORWARDER', {
from: deployer,
contract: 'TrustedForwarderMock',
log: true,
});
}
const orderValidator = await deployments.get('OrderValidator');
const royaltiesRegistry = await deployments.get('RoyaltiesRegistry');

// TODO: to be fetched from env?
const deployMeta = process.env.DEPLOY_META;
const nativeOrder = process.env.NATIVE_ORDER;
const metaNative = process.env.META_NATIVE;

const contract = deployMeta ? 'ExchangeMeta' : 'Exchange';

await deploy('Exchange', {
from: deployer,
contract: `@sandbox-smart-contracts/marketplace/src/exchange/${contract}.sol:${contract}`,
proxy: {
owner: upgradeAdmin,
proxyContract: 'OpenZeppelinTransparentProxy',
execute: {
methodName: '__Exchange_init',
args: [
TRUSTED_FORWARDER.address,
0,
250,
exchangeFeeRecipient,
royaltiesRegistry,
orderValidator.address,
nativeOrder,
metaNative,
],
},
upgradeIndex: 0,
},
log: true,
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['Exchange', 'Exchange_deploy'];
func.dependencies = ['RoyaltiesRegistry_deploy', 'OrderValidator_deploy'];
29 changes: 29 additions & 0 deletions packages/deploy/deploy/marketplace/03_deploy_asset_matcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer} = await getNamedAccounts();

// TODO: to be fetched from env?
const deployMeta = process.env.DEPLOY_META;
const exchangeContract = deployMeta ? 'ExchangeMeta' : 'Exchange';

const assetMatcher = await deploy('AssetMatcher', {
from: deployer,
contract: `@sandbox-smart-contracts/marketplace/src/exchange/AssetMatcher.sol:AssetMatcher`,
log: true,
skipIfAlreadyDeployed: true,
});

await deployments.execute(
exchangeContract,
{from: deployer},
'setAssetMatcherContract',
assetMatcher.address
);
};
export default func;
func.tags = ['AssetMatcher', 'AssetMatcher_deploy'];
func.dependencies = ['Exchange'];
10 changes: 10 additions & 0 deletions packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './tasks/importedPackages';
// Package name : solidity source code path
const importedPackages = {
'@sandbox-smart-contracts/giveaway': 'contracts/SignedMultiGiveaway.sol',
'@sandbox-smart-contracts/marketplace': 'src/',
};

const namedAccounts = {
Expand Down Expand Up @@ -96,6 +97,14 @@ const namedAccounts = {
polygon: '0x42a4a3795446A4c070565da201c6303fC78a2569',
}, // collect 5% fee from land sales (prior to implementation of FeeDistributor)

exchangeFeeRecipient: {
default: '0xc66d094ed928f7840a6b0d373c1cd825c97e3c7c', // TODO: set the correct wallet for the FeeReceiver
goerli: '0xc66d094ed928f7840a6b0d373c1cd825c97e3c7c', // TODO: set the correct wallet for the FeeReceiver
mumbai: '0xc66d094ed928f7840a6b0d373c1cd825c97e3c7c', // TODO: set the correct wallet for the FeeReceiver
mainnet: '0xc66d094ed928f7840a6b0d373c1cd825c97e3c7c', // TODO: set the correct wallet for the FeeReceiver
polygon: '0xc66d094ed928f7840a6b0d373c1cd825c97e3c7c', // TODO: set the correct wallet for the FeeReceiver
},

landAdmin: {
default: 2,
mainnet: 'sandAdmin',
Expand Down Expand Up @@ -242,6 +251,7 @@ const networks = {
};

const compilers = [
'0.8.19',
'0.8.18',
'0.8.15',
'0.8.2',
Expand Down
4 changes: 3 additions & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"homepage": "https://github.com/thesandboxgame/sandbox-smart-contracts#readme",
"private": true,
"dependencies": {
"@sandbox-smart-contracts/giveaway": "*"
"@sandbox-smart-contracts/giveaway": "*",
"@sandbox-smart-contracts/marketplace": "*"
},
"files": [
"deployments"
Expand Down Expand Up @@ -61,6 +62,7 @@
"eslint-plugin-prettier": "^4.2.1",
"ethers": "5",
"hardhat": "~2.15.0",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.11.30",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/marketplace/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "marketplace",
"name": "@sandbox-smart-contracts/marketplace",
"version": "1.0.0",
"description": "",
"dependencies": {
Expand All @@ -8,7 +8,10 @@
"devDependencies": {
"@openzeppelin/contracts": "4.9.3",
"@openzeppelin/contracts-upgradeable": "4.9.3",
"@types/chai": "^4.2.11",
"hardhat": "^2.17.2",
"hardhat-contract-sizer": "^2.0.3",
"hardhat-deploy": "^0.10.5",
"ts-node": "^10.9.1",
"typescript": "^4.0.5"
},
Expand Down
Loading

0 comments on commit 245dee7

Please sign in to comment.