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

Land Sale Package #1612

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
138 changes: 138 additions & 0 deletions packages/deploy/deploy/1000_landsale/1000_deploy_estate_sale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import {DeployFunction, Deployment} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {
getDeadline,
getLandSales,
LandSale,
setAsLandMinter,
writeProofs,
} from '../../land-sale-artifacts/getLandSales';
import {skipUnlessTest} from '../../land-sale-artifacts/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 () => true},
];

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,
});
capedcrusader21 marked this conversation as resolved.
Show resolved Hide resolved
} 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'];
4 changes: 4 additions & 0 deletions packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const importedPackages = {
'contracts/PolygonLand.sol',
'contracts/LandMetadataRegistry.sol',
],
'@sandbox-smart-contracts/land-sale': [
'contracts/AuthValidator.sol',
'contracts/EstateSaleWithAuth.sol',
],
'@sandbox-smart-contracts/batch-transfers': ['contracts/BatchTransfer.sol'],
'@sandbox-smart-contracts/oft-sand': [
'contracts/OFTAdapterForSand.sol',
Expand Down
19 changes: 19 additions & 0 deletions packages/deploy/land-sale-artifacts/addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"sandbox": "0x7A9fe22691c811ea339D9B73150e6911a5343DcA",
"qa_list": [
"0x57B3bb9d075487e13C9c9d0D0dB883D6E050D059",
"0xBCDE366987eB1736e93428252753B0F468f9DE92",
"0xCE433cc911D8DD8FeB5Ef0614f3f908527D03eeD",
"0xC882F427330eEb47F96623925086fA2BE9572434",
"0xF9831501728289e96fF780ee439BAC75565C57dE",
"0x6c14E662b2f29eaB9a33F349f674E6543212532e",
"0x8C2E67Bd3D0f432eF75D9AE6623Cd0DFbCE66050",
"0x7A9fe22691c811ea339D9B73150e6911a5343DcA",
"0xA20E0E4fCCF921D449c21c4b696d1491201597C1",
"0x2128d2366151a01f63F4fC560e885e10eCa475BF",
"0xbDDB98Cee24aDF58b751259ed174Dd0a58Afd1Cc",
"0xD726cdA113774e8628307989D5abFd63aE6F14De",
"0x1765Acd5b00c8CD123F2971E2608CE37B3B17c66",
"0x5BC3D5A39a50BE2348b9C529f81aE79f00945897"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"0": [
"41506478881403507349696680653240014914910929820234476107906210059990541021186"
],
"1": [
"41506478881403503469696680653240014914910929820314476107906210059990541021186",
"41506478881403534969696680653240014914910929820314476107906210059990541021187"
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"sector": 0,
"lands": [
{
"coordinateX": 101,
"coordinateY": 103,
"ownerAddress": "",
"bundleId": ""
},
{
"coordinateX": 101,
"coordinateY": 104,
"ownerAddress": "",
"bundleId": "1"
},
{
"coordinateX": 103,
"coordinateY": 101,
"ownerAddress": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"bundleId": ""
},
{
"coordinateX": 103,
"coordinateY": 121,
"ownerAddress": "",
"bundleId": "0"
}
],
"estates": []
}
]

63 changes: 63 additions & 0 deletions packages/deploy/land-sale-artifacts/deadlines.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const deadlines: {[sector: number]: number} = {
0: new Date('2100-01-01T00:00:00.000Z').valueOf() / 1000,
1: new Date('2019-12-19T11:00:00.000Z').valueOf() / 1000,
2: new Date('2020-02-26T12:00:00.000Z').valueOf() / 1000,
3: new Date('2020-04-14T13:00:00.000Z').valueOf() / 1000,
4: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
5: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
6: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
7: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
8: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
9: new Date('2020-07-09T18:59:00.000Z').valueOf() / 1000,
10: new Date('2020-08-18T13:00:00.000Z').valueOf() / 1000,
11: new Date('2020-09-25T17:00:00.000Z').valueOf() / 1000,
12: new Date('2020-09-25T17:00:00.000Z').valueOf() / 1000,
13: new Date('2020-09-25T17:00:00.000Z').valueOf() / 1000,
14: new Date('2020-09-25T17:00:00.000Z').valueOf() / 1000,
15: new Date('2020-11-26T13:00:00.000Z').valueOf() / 1000,
16: new Date('2021-02-17T13:00:00.000Z').valueOf() / 1000,
17: new Date('2021-03-03T13:00:00.000Z').valueOf() / 1000,
18: new Date('2021-04-29T13:00:00.000Z').valueOf() / 1000,
19: new Date('2021-06-10T13:00:00.000Z').valueOf() / 1000,
20: new Date('2021-07-01T13:00:00.000Z').valueOf() / 1000,
21: new Date('2021-07-08T13:00:00.000Z').valueOf() / 1000,
22: new Date('2021-07-15T13:00:00.000Z').valueOf() / 1000,
23: new Date('2021-07-22T13:00:00.000Z').valueOf() / 1000,
24: new Date('2021-07-29T13:00:00.000Z').valueOf() / 1000,
25: new Date('2021-08-12T13:00:00.000Z').valueOf() / 1000,
26: new Date('2021-08-19T13:00:00.000Z').valueOf() / 1000,
27: new Date('2021-09-02T13:00:00.000Z').valueOf() / 1000,
28: new Date('2021-09-09T13:00:00.000Z').valueOf() / 1000,
29: new Date('2021-09-16T13:00:00.000Z').valueOf() / 1000,
30: new Date('2021-09-23T13:00:00.000Z').valueOf() / 1000,
31: new Date('2021-09-30T13:00:00.000Z').valueOf() / 1000,
32: new Date('2021-11-11T13:00:00.000Z').valueOf() / 1000,
33: new Date('2021-12-09T13:00:00.000Z').valueOf() / 1000,
34: new Date('2021-12-23T13:00:00.000Z').valueOf() / 1000,
35: new Date('2022-03-03T13:00:00.000Z').valueOf() / 1000,
36: new Date('2022-01-20T13:00:00.000Z').valueOf() / 1000,
38: new Date('2022-02-17T13:00:00.000Z').valueOf() / 1000,
39: new Date('2022-03-10T13:00:00.000Z').valueOf() / 1000,
40: new Date('2022-04-14T13:00:00.000Z').valueOf() / 1000,
41: new Date('2022-05-05T13:00:00.000Z').valueOf() / 1000,
42: new Date('2022-11-12T16:00:00.000Z').valueOf() / 1000,
43: new Date('2022-12-20T12:00:00.000Z').valueOf() / 1000,
44: new Date('2022-12-20T12:00:00.000Z').valueOf() / 1000,
45: new Date('2022-12-20T12:00:00.000Z').valueOf() / 1000,
46: new Date('2023-02-28T13:00:00.000Z').valueOf() / 1000,
47: new Date('2023-05-25T12:00:00.000Z').valueOf() / 1000,
48: new Date('2023-06-22T12:00:00.000Z').valueOf() / 1000,
49: new Date('2023-07-28T12:00:00.000Z').valueOf() / 1000,
50: new Date('2023-09-04T12:00:00.000Z').valueOf() / 1000,
51: new Date('2023-10-12T12:00:00.000Z').valueOf() / 1000,
52: new Date('2023-12-07T12:00:00.000Z').valueOf() / 1000,
53: new Date('2023-11-14T12:00:00.000Z').valueOf() / 1000,
54: new Date('2023-12-29T12:00:00.000Z').valueOf() / 1000,
55: new Date('2024-03-20T12:00:00.000Z').valueOf() / 1000,
56: new Date('2024-04-19T12:00:00.000Z').valueOf() / 1000,
57: new Date('2024-07-29T12:00:00.000Z').valueOf() / 1000,
58: new Date('2024-09-20T12:00:00.000Z').valueOf() / 1000,
61: new Date('2024-10-14T12:00:00.000Z').valueOf() / 1000,
62: new Date('2024-12-24T12:00:00.000Z').valueOf() / 1000,
};
export default deadlines;
Loading
Loading