refactoring & cleanup in ts tooling

This commit is contained in:
chase-45 2023-01-07 14:57:57 -05:00 committed by Joe Howarth
parent 2dc8d45b95
commit 7005533a23
11 changed files with 164 additions and 104 deletions

View File

@ -21,8 +21,6 @@
"integration-test": "bash shell-scripts/run_integration_tests.sh",
"typechain": "bash ../sdk/scripts/make_ethers_types.sh",
"flatten": "mkdir -p node_modules/@poanet/solidity-flattener/contracts && cp -r contracts/* node_modules/@poanet/solidity-flattener/contracts/ && poa-solidity-flattener",
"registerChains": "ts-node ./ts-scripts/registerChains.ts",
"messageTest": "ts-node ./ts-scripts/messageTest.ts",
"deployAndConfigureTilt": "ENV=tilt bash ./ts-scripts/shell/deployConfigureTest.sh"
},
"author": "",

View File

@ -1,5 +1,5 @@
{
"description": "This file contains the addresses for the relayProviderProxy and CoreRelayerProxy on each chain. If useLastRun is true, this file will be ignored, and the addresses will be taken from the lastrun.json of the deployment scripts.",
"description": "This file contains the addresses for the contracts on each chain. If useLastRun is true, this file will be ignored, and the addresses will be taken from the lastrun.json of the deployment scripts.",
"useLastRun": true,
"relayProviders": [
{

View File

@ -1,18 +1,15 @@
import { CoreRelayerProxy__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerProxy__factory"
import { CoreRelayerSetup__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerSetup__factory"
import { CoreRelayerImplementation__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerImplementation__factory"
import {
deployCoreRelayerImplementation,
deployCoreRelayerProxy,
deployCoreRelayerSetup,
} from "../helpers/deployments"
import {
init,
loadChains,
writeOutputFiles,
ChainInfo,
Deployment,
getRelayProviderAddress,
getSigner,
} from "../helpers/env"
import { ethers } from "ethers"
const processName = "deployCoreRelayer"
init()
const chains = loadChains()
@ -45,60 +42,4 @@ async function run() {
writeOutputFiles(output, processName)
}
async function deployCoreRelayerImplementation(chain: ChainInfo): Promise<Deployment> {
console.log("deployCoreRelayerImplementation " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerImplementation__factory.createInterface()
const bytecode = CoreRelayerImplementation__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployCoreRelayerSetup " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerSetup__factory.createInterface()
const bytecode = CoreRelayerSetup__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
async function deployCoreRelayerProxy(
chain: ChainInfo,
coreRelayerSetupAddress: string,
coreRelayerImplementationAddress: string,
wormholeAddress: string,
relayProviderProxyAddress: string
): Promise<Deployment> {
console.log("deployCoreRelayerProxy " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerProxy__factory.createInterface()
const bytecode = CoreRelayerProxy__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
let ABI = ["function setup(address,uint16,address,address)"]
let iface = new ethers.utils.Interface(ABI)
let encodedData = iface.encodeFunctionData("setup", [
coreRelayerImplementationAddress,
chain.chainId,
wormholeAddress,
relayProviderProxyAddress,
])
const contract = await factory.deploy(coreRelayerSetupAddress, encodedData)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
run().then(() => console.log("Done! " + processName))

View File

@ -0,0 +1,151 @@
import { RelayProviderProxy__factory } from "../../../sdk/src/ethers-contracts/factories/RelayProviderProxy__factory"
import { RelayProviderSetup__factory } from "../../../sdk/src/ethers-contracts/factories/RelayProviderSetup__factory"
import { RelayProviderImplementation__factory } from "../../../sdk/src/ethers-contracts/factories/RelayProviderImplementation__factory"
import { MockRelayerIntegration__factory } from "../../../sdk/src"
import { CoreRelayerProxy__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerProxy__factory"
import { CoreRelayerSetup__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerSetup__factory"
import { CoreRelayerImplementation__factory } from "../../../sdk/src/ethers-contracts/factories/CoreRelayerImplementation__factory"
import {
init,
loadChains,
loadPrivateKey,
writeOutputFiles,
ChainInfo,
Deployment,
getSigner,
getCoreRelayerAddress,
} from "./env"
import { ethers } from "ethers"
export async function deployRelayProviderImplementation(
chain: ChainInfo
): Promise<Deployment> {
console.log("deployRelayProviderImplementation " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = RelayProviderImplementation__factory.createInterface()
const bytecode = RelayProviderImplementation__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployRelayProviderSetup " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = RelayProviderSetup__factory.createInterface()
const bytecode = RelayProviderSetup__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployRelayProviderProxy(
chain: ChainInfo,
relayProviderSetupAddress: string,
relayProviderImplementationAddress: string
): Promise<Deployment> {
console.log("deployRelayProviderProxy " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = RelayProviderProxy__factory.createInterface()
const bytecode = RelayProviderProxy__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
let ABI = ["function setup(address,uint16)"]
let iface = new ethers.utils.Interface(ABI)
let encodedData = iface.encodeFunctionData("setup", [
relayProviderImplementationAddress,
chain.chainId,
])
const contract = await factory.deploy(relayProviderSetupAddress, encodedData)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployMockIntegration(chain: ChainInfo): Promise<Deployment> {
console.log("deployMockIntegration " + chain.chainId)
let signer = getSigner(chain)
const contractInterface = MockRelayerIntegration__factory.createInterface()
const bytecode = MockRelayerIntegration__factory.bytecode
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy(
chain.wormholeAddress,
getCoreRelayerAddress(chain)
)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployCoreRelayerImplementation(
chain: ChainInfo
): Promise<Deployment> {
console.log("deployCoreRelayerImplementation " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerImplementation__factory.createInterface()
const bytecode = CoreRelayerImplementation__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployCoreRelayerSetup " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerSetup__factory.createInterface()
const bytecode = CoreRelayerSetup__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
export async function deployCoreRelayerProxy(
chain: ChainInfo,
coreRelayerSetupAddress: string,
coreRelayerImplementationAddress: string,
wormholeAddress: string,
relayProviderProxyAddress: string
): Promise<Deployment> {
console.log("deployCoreRelayerProxy " + chain.chainId)
const signer = getSigner(chain)
const contractInterface = CoreRelayerProxy__factory.createInterface()
const bytecode = CoreRelayerProxy__factory.bytecode
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
let ABI = ["function setup(address,uint16,address,address)"]
let iface = new ethers.utils.Interface(ABI)
let encodedData = iface.encodeFunctionData("setup", [
coreRelayerImplementationAddress,
chain.chainId,
wormholeAddress,
relayProviderProxyAddress,
])
const contract = await factory.deploy(coreRelayerSetupAddress, encodedData)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}

View File

@ -1,15 +1,5 @@
import {
init,
loadChains,
loadPrivateKey,
writeOutputFiles,
ChainInfo,
Deployment,
} from "../helpers/env"
import { ethers } from "ethers"
import { getCoreRelayerAddress, getSigner } from "../helpers/env"
import { MockRelayerIntegration__factory } from "../../../sdk/src"
import { init, loadChains, writeOutputFiles } from "../helpers/env"
import { deployMockIntegration } from "../helpers/deployments"
const processName = "deployMockIntegration"
init()
@ -30,21 +20,4 @@ async function run() {
writeOutputFiles(output, processName)
}
async function deployMockIntegration(chain: ChainInfo): Promise<Deployment> {
console.log("deployMockIntegration " + chain.chainId)
let signer = getSigner(chain)
const contractInterface = MockRelayerIntegration__factory.createInterface()
const bytecode = MockRelayerIntegration__factory.bytecode
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy(
chain.wormholeAddress,
getCoreRelayerAddress(chain)
)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
}
run().then(() => console.log("Done!"))

View File

@ -42,7 +42,9 @@ async function run() {
writeOutputFiles(output, processName)
}
async function deployRelayProviderImplementation(chain: ChainInfo): Promise<Deployment> {
export async function deployRelayProviderImplementation(
chain: ChainInfo
): Promise<Deployment> {
console.log("deployRelayProviderImplementation " + chain.chainId)
let provider = new ethers.providers.StaticJsonRpcProvider(chain.rpc)
let signer = new ethers.Wallet(privateKey, provider)
@ -58,7 +60,7 @@ async function deployRelayProviderImplementation(chain: ChainInfo): Promise<Depl
})
}
async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployRelayProviderSetup " + chain.chainId)
let provider = new ethers.providers.StaticJsonRpcProvider(chain.rpc)
let signer = new ethers.Wallet(privateKey, provider)
@ -72,7 +74,7 @@ async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
return { address: result.address, chainId: chain.chainId }
})
}
async function deployRelayProviderProxy(
export async function deployRelayProviderProxy(
chain: ChainInfo,
relayProviderSetupAddress: string,
relayProviderImplementationAddress: string