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

Deploy scripts with hardhat deploy migrations + OZ upgrades plugin #107

Merged
merged 4 commits into from
Dec 7, 2023
Merged
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
5 changes: 5 additions & 0 deletions .changeset/late-files-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fuel-bridge/solidity-contracts': patch
---

Add deploy scripts
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"tsup": "^7.2.0",
"turbo": "^1.10.7"
},
"pnpm": {
"overrides": {
"@openzeppelin/upgrades-core": "1.20.5"
}
},
"devDependencies": {
"@changesets/cli": "^2.26.2"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/solidity-contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
.env
.vscode
.openzeppelin
.openzeppelin/unknown*
Braqzen marked this conversation as resolved.
Show resolved Hide resolved

# local deployments
deployments/deployments.local.json
Expand Down
36 changes: 36 additions & 0 deletions packages/solidity-contracts/deploy/beta5/001.chain_state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import { FuelChainState__factory as FuelChainState } from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { deployProxy, erc1967 },
deployments: { save },
} = hre;
const [deployer] = await ethers.getSigners();

const { deployTransaction, address } = await deployProxy(
new FuelChainState(deployer),
[],
{
initializer: 'initialize',
}
);
await deployTransaction.wait();
const implementation = await erc1967.getImplementationAddress(address);

console.log('Deployed FuelChainState at', address);
await save('FuelChainState', {
address,
abi: [],
implementation,
});

return true;
};

func.tags = ['state', 'chain-state', 'chain_state', 'FuelChainState'];
func.id = 'chain_state';
export default func;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import { FuelMessagePortal__factory as FuelMessagePortal } from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { deployProxy, erc1967 },
deployments: { get, save },
} = hre;
const [deployer] = await ethers.getSigners();

const { address: fuelChainState } = await get('FuelChainState');

const { deployTransaction, address } = await deployProxy(
new FuelMessagePortal(deployer),
[fuelChainState],
{
initializer: 'initialize',
}
);

await deployTransaction.wait();
const implementation = await erc1967.getImplementationAddress(address);

console.log('Deployed FuelMessagePortal at', address);
await save('FuelMessagePortal', {
address,
abi: [],
implementation,
});

return true;
};

func.tags = ['portal', 'message_portal', 'FuelMessagePortal'];
func.id = 'fuel_message_portal';
export default func;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import { FuelERC20GatewayV2__factory as FuelERC20GatewayV2 } from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { deployProxy, erc1967 },
deployments: { get, save },
} = hre;
const [deployer] = await ethers.getSigners();

const fuelMessagePortal = await get('FuelMessagePortal');

const { deployTransaction, address } = await deployProxy(
new FuelERC20GatewayV2(deployer),
[fuelMessagePortal.address],
{
initializer: 'initialize',
}
);

await deployTransaction.wait();
const implementation = await erc1967.getImplementationAddress(address);

console.log('Deployed FuelERC20GatewayV2 at', address);
await save('FuelERC20GatewayV2', {
address,
abi: [],
implementation,
});

return true;
};

func.tags = ['erc20', 'erc20_gateway', 'FuelERC20GatewayV2'];
func.id = 'fuel_erc20_gateway_v2';
export default func;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import { FuelERC721GatewayV2__factory as FuelERC721GatewayV2 } from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { deployProxy, erc1967 },
deployments: { get, save },
} = hre;
const [deployer] = await ethers.getSigners();

const fuelMessagePortal = await get('FuelMessagePortal');

const { deployTransaction, address } = await deployProxy(
new FuelERC721GatewayV2(deployer),
[fuelMessagePortal.address],
{
initializer: 'initialize',
}
);

await deployTransaction.wait();
const implementation = await erc1967.getImplementationAddress(address);

console.log('Deployed FuelERC721GatewayV2 at', address);
await save('FuelERC721GatewayV2', {
address,
abi: [],
implementation,
});

return true;
};

func.tags = ['erc721', 'erc721_gateway', 'FuelERC721GatewayV2'];
func.id = 'fuel_erc721_gateway_v2';
export default func;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import { FuelMessagePortalV2__factory as FuelMessagePortalV2 } from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { upgradeProxy, erc1967 },
deployments: { get, save },
} = hre;
const [deployer] = await ethers.getSigners();

const fuelMessagePortal = await get('FuelMessagePortal');

const { deployTransaction, address } = await upgradeProxy(
fuelMessagePortal,
new FuelMessagePortalV2(deployer),
{
unsafeAllow: ['constructor'],
Braqzen marked this conversation as resolved.
Show resolved Hide resolved
constructorArgs: [ethers.constants.MaxUint256],
}
);

await deployTransaction.wait();
const implementation = await erc1967.getImplementationAddress(address);
Braqzen marked this conversation as resolved.
Show resolved Hide resolved

console.log('Upgraded FuelMessagePortal at', address);
await save('FuelMessagePortal', {
Braqzen marked this conversation as resolved.
Show resolved Hide resolved
address,
abi: [],
implementation,
});

return true;
};

func.tags = ['upgrade_portal_v2', 'message_portal_v2', 'FuelMessagePortalV2'];
func.id = 'fuel_message_portal_v2_upgrade';
Braqzen marked this conversation as resolved.
Show resolved Hide resolved
export default func;
11 changes: 11 additions & 0 deletions packages/solidity-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dotEnvConfig();
const CONTRACTS_DEPLOYER_KEY = process.env.CONTRACTS_DEPLOYER_KEY || '';
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || '';
const INFURA_API_KEY = process.env.INFURA_API_KEY || '';
const RPC_URL = process.env.RPC_URL || 'http://127.0.0.1:8545';

const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
Expand Down Expand Up @@ -48,6 +49,16 @@ const config: HardhatUserConfig = {
url: `https://sepolia.infura.io/v3/${INFURA_API_KEY}`,
accounts: CONTRACTS_DEPLOYER_KEY ? [CONTRACTS_DEPLOYER_KEY] : [],
},
beta5: {
url: RPC_URL,
accounts: CONTRACTS_DEPLOYER_KEY
? [CONTRACTS_DEPLOYER_KEY]
: {
mnemonic:
'test test test test test test test test test test test junk',
Braqzen marked this conversation as resolved.
Show resolved Hide resolved
},
deploy: ['deploy/beta5'],
},
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
Expand Down
4 changes: 2 additions & 2 deletions packages/solidity-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@nomiclabs/hardhat-etherscan": "^3.1.2",
"@openzeppelin/contracts": "^4.8.0",
"@openzeppelin/contracts-upgradeable": "^4.8.0",
"@openzeppelin/hardhat-upgrades": "^1.21.0"
"@openzeppelin/hardhat-upgrades": "1.26.0"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
Expand All @@ -69,7 +69,7 @@
"ethers": "^5.7.2",
"express": "^4.18.2",
"hardhat": "^2.17.4",
"hardhat-deploy": "^0.11.37",
"hardhat-deploy": "^0.11.44",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-typechain": "^0.3.5",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/solidity-contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"resolveJsonModule": true,
"lib": ["ES2021"]
},
"include": ["./scripts", "./protocol", "./test", "./typechain"],
"include": ["./scripts", "./protocol", "./test", "./typechain", "./deploy"],
"files": ["./hardhat.config.ts"]
}
Loading
Loading