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:
parent
c9d100491c
commit
d3653bc31f
@ -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 BRIDGE_VALIDATORS_ABI = require('../contracts/build/contracts/BridgeValidators').abi
|
||||||
const REWARDABLE_VALIDATORS_ABI = require('../contracts/build/contracts/RewardableValidators').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 { 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) {
|
function getBridgeABIs(bridgeMode) {
|
||||||
let HOME_ABI = null
|
let HOME_ABI = null
|
||||||
let FOREIGN_ABI = null
|
let FOREIGN_ABI = null
|
||||||
@ -30,8 +61,8 @@ function getBridgeABIs(bridgeMode) {
|
|||||||
HOME_ABI = HOME_ERC_TO_NATIVE_ABI
|
HOME_ABI = HOME_ERC_TO_NATIVE_ABI
|
||||||
FOREIGN_ABI = FOREIGN_ERC_TO_NATIVE_ABI
|
FOREIGN_ABI = FOREIGN_ERC_TO_NATIVE_ABI
|
||||||
} else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) {
|
} else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) {
|
||||||
HOME_ABI = homeV1Abi
|
HOME_ABI = HOME_V1_ABI
|
||||||
FOREIGN_ABI = foreignViAbi
|
FOREIGN_ABI = FOREIGN_V1_ABI
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unrecognized bridge mode: ${bridgeMode}`)
|
throw new Error(`Unrecognized bridge mode: ${bridgeMode}`)
|
||||||
}
|
}
|
||||||
@ -52,5 +83,8 @@ module.exports = {
|
|||||||
ERC677_BRIDGE_TOKEN_ABI,
|
ERC677_BRIDGE_TOKEN_ABI,
|
||||||
BLOCK_REWARD_ABI,
|
BLOCK_REWARD_ABI,
|
||||||
BRIDGE_VALIDATORS_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 = {
|
module.exports = {
|
||||||
homeV1Abi,
|
HOME_V1_ABI: homeV1Abi,
|
||||||
foreignViAbi
|
FOREIGN_V1_ABI: foreignViAbi
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const logger = require('./logger')('stuckTransfers.js')
|
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_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env
|
||||||
const FOREIGN_DEPLOYMENT_BLOCK = Number(process.env.FOREIGN_DEPLOYMENT_BLOCK) || 0
|
const FOREIGN_DEPLOYMENT_BLOCK = Number(process.env.FOREIGN_DEPLOYMENT_BLOCK) || 0
|
||||||
@ -75,7 +75,7 @@ function compareTransfers(transfersNormal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
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 erc20Address = await foreignBridge.methods.erc677token().call()
|
||||||
const tokenContract = new web3Foreign.eth.Contract(ABITransferWithoutData, erc20Address)
|
const tokenContract = new web3Foreign.eth.Contract(ABITransferWithoutData, erc20Address)
|
||||||
const tokenContractWithData = new web3Foreign.eth.Contract(ABIWithData, erc20Address)
|
const tokenContractWithData = new web3Foreign.eth.Contract(ABIWithData, erc20Address)
|
||||||
|
@ -7,7 +7,8 @@ import {
|
|||||||
FEE_MANAGER_MODE,
|
FEE_MANAGER_MODE,
|
||||||
getUnit,
|
getUnit,
|
||||||
decodeFeeManagerMode,
|
decodeFeeManagerMode,
|
||||||
getBridgeABIs
|
getBridgeABIs,
|
||||||
|
ERC20_BYTES32_ABI
|
||||||
} from '../../../commons'
|
} from '../../../commons'
|
||||||
import {
|
import {
|
||||||
getMaxPerTxLimit,
|
getMaxPerTxLimit,
|
||||||
@ -34,7 +35,6 @@ import {
|
|||||||
} from './utils/contract'
|
} from './utils/contract'
|
||||||
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
|
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
|
||||||
import sleep from './utils/sleep'
|
import sleep from './utils/sleep'
|
||||||
import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi'
|
|
||||||
import BN from 'bignumber.js'
|
import BN from 'bignumber.js'
|
||||||
import { processLargeArrayAsync } from './utils/array'
|
import { processLargeArrayAsync } from './utils/array'
|
||||||
import { fromDecimals } from './utils/decimals'
|
import { fromDecimals } from './utils/decimals'
|
||||||
@ -192,7 +192,7 @@ class ForeignStore {
|
|||||||
)
|
)
|
||||||
this.tokenType = await getTokenType(this.tokenContract, this.FOREIGN_BRIDGE_ADDRESS)
|
this.tokenType = await getTokenType(this.tokenContract, this.FOREIGN_BRIDGE_ADDRESS)
|
||||||
const alternativeContract = new this.foreignWeb3.eth.Contract(
|
const alternativeContract = new this.foreignWeb3.eth.Contract(
|
||||||
ERC20Bytes32Abi,
|
ERC20_BYTES32_ABI,
|
||||||
this.tokenAddress
|
this.tokenAddress
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
|
@ -9,7 +9,9 @@ import {
|
|||||||
FEE_MANAGER_MODE,
|
FEE_MANAGER_MODE,
|
||||||
getUnit,
|
getUnit,
|
||||||
decodeFeeManagerMode,
|
decodeFeeManagerMode,
|
||||||
getBridgeABIs
|
getBridgeABIs,
|
||||||
|
HOME_V1_ABI,
|
||||||
|
ERC20_BYTES32_ABI
|
||||||
} from '../../../commons'
|
} from '../../../commons'
|
||||||
import {
|
import {
|
||||||
getMaxPerTxLimit,
|
getMaxPerTxLimit,
|
||||||
@ -40,10 +42,8 @@ import {
|
|||||||
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
|
import { balanceLoaded, removePendingTransaction } from './utils/testUtils'
|
||||||
import sleep from './utils/sleep'
|
import sleep from './utils/sleep'
|
||||||
import BN from 'bignumber.js'
|
import BN from 'bignumber.js'
|
||||||
import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi'
|
|
||||||
import { processLargeArrayAsync } from './utils/array'
|
import { processLargeArrayAsync } from './utils/array'
|
||||||
import { getRewardableData } from './utils/rewardable'
|
import { getRewardableData } from './utils/rewardable'
|
||||||
import HomeBridgeV1Abi from './utils/HomeBridgeV1.abi'
|
|
||||||
|
|
||||||
async function asyncForEach(array, callback) {
|
async function asyncForEach(array, callback) {
|
||||||
for (let index = 0; index < array.length; index++) {
|
for (let index = 0; index < array.length; index++) {
|
||||||
@ -199,7 +199,10 @@ class HomeStore {
|
|||||||
)
|
)
|
||||||
this.symbol = await getSymbol(this.tokenContract)
|
this.symbol = await getSymbol(this.tokenContract)
|
||||||
this.tokenName = await getName(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 {
|
try {
|
||||||
this.symbol = await getSymbol(this.tokenContract)
|
this.symbol = await getSymbol(this.tokenContract)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -447,7 +450,7 @@ class HomeStore {
|
|||||||
try {
|
try {
|
||||||
const deployedAtBlock = await getDeployedAtBlock(this.homeBridge)
|
const deployedAtBlock = await getDeployedAtBlock(this.homeBridge)
|
||||||
const { HOME_ABI } = getBridgeABIs(this.rootStore.bridgeMode)
|
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 contract = new this.homeWeb3.eth.Contract(abi, this.HOME_BRIDGE_ADDRESS)
|
||||||
const events = await getPastEvents(contract, deployedAtBlock, 'latest')
|
const events = await getPastEvents(contract, deployedAtBlock, 'latest')
|
||||||
processLargeArrayAsync(events, this.processEvent, () => {
|
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"
|
|
||||||
}
|
|
||||||
]
|
|
Loading…
Reference in New Issue
Block a user