Skip to content

Commit

Permalink
fix networkFee
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonHJ committed Nov 15, 2022
1 parent 3a702ab commit 74802eb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
Expand Up @@ -133,6 +133,7 @@ class CrossETHForm extends Component {

handleNext = () => {
const { updateTransParams, settings, form, from, type, getChainAddressInfoByChain, currentTokenPairInfo: info } = this.props;
const { networkFee } = this.state
let toAddrInfo = getChainAddressInfoByChain(info[type === INBOUND ? 'toChainSymbol' : 'fromChainSymbol']);
let isNativeAccount = false; // Figure out if the to value is contained in my wallet.
form.validateFields(['from', 'balance', 'storemanAccount', 'quota', 'to', 'totalFee', 'amount'], { force: true }, (err, values) => {
Expand Down Expand Up @@ -171,12 +172,12 @@ class CrossETHForm extends Component {
if (err) {
message.warn(intl.get('Backup.invalidPassword'));
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount), networkFee });
this.setState({ confirmVisible: true });
}
})
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount), networkFee });
this.setState({ confirmVisible: true });
}
});
Expand Down
Expand Up @@ -186,12 +186,12 @@ class CrossWANForm extends Component {
if (err) {
message.warn(intl.get('Backup.invalidPassword'));
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendValue) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendValue), networkFee });
this.setState({ confirmVisible: true });
}
})
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendValue) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendValue), networkFee });
this.setState({ confirmVisible: true });
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/CrossChain/CrossChainTransForm/index.js
Expand Up @@ -131,6 +131,7 @@ class CrossChainTransForm extends Component {

handleNext = () => {
const { updateTransParams, settings, form, from, type, getChainAddressInfoByChain, currentTokenPairInfo: info } = this.props;
const { networkFee } = this.state;
let toAddrInfo = getChainAddressInfoByChain(info[type === INBOUND ? 'toChainSymbol' : 'fromChainSymbol']);
let isNativeAccount = false; // Figure out if the to value is contained in my wallet.
form.validateFields(['from', 'balance', 'storemanAccount', 'quota', 'to', 'totalFee', 'amount'], { force: true }, async (err, { pwd, amount: sendAmount, to }) => {
Expand Down Expand Up @@ -180,12 +181,12 @@ class CrossChainTransForm extends Component {
if (err) {
message.warn(intl.get('Backup.invalidPassword'));
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount), networkFee });
this.setState({ confirmVisible: true });
}
})
} else {
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount) });
updateTransParams(from, { to: toValue ? { walletID, path: toPath } : to, toAddr: to, amount: formatAmount(sendAmount), networkFee });
this.setState({ confirmVisible: true });
}
});
Expand Down
7 changes: 5 additions & 2 deletions src/app/containers/CrossChain/CrossETH/index.js
Expand Up @@ -72,8 +72,10 @@ class CrossETH extends Component {
gasLimit: transParams.gasLimit,
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType
crossType: transParams.crossType,
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
};

return new Promise((resolve, reject) => {
wand.request('crossChain_crossChain', { input, tokenPairID, sourceSymbol: info.fromChainSymbol, sourceAccount: info.fromAccount, destinationSymbol: info.toChainSymbol, destinationAccount: info.toAccount, type: 'LOCK' }, (err, ret) => {
console.log('ETH inbound result:', err, ret);
Expand Down Expand Up @@ -111,7 +113,8 @@ class CrossETH extends Component {
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType,
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10),
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
};

return new Promise((resolve, reject) => {
Expand Down
6 changes: 4 additions & 2 deletions src/app/containers/CrossChain/CrossWAN/index.js
Expand Up @@ -75,7 +75,8 @@ class CrossWAN extends Component {
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType,
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10),
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
};
return new Promise((resolve, reject) => {
if (input.from.walletID === 2) {
Expand Down Expand Up @@ -126,7 +127,8 @@ class CrossWAN extends Component {
gasLimit: transParams.gasLimit,
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType
crossType: transParams.crossType,
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
};
return new Promise((resolve, reject) => {
wand.request('crossChain_crossChain', { input, tokenPairID, sourceSymbol: info.toChainSymbol, sourceAccount: info.toAccount, destinationSymbol: info.fromChainSymbol, destinationAccount: info.fromAccount, type: 'LOCK' }, (err, ret) => {
Expand Down
6 changes: 4 additions & 2 deletions src/app/containers/CrossChain/index.js
Expand Up @@ -101,7 +101,8 @@ class CrossChain extends Component {
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType,
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10),
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, 18)).toString(10)
};

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -154,7 +155,8 @@ class CrossChain extends Component {
storeman: transParams.storeman,
tokenPairID: tokenPairID,
crossType: transParams.crossType,
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10)
amountUnit: new BigNumber(transParams.amount).multipliedBy(Math.pow(10, info.ancestorDecimals)).toString(10),
networkFee: new BigNumber(transParams.networkFee).multipliedBy(Math.pow(10, 18)).toString(10)
};

return new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions src/app/stores/sendCrossChainParams.js
Expand Up @@ -89,6 +89,7 @@ class SendCrossChainParams {
txFeeRatio: 0,
gasLimit: GASLIMIT,
crossType: params.crossType ? params.crossType : CROSS_TYPE[0],
networkFee: '0'
};
}

Expand Down

0 comments on commit 74802eb

Please sign in to comment.