Skip to content

Commit

Permalink
Merge pull request #61 from liquality/fix-send-max
Browse files Browse the repository at this point in the history
fixes for send amount
  • Loading branch information
bradleySuira authored Mar 1, 2021
2 parents 3b28bf7 + 212311e commit e8ac00d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "liquality-wallet",
"version": "0.17.7",
"version": "0.17.8",
"private": true,
"license": "MIT",
"author": "Liquality <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"version": "0.17.7",
"version": "0.17.8",
"name": "Liquality Wallet",
"description": "Secure multi-crypto wallet with built-in Atomic Swaps!",
"homepage_url": "https://liquality.io",
Expand Down
56 changes: 25 additions & 31 deletions src/views/Send.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<span class="input-group-text">{{ asset }}</span>
</div>
<input
type="text"
maxlength="8"
pattern="\d*"
type="number"
:min="0"
:max="dpUI(available)"
:class="{ 'is-invalid': amount && amountError }"
:style="getAssetColorStyle(asset)"
v-model="amount"
Expand Down Expand Up @@ -234,7 +234,7 @@ export default {
},
data () {
return {
stateAmount: BN(0),
amount: 0,
address: null,
selectedFee: 'average',
showConfirm: false,
Expand All @@ -246,27 +246,6 @@ export default {
asset: String
},
computed: {
amount: {
get () {
const uiAmount = dpUI(this.stateAmount)
if (uiAmount.gt(0)) {
return uiAmount
} else {
return this.stateAmount
}
},
set (newValue) {
if (newValue && !isNaN(newValue)) {
this.stateAmount = newValue
if (!BN(newValue).eq(this.available)) {
this.maxOptionActive = false
}
} else {
this.stateAmount = 0
this.maxOptionActive = false
}
}
},
...mapState([
'activeNetwork',
'activeWalletId',
Expand Down Expand Up @@ -332,7 +311,7 @@ export default {
return cryptoassets[this.asset].unitToCurrency(available)
},
amountInFiat () {
return prettyFiatBalance(this.stateAmount, this.fiatRates[this.asset])
return prettyFiatBalance(this.amount, this.fiatRates[this.asset])
},
totalFeeInFiat () {
return prettyFiatBalance(this.sendFee, this.fiatRates[this.asset])
Expand All @@ -347,11 +326,11 @@ export default {
return getFeeLabel(this.selectedFee)
},
totalToSendInFiat () {
const total = BN(this.stateAmount).plus(BN(this.sendFee))
const total = BN(this.amount).plus(BN(this.sendFee))
return prettyFiatBalance(total, this.fiatRates[this.asset])
},
amountWithFee () {
return BN(this.stateAmount).plus(BN(this.sendFee))
return BN(this.amount).plus(BN(this.sendFee))
}
},
methods: {
Expand All @@ -363,8 +342,10 @@ export default {
getAssetColorStyle,
shortenAddress,
async send () {
const amountToSend = this.maxOptionActive ? this.available : this.amount
const amount = cryptoassets[this.asset]
.currencyToUnit(this.stateAmount)
.currencyToUnit(amountToSend)
.toNumber()
const fee = this.feesAvailable
? this.assetFees[this.selectedFee].fee
Expand All @@ -385,7 +366,10 @@ export default {
toogleMaxAmount () {
this.maxOptionActive = !this.maxOptionActive
if (this.maxOptionActive) {
this.amount = this.available
this.amount = BN.min(
BN(this.available),
dpUI(this.available)
)
}
},
back () {
Expand All @@ -399,10 +383,20 @@ export default {
selectedFee: {
handler () {
if (this.maxOptionActive) {
this.amount = this.available
this.amount = BN.min(
BN(this.available),
dpUI(this.available)
)
}
},
deep: true
},
amount: function (val) {
const amount = BN(val)
const available = dpUI(this.available)
if (!amount.eq(available)) {
this.maxOptionActive = false
}
}
}
}
Expand Down

0 comments on commit e8ac00d

Please sign in to comment.