Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Jul 25, 2023
1 parent 7115901 commit 6421c7a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
22 changes: 5 additions & 17 deletions resources/js/components/UserNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
<WalletIcon class="h-6 w-6 text-gray-400 cursor-pointer" @click="connectWallet" />
<Suspense>
<WalletConnectButton></WalletConnectButton>
<template #fallback><div class="text-gray-600">Loading</div></template>
<template #fallback>
<LoadingCircle></LoadingCircle>
</template>
</Suspense>
<InformationCircleIcon class="h-6 w-6 text-gray-400 cursor-pointer" @click="openHelp" />
<NotificationsList />
Expand Down Expand Up @@ -61,6 +63,7 @@ import WalletConnectButton from '~/components/WalletConnectButton.vue';
import { WalletConnectModalSign } from '@walletconnect/modal-sign-html';
import { getAppMetadata } from '@walletconnect/utils';
import { SessionTypes } from '@walletconnect/types';
import LoadingCircle from '~/components/LoadingCircle.vue';
const open = ref(false);
const help = ref(false);
Expand All @@ -70,22 +73,7 @@ const appStore = useAppStore();
const navigations = computed(() => appStore.navigations);
const connectWallet = async () => {
const walletConnect = new WalletConnectModalSign({
projectId: 'a4b92f550ab3039f7e084a879882bc96',
metadata: getAppMetadata(),
modalOptions: {
themeMode: 'light',
explorerRecommendedWalletIds: ['bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a'],
enableExplorer: true,
walletImages: {},
themeVariables: {
'--wcm-background-color': '#7567CE',
'--wcm-accent-color': '#7567CE',
'--wcm-accent-fill-color': '#FFFFFF',
},
},
});
const walletConnect = appStore.getWeb3Modal();
let session: SessionTypes.Struct | undefined = await walletConnect.getSession();
if (!session) {
Expand Down
22 changes: 2 additions & 20 deletions resources/js/components/WalletConnectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,11 @@
</template>

<script setup>
import { WalletConnectModalSign } from '@walletconnect/modal-sign-html';
import { getAppMetadata } from '@walletconnect/utils';
import { useAppStore } from '~/store';
const appStore = useAppStore();
const walletConnect = new WalletConnectModalSign({
projectId: 'a4b92f550ab3039f7e084a879882bc96',
metadata: getAppMetadata(),
modalOptions: {
themeMode: 'light',
explorerRecommendedWalletIds: ['bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a'],
enableExplorer: true,
walletImages: {},
themeVariables: {
'--wcm-background-color': '#7567CE',
'--wcm-accent-color': '#7567CE',
'--wcm-accent-fill-color': '#FFFFFF',
},
},
});
let session = await walletConnect.getSession();
const walletConnect = appStore.getWeb3Modal();
const session = await walletConnect.getSession();
const hasValidSession = session && session.acknowledged;
if (hasValidSession) {
Expand Down
5 changes: 5 additions & 0 deletions resources/js/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ApiService } from '~/api';
import snackbar from '~/util/snackbar';
import { AuthApi } from '~/api/auth';
import { CollectionApi } from '~/api/collection';
import { WalletConnectModalSign } from '@walletconnect/modal-sign-html';
import { wcOptions } from '~/util';

const parseConfigHostname = (hostname: string): string => {
try {
Expand Down Expand Up @@ -242,6 +244,9 @@ export const useAppStore = defineStore('app', {
setCollections(collections: string[]) {
this.collections = collections;
},
getWeb3Modal() {
return new WalletConnectModalSign(wcOptions);
},
},
getters: {
hasValidConfig(state: AppState) {
Expand Down
19 changes: 19 additions & 0 deletions resources/js/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { TokenIdSelectType } from '~/types/types.enums';
import { TokenIdType } from '~/types/types.interface';
import snackbar from '~/util/snackbar';
import { getAppMetadata } from '@walletconnect/utils';
import { WalletConnectModalSignOptions } from '@walletconnect/modal-sign-html';

export const formatData = (entries: any, type = 'object') => {
const data: { [key: string]: any } = type === 'object' ? {} : [];
Expand Down Expand Up @@ -136,3 +138,20 @@ export const shortString = (str: string, length = 10) => {

return `${str.substring(0, length)}...`;
};

export const wcProjectId = 'a4b92f550ab3039f7e084a879882bc96';
export const wcOptions: WalletConnectModalSignOptions = {
projectId: wcProjectId,
metadata: getAppMetadata(),
modalOptions: {
themeMode: 'light',
explorerRecommendedWalletIds: ['bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a'],
enableExplorer: true,
walletImages: {},
themeVariables: {
'--wcm-background-color': '#7567CE',
'--wcm-accent-color': '#7567CE',
'--wcm-accent-fill-color': '#FFFFFF',
},
},
};

0 comments on commit 6421c7a

Please sign in to comment.