-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/mvc-labs/metalet-extension
- Loading branch information
Showing
8 changed files
with
177 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts" setup> | ||
import { useRouter } from 'vue-router' | ||
import { ChevronRightIcon } from '@heroicons/vue/20/solid' | ||
const router = useRouter() | ||
const toSpaceMerge = () => { | ||
router.push('/settings/toolkit/space-merge') | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="space-y-8 pt-4 text-sm"> | ||
<!-- security --> | ||
<div class="space-y-2"> | ||
<div class="divide-y divide-gray-100"> | ||
<div class="setting-item group cursor-pointer" @click="toSpaceMerge"> | ||
<div class="text-gray-500 group-hover:underline">Space Merge</div> | ||
<div class=""> | ||
<ChevronRightIcon class="link-icon" /> | ||
</div> | ||
</div> | ||
|
||
<div class="setting-item group cursor-not-allowed" title="coming sonn"> | ||
<div class="text-gray-500 group-hover:underline">Ft Merge</div> | ||
<div class=""> | ||
<ChevronRightIcon class="link-icon" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style lang="css" scoped> | ||
.setting-item { | ||
@apply -mx-2 flex items-center justify-between px-2 py-4 transition-all duration-200 ease-in-out hover:bg-gray-300/20; | ||
} | ||
.link-icon { | ||
@apply h-4 w-4 text-gray-500 group-hover:text-blue-500; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref } from 'vue' | ||
import { FEEB } from '@/data/config' | ||
import { getApiHost } from '@/lib/host' | ||
import { getNetwork } from '@/lib/network' | ||
import { getPrivateKey, getAddress } from '@/lib/account' | ||
import { API_NET, API_TARGET, Wallet } from 'meta-contract' | ||
import { useMVCUTXOQuery } from '@/queries/utxos' | ||
import { fetchSpaceBalance } from '@/queries/balance' | ||
import TransactionResultModal, { type TransactionResult } from '@/pages/wallet/components/TransactionResultModal.vue' | ||
const address = ref() | ||
const isOpenResultModal = ref(false) | ||
const transactionResult = ref<TransactionResult | undefined>() | ||
const merge = async () => { | ||
const network: API_NET = (await getNetwork()) as API_NET | ||
const purse = await getPrivateKey('mvc') | ||
const apiHost = await getApiHost() | ||
const wallet = new Wallet(purse, network, FEEB, API_TARGET.MVC, apiHost) | ||
let { txId } = await wallet.merge().catch((err) => { | ||
isOpenResultModal.value = true | ||
transactionResult.value = { | ||
status: 'warning', | ||
message: err.message, | ||
} | ||
throw err | ||
}) | ||
isOpenResultModal.value = true | ||
const balance = await fetchSpaceBalance(address.value) | ||
transactionResult.value = { | ||
chain: 'mvc', | ||
status: 'success', | ||
txId, | ||
fromAddress: address.value, | ||
toAdddress: address.value, | ||
amount: balance.total, | ||
token: { | ||
symbol: 'SPACE', | ||
decimal: 8, | ||
}, | ||
} | ||
} | ||
getAddress('mvc').then((_address) => { | ||
address.value = _address | ||
}) | ||
const { data } = useMVCUTXOQuery(address, { enabled: computed(() => !!address.value) }) | ||
</script> | ||
|
||
<template> | ||
<div class="space-y-4"> | ||
<div class="space-y-2"> | ||
<div class="label">MVC Address</div> | ||
<div class="value">{{ address }}</div> | ||
</div> | ||
|
||
<div class="space-y-2"> | ||
<div class="label">UTXO Count</div> | ||
<div class="value">{{ data?.length ? (data.length >= 300 ? '>=300' : data.length) : '--' }}</div> | ||
</div> | ||
|
||
<button | ||
@click="merge" | ||
:disabled="!data || data.length < 3" | ||
:class="[ | ||
'bg-primary-blue text-white py-2 rounded-md text-xs w-full', | ||
!data || data.length < 3 ? 'cursor-not-allowed opacity-50' : null, | ||
]" | ||
> | ||
Merge | ||
</button> | ||
<TransactionResultModal v-model:is-open-result="isOpenResultModal" :result="transactionResult" /> | ||
</div> | ||
</template> | ||
|
||
<style lang="css" scoped> | ||
.label { | ||
@apply text-sm font-bold text-gray-500; | ||
} | ||
.value { | ||
@apply text-sm text-gray-700; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters