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

Feat/undeposit #343

Draft
wants to merge 4 commits into
base: suite
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ module.exports = {
'no-unused-vars': 'off',
'no-var': 'off',
'vue/multi-word-component-names': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
plugins: ['simple-import-sort'],
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
"vue-template-compiler": "^2.7.14",
"vue-virtual-scroll-list": "^2.3.2",
"vuex": "3.1.2",
"web3-eth": "1.3.6",
"web3": "^1.8.2",
"web3-eth": "1.3.6",
"webpack": "^5.57.1",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.3.1",
Expand All @@ -176,6 +176,7 @@
"dependencies": {
"@c4tplatform/signavaultjs": "^1.1",
"@cypress/xpath": "^2.0.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
"vue": "^2.6.11",
"vue-cli-plugin-vuetify": "^2.0.3",
"vuetify": "^2.6.14",
Expand Down
14 changes: 6 additions & 8 deletions src/components/wallet/earn/ClaimableRewardCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<p class="reward">{{ cleanAvaxBN(reward.amountToClaim) }} {{ nativeAssetSymbol }}</p>
</div>
<div class="claim_button_container">
<button
class="claim_button button_primary"
@click="openModal"
:disabled="!isClaimDisabled"
>
<CamBtn variant="primary" @click="openModal" :disabled="!isClaimDisabled">
{{ $t('earn.rewards.active_earning.claim') }}
</button>
</CamBtn>
</div>
<ModalClaimReward
ref="modal_claim_reward"
Expand All @@ -23,17 +19,19 @@
</template>
<script lang="ts">
import 'reflect-metadata'

import { BN } from '@c4tplatform/caminojs/dist'
import { Component, Prop, Vue } from 'vue-property-decorator'

import CamBtn from '@/components/CamBtn.vue'
import ModalClaimReward from '@/components/modals/ClaimRewardModal.vue'
import { cleanAvaxBN } from '@/helpers/helper'
import { PlatformRewardTreasury } from '@/store/modules/platform/types'

import { BN } from '@c4tplatform/caminojs/dist'

@Component({
components: {
ModalClaimReward,
CamBtn,
},
})
export default class ClaimableRewardCard extends Vue {
Expand Down
116 changes: 72 additions & 44 deletions src/components/wallet/earn/DepositRewardCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@
{{ cleanAvaxBN(reward.deposit.amount) }} {{ nativeAssetSymbol }}
</p>
</div>
<div>
<label>{{ $t('earn.rewards.active_earning.undepositable_amount') }}:</label>
<p class="reward">
{{ cleanAvaxBN(reward?.deposit?.unlockableAmount) }} {{ nativeAssetSymbol }}
</p>
</div>
<div>
<label>{{ $t('earn.rewards.active_earning.pending_reward') }}:</label>
<p class="reward">
{{ cleanAvaxBN(reward.amountToClaim) }} {{ nativeAssetSymbol }}
</p>
</div>
<div>
<label>{{ $t('earn.rewards.active_earning.already_undeposited') }}:</label>
<p class="reward">
{{ cleanAvaxBN(reward?.deposit?.unlockedAmount) }} {{ nativeAssetSymbol }}
</p>
</div>
<div>
<label>{{ $t('earn.rewards.active_earning.already_claimed') }}:</label>
<p class="reward">
Expand All @@ -43,41 +55,32 @@
</div>
</div>
<div v-if="!isMultiSig" class="button_group">
<v-btn
class="claim_button button_primary"
@click="openModal"
:disabled="isClaimDisabled"
>
<CamBtn variant="primary" @click="openUndepositModal" :disabled="isUndepositDisabled">
{{ $t('earn.rewards.active_earning.undeposit') }}
</CamBtn>
<CamBtn variant="primary" @click="openModal" :disabled="isClaimDisabled">
{{ $t('earn.rewards.active_earning.claim') }}
</v-btn>
</CamBtn>
</div>
<template v-else>
<div v-if="signatureStatus(reward.deposit.depositTxID) === 2" class="button_group">
<v-btn
class="claim_button button_secondary"
@click="openModal"
:disabled="isClaimDisabled"
>
<CamBtn variant="primary" @click="openModal" :disabled="isClaimDisabled">
{{ $t('earn.rewards.active_earning.execute_claim') }}
</v-btn>
<v-btn class="claim_button button_primary" @click="openAbortModal">
</CamBtn>
<CamBtn variant="negative" @click="openAbortModal">
{{ $t('earn.rewards.active_earning.abort') }}
</v-btn>
</CamBtn>
</div>
<div
v-else-if="signatureStatus(reward.deposit.depositTxID) === -1 && disclamer"
class="button_group"
>
<v-btn
class="claim_button bordered_button"
@click="openModal"
:disabled="isClaimDisabled"
>
<CamBtn variant="primary" @click="openModal" :disabled="isClaimDisabled">
{{ $t('earn.rewards.active_earning.initiate_transaction') }}
</v-btn>
<v-btn class="claim_button button_primary" @click="disclamer = false">
</CamBtn>
<CamBtn variant="transparent" @click="disclamer = false">
{{ $t('earn.rewards.active_earning.cancel') }}
</v-btn>
</CamBtn>
</div>
<div
v-else-if="
Expand All @@ -86,16 +89,16 @@
"
class="button_group"
>
<v-btn
class="claim_button bordered_button"
<CamBtn
variant="primary"
@click="signMultisigTx"
:disabled="alreadySigned(reward.deposit.depositTxID)"
>
{{ $t('earn.rewards.active_earning.sign') }}
</v-btn>
<v-btn class="claim_button button_primary" @click="openAbortModal">
</CamBtn>
<CamBtn variant="negative" @click="openAbortModal">
{{ $t('earn.rewards.active_earning.abort') }}
</v-btn>
</CamBtn>
</div>
<div
v-else-if="
Expand All @@ -104,8 +107,8 @@
"
class="button_group"
>
<v-btn
class="claim_button bordered_button"
<CamBtn
variant="primary"
@click="signMultisigTx"
:disabled="alreadySigned(reward.deposit.depositTxID)"
>
Expand All @@ -115,24 +118,32 @@
threshold: threshold,
})
}}
</v-btn>
<v-btn class="claim_button button_primary" @click="openAbortModal">
</CamBtn>
<CamBtn variant="negative" @click="openAbortModal">
{{ $t('earn.rewards.active_earning.abort') }}
</v-btn>
</CamBtn>
</div>
<div v-else class="button_group">
<v-btn
class="claim_button button_primary"
<CamBtn
variant="primary"
@click="openUndepositModal"
:disabled="isUndepositDisabled"
>
{{ $t('earn.rewards.active_earning.undeposit') }}
</CamBtn>
<CamBtn
variant="primary"
@click="disclamer = true"
:disabled="isClaimDisabled || disallowedClaim(reward.deposit.depositTxID)"
>
{{ $t('earn.rewards.active_earning.claim') }}
</v-btn>
</CamBtn>
</div>
<div v-if="disclamer && !alreadySigned(reward.deposit.depositTxID)" class="err">
{{ $t('earn.rewards.active_earning.are_you_sure') }}
</div>
</template>
<ModalUndeposit ref="modal_undeposit" />
<ModalClaimDepositReward
ref="modal_claim_reward"
:depositTxID="reward.deposit.depositTxID"
Expand All @@ -156,38 +167,44 @@
</template>
<script lang="ts">
import 'reflect-metadata'
import { Component, Prop, Vue } from 'vue-property-decorator'

import ModalClaimReward from '@/components/modals/ClaimRewardModal.vue'
import { cleanAvaxBN } from '@/helpers/helper'
import AvaAsset from '@/js/AvaAsset'
import { PlatformRewardDeposit } from '@/store/modules/platform/types'
import { BN, Buffer } from '@c4tplatform/caminojs/dist'
import { ClaimTx, UnsignedTx } from '@c4tplatform/caminojs/dist/apis/platformvm'
import { DepositOffer } from '@c4tplatform/caminojs/dist/apis/platformvm/interfaces'
import { ModelMultisigTxOwner } from '@c4tplatform/signavaultjs'
import { Component, Prop, Vue } from 'vue-property-decorator'

import { bintools } from '@/AVA'
import CamBtn from '@/components/CamBtn.vue'
import ModalClaimReward from '@/components/modals/ClaimRewardModal.vue'
import { ZeroBN } from '@/constants'
import { cleanAvaxBN } from '@/helpers/helper'
import { WalletHelper } from '@/helpers/wallet_helper'
import AvaAsset from '@/js/AvaAsset'
import { MultisigWallet } from '@/js/wallets/MultisigWallet'
import { WalletType } from '@/js/wallets/types'
import { PlatformRewardDeposit } from '@/store/modules/platform/types'
import { MultisigTx as SignavaultTx } from '@/store/modules/signavault/types'
import { BN, Buffer } from '@c4tplatform/caminojs/dist'
import { ClaimTx, UnsignedTx } from '@c4tplatform/caminojs/dist/apis/platformvm'
import { DepositOffer } from '@c4tplatform/caminojs/dist/apis/platformvm/interfaces'
import { ModelMultisigTxOwner } from '@c4tplatform/signavaultjs'

import ModalAbortSigning from './ModalAbortSigning.vue'
import ModalClaimDepositReward from './ModalClaimDepositReward.vue'
import ModalUndeposit from './ModalUndeposit.vue'

@Component({
components: {
ModalClaimReward,
ModalClaimDepositReward,
ModalAbortSigning,
ModalUndeposit,
CamBtn,
},
})
export default class DepositRewardCard extends Vue {
now: number = Date.now()
intervalID: any = null
claimDisabled: boolean = true
disclamer: boolean = false
// @ts-ignore
helpers = this.globalHelper()
// signedDepositID: string = ''
@Prop() reward!: PlatformRewardDeposit
Expand All @@ -196,6 +213,7 @@ export default class DepositRewardCard extends Vue {
// modal_claim_reward: ModalClaimReward
modal_claim_reward: ModalClaimDepositReward
modal_abort_signing: ModalAbortSigning
modal_undeposit: ModalUndeposit
}

openAbortModal() {
Expand Down Expand Up @@ -444,6 +462,10 @@ export default class DepositRewardCard extends Vue {
return this.reward.amountToClaim.isZero()
}

get isUndepositDisabled() {
return this.reward.deposit.unlockableAmount.isZero()
}

cleanAvaxBN(val: BN): string {
return cleanAvaxBN(val)
}
Expand All @@ -452,6 +474,11 @@ export default class DepositRewardCard extends Vue {
this.disclamer = false
this.$refs.modal_claim_reward.open()
}

openUndepositModal() {
this.disclamer = false
this.$refs.modal_undeposit.open()
}
}
</script>
<style scoped lang="scss">
Expand All @@ -476,6 +503,7 @@ export default class DepositRewardCard extends Vue {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 1.25rem;
margin-bottom: 1rem;
.offer_detail_left {
border-right: 2px solid var(--bg-wallet-light);
}
Expand Down
Loading
Loading