-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from poanetwork/213-support-erc677-foreign-er…
…c-to-erc Add support erc677 on Foreign network for erc-to-erc mode
- Loading branch information
Showing
10 changed files
with
152 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM parity/parity:v2.2.11 | ||
FROM parity/parity:v2.3.3 | ||
|
||
WORKDIR /stuff | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM parity/parity:v2.2.11 | ||
FROM parity/parity:v2.3.3 | ||
|
||
WORKDIR /stuff | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { toHex } from 'web3-utils' | |
import foreignLogoPurple from '../assets/images/logos/[email protected]' | ||
import homeLogoPurple from '../assets/images/logos/[email protected]' | ||
import swal from 'sweetalert' | ||
import { BRIDGE_MODES } from '../stores/utils/bridgeMode' | ||
import { BRIDGE_MODES, ERC_TYPES } from '../stores/utils/bridgeMode' | ||
import { BridgeAddress } from './index' | ||
import { BridgeForm } from './index' | ||
import { BridgeNetwork } from './index' | ||
|
@@ -111,8 +111,8 @@ export class Bridge extends React.Component { | |
} | ||
|
||
async _sendToForeign(amount){ | ||
const { web3Store, foreignStore, alertStore, txStore, bridgeMode } = this.props.RootStore | ||
const isExternalErc20 = bridgeMode === BRIDGE_MODES.ERC_TO_ERC || bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE | ||
const { web3Store, foreignStore, alertStore, txStore } = this.props.RootStore | ||
const isExternalErc20 = foreignStore.tokenType === ERC_TYPES.ERC20 | ||
const { isLessThan, isGreaterThan } = this | ||
if(web3Store.metamaskNet.id.toString() !== web3Store.foreignNet.id.toString()){ | ||
swal("Error", `Please switch wallet to ${web3Store.foreignNet.name} network`, "error") | ||
|
@@ -257,8 +257,8 @@ export class Bridge extends React.Component { | |
} | ||
|
||
loadForeignDetails = () => { | ||
const { web3Store, foreignStore, bridgeMode } = this.props.RootStore | ||
const isExternalErc20 = bridgeMode === BRIDGE_MODES.ERC_TO_ERC || bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE | ||
const { web3Store, foreignStore } = this.props.RootStore | ||
const isExternalErc20 = foreignStore.tokenType === ERC_TYPES.ERC20 | ||
const foreignURL = new URL(web3Store.FOREIGN_HTTP_PARITY_URL) | ||
const foreignDisplayUrl = `${foreignURL.protocol}//${foreignURL.hostname}` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react' | ||
import { render, cleanup } from 'react-testing-library' | ||
import { NetworkDetails } from '../NetworkDetails' | ||
import 'jest-dom/extend-expect' | ||
|
||
afterEach(cleanup) | ||
|
||
const baseData = { | ||
address: "0xCecBE80Ed3548dE11D7d2D922a36576eA40C4c26", | ||
balance: "99.99", | ||
currency: "TEST", | ||
displayTokenAddress: true, | ||
getExplorerAddressUrl: () => {}, | ||
isHome: false, | ||
maxCurrentLimit: "20000", | ||
maxPerTx: "2000", | ||
minPerTx: "0.01", | ||
tokenAddress: "0xb69d9C58C258080eABF499270c778bBDE38dd6Ac", | ||
tokenName: "TEST", | ||
totalSupply: "100", | ||
url: "https://ropsten.infura.io" | ||
} | ||
|
||
describe('NetworkDetails', () => { | ||
it('should display bridge limits information ', () => { | ||
// Given | ||
const data = { | ||
...baseData, | ||
displayBridgeLimits: true | ||
} | ||
|
||
// When | ||
const { queryByTestId } = render(<NetworkDetails {...data}/>) | ||
|
||
// Then | ||
const container = queryByTestId('network-details') | ||
expect(container).toHaveTextContent('Minimum Amount Per Transaction') | ||
expect(container).toHaveTextContent('Maximum Amount Per Transaction') | ||
expect(container).toHaveTextContent('Remaining Daily') | ||
}) | ||
it('should not display bridge limits information ', () => { | ||
// Given | ||
const data = { | ||
...baseData, | ||
displayBridgeLimits: false | ||
} | ||
|
||
// When | ||
const { queryByTestId } = render(<NetworkDetails {...data}/>) | ||
|
||
// Then | ||
const container = queryByTestId('network-details') | ||
expect(container).not.toHaveTextContent('Minimum Amount Per Transaction') | ||
expect(container).not.toHaveTextContent('Maximum Amount Per Transaction') | ||
expect(container).not.toHaveTextContent('Remaining Daily') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getTokenType } from '../contract' | ||
import { ERC_TYPES } from '../bridgeMode' | ||
|
||
describe('getTokenType', () => { | ||
it('should return ERC677 if bridgeContract is equal to bridgeAddress', async () => { | ||
// Given | ||
const bridgeAddress = '0xCecBE80Ed3548dE11D7d2D922a36576eA40C4c26' | ||
const contract = { | ||
methods: { | ||
bridgeContract: () => { | ||
return { | ||
call: () => Promise.resolve(bridgeAddress) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// When | ||
const type = await getTokenType(contract, bridgeAddress) | ||
|
||
// Then | ||
expect(type).toEqual(ERC_TYPES.ERC677) | ||
}) | ||
it('should return ERC20 if bridgeContract is not equal to bridgeAddress', async () => { | ||
// Given | ||
const bridgeAddress = '0xCecBE80Ed3548dE11D7d2D922a36576eA40C4c26' | ||
const contract = { | ||
methods: { | ||
bridgeContract: () => { | ||
return { | ||
call: () => Promise.resolve('0xBFCb120F7B1de491262CA4D9D8Eba70438b6896E') | ||
} | ||
} | ||
} | ||
} | ||
|
||
// When | ||
const type = await getTokenType(contract, bridgeAddress) | ||
|
||
// Then | ||
expect(type).toEqual(ERC_TYPES.ERC20) | ||
}) | ||
it('should return ERC20 if bridgeContract is not present', async () => { | ||
// Given | ||
const bridgeAddress = '0xCecBE80Ed3548dE11D7d2D922a36576eA40C4c26' | ||
const contract = { | ||
methods: { | ||
bridgeContract: () => { | ||
return { | ||
call: () => Promise.reject() | ||
} | ||
} | ||
} | ||
} | ||
|
||
// When | ||
const type = await getTokenType(contract, bridgeAddress) | ||
|
||
// Then | ||
expect(type).toEqual(ERC_TYPES.ERC20) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule poa-bridge-contracts
updated
from c7c84c to 492f6d