Oracle using commons (#144)
This commit is contained in:
parent
b88dd66cac
commit
2e89d7724a
@ -10,6 +10,7 @@ RUN apt-get clean
|
||||
WORKDIR /mono
|
||||
COPY package.json .
|
||||
COPY contracts/package.json ./contracts/
|
||||
COPY commons/package.json ./commons/
|
||||
COPY oracle/package.json ./oracle/
|
||||
COPY yarn.lock .
|
||||
RUN yarn install --production --frozen-lockfile
|
||||
@ -18,6 +19,8 @@ COPY ./contracts ./contracts
|
||||
RUN yarn run compile:contracts
|
||||
RUN mv ./contracts/build ./ && rm -rf ./contracts/* ./contracts/.[!.]* && mv ./build ./contracts/
|
||||
|
||||
COPY ./commons ./commons
|
||||
|
||||
COPY ./oracle ./oracle
|
||||
WORKDIR /mono/oracle
|
||||
CMD echo "To start a bridge process run:" \
|
||||
|
@ -1,5 +1,5 @@
|
||||
const baseConfig = require('./base.config')
|
||||
const erc20Abi = require('../../contracts/build/contracts/ERC20').abi
|
||||
const { ERC20_ABI } = require('../../commons')
|
||||
const { ERC_TYPES } = require('../src/utils/constants')
|
||||
|
||||
const initialChecksJson = process.argv[3]
|
||||
@ -29,7 +29,7 @@ module.exports =
|
||||
...baseConfig.foreignConfig,
|
||||
event: 'Transfer',
|
||||
eventContractAddress: process.env.ERC20_TOKEN_ADDRESS,
|
||||
eventAbi: erc20Abi,
|
||||
eventAbi: ERC20_ABI,
|
||||
eventFilter: { to: process.env.FOREIGN_BRIDGE_ADDRESS },
|
||||
queue: 'home',
|
||||
name: `watcher-${id}`,
|
||||
|
@ -1,19 +1,18 @@
|
||||
require('../env')
|
||||
|
||||
const { toBN } = require('web3').utils
|
||||
const {
|
||||
BRIDGE_MODES,
|
||||
HOME_NATIVE_TO_ERC_ABI,
|
||||
FOREIGN_NATIVE_TO_ERC_ABI,
|
||||
HOME_ERC_TO_ERC_ABI,
|
||||
FOREIGN_ERC_TO_ERC_ABI,
|
||||
HOME_ERC_TO_NATIVE_ABI,
|
||||
FOREIGN_ERC_TO_NATIVE_ABI
|
||||
} = require('../../commons')
|
||||
const { web3Home, web3Foreign } = require('../src/services/web3')
|
||||
const { privateKeyToAddress } = require('../src/utils/utils')
|
||||
|
||||
const homeNativeErcAbi = require('../../contracts/build/contracts/HomeBridgeNativeToErc').abi
|
||||
const foreignNativeErcAbi = require('../../contracts/build/contracts/ForeignBridgeNativeToErc').abi
|
||||
|
||||
const homeErcErcAbi = require('../../contracts/build/contracts/HomeBridgeErcToErc').abi
|
||||
const foreignErc677Erc677Abi = require('../../contracts/build/contracts/ForeignBridgeErc677ToErc677')
|
||||
.abi
|
||||
|
||||
const homeErcNativeAbi = require('../../contracts/build/contracts/HomeBridgeErcToNative').abi
|
||||
const foreignErcNativeAbi = require('../../contracts/build/contracts/ForeignBridgeErcToNative').abi
|
||||
|
||||
const { VALIDATOR_ADDRESS, VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env
|
||||
|
||||
let homeAbi
|
||||
@ -21,27 +20,27 @@ let foreignAbi
|
||||
let id
|
||||
|
||||
switch (process.env.BRIDGE_MODE) {
|
||||
case 'NATIVE_TO_ERC':
|
||||
homeAbi = homeNativeErcAbi
|
||||
foreignAbi = foreignNativeErcAbi
|
||||
case BRIDGE_MODES.NATIVE_TO_ERC:
|
||||
homeAbi = HOME_NATIVE_TO_ERC_ABI
|
||||
foreignAbi = FOREIGN_NATIVE_TO_ERC_ABI
|
||||
id = 'native-erc'
|
||||
break
|
||||
case 'ERC_TO_ERC':
|
||||
homeAbi = homeErcErcAbi
|
||||
foreignAbi = foreignErc677Erc677Abi
|
||||
case BRIDGE_MODES.ERC_TO_ERC:
|
||||
homeAbi = HOME_ERC_TO_ERC_ABI
|
||||
foreignAbi = FOREIGN_ERC_TO_ERC_ABI
|
||||
id = 'erc-erc'
|
||||
break
|
||||
case 'ERC_TO_NATIVE':
|
||||
homeAbi = homeErcNativeAbi
|
||||
foreignAbi = foreignErcNativeAbi
|
||||
case BRIDGE_MODES.ERC_TO_NATIVE:
|
||||
homeAbi = HOME_ERC_TO_NATIVE_ABI
|
||||
foreignAbi = FOREIGN_ERC_TO_NATIVE_ABI
|
||||
id = 'erc-native'
|
||||
break
|
||||
default:
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
throw new Error(`Bridge Mode: ${process.env.BRIDGE_MODE} not supported.`)
|
||||
} else {
|
||||
homeAbi = homeErcNativeAbi
|
||||
foreignAbi = foreignErcNativeAbi
|
||||
homeAbi = HOME_ERC_TO_NATIVE_ABI
|
||||
foreignAbi = FOREIGN_ERC_TO_NATIVE_ABI
|
||||
id = 'erc-native'
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ const Web3 = require('web3')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { ERC20_ABI } = require('../../../commons')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
@ -14,15 +15,14 @@ const {
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_DEPOSITS_TO_SEND || 1
|
||||
|
||||
const ERC20_ABI = require('../../../contracts/build/contracts/ERC20').abi
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/ForeignBridgeErcToErc').abi
|
||||
const { FOREIGN_ERC_TO_ERC_ABI } = require('../../../commons')
|
||||
|
||||
const foreignRpcUrl = rpcUrlsManager.foreignUrls[0]
|
||||
const foreignProvider = new Web3.providers.HttpProvider(foreignRpcUrl)
|
||||
const web3Foreign = new Web3(foreignProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Foreign.eth.Contract(FOREIGN_ERC_TO_ERC_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc20token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC20_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
|
@ -4,6 +4,7 @@ const Web3Utils = require('web3-utils')
|
||||
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const { HOME_ERC_TO_ERC_ABI } = require('../../../commons')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
@ -46,14 +47,12 @@ const BRIDGEABLE_TOKEN_ABI = [
|
||||
}
|
||||
]
|
||||
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/HomeBridgeErcToErc').abi
|
||||
|
||||
const homeRpcUrl = rpcUrlsManager.homeUrls[0]
|
||||
const homeProvider = new Web3.providers.HttpProvider(homeRpcUrl)
|
||||
const web3Home = new Web3(homeProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Home.eth.Contract(HOME_ERC_TO_ERC_ABI, HOME_BRIDGE_ADDRESS)
|
||||
const BRIDGEABLE_TOKEN_ADDRESS = await bridge.methods.erc677token().call()
|
||||
const erc677 = new web3Home.eth.Contract(BRIDGEABLE_TOKEN_ABI, BRIDGEABLE_TOKEN_ADDRESS)
|
||||
|
||||
|
@ -14,15 +14,14 @@ const {
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_DEPOSITS_TO_SEND || 1
|
||||
|
||||
const ERC20_ABI = require('../../../contracts/build/contracts/ERC20').abi
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/ForeignBridgeErcToNative').abi
|
||||
const { ERC20_ABI, FOREIGN_ERC_TO_NATIVE_ABI } = require('../../../commons')
|
||||
|
||||
const foreignRpcUrl = rpcUrlsManager.foreignUrls[0]
|
||||
const foreignProvider = new Web3.providers.HttpProvider(foreignRpcUrl)
|
||||
const web3Foreign = new Web3(foreignProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Foreign.eth.Contract(FOREIGN_ERC_TO_NATIVE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc20token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC20_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
|
@ -3,7 +3,7 @@ const Web3Utils = require('web3-utils')
|
||||
const { web3Home } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/HomeBridgeErcToNative').abi
|
||||
const { HOME_ERC_TO_NATIVE_ABI } = require('../../../commons')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
@ -16,7 +16,7 @@ const {
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || 1
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Home.eth.Contract(HOME_ERC_TO_NATIVE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(HOME_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
@ -1,9 +1,8 @@
|
||||
require('../env')
|
||||
const Web3 = require('web3')
|
||||
const bridgeValidatorsABI = require('../../contracts/build/contracts/BridgeValidators').abi
|
||||
|
||||
const { BRIDGE_VALIDATORS_ABI } = require('../../commons')
|
||||
const rpcUrlsManager = require('../src/services/getRpcUrlsManager')
|
||||
|
||||
const { bridgeConfig } = require('../config/base.config')
|
||||
|
||||
const homeABI = bridgeConfig.homeBridgeAbi
|
||||
@ -19,7 +18,7 @@ async function getStartBlock(rpcUrl, bridgeAddress, bridgeAbi) {
|
||||
|
||||
const validatorContractAddress = await bridgeContract.methods.validatorContract().call()
|
||||
const validatorContract = new web3Instance.eth.Contract(
|
||||
bridgeValidatorsABI,
|
||||
BRIDGE_VALIDATORS_ABI,
|
||||
validatorContractAddress
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
require('../env')
|
||||
const Web3 = require('web3')
|
||||
const ERC677BridgeTokenABI = require('../../contracts/build/contracts/ERC677BridgeToken').abi
|
||||
const { ERC677_BRIDGE_TOKEN_ABI } = require('../../commons')
|
||||
const { ERC_TYPES } = require('../src/utils/constants')
|
||||
|
||||
async function initialChecks() {
|
||||
@ -9,7 +9,7 @@ async function initialChecks() {
|
||||
|
||||
if (BRIDGE_MODE === 'ERC_TO_ERC') {
|
||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL))
|
||||
const tokenContract = new foreignWeb3.eth.Contract(ERC677BridgeTokenABI, ERC20_TOKEN_ADDRESS)
|
||||
const tokenContract = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ERC20_TOKEN_ADDRESS)
|
||||
try {
|
||||
const bridgeContract = await tokenContract.methods.bridgeContract().call()
|
||||
if (bridgeContract === FOREIGN_BRIDGE_ADDRESS) {
|
||||
|
@ -3,6 +3,7 @@ const Web3Utils = require('web3-utils')
|
||||
const { web3Foreign } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const { FOREIGN_NATIVE_TO_ERC_ABI } = require('../../../commons')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
@ -44,10 +45,9 @@ const ERC677_ABI = [
|
||||
type: 'function'
|
||||
}
|
||||
]
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/ForeignBridgeNativeToErc').abi
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Foreign.eth.Contract(FOREIGN_NATIVE_TO_ERC_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc677token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC677_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
|
@ -3,7 +3,7 @@ const Web3Utils = require('web3-utils')
|
||||
const { web3Home } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const BRIDGE_ABI = require('../../../contracts/build/contracts/HomeBridgeNativeToErc').abi
|
||||
const { HOME_NATIVE_TO_ERC_ABI } = require('../../../commons')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
@ -16,7 +16,7 @@ const {
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || 1
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
const bridge = new web3Home.eth.Contract(HOME_NATIVE_TO_ERC_ABI, HOME_BRIDGE_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(HOME_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
@ -4,7 +4,7 @@ const { HttpListProviderError } = require('http-list-provider')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
|
||||
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi
|
||||
const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
const estimateGas = require('./estimateGas')
|
||||
const {
|
||||
@ -28,7 +28,7 @@ function processAffirmationRequestsBuilder(config) {
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
validatorContract = new web3Home.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${affirmationRequests.length} AffirmationRequest events`)
|
||||
|
@ -1,7 +1,7 @@
|
||||
require('../../../env')
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi
|
||||
const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home, web3Foreign } = require('../../services/web3')
|
||||
const { signatureToVRS } = require('../../utils/message')
|
||||
@ -34,7 +34,7 @@ function processCollectedSignaturesBuilder(config) {
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Foreign.eth.Contract(
|
||||
bridgeValidatorsABI,
|
||||
BRIDGE_VALIDATORS_ABI,
|
||||
validatorContractAddress
|
||||
)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
require('../../../env')
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi
|
||||
const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
const { createMessage } = require('../../utils/message')
|
||||
@ -35,7 +35,7 @@ function processSignatureRequestsBuilder(config) {
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
validatorContract = new web3Home.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${signatureRequests.length} SignatureRequest events`)
|
||||
|
@ -1,7 +1,7 @@
|
||||
require('../../../env')
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi
|
||||
const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
const {
|
||||
@ -27,7 +27,7 @@ function processTransfersBuilder(config) {
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
validatorContract = new web3Home.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${transfers.length} Transfer events`)
|
||||
|
Loading…
Reference in New Issue
Block a user