diff --git a/src/locales/en-us.json b/src/locales/en-us.json
index f7bc43c..c46b01a 100644
--- a/src/locales/en-us.json
+++ b/src/locales/en-us.json
@@ -23,7 +23,10 @@
"Destination": "Destination",
"darwinaPage": "https://darwinia.network/",
"Claims": "Claimed",
- "Not claimed": "Not claimed"
+ "Not claimed": "Not claimed",
+ "Extension": "Extension",
+ "Manual": "Manual",
+ "Please input the Darwinia address to be queried": "Please input the Darwinia address to be queried"
},
"crosschain": {
"title": "Cross-chain Transfer",
diff --git a/src/locales/zh-cn.json b/src/locales/zh-cn.json
index fca3e90..4b02d75 100644
--- a/src/locales/zh-cn.json
+++ b/src/locales/zh-cn.json
@@ -120,7 +120,10 @@
"The amount exceeds the account available balance": "输入数量超过账户可用余额",
"The entered recipient account is incorrect": "输入的接收账号错误",
"d2e crosschain gas tip 1": "· 请在「跨链历史交易」中发起以太坊网络的「领取交易」。",
- "d2e crosschain gas tip 2": "· 每笔以太坊网络的「领取交易」预计消耗 600000 Gas。"
+ "d2e crosschain gas tip 2": "· 每笔以太坊网络的「领取交易」预计消耗 600000 Gas。",
+ "Extension": "从插件获取",
+ "Manual": "手动输入",
+ "Please input the Darwinia address to be queried": "输入需要查询的 Darwinia 账号"
},
"crosschain_ethtron": {
"claim": "跨链转账",
diff --git a/src/page/CrossChain/index.js b/src/page/CrossChain/index.js
index 4acfa4d..79b14b8 100644
--- a/src/page/CrossChain/index.js
+++ b/src/page/CrossChain/index.js
@@ -1,5 +1,5 @@
import React, { Component } from "react";
-import { Button, Form, Spinner, Dropdown, ButtonGroup, Modal } from 'react-bootstrap'
+import { Button, Form, Spinner, Dropdown, ButtonGroup, Modal, Col } from 'react-bootstrap'
import { withRouter } from 'react-router-dom';
import 'react-toastify/dist/ReactToastify.css';
@@ -113,6 +113,11 @@ class CrossChain extends Component {
d2eModalData: {
isShow: false,
hash: ''
+ },
+ crabAndDarwiniaHistory: {
+ isManual: false,
+ address: '',
+ isFetchingClaimParams: false
}
}
this.querySubscribe = null
@@ -258,6 +263,8 @@ class CrossChain extends Component {
// this.querySubscribe = subscribe;
if (Array.isArray(_account) && _account.length > 0) {
initAccount = _account[0].address
+ } else if (Array.isArray(_account) && _account.length === 0) {
+ initAccount = ''
} else {
initAccount = _account
}
@@ -272,6 +279,7 @@ class CrossChain extends Component {
crossChainFee: Web3.utils.toBN(0),
}
}, async () => {
+
if (this.state.account[_networkType]) {
this.setState({
status: status
@@ -315,6 +323,11 @@ class CrossChain extends Component {
isReady: true
}
})
+ } else {
+ if (status === 4) {
+ this.queryClaims()
+ return;
+ }
}
})
}, t);
@@ -355,7 +368,6 @@ class CrossChain extends Component {
}, t);
break;
case 'darwinia':
-
this.setState({
history: null,
account: {
@@ -378,6 +390,8 @@ class CrossChain extends Component {
initAccount = this.state.account[_networkType]
} else if (Array.isArray(_account) && _account.length > 0) {
initAccount = _account[0].address
+ } else if (Array.isArray(_account) && _account.length === 0) {
+ initAccount = ''
} else {
initAccount = _account
}
@@ -388,7 +402,12 @@ class CrossChain extends Component {
...account,
[_networkType]: initAccount,
[`${_networkType}List`]: _account,
- isReady: false
+ isReady: false,
+ },
+ crabAndDarwiniaHistory: {
+ ...this.state.crabAndDarwiniaHistory,
+ isManual: !initAccount,
+ address: ''
}
}, async () => {
if (this.state.account[_networkType]) {
@@ -408,6 +427,11 @@ class CrossChain extends Component {
isReady: true
}
})
+ } else {
+ if (status === 4) {
+ this.queryClaims()
+ return;
+ }
}
})
}, t);
@@ -601,6 +625,10 @@ class CrossChain extends Component {
async queryClaims() {
const { networkType, account } = this.state;
let address = ''
+ this.setState({
+ history: null
+ })
+
switch (networkType) {
case "eth":
address = account[networkType]
@@ -669,27 +697,35 @@ class CrossChain extends Component {
break;
case "darwinia":
address = account[networkType]
- await getDarwiniaToEthereumGenesisSwapInfo({
- query: {
- address: '0x' + substrateAddressToPublicKey(address),
- row: 200,
- page: 0
- },
- method: "get"
- }, (list, data) => {
- this.setState({
- history: list,
- historyMeta: {
- best: data.best,
- mmrRoot: data.MMRRoot
- }
- })
- }, () => {
+ try {
+ await getDarwiniaToEthereumGenesisSwapInfo({
+ query: {
+ address: '0x' + substrateAddressToPublicKey(address),
+ row: 200,
+ page: 0
+ },
+ method: "get"
+ }, (list, data) => {
+ this.setState({
+ history: list,
+ historyMeta: {
+ best: data.best,
+ mmrRoot: data.MMRRoot
+ }
+ })
+ }, () => {
+ this.setState({
+ history: [],
+ historyMeta: {}
+ })
+ });
+ } catch (error) {
this.setState({
history: [],
historyMeta: {}
})
- });
+ }
+
break;
default:
break;
@@ -1298,7 +1334,7 @@ class CrossChain extends Component {
step4 = () => {
const { t } = this.props
- const { networkType, account, history } = this.state
+ const { networkType, account, history, crabAndDarwiniaHistory } = this.state
const middleScreen = isMiddleScreen()
return (
@@ -1311,32 +1347,78 @@ class CrossChain extends Component {
{networkType === 'crab' || networkType === 'darwinia' ?
<>
{convertSS58Address(account[networkType])}
-
- this.setCurrentAccount(networkType, value, async (account) => {
- // const balances = await getTokenBalance('crab', account);
- // this.setState({
- // ringBalance: Web3.utils.toBN(balances[0]),
- // darwiniaAddress: convertSS58Address(account)
- // })
- const params = new URLSearchParams()
- const {hash} = this.props.location;
-
- if (account) {
- params.append("address", account)
- } else {
- params.delete("address")
+
+ {crabAndDarwiniaHistory.isManual ?
+
+ this.setCurrentAccount(networkType, value, async (account) => {
+ const params = new URLSearchParams();
+ const {hash} = this.props.location;
+
+ if (account) {
+ params.append("address", account)
+ } else {
+ params.delete("address")
+ }
+ this.props.history.replace({hash: hash, search: params.toString()})
+
+ this.queryClaims()
+ })} type="text" placeholder={t('crosschain:Please input the Darwinia address to be queried')} />
+
+ :
+
+ this.setCurrentAccount(networkType, value, async (account) => {
+ // const balances = await getTokenBalance('crab', account);
+ // this.setState({
+ // ringBalance: Web3.utils.toBN(balances[0]),
+ // darwiniaAddress: convertSS58Address(account)
+ // })
+ const params = new URLSearchParams();
+ const {hash} = this.props.location;
+
+ if (account) {
+ params.append("address", account)
+ } else {
+ params.delete("address")
+ }
+ this.props.history.replace({hash: hash, search: params.toString()})
+
+ this.queryClaims()
+ })}>
+ {account[`${networkType}List`]?.map((item, index) => {
+ return
+ })
}
- this.props.history.replace({hash: hash, search: params.toString()})
+
+ }
+
+
+
- > : {account[networkType]}
}
+ this.queryClaims()
+ })
+ }
+ this.setState({crabAndDarwiniaHistory: {
+ ...this.state.crabAndDarwiniaHistory,
+ isManual: !crabAndDarwiniaHistory.isManual,
+ address: ''
+ }})
+ }
+ }>{crabAndDarwiniaHistory.isManual ? t('crosschain:Extension') : t('crosschain:Manual')}
+
+
+ > : {account[networkType]}
}
{networkType === 'eth' || networkType === 'tron' ? this.renderEthereumTronHistory(history) : null}
{networkType === 'darwinia' ? this.renderDarwiniaToEthereumHistory(history) : null}
@@ -1477,7 +1559,13 @@ class CrossChain extends Component {
chain: 'eth'
},
}, true, () =>
- item.signatures && !item.tx ?