Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 614a3b0
Author: Viki Val <[email protected]>
Date:   Tue Aug 15 13:02:11 2023 +0300

    :nail_care: Error into composition API (kodadot#6715)

commit c3ff15d
Merge: d3e2124 3cde46d
Author: Matej yangwao <[email protected]>
Date:   Tue Aug 15 11:32:36 2023 +0200

    Merge pull request kodadot#6712 from floyd-li/fix/6706

commit d3e2124
Merge: df0e9f6 083969e
Author: Matej yangwao <[email protected]>
Date:   Tue Aug 15 11:28:27 2023 +0200

    Merge pull request kodadot#6695 from Jarsen136/issue-6466

commit df0e9f6
Author: Jarsen <[email protected]>
Date:   Tue Aug 15 16:50:35 2023 +0800

    fix: forbiding landing page on DOT (kodadot#6710)

commit 3cde46d
Author: Floyd Li <[email protected]>
Date:   Tue Aug 15 15:52:43 2023 +0800

    fix: remove console error

commit c96e3f9
Merge: 3fa9006 b8ddaca
Author: Matej yangwao <[email protected]>
Date:   Tue Aug 15 09:24:43 2023 +0200

    Merge pull request kodadot#6699 from kodadot/renovate/bumped-minor-version-of-packages

    [skip netlify] Update Bumped minor version of packages

commit b8ddaca
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Aug 14 20:29:13 2023 +0000

    [skip netlify] Update Bumped minor version of packages

commit 083969e
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 23:42:30 2023 +0800

    fix: font size

commit ccf5a59
Merge: 03c51d1 d3102c9
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 22:53:47 2023 +0800

    Merge branch 'issue-6466' of github.com:Jarsen136/nft-gallery into issue-6466

commit 03c51d1
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 22:53:23 2023 +0800

    fix: transfer redesign

commit d3102c9
Merge: cc0d9d7 b123f32
Author: Viki Val <[email protected]>
Date:   Mon Aug 14 13:58:45 2023 +0300

    Merge branch 'main' into issue-6466

commit cc0d9d7
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 13:44:33 2023 +0800

    Revert "fix: flex to table"

    This reverts commit f3644a6.

commit f3644a6
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 10:51:25 2023 +0800

    fix: flex to table

commit 460345b
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 09:45:40 2023 +0800

    fix: UI issue

commit 9eb4954
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 00:25:46 2023 +0800

    fix: total value

commit 881a3b7
Author: Jarsen <[email protected]>
Date:   Mon Aug 14 00:04:41 2023 +0800

    fix: redesign issue

commit 0be1770
Author: Jarsen <[email protected]>
Date:   Sun Aug 13 21:39:12 2023 +0800

    feat: transfer transaction

commit 5911cb6
Author: Jarsen <[email protected]>
Date:   Sun Aug 13 20:58:30 2023 +0800

    feat: Transfer Redesign handover - (2) Transaction confirm
  • Loading branch information
floyd-li committed Aug 15, 2023
1 parent 9502da6 commit 0d6dc5f
Show file tree
Hide file tree
Showing 10 changed files with 1,231 additions and 927 deletions.
9 changes: 7 additions & 2 deletions components/landing/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@
<script lang="ts" setup>
import type { Prefix } from '@kodadot1/static'
const hiddenCarrouselPrefixes: Prefix[] = ['movr', 'glmr']
const forbiddenPrefixesForTopCollections: Prefix[] = ['ksm', 'ahk', 'ahp']
const hiddenCarrouselPrefixes: Prefix[] = ['movr', 'glmr', 'dot']
const forbiddenPrefixesForTopCollections: Prefix[] = [
'ksm',
'ahk',
'ahp',
'dot',
]
const { urlPrefix } = usePrefix()
Expand Down
29 changes: 16 additions & 13 deletions components/shared/Error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
</p>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'nuxt-property-decorator'
@Component({})
export default class Error extends Vue {
@Prop({ default: 500 }) readonly errorCode!: number
@Prop({ default: true }) readonly hasImg!: boolean
@Prop({ default: 'Indexer Error' }) errorTitle!: string
@Prop({ default: 'Indexer is not working properly.' }) errorSubtitle!: string
get imgSrc() {
return `https://http.cat/${this.$props.errorCode}`
<script setup lang="ts">
const props = withDefaults(
defineProps<{
errorCode: number
hasImg: boolean
errorTitle: string
errorSubtitle: string
}>(),
{
errorCode: 500,
hasImg: true,
errorTitle: 'Indexer Error',
errorSubtitle: 'Indexer is not working properly.',
}
}
)
const imgSrc = computed(() => `https://http.cat/${props.errorCode}`)
</script>
97 changes: 64 additions & 33 deletions components/transfer/Transfer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="transfer-card theme-background-color k-shadow border py-8 px-6">
<Loader v-model="isLoading" :status="status" />
<div
class="is-flex is-justify-content-space-between is-align-items-center mb-2">
<p class="has-text-weight-bold is-size-3">
Expand All @@ -25,7 +26,7 @@

<div class="is-flex mb-5">
<div class="token-price py-2 px-4 is-flex is-align-items-center">
<img class="mr-2 is-20x20" :src="tokenIcon" alt="token" />
<img class="mr-2 square-20" :src="tokenIcon" alt="token" />
{{ unit }} ${{ currentTokenValue }}
</div>
</div>
Expand Down Expand Up @@ -169,11 +170,13 @@
$t('spotlight.total')
}}</span>
<div class="is-flex is-align-items-center">
<span class="is-size-7 has-text-grey mr-1">(${{ totalUsdValue }})</span>

<span class="has-text-weight-bold is-size-6"
>{{ totalTokenAmount }} {{ unit }}</span
<span class="is-size-7 has-text-grey mr-1"
>({{ displayTotalValue[0] }})</span
>

<span class="has-text-weight-bold is-size-6">{{
displayTotalValue[1]
}}</span>
</div>
</div>

Expand All @@ -182,10 +185,18 @@
class="is-flex is-flex-1 fixed-height"
variant="k-accent"
:disabled="disabled"
@click.native="submit"
@click.native="handleOpenConfirmModal"
>{{ $t('redirect.continue') }}</NeoButton
>
</div>
<TransferConfirmModal
:is-modal-active="isTransferModalVisible"
:display-total-value="displayTotalValue"
:token-icon="tokenIcon"
:unit="unit"
:target-addresses="targetAddresses"
@close="isTransferModalVisible = false"
@confirm="submit" />
</div>
</template>

Expand All @@ -208,8 +219,7 @@ import { useFiatStore } from '@/stores/fiat'
import { useIdentityStore } from '@/stores/identity'
import Avatar from '@/components/shared/Avatar.vue'
import Identity from '@/components/identity/IdentityIndex.vue'
import { emptyObject } from '@kodadot1/minimark/utils'
import TransferConfirmModal from '@/components/transfer/TransferConfirmModal.vue'
import {
NeoButton,
NeoDropdown,
Expand All @@ -231,16 +241,14 @@ const { unit, decimals } = useChain()
const { apiInstance } = useApi()
const { urlPrefix } = usePrefix()
const { isLogIn, accountId } = useAuth()
const { redesign } = useExperiments()
const { getAuthBalance } = useIdentityStore()
const { fetchFiatPrice, getCurrentTokenValue } = useFiatStore()
const { initTransactionLoader, isLoading, resolveStatus } =
const { initTransactionLoader, isLoading, resolveStatus, status } =
useTransactionStatus()
const { toast } = useToast()
const isTransferModalVisible = ref(false)
type Target = 'target' | `target${number}`
type TargetMap = Record<Target, string>
type TargetAddress = {
export type TargetAddress = {
address?: string
usd?: number | string
token?: number | string
Expand All @@ -249,7 +257,6 @@ type TargetAddress = {
const transactionValue = ref('')
const price = ref(0)
const usdValue = ref(0)
const targets = ref(emptyObject<TargetMap>())
const sendSameAmount = ref(false)
const displayUnit = ref<'token' | 'usd'>('token')
const { getTokenIconBySymbol } = useIcon()
Expand All @@ -262,6 +269,12 @@ const hasValidTarget = computed(() =>
targetAddresses.value.some((item) => isAddress(item.address) && item.token)
)
const displayTotalValue = computed(() =>
displayUnit.value === 'token'
? [`$${totalUsdValue.value}`, `${totalTokenAmount.value} ${unit.value}`]
: [`${totalTokenAmount.value} ${unit.value}`, `$${totalUsdValue.value}`]
)
const balance = getAuthBalance
const disabled = computed(
() =>
Expand Down Expand Up @@ -326,10 +339,12 @@ watch(sendSameAmount, (value) => {
})
const totalTokenAmount = computed(() =>
Number(getNumberSumOfObjectField(targetAddresses.value, 'token')).toFixed(4)
Number(
Number(getNumberSumOfObjectField(targetAddresses.value, 'token')).toFixed(4)
)
)
const totalUsdValue = computed(() =>
getNumberSumOfObjectField(targetAddresses.value, 'usd')
calculateUsdFromKsm(totalTokenAmount.value, Number(currentTokenValue.value))
)
const currentTokenValue = computed(() => getCurrentTokenValue(unit.value))
Expand All @@ -339,6 +354,7 @@ const balanceUsdValue = computed(() =>
decimals.value
)
)
const onAmountFieldChange = (target: TargetAddress) => {
/* calculating usd value on the basis of price entered */
Expand Down Expand Up @@ -382,34 +398,48 @@ const unifyAddressAmount = (target: TargetAddress) => {
}))
}
const handleOpenConfirmModal = () => {
if (!disabled.value) {
targetAddresses.value = targetAddresses.value.filter(
(address) => address.address && address.token && address.usd
)
isTransferModalVisible.value = true
}
}
const submit = async (
event: any,
usedNodeUrls: string[] = []
): Promise<void> => {
if (redesign.value) {
showNotification('coming soon')
return
}
showNotification(`${route.query.target ? 'Sent for Sign' : 'Dispatched'}`)
isTransferModalVisible.value = false
initTransactionLoader()
try {
const api = await apiInstance.value
const amountToTansfer = String(
calculateBalance(price.value, decimals.value)
)
const numOfTargetAddresses = Object.keys(targets.value).length
const numOfTargetAddresses = targetAddresses.value.length
const cb =
numOfTargetAddresses > 1 ? api.tx.utility.batch : api.tx.balances.transfer
const arg =
numOfTargetAddresses > 1
? [
Object.values(targets.value).map((target) =>
api.tx.balances.transfer(target, amountToTansfer)
targetAddresses.value.map((target) => {
const amountToTransfer = String(
calculateBalance(Number(target.token), decimals.value)
)
return api.tx.balances.transfer(
target.address as string,
amountToTransfer
)
}),
]
: [
targetAddresses.value[0].address as string,
calculateBalance(
Number(targetAddresses.value[0].token),
decimals.value
),
]
: [targets.value['target'], amountToTansfer]
const tx = await exec(
accountId.value,
Expand All @@ -423,9 +453,7 @@ const submit = async (
const blockNumber = header.number.toString()
showNotification(
`[${unit.value}] Transfered ${price.value * numOfTargetAddresses} ${
unit.value
} in block ${blockNumber}`,
`[${unit.value}] Transfered ${totalTokenAmount.value} ${unit.value} in block ${blockNumber}`,
notificationTypes.success
)
Expand Down Expand Up @@ -542,7 +570,10 @@ watch(
width: 32px;
height: 32px;
}
.square-20 {
width: 20px;
height: 20px;
}
.fixed-height {
height: 51px;
}
Expand Down
Loading

0 comments on commit 0d6dc5f

Please sign in to comment.