Skip to content
This repository was archived by the owner on Feb 22, 2024. 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
135 changes: 135 additions & 0 deletions .openzeppelin/goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"manifestVersion": "3.2",
"admin": {
"address": "0xae7689F1cd6F1058367112Aa3cB6551FA295c5e8",
"txHash": "0x33dbc2995f3e462d67ded698e102b526b52acca47ef54edbb0516256d47ae90c"
},
"proxies": [
{
"address": "0x739a6BC599347adA0Cec67520559F46eA8B9155E",
"txHash": "0xb5573f00c85aa1e6030e886539169f1ac1efd2685cb6176d5a33ae92a4e6be34",
"kind": "transparent"
}
],
"impls": {
"341eb5d6655192ae31d6d3c7a80564f55f0b10c7b348ec97068ce47b70185003": {
"address": "0xc05C97797B868F0DB09E67370948bDD224792764",
"txHash": "0xd2ab63d5cf4f56b983c077f8373e86553876b4c2a65deac0ebf46f74e95c03c2",
"layout": {
"solcVersion": "0.7.3",
"storage": [
{
"label": "_owner",
"offset": 0,
"slot": "0",
"type": "t_address",
"contract": "Ownable",
"src": "contracts/Ownable.sol:19"
},
{
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "t_array(t_uint256)50_storage",
"contract": "Ownable",
"src": "contracts/Ownable.sol:22"
},
{
"label": "_initialized",
"offset": 0,
"slot": "51",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol:25"
},
{
"label": "_initializing",
"offset": 1,
"slot": "51",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol:30"
},
{
"label": "l2LockManager",
"offset": 0,
"slot": "52",
"type": "t_mapping(t_address,t_address)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:50"
},
{
"label": "l2WalletOwner",
"offset": 0,
"slot": "53",
"type": "t_mapping(t_address,t_address)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:53"
},
{
"label": "l2WalletAddress",
"offset": 0,
"slot": "54",
"type": "t_mapping(t_address,t_address)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:56"
},
{
"label": "tokenLockETHBalances",
"offset": 0,
"slot": "55",
"type": "t_mapping(t_address,t_uint256)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:59"
},
{
"label": "l2Beneficiary",
"offset": 0,
"slot": "56",
"type": "t_mapping(t_address,t_address)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:62"
},
{
"label": "l2WalletAddressSetManually",
"offset": 0,
"slot": "57",
"type": "t_mapping(t_address,t_bool)",
"contract": "L1GraphTokenLockTransferTool",
"src": "contracts/L1GraphTokenLockTransferTool.sol:66"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_mapping(t_address,t_address)": {
"label": "mapping(address => address)",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_uint256)": {
"label": "mapping(address => uint256)",
"numberOfBytes": "32"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}
}
}
25 changes: 25 additions & 0 deletions .openzeppelin/unknown-421613.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"manifestVersion": "3.2",
"admin": {
"address": "0x71F1917472AF194fDDbD53D37843366075e0AB85",
"txHash": "0x4860fd3ed4a04ec03185e46bf1460bd7442cb06f71f8c8916c141b8cb4d2a512"
},
"proxies": [
{
"address": "0xf45306Cfef49B86A2D8964918FE33f780C76cAC2",
"txHash": "0xd2150150fe059eb6f0ea3323b71457bc54c7ee4294c2d82d539b4d2ab11fb958",
"kind": "transparent"
}
],
"impls": {
"f41636e76bf4c9ffd1fc601ec54f31d61e3ff3d0ac46012d6c0b957d81bd812a": {
"address": "0x893728151DB307E2034516Aa7602c240c4f114b2",
"txHash": "0x7ee6681bdf3c07a8ed9478dae1a9273e1a94c819b494919254b14a5d5161f4ae",
"layout": {
"solcVersion": "0.7.3",
"storage": [],
"types": {}
}
}
}
}
42 changes: 4 additions & 38 deletions deploy/2_deploy.ts → deploy/2_l1_manager_wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import consola from 'consola'
import inquirer from 'inquirer'
import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
Expand All @@ -8,53 +7,20 @@ import { DeployFunction } from 'hardhat-deploy/types'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { GraphTokenLockManager } from '../build/typechain/contracts/GraphTokenLockManager'
import { askConfirm, getDeploymentName, promptContractAddress } from './lib/utils'

const { getAddress, parseEther, formatEther } = utils
const { parseEther, formatEther } = utils

const logger = consola.create({})

