Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unbreak paratime withdraw #228

Merged
merged 6 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Change Log

## Unrelease changes
## Unreleased changes

New features:

- ParaTime withdrawals now automatically set the fee that will soon be required on Emerald
(0.00015 ROSE/TEST)

Little things:

- The advanced fee options now indicates the unit for the amount (nano ROSE/TEST).

Bug fixes:

- Brought ParaTime transaction hashing in sync with block explorer.
- Emerald transactions had mistakenly used a lower fee than configured, when using the advanced fee
options. This is corrected.
- Corrected how the total amount+fee is calculated when checking if you have enough funds for a
transaction.

## 1.2.0

Expand Down
6 changes: 4 additions & 2 deletions src/background/api/txHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,17 @@ export async function buildParatimeTxBody(params, wrapper) {
oasis.quantity.fromBigInt(amount),
oasisRT.token.NATIVE_DENOMINATION
]);
let feeAmount = params.feeAmount||0
// Fee amount idiosyncrasy: UI presents it in 1e-9 always, regardless of paratime setting.
let feeAmountDecimal = new BigNumber(10).pow(cointypes.decimals)
let feeAmount = new BigNumber(params.feeAmount||0).multipliedBy(decimal).dividedBy(feeAmountDecimal).toFixed()
pro-wh marked this conversation as resolved.
Show resolved Hide resolved
feeAmount = BigInt(feeAmount)
const FEE_FREE =([
oasis.quantity.fromBigInt(feeAmount),
oasisRT.token.NATIVE_DENOMINATION,
]);
feeAmount = FEE_FREE
// Use default if feeGas is "" or 0 (0 is illegal in send page)
let feeGas = params.feeGas||50000
let feeGas = params.feeGas||15000
pro-wh marked this conversation as resolved.
Show resolved Hide resolved
feeGas = BigInt(feeGas)
let consensusChainContext = await getChainContext(RETRY_TIME)
let txWrapper
Expand Down
15 changes: 10 additions & 5 deletions src/popup/pages/Send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class SendPage extends React.Component {
let runtimeType = params.accountType||""
let runtimeDecimals = params.decimals||cointypes.decimals
let isWithdraw = false
let defaultFeeAmount = "0"


let confirmTitle = ""
Expand Down Expand Up @@ -137,6 +138,9 @@ class SendPage extends React.Component {
toAddressCanInputDefaultValue = currentAccount.address
sendAction = WALLET_SEND_RUNTIME_WITHDRAW
}
// A wild guess: the minimum gas price on Emerald (10 nano ROSE) times the default loose
// overestimate of the gas (15k).
defaultFeeAmount = "150000"
}

pageTitle = getLanguage('send')
Expand Down Expand Up @@ -207,6 +211,7 @@ class SendPage extends React.Component {
toAddressShowValue,
runtimeType,
runtimeId,
defaultFeeAmount,
confirmTitle,
confirmToAddressTitle,
sendAction,
Expand Down Expand Up @@ -425,7 +430,7 @@ class SendPage extends React.Component {
/>}
<CustomInput
value={this.state.feeAmount}
placeholder={"Fee Amount"}
placeholder={`Fee Amount (nano ${this.props.netConfig.currentSymbol})`}
pro-wh marked this conversation as resolved.
Show resolved Hide resolved
onTextInput={this.onFeeInput}
/>
<CustomInput
Expand Down Expand Up @@ -541,9 +546,9 @@ class SendPage extends React.Component {
return
}

feeAmount = feeAmount || 0
feeAmount = feeAmount || this.pageConfig.defaultFeeAmount
tjanez marked this conversation as resolved.
Show resolved Hide resolved
feeGas = feeGas || 0
let payFee = new BigNumber(amountDecimals(feeAmount)).multipliedBy(feeGas).toString()
let payFee = new BigNumber(amountDecimals(feeAmount)).toString()


let checkStatus = this.checkBalanceEnough(amount,payFee)
Expand Down Expand Up @@ -622,7 +627,7 @@ class SendPage extends React.Component {
let nonce = trimSpace(this.state.nonce) || accountInfo.nonce
let fromAddress = currentAccount.address

let feeAmount = trimSpace(this.state.feeAmount)
let feeAmount = trimSpace(this.state.feeAmount) || this.pageConfig.defaultFeeAmount
let feeGas = trimSpace(this.state.feeGas)

let depositAddress = ""
Expand Down Expand Up @@ -734,7 +739,7 @@ class SendPage extends React.Component {
let netNonce = isNumber(accountInfo.nonce) ? accountInfo.nonce : ""
let nonce = this.state.nonce ? this.state.nonce : netNonce

let feeAmount = this.state.feeAmount ? this.state.feeAmount : 0
let feeAmount = this.state.feeAmount ? this.state.feeAmount : this.pageConfig.defaultFeeAmount
feeAmount = toNonExponential(amountDecimals(feeAmount, cointypes.decimals))
let title = ""
let toTitle = ""
Expand Down