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: enable wallet connect #439

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ace7c1e
feat: GraphQL indexer integration - Setup, profile page (#332)
dzbo Jun 18, 2024
91976fe
Metadata validation updates
dzbo May 8, 2024
34fc56e
Fix Rollup error
dzbo Jun 18, 2024
8decb72
Logs type update
dzbo May 24, 2024
01dffde
feat: Use GraphQL indexer for profile showcase (#347)
dzbo Jun 18, 2024
8a75b6e
Add basic profile fragment
dzbo Jun 18, 2024
748d06d
Cleanups
dzbo Jun 18, 2024
22ea8e6
feat: Use GraphQL for profile search (#346)
dzbo Jun 18, 2024
7742bc6
feat: move asset showcase to graph domain (#348)
dzbo Jun 18, 2024
66d45f7
Lint
dzbo Jun 18, 2024
02dbbea
Move profile showcase to graph domain
dzbo Jun 18, 2024
e21f55c
Update index
dzbo Jun 18, 2024
8754005
Fix breakpoint
dzbo Jun 19, 2024
dc61110
Fix grouped assets modal
dzbo Jun 19, 2024
1f91d9d
Rework routes
dzbo Jun 19, 2024
c62f0fe
Rename pages
dzbo Jun 19, 2024
4ec1f31
chore: Query aliases (#352)
dzbo Jun 22, 2024
32f6668
feat: collection page (#349)
dzbo Jun 22, 2024
c1737bc
feat: Rework details page (#350)
dzbo Jun 24, 2024
85ce0c5
fix: GraphQL improvements and bugfixes (#353)
dzbo Jul 2, 2024
1d19308
Fix CI
dzbo Jul 2, 2024
a9e5577
fix: improve asset load in send (#357)
dzbo Jul 8, 2024
d0d4ef7
feat: small updates for collection page (#356)
dzbo Jul 8, 2024
100183a
chore: switch to testing endpoint (#362)
dzbo Jul 8, 2024
c295744
fix: creators are displayed as unverified (#361)
dzbo Jul 8, 2024
6823e67
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Jul 9, 2024
ecc39ec
Cleanup
dzbo Jul 9, 2024
d708937
Fix tests
dzbo Jul 9, 2024
e097f61
feat: Use formatted token id from indexer (#366)
dzbo Jul 11, 2024
043271d
fix: Wrong order in asset `images` (#364)
dzbo Jul 11, 2024
3223ff9
feat: Read image `src` and verification from index (#365)
dzbo Jul 16, 2024
0ceb79a
Switch endpoint
dzbo Jul 16, 2024
e7c6d07
Merge branch 'feat/graphql-indexer-integration' of github.com:lukso-n…
dzbo Jul 16, 2024
8af8f65
feat: filter collectibles (#368)
dzbo Jul 18, 2024
6ba5683
Biome fix
dzbo Jul 18, 2024
452d5e5
fix: wrap filter chips (#369)
dzbo Jul 18, 2024
900039b
feat: data provider switch (#370)
dzbo Jul 22, 2024
c99125f
perf: asset query optimization (#371)
dzbo Jul 25, 2024
6e814d9
feat: profile filters (#372)
dzbo Jul 29, 2024
40295a7
fix: filter issues (#373)
dzbo Jul 30, 2024
0fe6c8c
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Aug 6, 2024
331687e
fix: Testnet lock (#383)
dzbo Aug 6, 2024
d077f59
Merge branch 'feat/graphql-indexer-integration' of github.com:lukso-n…
dzbo Aug 6, 2024
bd413bb
Fix query
dzbo Aug 6, 2024
c3e63d5
Fix icon button spacing
dzbo Aug 6, 2024
7cb10fb
Mobile alignment
dzbo Aug 7, 2024
6b7ff82
Update web-components
dzbo Aug 7, 2024
1f76969
feat: default to RPC (#384)
dzbo Aug 7, 2024
a68703e
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Aug 7, 2024
33560aa
fix: verify created assets (#387)
dzbo Aug 8, 2024
b6bd4b7
PR remarks
dzbo Aug 9, 2024
d7daab9
feat: mobile filters (#388)
dzbo Aug 9, 2024
5a80dbc
Merge branch 'feat/graphql-indexer-integration' of github.com:lukso-n…
dzbo Aug 9, 2024
e6c729d
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Aug 9, 2024
63ae7c0
Remove image error check
dzbo Aug 9, 2024
427329b
WIP
dzbo Aug 19, 2024
76717b8
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Aug 21, 2024
727927a
WIP provider use
dzbo Aug 22, 2024
685a68f
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Sep 3, 2024
d4a2e74
Fix navbar links on landing page
dzbo Sep 3, 2024
f47bb3f
Allow to copy qr code
dzbo Sep 3, 2024
2debe94
Check if modal is already open
dzbo Sep 3, 2024
aad6676
Improve network change logic
dzbo Sep 3, 2024
4edaaa0
Reverse buttons based on device
dzbo Sep 4, 2024
518a121
App link
dzbo Sep 4, 2024
30c868a
Use own deep link prefix
dzbo Sep 4, 2024
6e531b0
Manage WC reconnect and use proper provider after connecting
dzbo Sep 4, 2024
3d47edc
Fixes
dzbo Sep 4, 2024
c62ebd8
Network switch updates
dzbo Sep 4, 2024
bdf2c31
Fix await state
dzbo Sep 6, 2024
c9d7cee
Improve error display and connecting state
dzbo Sep 6, 2024
acdd466
Disable wallet connect
dzbo Sep 6, 2024
5c7200c
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Sep 6, 2024
8c423d3
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Sep 6, 2024
95170bf
Enable wallet connect
dzbo Sep 6, 2024
8f8a083
Update deep link
dzbo Oct 2, 2024
09eec85
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Oct 2, 2024
2f1a6a5
Lint
dzbo Oct 2, 2024
77607a9
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Oct 2, 2024
a4f463f
Show correct button
dzbo Oct 2, 2024
6fc3be1
Fix deep link
dzbo Oct 2, 2024
36b00df
Show loading only on desktop
dzbo Oct 2, 2024
9bc7bf6
Cleanup
dzbo Oct 2, 2024
ba23735
Refactor connecting logic
dzbo Oct 2, 2024
4d5c424
Merge branch 'main' of github.com:lukso-network/universalprofile.clou…
dzbo Oct 7, 2024
b5b21ba
Change deep link
dzbo Oct 7, 2024
df9cf33
Pass WC id as well
dzbo Oct 7, 2024
8325020
Add logging
dzbo Oct 7, 2024
be8b0b5
Fix
dzbo Oct 7, 2024
add4fbb
Add `redirectUrl`
dzbo Oct 17, 2024
b8dcd84
Enable qr code scan
dzbo Oct 17, 2024
1f0c18d
Fix comments in file
dzbo Oct 17, 2024
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
5 changes: 2 additions & 3 deletions components/ModalTemplateConnectWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ const browserSupportExtension = computed(() => extensionStore.value.url !== '')
)
}}
</lukso-button>
<WalletConnectButton v-if="false" />
<WalletConnectButton v-if="isMobile" />
<lukso-button
v-else
variant="secondary"
is-full-width
disabled
@click="handleToggleMobile"
>
<lukso-icon name="phone-portrait-outline" class="mr-2"></lukso-icon>
Expand All @@ -99,7 +99,6 @@ const browserSupportExtension = computed(() => extensionStore.value.url !== '')
'modal_connect_wallet_select_provider_connect_mobile_button'
)
}}
(soon)
</lukso-button>
</div>
<div class="paragraph-inter-12-regular mt-4 text-neutral-40">
Expand Down
9 changes: 3 additions & 6 deletions components/WalletConnectButton.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<script setup lang="ts">
const { formatMessage } = useIntl()
const deepLink = ref('')
const {
initProvider,
connect: connectWalletConnect,
deepLinkParser,
} = useWalletConnectProvider()
const { initProvider, connect: connectWalletConnect } =
useWalletConnectProvider()
const { walletConnectProvider: provider } = storeToRefs(useAppStore())

onMounted(async () => {
await initProvider()
provider.value?.on('display_uri', (data: string) => {
deepLink.value = deepLinkParser(data)
deepLink.value = walletConnectDeepLinkUrl(data)
})

try {
Expand Down
9 changes: 3 additions & 6 deletions components/WalletConnectQrCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ type Emits = (event: 'disconnect') => void
const emit = defineEmits<Emits>()

const qrCodeElement = ref<HTMLDivElement | null>(null)
const {
initProvider,
connect: connectWalletConnect,
deepLinkParser,
} = useWalletConnectProvider()
const { initProvider, connect: connectWalletConnect } =
useWalletConnectProvider()
const isLoading = ref(true)
const deepLink = ref('')
const { walletConnectProvider: provider, isMobile } = storeToRefs(useAppStore())
Expand All @@ -19,7 +16,7 @@ const { formatMessage } = useIntl()
const size = computed(() => (isMobile.value ? 300 : 340))

const generateQrCode = (data: string) => {
deepLink.value = deepLinkParser(data)
deepLink.value = walletConnectDeepLinkUrl(data)
const qrCode = new QRCodeStyling({
width: size.value,
height: size.value,
Expand Down
20 changes: 1 addition & 19 deletions composables/web3-provider/useWalletConnectProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const initProvider = async () => {
name: 'Universal Profiles',
description:
'Explore Universal Profiles and view all your assets in one place as well as send and receive tokens to other Universal Profile users.',
url: 'https://universalprofile.cloud/',
url: BASE_DAPP_URL,
icons: ['https://universalprofile.cloud/favicon.png'],
},
showQrModal: false,
Expand All @@ -28,7 +28,6 @@ const connect = async (requestAccounts = true) => {
walletConnectProvider: provider,
connectedProfileAddress,
isWalletConnect,
isConnecting,
} = storeToRefs(useAppStore())
const { setConnectionExpiry } = useConnectionExpiry()
const { addWeb3 } = useWeb3Store()
Expand All @@ -37,7 +36,6 @@ const connect = async (requestAccounts = true) => {
const { formatMessage } = useIntl()

try {
isConnecting.value = true
await provider.value?.connect()

if (requestAccounts) {
Expand Down Expand Up @@ -69,8 +67,6 @@ const connect = async (requestAccounts = true) => {
message: getErrorMessage(error),
},
})
} finally {
isConnecting.value = false
}
}

Expand All @@ -81,24 +77,10 @@ const reconnect = async () => {
connect(false)
}

/**
* Parse deep link to be used by mobile app
*
* By default WalletConnect uses wc: prefix for deep linking, but this also works with
* other wallets. We replace with own prefix to ensure it works with our app.
*
* @param data
* @returns
*/
const deepLinkParser = (data: string) => {
return data.replace('wc:', 'network.lukso.universalprofiles.ios:')
}

export const useWalletConnectProvider = () => {
return {
initProvider,
connect,
reconnect,
deepLinkParser,
}
}
4 changes: 4 additions & 0 deletions shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ export const PROFILE_SHOWCASE_POOL_SIZE = 500
// asset showcase params
export const ASSET_SHOWCASE_LIMIT = 4
export const ASSET_SHOWCASE_POOL_SIZE = 500

// deep link prefix used by Mobile App
export const MOBILE_APP_DEEP_LINK_PREFIX =
'io.universaleverything.universalprofiles'
21 changes: 21 additions & 0 deletions utils/__tests__/externalUrls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, test } from 'vitest'
import {
universalPageProfileUrl,
universalSwapsProfileUrl,
walletConnectDeepLinkUrl,
} from '../externalUrls'

describe('universalPageProfileUrl', () => {
Expand Down Expand Up @@ -147,3 +148,23 @@ describe('universalSwapsAssetUrl', () => {
)
})
})

describe('walletConnectDeepLinkUrl', () => {
test('should produce proper deep link', () => {
const input =
'wc:96c935c09bfae76a83d65747651a7e0c77592e3b7aeff8556bc91e9363a86689@2?expiryTimestamp=1728294685&relay-protocol=irn&symKey=8ba498cb98560cb940584b50450e77fe8699c29a5ecf28cbad7ee2f215685815'
const expectedOutput =
'io.universaleverything.universalprofiles://wallet-connect/96c935c09bfae76a83d65747651a7e0c77592e3b7aeff8556bc91e9363a86689@2?expiryTimestamp=1728294685&relay-protocol=irn&symKey=8ba498cb98560cb940584b50450e77fe8699c29a5ecf28cbad7ee2f215685815&redirectUrl=http://localhost:3000/'
expect(walletConnectDeepLinkUrl(input)).toBe(expectedOutput)
})

test('throws an error when data is invalid', () => {
// @ts-expect-error
expect(() => walletConnectDeepLinkUrl()).toThrow('Invalid URL')
expect(() => walletConnectDeepLinkUrl('123')).toThrow('Invalid URL')
// @ts-expect-error
expect(() => walletConnectDeepLinkUrl(null)).toThrow('Invalid URL')
// @ts-expect-error
expect(() => walletConnectDeepLinkUrl({})).toThrow('Invalid URL')
})
})
43 changes: 31 additions & 12 deletions utils/externalUrls.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import assert from 'assert'
import { isAddress } from 'web3-utils'

import { MOBILE_APP_DEEP_LINK_PREFIX } from '@/shared/config'

/**
* URL to transaction on blockchain explorer
*
* @param transactionHash
* @returns
*/
export const explorerTransactionUrl = (transactionHash: string) => {
const { currentNetwork } = storeToRefs(useAppStore())
Expand All @@ -17,7 +18,6 @@ export const explorerTransactionUrl = (transactionHash: string) => {
* URL to contract on blockchain explorer
*
* @param address
* @returns
*/
export const explorerContractUrl = (address?: string | Address) => {
const { currentNetwork } = storeToRefs(useAppStore())
Expand All @@ -27,8 +27,6 @@ export const explorerContractUrl = (address?: string | Address) => {

/**
* URL to Transak to buy LYX
*
* @returns
*/
export const transakBuyLyxUrl = () => {
const connectedProfile = useProfile().connectedProfile()
Expand All @@ -53,6 +51,9 @@ export const transakBuyLyxUrl = () => {
return `${TRANSAK_HOST}/?${queryParamsString(queryParams)}`
}

/**
* URL to Ramp to buy LYX
*/
export const rampBuyLyxUrl = () => {
const connectedProfile = useProfile().connectedProfile()
const { formatMessage } = useIntl()
Expand All @@ -75,8 +76,6 @@ export const rampBuyLyxUrl = () => {

/**
* URL to profile dashboard on my.universalprofile.cloud
*
* @returns
*/
export const myUpDappDashboardUrl = () => {
const { currentNetwork } = storeToRefs(useAppStore())
Expand All @@ -86,8 +85,6 @@ export const myUpDappDashboardUrl = () => {

/**
* URL to landing page on my.universalprofile.cloud
*
* @returns
*/
export const myUpDappBaseUrl = () => {
const { currentNetwork } = storeToRefs(useAppStore())
Expand All @@ -98,7 +95,7 @@ export const myUpDappBaseUrl = () => {
/**
* URL to profile page on universal.page
*
* @returns
* @param address
*/
export const universalPageProfileUrl = (address?: Address) => {
assert(address, 'Address is required')
Expand All @@ -111,7 +108,6 @@ export const universalPageProfileUrl = (address?: Address) => {
*
* @param address
* @param tokenId
* @returns
*/
export const universalPageAssetUrl = (address?: Address, tokenId?: string) => {
assert(address, 'Address is required')
Expand All @@ -127,7 +123,7 @@ export const universalPageAssetUrl = (address?: Address, tokenId?: string) => {
/**
* URL to profile page on universalswaps.io
*
* @returns
* @param address
*/
export const universalSwapsProfileUrl = (address?: Address) => {
assert(address, 'Address is required')
Expand All @@ -139,10 +135,33 @@ export const universalSwapsProfileUrl = (address?: Address) => {
* URL to token page on universalswaps.io
*
* @param address
* @returns
*/
export const universalSwapsAssetUrl = (address?: Address) => {
assert(address, 'Address is required')
assert(isAddress(address), 'Address is not a valid address')
return `https://universalswaps.io/tokens/lukso/${address.toLowerCase()}`
}

/**
* URL to Mobile App deep link used by Wallet Connect
*
* @param data
*/
export const walletConnectDeepLinkUrl = (data: string) => {
if (genericLog.enabled) {
genericLog(`Wallet Connect link: ${data}`)
}

const urlData = new URL(data)
const redirectUrl = location.href.replace(
'&modalTemplate=ConnectWallet&modalSize=auto',
''
)
const deepLink = `${MOBILE_APP_DEEP_LINK_PREFIX}://wallet-connect/${urlData.pathname}${urlData.search}&redirectUrl=${redirectUrl}`

if (genericLog.enabled) {
genericLog(`Mobile App link: ${deepLink}`)
}

return deepLink
}
Loading