const askConfirm = async (message: string) => {
const res = await inquirer.prompt({
name: 'confirm',
type: 'confirm',
message,
})
return res.confirm
}

const getTokenAddress = async (): Promise<string> => {
const res1 = await inquirer.prompt({
name: 'token',
type: 'input',
message: 'What is the GRT token address?',
})

try {
return getAddress(res1.token)
} catch (err) {
logger.error(err)
process.exit(1)
}
}

const getDeploymentName = async (defaultName: string): Promise<string> => {
const res = await inquirer.prompt({
name: 'deployment-name',
type: 'input',
default: defaultName,
message: 'Save deployment as?',
})
return res['deployment-name']
}

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

// -- Graph Token --

// Get the token address we will use
const tokenAddress = await getTokenAddress()
const tokenAddress = await promptContractAddress('L1 GRT', logger)
if (!tokenAddress) {
logger.warn('No token address provided')
process.exit(1)
Expand Down Expand Up @@ -102,6 +68,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}
}

func.tags = ['manager']
func.tags = ['manager', 'l1', 'l1-manager', 'l1-wallet']

export default func
27 changes: 27 additions & 0 deletions deploy/3_l2_wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import consola from 'consola'
import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'

import { getDeploymentName } from './lib/utils'


const logger = consola.create({})

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

// Deploy the master copy of GraphTokenLockWallet
logger.info('Deploying L2GraphTokenLockWallet master copy...')
const masterCopySaveName = await getDeploymentName('L2GraphTokenLockWallet')
await deploy(masterCopySaveName, {
from: deployer,
log: true,
contract: 'L2GraphTokenLockWallet',
})
}

func.tags = ['l2-wallet', 'l2']

export default func
79 changes: 79 additions & 0 deletions deploy/4_l1_transfer_tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import consola from 'consola'
import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'

import { getDeploymentName, promptContractAddress } from './lib/utils'
import { ethers, upgrades } from 'hardhat'
import { L1GraphTokenLockTransferTool } from '../build/typechain/contracts/L1GraphTokenLockTransferTool'
import path from 'path'
import { Artifacts } from 'hardhat/internal/artifacts'

const logger = consola.create({})

const ARTIFACTS_PATH = path.resolve('build/artifacts')
const artifacts = new Artifacts(ARTIFACTS_PATH)
const l1TransferToolAbi = artifacts.readArtifactSync('L1GraphTokenLockTransferTool').abi

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts()

// Get the addresses we will use
const tokenAddress = await promptContractAddress('L1 GRT', logger)
if (!tokenAddress) {
logger.warn('No token address provided')
process.exit(1)
}

const l2Implementation = await promptContractAddress('L2GraphTokenLockWallet implementation', logger)
if (!l2Implementation) {
logger.warn('No L2 implementation address provided')
process.exit(1)
}

const l1Gateway = await promptContractAddress('L1 token gateway', logger)
if (!l1Gateway) {
logger.warn('No L1 gateway address provided')
process.exit(1)
}

const l1Staking = await promptContractAddress('L1 Staking', logger)
if (!l1Staking) {
logger.warn('No L1 Staking address provided')
process.exit(1)
}

let owner = await promptContractAddress('owner (optional)', logger)
if (!owner) {
owner = deployer
logger.warn(`No owner address provided, will use the deployer address as owner: ${owner}`)
}

// Deploy the L1GraphTokenLockTransferTool with a proxy.
// hardhat-deploy doesn't get along with constructor arguments in the implementation
// combined with an OpenZeppelin transparent proxy, so we need to do this using
// the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually.

// TODO modify this to use upgradeProxy if a deployment already exists?
logger.info('Deploying L1GraphTokenLockTransferTool proxy...')
const transferToolFactory = await ethers.getContractFactory('L1GraphTokenLockTransferTool')
const transferTool = (await upgrades.deployProxy(transferToolFactory, [owner], {
kind: 'transparent',
unsafeAllow: ['state-variable-immutable', 'constructor'],
constructorArgs: [tokenAddress, l2Implementation, l1Gateway, l1Staking],
})) as L1GraphTokenLockTransferTool

// Save the deployment
const deploymentName = await getDeploymentName('L1GraphTokenLockTransferTool')
await hre.deployments.save(deploymentName, {
abi: l1TransferToolAbi,
address: transferTool.address,
transactionHash: transferTool.deployTransaction.hash,
})
}

func.tags = ['l1', 'l1-transfer-tool']

export default func
Loading