Skip to content

Commit

Permalink
🔀 Merge #474 to deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Sep 20, 2024
2 parents e89d32f + 57d3ef7 commit 97dbf96
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 18 deletions.
23 changes: 20 additions & 3 deletions layouts/wallet.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<template>
<RootLayout @connect-wallet-dialog-quit="$router.go(-1)">
<template v-if="walletAddress">
<template v-if="sessionWallet">
<AppHeader />
<Nuxt class="min-h-full" />
<AppFooter
:class="{ hidden: isHideFooter }"
/>
</template>
<div
v-else-if="isSignInLoading"
class="flex items-center justify-center w-full min-h-screen"
>
<Card >
<Label :text="$t('general.signIn.loading')" />
</Card>
</div>
</RootLayout>
</template>

Expand All @@ -28,6 +36,7 @@ export default class WalletLayout extends Vue {
@walletModule.Action('initWallet') initWallet!: (params: { method: any, accounts: any, offlineSigner?: any }) => Promise<any>
@walletModule.Action('signMessageMemo') signMessageMemo!: (action: string, permissions?: string[]) => Promise<any>
@walletModule.Getter('getSigner') signer!: any
@bookApiModule.Getter('getSessionWallet') sessionWallet!: string
@bookApiModule.Action('restoreSession') restoreSession!: () => void
@bookApiModule.Action('authenticate') authenticate!: ({ inputWallet, signature }: { inputWallet?: string, signature?: any }) => Promise<any>
@bookApiModule.Action('clearSession') clearSession!: () => void
Expand All @@ -38,13 +47,16 @@ export default class WalletLayout extends Vue {
severity: string
) => void
isSignInLoading = false
get isHideFooter() {
return this.$route.path.includes('/nft/purchase/') || this.$route.query.layout === 'popup';
}
async mounted() {
await this.restoreSession()
if (!this.walletAddress) {
if (!this.sessionWallet) {
this.isSignInLoading = true
const connection = await this.openConnectWalletModal({
language: this.$i18n.locale.split('-')[0],
fullPath: this.$route.fullPath,
Expand Down Expand Up @@ -81,13 +93,18 @@ export default class WalletLayout extends Vue {
signature,
})
}
this.$router.go(-1)
else {
this.$router.go(-1)
}
} catch (error) {
this.disconnectWallet()
this.clearSession()
// eslint-disable-next-line no-console
console.error('handleConnectWalletButtonClick error', error)
}
finally {
this.isSignInLoading = false
}
}
}
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"FileUploaded.guide.title": "Upload only mode. Files uploaded",
"general.closeWindow": "Close Window",
"general.loading": "Loading",
"general.signIn.loading": "Signing in...",
"HomePage.button.faucet": "Faucet",
"HomePage.button.help": "Help",
"HomePage.button.learnmore": "Learn more",
Expand Down
2 changes: 1 addition & 1 deletion pages/auth/redirect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class RedirectPage extends Vue {
'write:nftcollection',
])
if (!signature) { return }
await this.authenticate({inputWallet:this.currentAddress, signature})
await this.authenticate({ inputWallet: this.currentAddress, signature })
}
let postAuthRoute = '/';
if (window.sessionStorage) {
Expand Down
8 changes: 6 additions & 2 deletions pages/nft/url/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const base64toBlob = (base64Data: string, contentType: string, sliceSize = 512)
const iscnModule = namespace('iscn')
const walletModule = namespace('wallet')
const bookApiModule = namespace('book-api')
export enum ErrorType {
INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE',
Expand Down Expand Up @@ -193,6 +194,9 @@ export default class FetchIndex extends Vue {
@walletModule.Getter('getWalletAddress') address!: string
@walletModule.Getter('getSigner') signer!: OfflineSigner | null
@bookApiModule.Getter('getSessionWallet') sessionWallet!: string
state = State.INIT
url = this.$route.query.url as string || ''
platform = this.$route.query.platform as string || ''
Expand Down Expand Up @@ -365,7 +369,7 @@ export default class FetchIndex extends Vue {
const res = await this.fetchISCNById(this.iscnId)
if (res) {
const iscnOwner = res.owner
if (iscnOwner !== this.address) {
if (iscnOwner !== this.sessionWallet) {
this.toggleSnackbar(ErrorType.USER_NOT_ISCN_OWNER)
}
}
Expand Down Expand Up @@ -562,7 +566,7 @@ export default class FetchIndex extends Vue {
}
switch (this.state) {
case State.INIT: {
if (this.ownerWallet && this.address !== this.ownerWallet) {
if (this.ownerWallet && this.sessionWallet !== this.ownerWallet) {
throw new Error('PLEASE_USE_OWNER_WALLET_TO_SIGN')
}
if (this.iscnPrefixRegex.test(this.url)) {
Expand Down
7 changes: 4 additions & 3 deletions pages/view/_iscnId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ import {
const iscnModule = namespace('iscn')
const walletModule = namespace('wallet')
const bookApiModule = namespace('book-api')
export enum ErrorMessage {
statusCode400 = 'not iscn id or tx hash',
Expand Down Expand Up @@ -617,14 +617,15 @@ export default class ViewIscnIdPage extends Vue {
arg0: string
) => Promise<{ records: ISCNRecordWithID[] }>
@walletModule.Getter('getWalletAddress') currentAddress!: string
@bookApiModule.Getter('getSessionWallet') sessionWallet!: string
get isShowMintButton() {
return !this.isPreminted && this.isIscnOwner
}
get isIscnOwner() {
return Boolean(this.iscnOwner === this.currentAddress)
return Boolean(this.iscnOwner === this.sessionWallet)
}
get showContentLinks() {
Expand Down
14 changes: 8 additions & 6 deletions pages/works/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,24 @@ import { LIKER_LAND_URL } from '~/constant'
import { ISCNRecordWithID } from '~/utils/cosmos/iscn/iscn.type'
const iscnModule = namespace('iscn')
const walletModule = namespace('wallet')
const bookApiModule = namespace('book-api')
@Component({
layout: 'wallet',
})
export default class WorksIndexPageExtends extends Vue {
pageNumber = Number(this.$route.query.page) || 0
@walletModule.Getter('getWalletAddress') currentAddress!: string
@iscnModule.Getter('getISCNChunks') recordChunks!: ISCNRecordWithID[][]
@iscnModule.Getter('getIsLoading') isLoading!: boolean
@iscnModule.Action queryISCNByAddress!: (
arg0: string
) => ISCNRecordWithID[] | PromiseLike<ISCNRecordWithID[]>
@Watch('currentAddress')
@bookApiModule.Getter('getSessionWallet') sessionWallet!: string
@Watch('sessionWallet')
onCurrentAddressChanged() {
this.refreshWorks()
}
Expand All @@ -145,8 +147,8 @@ export default class WorksIndexPageExtends extends Vue {
}
refreshWorks() {
if (this.currentAddress) {
this.queryISCNByAddress(this.currentAddress)
if (this.sessionWallet) {
this.queryISCNByAddress(this.sessionWallet)
}
}
Expand All @@ -167,7 +169,7 @@ export default class WorksIndexPageExtends extends Vue {
}
get portfolioURL(): string {
return `${LIKER_LAND_URL}/${this.currentAddress}`
return `${LIKER_LAND_URL}/${this.sessionWallet}`
}
}
</script>
Expand Down
4 changes: 1 addition & 3 deletions store/book-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export default class BookAPI extends VuexModule {
try {
const { data } = await axios.post(
API_POST_AUTHORIZE,
{
...signature,
},
signature,
)
const token = (data as any)?.token
if (!token) {
Expand Down

0 comments on commit 97dbf96

Please sign in to comment.