Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.
Draft
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
49 changes: 49 additions & 0 deletions packages/deploy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# seed-phrase for the wallet to use on default network and rinkeby_test (personal test network)
# this is required for local testing otherwise hardhat will throw "Invalid mnemonic"
MNEMONIC=xxxxxxxxxxxxxxxxxxxxxx

# seed-phrase for the wallet to use on mainnet
MNEMONIC_ETHEREUM=xxxxxxxxxxxxxxxxxxxxxx

# seed-phrase for the wallet to use on rinkeby
MNEMONIC_RINKEBY=xxxxxxxxxxxxxxxxxxxxxx

# seed-phrase for the wallet to use on goerli
MNEMONIC_GOERLI=xxxxxxxxxxxxxxxxxxxxxx

# seed-phrase for the wallet to use on mumbai
MNEMONIC_MUMBAI=xxxxxxxxxxxxxxxxxxxxxx

# mainnet provider URI
ETH_NODE_URI_ETHEREUM=xxxxxxxxxxxxxxxxxxxxxx

# rinkeby provider URI
ETH_NODE_URI_RINKEBY=xxxxxxxxxxxxxxxxxxxxxx

# goerli provider URI
ETH_NODE_URI_GOERLI=xxxxxxxxxxxxxxxxxxxxxx

# goerli provider URI
ETH_NODE_URI_MUMBAI=xxxxxxxxxxxxxxxxxxxxxx

# provider URI for testnets
ETH_NODE_URI=xxxxxxxxxxxxxxxxxxxxxx

# polygon provider URI
ETH_NODE_URI_POLYGON=xxxxxxxxxxxxxxxxxxxxxx

# API key for etherscan verification
ETHERSCAN_API_KEY_ETHEREUM=xxxxxxxxxxxxxxxxxxxxxx
ETHERSCAN_API_KEY_RINKEBY=xxxxxxxxxxxxxxxxxxxxxx
ETHERSCAN_API_KEY_GOERLI=xxxxxxxxxxxxxxxxxxxxxx
ETHERSCAN_API_KEY_POLYGON=xxxxxxxxxxxxxxxxxxxxxx
ETHERSCAN_API_KEY_MUMBAI=xxxxxxxxxxxxxxxxxxxxxx

# Options to increase Node process memory (useful when running yarn coverage for example on some machine)
NODE_OPTIONS=--max-old-space-size=8192

INFURA_HTTP_BLOCK_QUERY_LIMIT=1000

# THE GRAPH URL
CLAIMS_GRAPH_URL_MUMBAI=xxxxxxxxxxxxxxxxxxxxxx
CLAIMS_GRAPH_URL_POLYGON=xxxxxxxxxxxxxxxxxxxxxx
10 changes: 10 additions & 0 deletions packages/deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cache/
artifacts/
node_modules/
.env
contractsInfo.json
deployments/hardhat
deployments/localhost

.idea/
.DS_Store
1 change: 1 addition & 0 deletions packages/deploy/contracts/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this directory is needed by hardhat-dependency-compiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL2, isNotMainnet, unless} from "../../../utils/deploymentSkip";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {getNamedAccounts} = hre;
const {deployer} = await getNamedAccounts();
const {deployments} = hre;
await deployments.deploy('TRUSTED_FORWARDER', {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.8/test/TestMetaTxForwarder.sol:TestMetaTxForwarder',
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ['TRUSTED_FORWARDER', 'L2'];
func.skip = unless(isL2, isNotMainnet);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL2, isNotMainnet, unless} from "../../../utils/deploymentSkip";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {getNamedAccounts} = hre;
const {deployer} = await getNamedAccounts();
const {deployments} = hre;
await deployments.deploy('TRUSTED_FORWARDER_V2', {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.8/test/TestMetaTxForwarder.sol:TestMetaTxForwarder',
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ['TRUSTED_FORWARDER_V2', 'L2'];
func.skip = unless(isL2, isNotMainnet);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL2, isNotMainnet, unless} from "../../../utils/deploymentSkip";

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

const {deployer} = await getNamedAccounts();
await deploy('CHILD_CHAIN_MANAGER', {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.8/test/FakeChildChainManager.sol:FakeChildChainManager',
from: deployer,
log: true,
skipIfAlreadyDeployed: true
});
};
export default func;
func.tags = ['CHILD_CHAIN_MANAGER', 'L2'];
func.skip = unless(isL2, isNotMainnet);
17 changes: 17 additions & 0 deletions packages/deploy/deploy/100_develop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isNotMainnet, unless} from "../utils/deploymentSkip";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
};

export default func;
func.tags = ["develop"];
func.skip = unless(isNotMainnet);
func.dependencies = [
"CHILD_CHAIN_MANAGER",
"Sand",
"PolygonSand",
"SandPermit", // Strange Permit support in a separated contract ?
"SandFaucet" // Sand faucet
]
15 changes: 15 additions & 0 deletions packages/deploy/deploy/100_production.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Deploy the production environment.
*/
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
};

export default func;
func.tags = ["production"];
func.dependencies = [
"Sand",
"PolygonSand"
]
23 changes: 23 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer1/10_deploy_sand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL1, unless} from "../../../utils/deploymentSkip";

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

const {sandBeneficiary, deployer} = await getNamedAccounts();

