Skip to content

Commit

Permalink
fix: improve wallet prompts and update metaId Pin and UI messages
Browse files Browse the repository at this point in the history
1. Prompt 'wallet already exists' when importing an existing wallet account.
2. Update the warning message for unselected network service.
3. Correct metaId Pin image type verification.
4. Revise the backup page warning message.
  • Loading branch information
AricRedemption committed May 16, 2024
1 parent 387eb2a commit 852c0e2
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/pages/manage/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import AddIcon from '@/assets/icons-v3/add.svg'
import { goToTab, goToPage } from '@/lib/utils'
import { getBackupV3Wallet } from '@/lib/backup'
import { WalletsStore } from '@/stores/WalletStore'
import { Chain } from '@metalet/utxo-wallet-service'
import { notifyContent } from '@/lib/notify-content'
import PencilIcon from '@/assets/icons-v3/pencil.svg'
import { FlexBox, Divider, Button } from '@/components'
import { ArrowRightIcon } from '@heroicons/vue/20/solid'
Expand All @@ -19,8 +21,6 @@ import { useChainWalletsStore } from '@/stores/ChainWalletsStore'
import { getCurrentAccountId, setCurrentAccountId } from '@/lib/account'
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
import { getCurrentWalletId, setV3WalletsStorage, getV3WalletsStorage, setCurrentWalletId } from '@/lib/wallet'
import { notifyContent } from '@/lib/notify-content'
import { Chain } from '@metalet/utxo-wallet-service'
const { updateAllWallets, getAddress } = useChainWalletsStore()
Expand Down
1 change: 1 addition & 0 deletions src/pages/nfts/MetaIDPinList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const toMetaPinDetail = (metaPinId: string) => {
:value="metaPin.outputValue"
:contentType="metaPin.contentType"
:contentSummary="metaPin.contentSummary"
:contentTypeDetect="metaPin.contentTypeDetect"
/>
<span class="text-sm text-center mt-3 truncate" :title="'# ' + metaPin.number"># {{ metaPin.number }}</span>
<span class="text-xs text-center mt-1 h-[30px]">{{ formatTimestamp(metaPin.timestamp) }}</span>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/nfts/MetaPin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { value, content } = defineProps<{
value: number
content: string
contentSummary: string
contentTypeDetect: string
contentType: 'utf-8' | 'image/jpeg' | string
}>()
</script>
Expand All @@ -11,7 +12,7 @@ const { value, content } = defineProps<{
<div
class="flex items-center justify-center rounded-md xs:p-2 bg-[#F5F5F5] relative aspect-square w-full overflow-hidden"
>
<img :src="content" :alt="contentSummary" v-if="contentType === 'image/jpeg'" class="w-full h-full" />
<img :src="content" :alt="contentSummary" v-if="contentTypeDetect.includes('image')" class="w-full h-full" />
<div
v-else
:title="contentSummary"
Expand All @@ -22,8 +23,9 @@ const { value, content } = defineProps<{
<span
:title="`${value} sat`"
class="absolute rounded right-0 bottom-1 py-3px px-1.5 bg-[#EBECFF] text-[#787FFF] text-xs scale-75"
>{{ value }} sat</span
>
{{ value }} sat
</span>
</div>
</template>

Expand Down
8 changes: 4 additions & 4 deletions src/pages/nfts/MetaPinDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const toSendNFT = (id: string) => {
query: {
satoshis: metaPin.value?.outputValue,
content: metaPin.value?.contentSummary,
imgUrl: metaPin.value?.contentType === 'image/jpeg' ? metaPin.value?.content : undefined,
imgUrl: metaPin.value?.contentTypeDetect.includes('image') ? metaPin.value?.content : undefined,
},
})
}
Expand All @@ -33,22 +33,22 @@ const toSendNFT = (id: string) => {
<div class="w-full flex items-center justify-center">
<div
:class="[
metaPin.contentType !== 'image/jpeg' ? 'p-2 bg-blue-primary' : undefined,
{ 'p-2 bg-blue-primary': !metaPin.contentTypeDetect.includes('image') },
'w-[220px] h-[220px] flex items-center justify-center rounded-xl relative text-white',
]"
>
<img
alt=""
:src="metaPin.content"
v-if="metaPin.contentType === 'image/jpeg'"
v-if="metaPin.contentTypeDetect.includes('image')"
class="w-full h-full border-2 border-gray-soft rounded-xl"
/>
<div class="overflow-hidden line-clamp-6 break-all" v-else>{{ metaPin.contentSummary }}</div>
<span
:title="`${metaPin.outputValue} sat`"
:class="[
'absolute rounded right-3 bottom-3 py-3px px-1.5 text-xs',
metaPin.contentType === 'image/jpeg'
metaPin.contentTypeDetect.includes('image')
? 'bg-[#EBECFF] text-[#787FFF]'
: 'bg-[rgb(235,236,255,0.2) text-[#EBECFF]',
]"
Expand Down
4 changes: 2 additions & 2 deletions src/pages/wallet/Backup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const back = () => {

<div v-else-if="phase === 3">
<div class="pt-4 space-y-2">
<h3 class="text-2xl font-medium">Please enter your mnemonic phrase according to the sequence number.</h3>
<!-- <p class="text-sm text-gray-primary">Please fill in your mnemonic phrase according to the sequence number.</p> -->
<h3 class="text-2xl font-medium">Please Reconfirm Your Mnemonic Phrase</h3>
<p class="text-sm text-gray-primary">Please enter your mnemonic phrase according to the sequence number.</p>
</div>
<VerifySeedPhrase ref="verifySeedPhrase" :randomNum="4" :words="mnemonic.split(' ')" class="mt-8" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/wallet/SelectNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const chains = [
const formSchema = toTypedSchema(
z.object({
chains: z.array(z.string()).refine((value) => value.some((item) => item), {
message: 'Please select at least one network service.',
message: 'Please select at least one network service before launching.',
}),
})
)
Expand Down
3 changes: 2 additions & 1 deletion src/pages/wallet/components/NFTs/MetaIDPinList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { ref, computed } from 'vue'
import MetaPin from './MetaPin.vue'
import { useRouter } from 'vue-router'
import NO_NFT_DATA from './NoNFTData.vue'
import { LoadingText } from '@/components'
import { formatTimestamp } from '@/lib/formatters'
import { Chain } from '@metalet/utxo-wallet-service'
import LoadingIcon from '@/components/LoadingIcon.vue'
import { useMetaPinsInfiniteQuery } from '@/queries/metaPin'
import { useChainWalletsStore } from '@/stores/ChainWalletsStore'
import { LoadingText } from '@/components'
const size = ref(10)
const router = useRouter()
Expand Down Expand Up @@ -45,6 +45,7 @@ const toMetaPinDetail = (metaPinId: string) => {
:value="metaPin.outputValue"
:contentType="metaPin.contentType"
:contentSummary="metaPin.contentSummary"
:contentTypeDetect="metaPin.contentTypeDetect"
/>
<span class="text-sm text-center mt-3 truncate" :title="'# ' + metaPin.number"># {{ metaPin.number }}</span>
<span class="text-xs text-center mt-1 h-[30px]">{{ formatTimestamp(metaPin.timestamp) }}</span>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/wallet/components/NFTs/MetaPin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { value, content } = defineProps<{
value: number
content: string
contentSummary: string
contentTypeDetect: string
contentType: 'utf-8' | 'image/jpeg' | string
}>()
</script>
Expand All @@ -11,7 +12,7 @@ const { value, content } = defineProps<{
<div
class="flex items-center justify-center rounded-md xs:p-2 bg-[#F5F5F5] relative aspect-square w-full overflow-hidden"
>
<img :src="content" :alt="contentSummary" v-if="contentType === 'image/jpeg'" class="w-full h-full" />
<img :src="content" :alt="contentSummary" v-if="contentTypeDetect.includes('image')" class="w-full h-full" />
<div
v-else
:title="contentSummary"
Expand All @@ -22,8 +23,9 @@ const { value, content } = defineProps<{
<span
:title="`${value} sat`"
class="absolute rounded right-0 bottom-1 py-3px px-1.5 bg-[#EBECFF] text-[#787FFF] text-xs scale-75"
>{{ value }} sat</span
>
{{ value }} sat
</span>
</div>
</template>

Expand Down
6 changes: 3 additions & 3 deletions src/pages/welcome/components/Activate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const chains = [
const formSchema = toTypedSchema(
z.object({
chains: z.array(z.string()).refine((value) => value.some((item) => item), {
message: 'Please select at least one network service.',
message: 'Please select at least one network service before launching.',
}),
})
)
Expand Down Expand Up @@ -201,7 +201,7 @@ onMounted(async () => {
</FormItem>
</FormField>
</FormItem>
<FormMessage class="text-red-500 text-ss text-center absolute bottom-[80px] w-full" />
<FormMessage class="text-red-500 text-ss text-center absolute bottom-[60px] w-full" />
</FormField>

<button
Expand All @@ -215,7 +215,7 @@ onMounted(async () => {
</button>
</form>
</template>
<Button v-else :class="['mt-26 w-61.5']" @click="$router.go(0)">Back To Step 1</Button>
<Button v-else :class="['mt-26 w-61.5']" @click="$router.replace('/welcome')">Back To Welcome</Button>
<div class="mt-4 text-center text-sm text-red-500" v-if="error">{{ error }}</div>
</div>
</div>
Expand Down
17 changes: 15 additions & 2 deletions src/pages/welcome/components/ImportPhrase.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts" setup>
import { ref, computed, watch } from 'vue'
import { getV3Wallets } from '@/lib/wallet'
import BrushIcon from '@/assets/icons-v3/brush.svg'
import { FlexBox, Button, SeedPhrase } from '@/components'
import ArrowLeftIcon from '@/assets/icons-v3/arrow-left.svg'
Expand All @@ -21,6 +22,7 @@ const finished = computed(() => props.words.every((word) => word.length > 0))
const emit = defineEmits(['nextStep'])
const clearWords = () => {
error.value = ''
props.words.splice(0, props.words.length, ...Array(Number(wordsLen.value)).fill(''))
}
Expand All @@ -37,6 +39,16 @@ const onPasteWords = (e: ClipboardEvent) => {
}
}
const next = async () => {
const wallets = await getV3Wallets()
const hasWallet = wallets.find((wallet) => wallet.mnemonic === props.words.join(' '))
if (hasWallet) {
error.value = 'Wallet already exists.'
return
}
emit('nextStep')
}
watch(
() => wordsLen.value,
() => {
Expand Down Expand Up @@ -76,9 +88,10 @@ watch(
<SeedPhrase :onPasteWords="onPasteWords" :words="words" />

<Button
@click="next"
type="primary"
@click="emit('nextStep')"
:class="['w-61.5 mt-15 mx-auto', { 'cursor-not-allowed opacity-50': !finished }]"
:disabled="!finished || !!error"
:class="['w-61.5 mt-15 mx-auto', { 'cursor-not-allowed opacity-50': !finished || error }]"
>
Next
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/queries/metaPin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface MetaIDPin {
contentBody: string
contentLength: number
contentSummary: string
contentTypeDetect: string
}

export async function fetchMetaPins(
Expand Down

0 comments on commit 852c0e2

Please sign in to comment.