diff --git a/.madison.env b/.madison.env new file mode 100644 index 000000000..a746a7125 --- /dev/null +++ b/.madison.env @@ -0,0 +1,6 @@ + +MADISON_RPC_USER=witcher +MADISON_RPC_PASS=tossAcelo2Cross +MADISON_RPC_URL=madisonbridge.net + +MADISON_PRIVKEY=c06c61f97cd0367dac2fa13ccfbae53cb2728822832682a280f6677be8f52396 diff --git a/solidity/optics-core/hardhat.config.js b/solidity/optics-core/hardhat.config.js index 3a436d239..1bdb274f3 100644 --- a/solidity/optics-core/hardhat.config.js +++ b/solidity/optics-core/hardhat.config.js @@ -4,6 +4,18 @@ require('solidity-coverage'); require('./lib'); require('./scripts'); +const path = require('path'); +require('dotenv').config({ + path: path.resolve(process.cwd(), '../../.madison.env'), +}); + +const { + MADISON_RPC_USER, + MADISON_RPC_PASS, + MADISON_RPC_URL, + MADISON_PRIVKEY, +} = process.env; + /** * @type import('hardhat/config').HardhatUserConfig */ @@ -26,5 +38,11 @@ module.exports = { localhost: { url: 'http://localhost:8545', }, + madison: { + gasPrice: 1, + chainId: 29739, + url: `http://${MADISON_RPC_USER}:${MADISON_RPC_PASS}@${MADISON_RPC_URL}`, + accounts: [MADISON_PRIVKEY], + }, }, }; diff --git a/solidity/optics-core/lib/index.js b/solidity/optics-core/lib/index.js index ce0509c9b..0a1838f0f 100644 --- a/solidity/optics-core/lib/index.js +++ b/solidity/optics-core/lib/index.js @@ -1,12 +1,12 @@ require('@nomiclabs/hardhat-waffle'); const { assert } = require('chai'); -const ethers = require('ethers'); const { extendEnvironment } = require('hardhat/config'); const HomeAbi = require('../../../abis/Home.abi.json'); const ReplicaAbi = require('../../../abis/ProcessingReplica.abi.json'); extendEnvironment((hre) => { + let { ethers } = hre; const State = { ACTIVE: 0, FAILED: 1, @@ -112,11 +112,6 @@ extendEnvironment((hre) => { } } - const getHomeFactory = async (...args) => - ethers.getContractFactory('Home', ...args); - const getReplicaFactory = async (...args) => - ethers.getContractFactory('ProcessingReplica', ...args); - const formatMessage = ( originDomain, senderAddr, @@ -171,15 +166,18 @@ extendEnvironment((hre) => { messageToLeaf, ethersAddressToBytes32, destinationAndSequence, - getHomeFactory, - getReplicaFactory, deployHome: async (signer, ...args) => { - let contract = await (await getHomeFactory(signer)).deploy(...args); + const factory = await ethers.getContractFactory('Home', signer); + let contract = await factory.deploy(...args); await contract.deployed(); return new Home(contract.address, signer); }, deployReplica: async (signer, ...args) => { - let contract = await (await getReplicaFactory(signer)).deploy(...args); + const factory = await ethers.getContractFactory( + 'ProcessingReplica', + signer, + ); + let contract = await factory.deploy(...args); await contract.deployed(); return new Replica(contract.address, signer); }, diff --git a/solidity/optics-core/package-lock.json b/solidity/optics-core/package-lock.json index bacd3b7b8..cd1030a1d 100644 --- a/solidity/optics-core/package-lock.json +++ b/solidity/optics-core/package-lock.json @@ -10,7 +10,8 @@ "license": "MIT OR Apache-2.0", "dependencies": { "@openzeppelin/contracts": "^3.4.0", - "@summa-tx/memview-sol": "^1.1.1" + "@summa-tx/memview-sol": "^1.1.1", + "dotenv": "^8.2.0" }, "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.1", @@ -3204,6 +3205,14 @@ "version": "0.1.2", "dev": true }, + "node_modules/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", + "engines": { + "node": ">=8" + } + }, "node_modules/drbg.js": { "version": "1.0.1", "dev": true, @@ -11972,6 +11981,20 @@ "verror": "1.10.0" } }, + "node_modules/ganache-core/node_modules/keccak": { + "version": "3.0.1", + "dev": true, + "hasInstallScript": true, + "inBundle": true, + "license": "MIT", + "dependencies": { + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/ganache-core/node_modules/keyv": { "version": "3.1.0", "dev": true, @@ -12536,6 +12559,7 @@ "node_modules/ganache-core/node_modules/node-addon-api": { "version": "2.0.2", "dev": true, + "inBundle": true, "license": "MIT" }, "node_modules/ganache-core/node_modules/node-fetch": { @@ -12549,6 +12573,7 @@ "node_modules/ganache-core/node_modules/node-gyp-build": { "version": "4.2.3", "dev": true, + "inBundle": true, "license": "MIT", "bin": { "node-gyp-build": "bin.js", @@ -25119,6 +25144,11 @@ "version": "0.1.2", "dev": true }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, "drbg.js": { "version": "1.0.1", "dev": true, @@ -31846,6 +31876,15 @@ "verror": "1.10.0" } }, + "keccak": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + } + }, "keyv": { "version": "3.1.0", "dev": true, @@ -32270,6 +32309,7 @@ }, "node-addon-api": { "version": "2.0.2", + "bundled": true, "dev": true }, "node-fetch": { @@ -32278,6 +32318,7 @@ }, "node-gyp-build": { "version": "4.2.3", + "bundled": true, "dev": true }, "normalize-url": { diff --git a/solidity/optics-core/package.json b/solidity/optics-core/package.json index 5aca0a6a9..6f4b267e5 100644 --- a/solidity/optics-core/package.json +++ b/solidity/optics-core/package.json @@ -33,6 +33,7 @@ "license": "MIT OR Apache-2.0", "dependencies": { "@openzeppelin/contracts": "^3.4.0", - "@summa-tx/memview-sol": "^1.1.1" + "@summa-tx/memview-sol": "^1.1.1", + "dotenv": "^8.2.0" } } diff --git a/solidity/optics-core/scripts/deploy.js b/solidity/optics-core/scripts/deploy.js index b5ded620e..2e51e1723 100644 --- a/solidity/optics-core/scripts/deploy.js +++ b/solidity/optics-core/scripts/deploy.js @@ -11,7 +11,7 @@ task('deploy-home', 'Deploy a home.') ) .setAction(async (args) => { let address = ethers.utils.getAddress(args.sortition); - let signer = ethers.getSigner(); + let [signer] = await ethers.getSigners(); let home = await optics.deployHome(signer, args.domain, address); console.log(home.address); }); @@ -49,7 +49,7 @@ task('deploy-replica', 'Deploy a replica.') throw new Error('current must be a 32-byte 0x prefixed hex string'); } - let signer = ethers.getSigner(); + let [signer] = await ethers.getSigners(); await optics.deployReplica( signer, diff --git a/solidity/optics-core/scripts/process.js b/solidity/optics-core/scripts/process.js index 4fe5b72cc..f8b121932 100644 --- a/solidity/optics-core/scripts/process.js +++ b/solidity/optics-core/scripts/process.js @@ -31,7 +31,7 @@ task('prove', 'Prove a message inclusion to a replica') throw new Error('newRoot must be a 0x prefixed hex string'); } - let signer = await ethers.getSigner(); + let [signer] = await ethers.getSigners(); let replica = new optics.Replica(address, signer); // preflight @@ -68,7 +68,7 @@ task('process', 'Process a message that has been proven to a replica') throw new Error('newRoot must be a 0x prefixed hex string'); } - let signer = await ethers.getSigner(); + let [signer] = await ethers.getSigners(); let replica = new optics.Replica(address, signer); try { @@ -111,7 +111,7 @@ task('prove-and-process', 'Prove and process a message') throw new Error('message must be a 0x prefixed hex string'); } - let signer = await ethers.getSigner(); + let [signer] = await ethers.getSigners(); let replica = new optics.Replica(address, signer); try { diff --git a/solidity/optics-core/scripts/update.js b/solidity/optics-core/scripts/update.js index dad5963f3..54b6d22a6 100644 --- a/solidity/optics-core/scripts/update.js +++ b/solidity/optics-core/scripts/update.js @@ -16,7 +16,7 @@ task('submit-update', 'Submit an update to a home or replica contract.') let { newRoot, oldRoot, signature } = args; let update = await utils.validateUpdate(newRoot, oldRoot, signature); - let signer = await ethers.getSigner(); + let [signer] = await ethers.getSigners(); // we should be able to use home for either. Consider moving this to common? let contract = new optics.Home(address, signer); @@ -51,7 +51,7 @@ task('submit-double-update', 'Submit a double update to a home or replica.') let update1 = await utils.validateUpdate(newRoot1, oldRoot1, signature1); let update2 = await utils.validateUpdate(newRoot2, oldRoot2, signature2); - let signer = await ethers.getSigner(); + let [signer] = await ethers.getSigners(); let contract = new optics.Common(address, signer); let tx = await contract.submitDoubleUpdate(update1, update2);