From 1cf0fd0fa48a2648396b4c00c9a08f1cefd817e4 Mon Sep 17 00:00:00 2001 From: Warren He Date: Fri, 21 Jan 2022 12:26:45 -0800 Subject: [PATCH 1/6] changelog: fix heading --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e716329b..1f596376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## Unrelease changes +## Unreleased changes Bug fixes: From 7842ad2293f359ad3f34f428eb39db1f9416d5c7 Mon Sep 17 00:00:00 2001 From: Warren He Date: Wed, 19 Jan 2022 17:02:17 -0800 Subject: [PATCH 2/6] background/txHelper: correct fee amount for paratime The fee entry UI specifically deals with nano (1e-9) units, not base units. In paratimes that have decimals != 9, this produced the wrong gas amount. --- CHANGELOG.md | 2 ++ src/background/api/txHelper.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f596376..77c405b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ 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. ## 1.2.0 diff --git a/src/background/api/txHelper.js b/src/background/api/txHelper.js index e9e75df5..a38209f8 100644 --- a/src/background/api/txHelper.js +++ b/src/background/api/txHelper.js @@ -299,7 +299,9 @@ 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() feeAmount = BigInt(feeAmount) const FEE_FREE =([ oasis.quantity.fromBigInt(feeAmount), From 0791c7357864e9d4ea3a653bf6036ec685a9a292 Mon Sep 17 00:00:00 2001 From: Warren He Date: Wed, 19 Jan 2022 17:05:29 -0800 Subject: [PATCH 3/6] pages/Send: show unit in fee field --- CHANGELOG.md | 4 ++++ src/popup/pages/Send/index.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c405b7..01888bc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased changes +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. diff --git a/src/popup/pages/Send/index.js b/src/popup/pages/Send/index.js index 2272013c..fade035c 100644 --- a/src/popup/pages/Send/index.js +++ b/src/popup/pages/Send/index.js @@ -425,7 +425,7 @@ class SendPage extends React.Component { />} Date: Wed, 19 Jan 2022 17:06:19 -0800 Subject: [PATCH 4/6] pages/Send: correct balance check The fee amount is the total fee. We shouldn't multiply it by the gas. --- CHANGELOG.md | 2 ++ src/popup/pages/Send/index.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01888bc2..dedc28d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ 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 diff --git a/src/popup/pages/Send/index.js b/src/popup/pages/Send/index.js index fade035c..a2c07351 100644 --- a/src/popup/pages/Send/index.js +++ b/src/popup/pages/Send/index.js @@ -543,7 +543,7 @@ class SendPage extends React.Component { feeAmount = feeAmount || 0 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) From b36e7f0f0050c4b9cb5910cc9591429a085dd2ac Mon Sep 17 00:00:00 2001 From: Warren He Date: Wed, 19 Jan 2022 17:07:18 -0800 Subject: [PATCH 5/6] pages/Send: add default fee An upcoming change to Emerald will require a minimum gas price. --- CHANGELOG.md | 5 +++++ src/popup/pages/Send/index.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dedc28d6..21158895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased changes +New features: + +- ParaTime withdrawals now automatically set the fee that will soon be required on Emerald + (0.0005 ROSE/TEST) + Little things: - The advanced fee options now indicates the unit for the amount (nano ROSE/TEST). diff --git a/src/popup/pages/Send/index.js b/src/popup/pages/Send/index.js index a2c07351..09c5d80c 100644 --- a/src/popup/pages/Send/index.js +++ b/src/popup/pages/Send/index.js @@ -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 = "" @@ -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 (50k). + defaultFeeAmount = "500000" } pageTitle = getLanguage('send') @@ -207,6 +211,7 @@ class SendPage extends React.Component { toAddressShowValue, runtimeType, runtimeId, + defaultFeeAmount, confirmTitle, confirmToAddressTitle, sendAction, @@ -541,7 +546,7 @@ class SendPage extends React.Component { return } - feeAmount = feeAmount || 0 + feeAmount = feeAmount || this.pageConfig.defaultFeeAmount feeGas = feeGas || 0 let payFee = new BigNumber(amountDecimals(feeAmount)).toString() @@ -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 = "" @@ -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 = "" From 2691cf2a2405e45bd9469a02fcab682c2ce11ecc Mon Sep 17 00:00:00 2001 From: Warren He Date: Thu, 20 Jan 2022 12:24:44 -0800 Subject: [PATCH 6/6] background/txHelper: lower deposit/withdraw gas An estimate from the SDK CLI indicated that it was ~11287 gas. --- CHANGELOG.md | 2 +- src/background/api/txHelper.js | 2 +- src/popup/pages/Send/index.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21158895..2d788ce8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ New features: - ParaTime withdrawals now automatically set the fee that will soon be required on Emerald - (0.0005 ROSE/TEST) + (0.00015 ROSE/TEST) Little things: diff --git a/src/background/api/txHelper.js b/src/background/api/txHelper.js index a38209f8..b3268790 100644 --- a/src/background/api/txHelper.js +++ b/src/background/api/txHelper.js @@ -309,7 +309,7 @@ export async function buildParatimeTxBody(params, wrapper) { ]); 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 feeGas = BigInt(feeGas) let consensusChainContext = await getChainContext(RETRY_TIME) let txWrapper diff --git a/src/popup/pages/Send/index.js b/src/popup/pages/Send/index.js index 09c5d80c..7f8513cc 100644 --- a/src/popup/pages/Send/index.js +++ b/src/popup/pages/Send/index.js @@ -139,8 +139,8 @@ class SendPage extends React.Component { 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 (50k). - defaultFeeAmount = "500000" + // overestimate of the gas (15k). + defaultFeeAmount = "150000" } pageTitle = getLanguage('send')