Skip to content

Commit

Permalink
deploy land-sale script
Browse files Browse the repository at this point in the history
  • Loading branch information
capedcrusader21 committed Oct 29, 2024
1 parent 95c4be7 commit 70faa71
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 3 deletions.
139 changes: 139 additions & 0 deletions packages/deploy/deploy/1000_landsale/01_deploy_estate_sale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import {Deployment} from 'hardhat-deploy/dist/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {
getDeadline,
getLandSales,
LandSale,
setAsLandMinter,
writeProofs,
} from '../../../core/data/landSales/getLandSales';
import {skipUnlessTest} from '../../../core/utils/network';

type SaleDeployment = {
name: string;
// top level skip function for the whole sale data
skip?: (env: HardhatRuntimeEnvironment) => Promise<boolean>;
// object map of skip function for each individual sector
skipSector?: {
[sector: number]: (env: HardhatRuntimeEnvironment) => Promise<boolean>;
};
};

const sales: SaleDeployment[] = [
{name: 'EstateSaleWithAuth_0', skip: skipUnlessTest},
{name: 'LandPreSale_19', skip: async () => true},
{name: 'LandPreSale_20', skip: async () => true},
{name: 'LandPreSale_21', skip: async () => true},
{name: 'LandPreSale_22', skip: async () => true},
{name: 'LandPreSale_23', skip: async () => true},
{name: 'LandPreSale_24', skip: async () => true},
{name: 'LandPreSale_25', skip: async () => true},
{name: 'LandPreSale_26', skip: async () => true},
{name: 'LandPreSale_27', skip: async () => true},
{name: 'LandPreSale_28', skip: async () => true},
{name: 'LandPreSale_29', skip: async () => true},
{name: 'LandPreSale_30', skip: async () => true},
{name: 'LandPreSale_31', skip: async () => true},
{name: 'LandPreSale_32', skip: async () => true},
{name: 'LandPreSale_33', skip: async () => true},
{name: 'LandPreSale_34', skip: async () => true},
{name: 'LandPreSale_35', skip: async () => true},
{name: 'LandPreSale_36', skip: async () => true},
{name: 'LandPreSale_37', skip: async () => false},
];

const func: DeployFunction = async function (hre) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {
deployer,
landSaleBeneficiary,
backendReferralWallet,
landSaleFeeRecipient,
landSaleAdmin,
assetAdmin,
} = await getNamedAccounts();
const sandContract = await deployments.get('PolygonSand');
const landContract = await deployments.get('PolygonLand');
let assetContract: Deployment;
const deployedAsset = await deployments.getOrNull('Asset'); // L2 Asset, json files available on Polygon and Mumbai
if (!deployedAsset) {
// mock asset used for test networks and forking
// TODO: change to MockAsset from packages/asset when outside core
assetContract = await deploy('MockERC1155Asset', {
from: assetAdmin,
args: ['http://nft-test/nft-1155-{id}'],
log: true,
skipIfAlreadyDeployed: true,
});
} else {
assetContract = deployedAsset;
}
const authValidatorContract = await deployments.get('PolygonAuthValidator');

async function deployLandSale(name: string, landSale: LandSale) {
const {lands, merkleRootHash, sector} = landSale;
const landSaleName = `${name}_${sector}`;
const deadline = getDeadline(hre, sector);
const deployName = `PolygonLandPreSale_${sector}`;
let landSaleDeployment = await deployments.getOrNull(deployName);
if (!landSaleDeployment) {
landSaleDeployment = await deploy(deployName, {
from: deployer,
linkedData: lands,
contract: 'EstateSaleWithAuth',
args: [
landContract.address,
sandContract.address,
sandContract.address,
landSaleAdmin,
landSaleBeneficiary,
merkleRootHash,
deadline,
backendReferralWallet,
2000,
'0x0000000000000000000000000000000000000000',
assetContract.address,
landSaleFeeRecipient,
authValidatorContract.address,
],
log: true,
});
writeProofs(hre, landSaleName, landSale);
}
await setAsLandMinter(hre, landSaleDeployment.address, 'PolygonLand');
}

for (const sale of sales) {
if (sale.skip) {
const skip = await sale.skip(hre);
if (skip) continue;
}
const landSales = await getLandSales(
sale.name,
hre.network.name,
hre.network.live
);
const skipSector = sale.skipSector || {};
const sectors = Object.keys(skipSector).map((k) => parseInt(k));
for (const landSale of landSales) {
if (sectors.includes(landSale.sector)) {
const skip = await skipSector[landSale.sector](hre);
if (skip) {
console.log(`Skipping sector ${landSale.sector}`);
continue;
}
}
await deployLandSale(sale.name, landSale);
}
}
};

export default func;
func.tags = ['PolygonEstateSaleWithAuth', 'PolygonEstateSaleWithAuth_deploy'];
func.dependencies = [
'PolygonSand_deploy',
'PolygonLand_deploy',
'PolygonAuthValidator_deploy',
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer, sandAdmin, backendAuthWallet} = await getNamedAccounts();
await deploy('PolygonAuthValidator', {
contract: 'AuthValidator',
from: deployer,
args: [sandAdmin, backendAuthWallet],
log: true,
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['PolygonAuthValidator', 'PolygonAuthValidator_deploy'];
12 changes: 9 additions & 3 deletions packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const importedPackages = {
'contracts/PolygonLand.sol',
'contracts/LandMetadataRegistry.sol',
],
'@sandbox-smart-contracts/land-sale': [
'contracts/AuthValidator.sol',
'contracts/EstateSaleWithAuth.sol',
'contracts/EstateSaleWithFee.sol',
'contracts/ILandToken.sol',
],
'@sandbox-smart-contracts/batch-transfers': ['contracts/BatchTransfer.sol'],
'@sandbox-smart-contracts/oft-sand': [
'contracts/OFTAdapterForSand.sol',
Expand All @@ -80,12 +86,12 @@ const namedAccounts = {
deployer: {
default: 1,
mainnet: '0xCba49d154b4Bb9a9aD7F5Dad396CB9a0a3a62ABc',
polygon: '0xCba49d154b4Bb9a9aD7F5Dad396CB9a0a3a62ABc',
polygon: '0xbB2C98E0fd4e0881745aeC8499dC17082a977448',
goerli: '0xA796AE911621E00809E0E7C8f0AD6BF118E5139e',
sepolia: '0xA796AE911621E00809E0E7C8f0AD6BF118E5139e',
bscTestnet: '0xA796AE911621E00809E0E7C8f0AD6BF118E5139e',
mumbai: '0x5F890c9522dCE5670d741D4277BFCC2d9cA8Af02',
amoy: '0x5F890c9522dCE5670d741D4277BFCC2d9cA8Af02',
mumbai: '0xbB2C98E0fd4e0881745aeC8499dC17082a977448',
amoy: '0xbB2C98E0fd4e0881745aeC8499dC17082a977448',
baseSepolia: '0xA796AE911621E00809E0E7C8f0AD6BF118E5139e',
base: '0xCba49d154b4Bb9a9aD7F5Dad396CB9a0a3a62ABc',
bscMainnet: '0xCba49d154b4Bb9a9aD7F5Dad396CB9a0a3a62ABc',
Expand Down
1 change: 1 addition & 0 deletions packages/deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@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/land-sale": "1.0.0-rc.1",
"@sandbox-smart-contracts/marketplace": "1.0.1",
"@sandbox-smart-contracts/oft-sand": "0.0.1"
},
Expand Down

0 comments on commit 70faa71

Please sign in to comment.