await deploy("Sand", {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.5/Sand.sol:Sand',
from: deployer,
args: [deployer, deployer, sandBeneficiary],
log: true,
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['Sand', 'Sand_deploy'];
func.skip = unless(isL1);


24 changes: 24 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer1/20_deploy_permit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL1, unless} from "../../../utils/deploymentSkip";

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

const {deployer} = await getNamedAccounts();

const sand = await deployments.get('Sand');

await deploy('Permit', {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.8/permit/Permit.sol:Permit',
from: deployer,
log: true,
args: [sand.address],
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['SandPermit', 'SandPermit_deploy'];
func.dependencies = ['Sand_deploy'];
func.skip = unless(isL1);
35 changes: 35 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer1/30_set_permit_sand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL1, unless} from "../../../utils/deploymentSkip";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments} = hre;
const {log, execute, read} = deployments;

const permit = await deployments.getOrNull('Permit');
if (!permit) {
return;
}

const isSandSuperOperator = await read(
'Sand',
'isSuperOperator',
permit.address
);

if (!isSandSuperOperator) {
log('setting Permit as Super Operator for SAND');
const currentSandAdmin = await read('Sand', 'getAdmin');
await execute(
'Sand',
{from: currentSandAdmin, log: true},
'setSuperOperator',
permit.address,
true
);
}
};
export default func;
func.tags = ['SandPermit', 'SandPermit_setup'];
func.dependencies = ['Permit_deploy', 'Sand_deploy'];
func.skip = unless(isL1);
40 changes: 40 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer1/40_set_sand_admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL1, unless} from "../../../utils/deploymentSkip";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, ethers, getNamedAccounts} = hre;
const {log, execute, read} = deployments;

const {sandAdmin, sandExecutionAdmin} = await getNamedAccounts();

const currentAdmin = await read('Sand', 'getAdmin');
if (currentAdmin.toLowerCase() !== sandAdmin.toLowerCase()) {
await execute(
'Sand',
{from: currentAdmin, log: true},
'changeAdmin',
sandAdmin
);
}

const sand = await ethers.getContract('Sand');
// skip for SAND contract without `changeExecutionAdmin` (rinkeby)
const currentExecutionAdmin = await read('Sand', 'getExecutionAdmin');
if (
currentExecutionAdmin.toLowerCase() !== sandExecutionAdmin.toLowerCase()
) {
log('setting Sand Execution Admin');
await execute(
'Sand',
{from: currentExecutionAdmin, log: true},
'changeExecutionAdmin',
sandExecutionAdmin
);
}
};
export default func;
func.runAtTheEnd = true;
func.tags = ['Sand', 'Sand_setup'];
func.dependencies = ['Sand_deploy'];
func.skip = unless(isL1);
28 changes: 28 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer1/50_deploy_faucet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL1, unless} from "../../../utils/deploymentSkip";
import {BigNumber} from '@ethersproject/bignumber';

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

const {deployer} = await getNamedAccounts();

const sand = await deployments.get('Sand');
const period = 30;
const DECIMALS_18 = BigNumber.from('1000000000000000000');
const amountLimit = DECIMALS_18.mul(10);

await deploy('Faucet', {
contract: "sandbox-smart-contracts-0.0.30/src/solc_0.8/faucet/Faucet.sol:Faucet",
from: deployer,
log: true,
args: [sand.address, period, amountLimit],
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['SandFaucet', 'SandFaucet_deploy'];
func.dependencies = ['Sand_deploy'];
func.skip = unless(isL1);
32 changes: 32 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer2/10_deploy_sand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL2, unless} from "../../../utils/deploymentSkip";

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

const {deployer, sandAdmin, sandExecutionAdmin} = await getNamedAccounts();

const TRUSTED_FORWARDER_V2 = await deployments.getOrNull(
'TRUSTED_FORWARDER_V2'
);
const CHILD_CHAIN_MANAGER = await deployments.get('CHILD_CHAIN_MANAGER');
await deploy('PolygonSand', {
contract: 'sandbox-smart-contracts-0.0.30/src/solc_0.8/polygon/child/sand/PolygonSand.sol:PolygonSand',
from: deployer,
args: [
CHILD_CHAIN_MANAGER.address,
TRUSTED_FORWARDER_V2?.address,
sandAdmin,
sandExecutionAdmin,
],
log: true,
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ['PolygonSand', 'PolygonSand_deploy'];
func.dependencies = ['CHILD_CHAIN_MANAGER', 'TRUSTED_FORWARDER_V2'];
func.skip = unless(isL2);
28 changes: 28 additions & 0 deletions packages/deploy/deploy/10_sand/10_layer2/20_deploy_faucet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {isL2, unless} from "../../../utils/deploymentSkip";
import {BigNumber} from '@ethersproject/bignumber';

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

const {deployer} = await getNamedAccounts();

const sand = await deployments.get('PolygonSand');
const period = 30;
const DECIMALS_18 = BigNumber.from('1000000000000000000');
const amountLimit = DECIMALS_18.mul(10);

await deploy('PolygonFaucet', {
contract: "sandbox-smart-contracts-0.0.30/src/solc_0.8/faucet/Faucet.sol:Faucet",
from: deployer,
log: true,
args: [sand.address, period, amountLimit],
skipIfAlreadyDeployed: true,
});
};
export default func;
func.tags = ['PolygonSandFaucet', 'PolygonSandFaucet_deploy'];
func.dependencies = ['PolygonSand_deploy'];
func.skip = unless(isL2);
Loading