Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

feat: send LSP7/LSP8 #113

Merged
merged 48 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3380c5c
Change modal templates namespace
dzbo Oct 12, 2023
3135cb1
Autofocus amount
dzbo Oct 12, 2023
cbc0baa
Cleanup unused util
dzbo Oct 12, 2023
6f9bde4
Modal wip
dzbo Oct 12, 2023
d324954
Allow to select assets
dzbo Oct 12, 2023
c2527c4
Types simplification
dzbo Oct 13, 2023
787dac0
Add icon click in nav
dzbo Oct 16, 2023
8f43f6c
Loaded profile flag
dzbo Oct 16, 2023
024142d
Update web components
dzbo Oct 16, 2023
abcc139
Fix opening send page
dzbo Oct 16, 2023
1938eb8
Adjust asset selection modal
dzbo Oct 16, 2023
aca285b
Adjust asset cards
dzbo Oct 16, 2023
89b188c
Fix input value update
dzbo Oct 16, 2023
d29c194
send LSP7
dzbo Oct 16, 2023
2599dbe
Fix unit display
dzbo Oct 16, 2023
7ea0935
Change logout time, remove default gas prices
dzbo Oct 16, 2023
594ab39
Move storeToRefs to auto imports
dzbo Oct 16, 2023
d831620
Fix decimal places issue
dzbo Oct 17, 2023
c1bc25c
Send LSP8
dzbo Oct 17, 2023
4103992
Truncate long amounts
dzbo Oct 17, 2023
a0e969e
Fix container width
dzbo Oct 17, 2023
00320dd
Add typechain types
dzbo Oct 17, 2023
c5feab2
Change icon redirect
dzbo Oct 17, 2023
4afe0ac
Show balance in details
dzbo Oct 17, 2023
ffa9f22
Fix types
dzbo Oct 17, 2023
a07a9c6
Swap back to number decimals
dzbo Oct 17, 2023
87e9df8
Non divisible token amount validation
dzbo Oct 18, 2023
fdad1c0
Switch back to contract based interface check
dzbo Oct 18, 2023
5413915
Upgrade erc725js package
dzbo Oct 18, 2023
9756e02
Block body scroll when modal is open
dzbo Oct 18, 2023
b3ab48a
Add scroll to token modal
dzbo Oct 18, 2023
4800737
Add send buttons from asset details
dzbo Oct 18, 2023
38ed678
Image optimizations
dzbo Oct 18, 2023
b2b8bbe
Types restructure
dzbo Oct 18, 2023
141eb7b
Cleanup
dzbo Oct 18, 2023
4fe38f1
Use decimals
dzbo Oct 18, 2023
361dc4d
Merge branch 'develop' of github.com:lukso-network/wallet.universalpr…
dzbo Oct 18, 2023
55b9c92
Fix checksum profile issue
dzbo Oct 18, 2023
e85fac4
Comment
dzbo Oct 18, 2023
293b218
Make creator clickable
dzbo Oct 18, 2023
84096ce
Change how tw config is loaded
dzbo Oct 19, 2023
1af2ff7
Update snapshots
dzbo Oct 19, 2023
2df1e81
Bump up content width
dzbo Oct 19, 2023
b8240ad
Fix how we match selected asset
dzbo Oct 19, 2023
7b407ab
PR remarks
dzbo Oct 20, 2023
e138130
Merge branch 'develop' of github.com:lukso-network/wallet.universalpr…
dzbo Oct 20, 2023
13feada
Fix profile check
dzbo Oct 20, 2023
9f25850
Handle account change only for connected users
dzbo Oct 20, 2023
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: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ logs
.fleet
.idea
/public/assets/*
# tailwind config is used just for vs code extension intelisense
tailwind.config.js
types/contracts

# Local env files
.env
Expand Down
30 changes: 28 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<script setup lang="ts">
import { RouteLocationNormalized, NavigationGuardNext } from 'vue-router'
import { isAddress } from 'web3-utils'

import { fetchProfile } from '@/utils/fetchProfile'
import { PROVIDERS, STORAGE_KEY } from '@/types/enums'
import { assertString } from '@/utils/validators'

if (typeof window !== 'undefined') {
// @ts-ignore
import('@lukso/web-components')
}

Expand Down Expand Up @@ -119,12 +118,39 @@ onMounted(async () => {
checkConnectionExpiry()
await setupConnectedProfile()
await routerBackProfileLoad()

try {
const profileAddress = useRouter().currentRoute.value.params?.profileAddress

if (!isAddress(profileAddress)) {
navigateTo(notFoundRoute())
}

await setupViewedProfile(profileAddress)
await setupViewedAssets(profileAddress)
} catch (error) {
console.error(error)
}

setStatus('isProfileLoaded', true)
})

onUnmounted(() => {
const provider = INJECTED_PROVIDER
removeProviderEvents(provider)
})

useHead({
bodyAttrs: {
class: computed(() => {
if (appStore.modal?.isOpen) {
return 'overflow-hidden'
}

return ''
}),
},
})
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion components/AppModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const loadModalTemplate = () => {
const templateName = appStore.modal?.template
? appStore.modal.template
: MODAL_DEFAULT_TEMPLATE
return import(`./AppModalTemplate${templateName}.vue`)
return import(`./ModalTemplate${templateName}.vue`)
})
}

Expand Down
8 changes: 5 additions & 3 deletions components/AppNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { profile: connectedProfile, status } = useConnectedProfileStore()
const { connect, disconnect, isUniversalProfileExtension } =
useBrowserExtension()
const { reloadProfile } = useViewedProfileStore()
const { profile: viewedProfile, reloadProfile } = useViewedProfileStore()

const handleNavigateProfile = async () => {
try {
Expand All @@ -11,7 +11,8 @@ const handleNavigateProfile = async () => {
reloadProfile(connectedProfile)
navigateTo(profileRoute(connectedProfile.address))
} else {
navigateTo(homeRoute())
assertAddress(viewedProfile.address, 'profile')
navigateTo(profileRoute(viewedProfile.address))
}
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -61,8 +62,9 @@ const browserSupportExtension = extensionStore.url !== ''
icon="wallet-outline"
has-menu
@on-brand-click="handleNavigationDiscovery"
@on-icon-click="handleNavigateProfile"
>
<div class="w-full flex items-center justify-end" slot="desktop">
<div class="flex items-center justify-end" slot="desktop">
<lukso-button
variant="text"
custom-class="text-purple-51 hover:text-purple-41 uppercase text-12 nav-apax-12-medium-uppercase font-apax font-500"
Expand Down
27 changes: 27 additions & 0 deletions components/AssetBalance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script setup lang="ts">
type Props = {
balance: string
symbol?: string
decimals?: number
}

defineProps<Props>()
</script>

<template>
<div class="heading-inter-14-bold pb-2">
{{ $formatMessage('asset_balance_title') }}
</div>
<div
class="bg-neutral-100 border border-neutral-90 py-3 px-4 rounded-12 mb-8"
>
<div class="flex items-center justify-between paragraph-inter-14-regular">
{{ $formatNumber(fromWeiWithDecimals(balance, decimals)) }}
<div
class="paragraph-inter-12-regular text-neutral-60 border-l border-l-neutral-90 pl-3 ml-3"
>
{{ symbol }}
</div>
</div>
</div>
</template>
44 changes: 44 additions & 0 deletions components/AssetCreator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script setup lang="ts">
import { Asset } from '@/types/assets'

type Props = {
asset: Asset
}

const props = defineProps<Props>()

const handleOpenCreator = (event: Event) => {
try {
event.stopPropagation()
assertAddress(props.asset.creatorAddress)
navigateTo(profileRoute(props.asset.creatorAddress))
} catch (error) {
console.error(error)
}
}
</script>

<template>
<div
v-if="asset.creatorAddress"
class="cursor-pointer shadow-neutral-drop-shadow p-2 pr-6 rounded-4 inline-flex bg-neutral-100 transition hover:scale-105"
@click="handleOpenCreator"
>
<lukso-profile
size="x-small"
:profile-url="asset.creatorProfileImage"
></lukso-profile>
<div class="pl-1">
<div class="text-neutral-60 paragraph-inter-10-semi-bold">
{{ $formatMessage('asset_created_by') }}
</div>
<lukso-username
:name="asset.creatorName"
:address="asset.creatorAddress"
size="x-small"
class="flex"
name-color="neutral-20"
></lukso-username>
</div>
</div>
</template>
6 changes: 2 additions & 4 deletions components/AssetImages.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
import { ImageMetadata } from '@lukso/lsp-factory.js'

type Props = {
images: ImageMetadata[][]
images: string[]
}

defineProps<Props>()
Expand All @@ -19,7 +17,7 @@ defineProps<Props>()
:key="index"
class="w-14 h-14 rounded-8 bg-cover bg-position-center bg-neutral-90"
:style="{
backgroundImage: `url(${formatUrl(image[0]?.url)})`,
backgroundImage: `url(${image})`,
}"
></div>
</div>
Expand Down
56 changes: 56 additions & 0 deletions components/AssetListItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<script setup lang="ts">
type Props = {
icon?: string
name?: string
symbol?: string
address?: Address
hasIdenticon?: boolean
hasSquareIcon?: boolean
isSelected?: boolean
}

defineProps<Props>()
</script>

<template>
<div
class="grid grid-cols-[max-content,auto] p-2 rounded-12 cursor-pointer hover:bg-neutral-95"
:class="{
'bg-neutral-95': isSelected,
}"
>
<div class="pr-4 flex items-center">
<div
class="shadow-neutral-above-shadow-1xl"
:class="{
'rounded-full': !hasSquareIcon,
'rounded-4': hasSquareIcon,
}"
>
<lukso-profile
size="small"
:profile-url="icon"
:profile-address="address"
:has-identicon="hasIdenticon ? true : undefined"
:is-square="hasSquareIcon ? true : undefined"
></lukso-profile>
</div>
</div>
<div class="grid grid-cols-[auto,max-content] items-center">
<div class="flex flex-col text-left">
<div class="paragraph-inter-14-semi-bold">
{{ name }}
</div>
<div class="paragraph-inter-12-semi-bold text-neutral-60">
{{ symbol }}
</div>
</div>
<lukso-icon
v-if="isSelected"
name="complete-filled"
color="green-54"
secondary-color="neutral-100"
></lukso-icon>
</div>
</div>
</template>
7 changes: 4 additions & 3 deletions components/AssetOwnInfo.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script setup lang="ts">
import { fromWei } from 'web3-utils'

type Props = {
profile: Profile
amount?: string
symbol?: string
decimals?: number
}

defineProps<Props>()
Expand All @@ -25,7 +24,9 @@ defineProps<Props>()
</div>
<div class="paragraph-inter-12-semi-bold">
<span v-if="amount">{{
$formatNumber(fromWei(amount, 'ether'))
$formatNumber(fromWeiWithDecimals(amount, decimals), {
maximumFractionDigits: decimals,
})
}}</span>
<span v-else>0</span>
<span class="text-neutral-60 ml-1">{{ symbol }}</span>
Expand Down
7 changes: 4 additions & 3 deletions components/AssetSupply.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script setup lang="ts">
type Props = {
supply: string
symbol: string
tokenSupply: string
symbol?: string
decimals?: number
}

defineProps<Props>()
Expand All @@ -15,7 +16,7 @@ defineProps<Props>()
class="bg-neutral-100 border border-neutral-90 py-3 px-4 rounded-12 mb-8"
>
<div class="flex items-center justify-between paragraph-inter-14-regular">
{{ $formatNumber(supply, { maximumFractionDigits: 20 }) }}
{{ $formatNumber(fromWeiWithDecimals(tokenSupply, decimals)) }}
<div
class="paragraph-inter-12-regular text-neutral-60 border-l border-l-neutral-90 pl-3 ml-3"
>
Expand Down
72 changes: 72 additions & 0 deletions components/ModalTemplateSelectAssets.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup lang="ts">
import { Asset } from '@/types/assets'

const { currentNetwork } = useAppStore()
const { ownedAssets } = storeToRefs(useViewedProfileStore())
const { profile: connectedProfile } = useConnectedProfileStore()
const { asset: selectedAsset } = storeToRefs(useSendStore())

type Props = {
closeModal: () => void
}

const props = defineProps<Props>()

const handleSelectLyx = () => {
assertAddress(connectedProfile.address, 'profile')
navigateTo(sendRoute(connectedProfile.address))
props.closeModal()
}

const handleSelectAsset = (asset: Asset) => {
assertAddress(connectedProfile.address, 'profile')
navigateTo({
path: sendRoute(connectedProfile.address),
query: {
asset: asset.address,
},
})
props.closeModal()
}
</script>

<template>
<div class="bg-neutral-98 text-center p-6 rounded-12 flex flex-col">
<div
class="heading-inter-21-semi-bold flex items-center justify-between pb-6"
>
{{ $formatMessage('modal_select_assets_title') }}
<lukso-icon
name="close-lg"
class="cursor-pointer"
@click="closeModal"
></lukso-icon>
</div>
<ul class="space-y-2 max-h-72 overflow-y-auto -mr-4">
<li class="mr-4">
<AssetListItem
:icon="ASSET_LYX_ICON_URL"
:name="currentNetwork.token.name"
:symbol="currentNetwork.token.symbol"
:is-selected="selectedAsset?.isNativeToken"
@click="handleSelectLyx"
/>
</li>
<li v-for="asset in ownedAssets" :key="asset.address" class="mr-4">
<AssetListItem
:icon="getAssetThumb(asset)"
:name="asset.name"
:symbol="asset.symbol"
:address="asset.address"
:has-identicon="true"
:has-square-icon="isLsp8(asset)"
:is-selected="
selectedAsset?.address === asset.address &&
selectedAsset?.tokenId === asset.tokenId
"
@click="handleSelectAsset(asset)"
/>
</li>
</ul>
</div>
</template>
2 changes: 0 additions & 2 deletions components/NftList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'

const { nfts, assetFilter } = storeToRefs(useViewedProfileStore())
</script>

Expand Down
Loading