Skip to content

Commit

Permalink
insufficient fee error controlling,using all coins functionality adde…
Browse files Browse the repository at this point in the history
…d and some other critical bugs removed
  • Loading branch information
bilalrns committed Dec 23, 2019
1 parent d513304 commit 9cfda8d
Show file tree
Hide file tree
Showing 17 changed files with 159 additions and 47 deletions.
32 changes: 25 additions & 7 deletions src/ActionModal/components/ActionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
step="0.000000001"
type="number"
min="0"
readonly
/>
<TmFormMsg
v-if="balanceInAtoms === 0"
Expand Down Expand Up @@ -514,7 +515,13 @@ export default {
this.gasEstimate = await this.actionManager.simulate(memo)
this.step = feeStep
} catch ({ message }) {
this.submissionError = `${this.submissionErrorPrefix}: ${message}.`
if(message.includes("insufficient")){
// ${this.submissionErrorPrefix}:
this.submissionError = `Insufficient Fees`
}
else {
this.submissionError = `${message}`
}
}
// limit fees to the maximum the user has
Expand All @@ -531,9 +538,8 @@ export default {
try {
await this.connectLedger()
} catch (error) {
this.submissionError = `${this.submissionErrorPrefix}: ${
error.message
}.`
// ${this.submissionErrorPrefix}:
this.submissionError = `${error.message}.`
this.sending = false
return
}
Expand Down Expand Up @@ -587,14 +593,16 @@ export default {
},
onSendingFailed(message) {
this.step = signStep
this.submissionError = `${this.submissionErrorPrefix}: ${message}.`
// ${this.submissionErrorPrefix}:
this.submissionError = `${message}.`
this.trackEvent(`event`, `failed-submit`, this.title, message)
},
async connectLedger() {
await this.$store.dispatch(`connectLedgerApp`)
},
gotostepone() {
this.step = defaultStep
this.gasPrice = config.default_gas_price.toFixed(9)
this.submissionError = null
},
gotosteptwo() {
Expand Down Expand Up @@ -703,8 +711,10 @@ export default {
margin: 15px 0;
}
.action-modal-footer .tm-form-group {
padding: 0;
@media screen and (max-width: 480px) {
#delegation-modal .action-modal-footer {
margin: 2.5rem 0 0 0
}
}
.submission-error {
Expand All @@ -721,6 +731,14 @@ export default {
display: inline-block;
}
#modal-propose .addressbreak {
word-break: break-word;
}
#modal-vote .addressbreak {
word-break: break-word;
}
.addressbreak {
word-break: break-all;
}
Expand Down
11 changes: 9 additions & 2 deletions src/ActionModal/components/DelegationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
:amount="isRedelegation() ? 0 : amount"
:title="isRedelegation() ? 'Redelegate' : 'Delegate'"
class="delegation-modal"
submission-error-prefix="Delegating failed"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
v-if="session.signedIn"
v-focus-last
>
<!-- submission-error-prefix="Delegating failed" -->
<TmFormGroup class="action-modal-form-group" field-id="to" field-label="To">
<TmField id="to" v-model="to" type="text" readonly />
</TmFormGroup>
Expand Down Expand Up @@ -55,7 +56,7 @@
{{ getFromBalance() }}
{{ denom | viewDenom }}
</span>
<TmFormMsg
<TmFormMsg
v-if="balance === 0"
:msg="`doesn't have any ${viewDenom(denom)}`"
name="Wallet"
Expand All @@ -78,6 +79,12 @@
name="Amount"
type="between"
/>
<TmFormMsg
v-else-if="amount == getFromBalance()"
msg="You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
class="tm-form-msg--desc"
type="custom"
/>
</TmFormGroup>
</ActionModal>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/ActionModal/components/ModalDeposit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
:amount="amount"
title="Deposit"
class="modal-deposit"
submission-error-prefix="Depositing failed"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
>
<!-- submission-error-prefix="Depositing failed" -->
<TmFormGroup
:error="$v.amount.$error && $v.amount.$invalid"
class="action-modal-form-group"
Expand Down
5 changes: 3 additions & 2 deletions src/ActionModal/components/ModalPropose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
:validate="validateForm"
:amount="amount"
title="Proposal"
submission-error-prefix="Submitting proposal failed"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
v-if="session.signedIn"
v-focus-last
>
<!-- submission-error-prefix="Submitting proposal failed" -->
<TmFormGroup
:error="$v.title.$error && $v.title.$invalid"
class="action-modal-form-group"
Expand Down Expand Up @@ -237,7 +238,7 @@ export default {
}),
watch: {
fundcycle (val) {
this.fundcycle = val.replace('.', '')
this.fundcycle = val.replace('.', '').replace('0','')
}
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/ActionModal/components/ModalVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
:validate="validateForm"
title="Vote"
class="modal-vote"
submission-error-prefix="Voting failed"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
v-if="session.signedIn"
>
<!-- submission-error-prefix="Voting failed" -->
<TmFormGroup class="action-modal-group vote-options">
<TmBtn
id="vote-yes"
Expand Down
2 changes: 1 addition & 1 deletion src/ActionModal/components/ModalWithdrawRewards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
:notify-message="notifyMessage"
title="Withdraw"
class="modal-withdraw-rewards"
submission-error-prefix="Withdrawal failed"
:disable="validatorsWithRewards"
>
<!-- submission-error-prefix="Withdrawal failed" -->
<span class="form-message notice withdraw-limit">
Color Wallet will only withdraw rewards from 5 validators at a time because of a
limitation with the Ledger Nano S.
Expand Down
25 changes: 22 additions & 3 deletions src/ActionModal/components/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
:validate="validateForm"
:amount="amount"
title="Send"
submission-error-prefix="Sending tokens failed"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
v-if="session.signedIn"
>
<!-- submission-error-prefix="Sending tokens failed" -->
<TmFormGroup
:error="$v.denom.$dirty && $v.denom.$invalid"
class="action-modal-form-group"
Expand Down Expand Up @@ -81,6 +81,12 @@
name="Amount"
type="between"
/>
<TmFormMsg
v-else-if="amount == num.atoms(balance)"
msg="You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
class="tm-form-msg--desc max-message"
type="custom"
/>
</TmFormGroup>
<TmBtn
v-if="editMemo === false"
Expand All @@ -95,7 +101,7 @@
v-if="editMemo"
id="memo"
:error="$v.memo.$error && $v.memo.$invalid"
class="action-modal-group"
class="action-modal-group memo"
field-id="memo"
field-label="Memo"
>
Expand All @@ -117,6 +123,7 @@
</template>

<script>
import num from "scripts/num"
import b32 from "scripts/b32"
import { required, between, decimal, maxLength } from "vuelidate/lib/validators"
import { uatoms, atoms, viewDenom, SMALLEST } from "src/scripts/num.js"
Expand All @@ -140,6 +147,7 @@ export default {
TmBtn
},
data: () => ({
num,
address: ``,
amount: null,
denom: ``,
Expand Down Expand Up @@ -238,8 +246,19 @@ export default {
#edit-memo-btn {
display: inline-block;
height: 58px;
padding: 12px 0;
padding: 2rem 0 0 0;
box-sizing: content-box;
font-size: var(--sm);
}
.memo {
padding: 1.5rem 0 0 0;
}
@media screen and (max-width: 390px) {
#edit-memo-btn {
padding: 3rem 0 0 0;
}
.memo {
padding: 2.5rem 0 0 0;
}
}
</style>
27 changes: 23 additions & 4 deletions src/ActionModal/components/SendModalQRCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
ref="actionModal"
:validate="validateForm"
:amount="amount"
title="Send"
submission-error-prefix="Sending tokens failed"
title="Send"
:transaction-data="transactionData"
:notify-message="notifyMessage"
@close="clear"
:show="true"
v-if="session.signedIn"
>
<!-- submission-error-prefix="Sending tokens failed" -->
<TmFormGroup
:error="$v.denom.$dirty && $v.denom.$invalid"
class="action-modal-form-group"
Expand Down Expand Up @@ -82,6 +82,12 @@
name="Amount"
type="between"
/>
<TmFormMsg
v-else-if="amount == num.atoms(balance)"
msg="You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
class="tm-form-msg--desc max-message"
type="custom"
/>
</TmFormGroup>
<TmBtn
v-if="editMemo === false"
Expand All @@ -96,7 +102,7 @@
v-if="editMemo"
id="memo"
:error="$v.memo.$error && $v.memo.$invalid"
class="action-modal-group"
class="action-modal-group memo"
field-id="memo"
field-label="Memo"
>
Expand All @@ -118,6 +124,7 @@
</template>

<script>
import num from "scripts/num"
import b32 from "scripts/b32"
import { required, between, decimal, maxLength } from "vuelidate/lib/validators"
import { uatoms, atoms, viewDenom, SMALLEST } from "src/scripts/num.js"
Expand All @@ -144,6 +151,7 @@ export default {
viewDenom
},
data: () => ({
num,
amount: null,
denom: ``,
memo: defaultMemo,
Expand Down Expand Up @@ -242,8 +250,19 @@ export default {
#edit-memo-btn {
display: inline-block;
height: 58px;
padding: 12px 0;
padding: 2rem 0 0 0;
box-sizing: content-box;
font-size: var(--sm);
}
.memo {
padding: 1.5rem 0 0 0;
}
@media screen and (max-width: 390px) {
#edit-memo-btn {
padding: 3rem 0 0 0;
}
.memo {
padding: 2.5rem 0 0 0;
}
}
</style>
Loading

0 comments on commit 9cfda8d

Please sign in to comment.