d656025378
* Moved audit to root directory. * Moved code of conduct, contributing and licence files. * Removed travis config and badge. * Updated repository links in CONTRIBUTING. * Moved Gitter badge to main readme. Updated links to contributing and licence. * Updated main readme. * Moved references to main readme. * Renamed token-bridge to oracle. * Update README.md Co-Authored-By: rzadp <rzadp@student.mini.pw.edu.pl>
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
const path = require('path')
|
|
require('dotenv').config({
|
|
path: path.join(__dirname, '../.env')
|
|
})
|
|
const Web3 = require('web3')
|
|
const ERC677BridgeTokenABI = require('../abis/ERC677BridgeToken.abi')
|
|
const { ERC_TYPES } = require('../src/utils/constants')
|
|
|
|
async function initialChecks() {
|
|
const { ERC20_TOKEN_ADDRESS, BRIDGE_MODE, FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env
|
|
const result = {}
|
|
|
|
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)
|
|
try {
|
|
const bridgeContract = await tokenContract.methods.bridgeContract().call()
|
|
if (bridgeContract === FOREIGN_BRIDGE_ADDRESS) {
|
|
result.foreignERC = ERC_TYPES.ERC677
|
|
} else {
|
|
result.foreignERC = ERC_TYPES.ERC20
|
|
}
|
|
} catch (e) {
|
|
result.foreignERC = ERC_TYPES.ERC20
|
|
}
|
|
}
|
|
console.log(JSON.stringify(result))
|
|
return result
|
|
}
|
|
|
|
initialChecks()
|
|
|
|
module.exports = initialChecks
|