UI using abis from commons (#164)

* Renamed v1 abi names

* Home store using v1 from commons

* Using ERC20_BYTES32_ABI from commons
This commit is contained in:
Przemyslaw Rzad 2019-07-26 10:30:35 +02:00 committed by GitHub
parent c9d100491c
commit d3653bc31f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 87 deletions

@ -14,9 +14,40 @@ const BLOCK_REWARD_ABI = require('../contracts/build/contracts/IBlockReward').ab
const BRIDGE_VALIDATORS_ABI = require('../contracts/build/contracts/BridgeValidators').abi
const REWARDABLE_VALIDATORS_ABI = require('../contracts/build/contracts/RewardableValidators').abi
const { homeV1Abi, foreignViAbi } = require('./v1Abis')
const { HOME_V1_ABI, FOREIGN_V1_ABI } = require('./v1Abis')
const { BRIDGE_MODES } = require('./constants')
const ERC20_BYTES32_ABI = [
{
constant: true,
inputs: [],
name: 'name',
outputs: [
{
name: '',
type: 'bytes32'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
},
{
constant: true,
inputs: [],
name: 'symbol',
outputs: [
{
name: '',
type: 'bytes32'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
}
]
function getBridgeABIs(bridgeMode) {
let HOME_ABI = null
let FOREIGN_ABI = null
@ -30,8 +61,8 @@ function getBridgeABIs(bridgeMode) {
HOME_ABI = HOME_ERC_TO_NATIVE_ABI
FOREIGN_ABI = FOREIGN_ERC_TO_NATIVE_ABI
} else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) {
HOME_ABI = homeV1Abi
FOREIGN_ABI = foreignViAbi
HOME_ABI = HOME_V1_ABI
FOREIGN_ABI = FOREIGN_V1_ABI
} else {
throw new Error(`Unrecognized bridge mode: ${bridgeMode}`)
}
@ -52,5 +83,8 @@ module.exports = {
ERC677_BRIDGE_TOKEN_ABI,
BLOCK_REWARD_ABI,
BRIDGE_VALIDATORS_ABI,
REWARDABLE_VALIDATORS_ABI
REWARDABLE_VALIDATORS_ABI,
HOME_V1_ABI,
FOREIGN_V1_ABI,
ERC20_BYTES32_ABI
}

@ -158,6 +158,6 @@ const foreignViAbi = [
]
module.exports = {
homeV1Abi,
foreignViAbi
HOME_V1_ABI: homeV1Abi,
FOREIGN_V1_ABI: foreignViAbi
}

@ -1,7 +1,7 @@
require('dotenv').config()
const Web3 = require('web3')
const logger = require('./logger')('stuckTransfers.js')
const { foreignViAbi } = require('../commons/abis')
const { FOREIGN_V1_ABI } = require('../commons/abis')
const { FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env
const FOREIGN_DEPLOYMENT_BLOCK = Number(process.env.FOREIGN_DEPLOYMENT_BLOCK) || 0
@ -75,7 +75,7 @@ function compareTransfers(transfersNormal) {
}
async function main() {
const foreignBridge = new web3Foreign.eth.Contract(foreignViAbi, FOREIGN_BRIDGE_ADDRESS)
const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_V1_ABI, FOREIGN_BRIDGE_ADDRESS)
const erc20Address = await foreignBridge.methods.erc677token().call()
const tokenContract = new web3Foreign.eth.Contract(ABITransferWithoutData, erc20Address)
const tokenContractWithData = new web3Foreign.eth.Contract(ABIWithData, erc20Address)

@ -7,7 +7,8 @@ import {
FEE_MANAGER_MODE,
getUnit,
decodeFeeManagerMode,
getBridgeABIs
getBridgeABIs,
ERC20_BYTES32_ABI
} from '../../../commons'
import {
getMaxPerTxLimit,
@ -34,7 +35,6 @@ import {
} from './utils/contract'
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
import sleep from './utils/sleep'
import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi'
import BN from 'bignumber.js'
import { processLargeArrayAsync } from './utils/array'
import { fromDecimals } from './utils/decimals'
@ -192,7 +192,7 @@ class ForeignStore {
)
this.tokenType = await getTokenType(this.tokenContract, this.FOREIGN_BRIDGE_ADDRESS)
const alternativeContract = new this.foreignWeb3.eth.Contract(
ERC20Bytes32Abi,
ERC20_BYTES32_ABI,
this.tokenAddress
)
try {

@ -9,7 +9,9 @@ import {
FEE_MANAGER_MODE,
getUnit,
decodeFeeManagerMode,
getBridgeABIs
getBridgeABIs,
HOME_V1_ABI,
ERC20_BYTES32_ABI
} from '../../../commons'
import {
getMaxPerTxLimit,
@ -40,10 +42,8 @@ import {
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
import sleep from './utils/sleep'
import BN from 'bignumber.js'
import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi'
import { processLargeArrayAsync } from './utils/array'
import { getRewardableData } from './utils/rewardable'
import HomeBridgeV1Abi from './utils/HomeBridgeV1.abi'
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
@ -199,7 +199,10 @@ class HomeStore {
)
this.symbol = await getSymbol(this.tokenContract)
this.tokenName = await getName(this.tokenContract)
const alternativeContract = new this.homeWeb3.eth.Contract(ERC20Bytes32Abi, this.tokenAddress)
const alternativeContract = new this.homeWeb3.eth.Contract(
ERC20_BYTES32_ABI,
this.tokenAddress
)
try {
this.symbol = await getSymbol(this.tokenContract)
} catch (e) {
@ -447,7 +450,7 @@ class HomeStore {
try {
const deployedAtBlock = await getDeployedAtBlock(this.homeBridge)
const { HOME_ABI } = getBridgeABIs(this.rootStore.bridgeMode)
const abi = [...HomeBridgeV1Abi, ...HOME_ABI]
const abi = [...HOME_V1_ABI, ...HOME_ABI]
const contract = new this.homeWeb3.eth.Contract(abi, this.HOME_BRIDGE_ADDRESS)
const events = await getPastEvents(contract, deployedAtBlock, 'latest')
processLargeArrayAsync(events, this.processEvent, () => {

@ -1,30 +0,0 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]

@ -1,41 +0,0 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "recipient",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "recipient",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"name": "transactionHash",
"type": "bytes32"
}
],
"name": "Withdraw",
"type": "event"
}
]