Skip to content

Commit

Permalink
🔀 Merge #389 to deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Sep 19, 2023
2 parents 511b95c + 36046a2 commit c8a1247
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
74 changes: 59 additions & 15 deletions components/Alerts/SignFailed.vue
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@

<template>
<Snackbar
:open="isOpenSnackbar"
preset="warn"
@close="handleSnackbarClose"
>
{{ errorAlert }}
<Link
v-if="errorType === 'INSUFFICIENT_BALANCE'"
:class="['text-white', 'ml-[2px]']"
href="https://go.crisp.chat/chat/embed/?website_id=5c009125-5863-4059-ba65-43f177ca33f7"
>
, {{ $t('IscnRegisterForm.error.buy') }}
</Link>
<Snackbar :open="isOpenSnackbar" preset="warn" @close="handleSnackbarClose">
<i18n :path="errorAlert" tag="div" class="flex items-center flex-nowrap">
<Link
place="buy"
:class="['text-white', 'ml-[2px]']"
href="https://go.crisp.chat/chat/embed/?website_id=5c009125-5863-4059-ba65-43f177ca33f7"
>
{{ $t('IscnRegisterForm.error.buy') }}
</Link>
<div
place="login"
class="flex flex-nowrap items-center gap-[4px] ml-[8px] text-white underline font-bold cursor-pointer"
@click="handleReLogin"
>
{{ $t('IscnRegisterForm.error.reLogIn') }}
<IconSignIn />
</div>
</i18n>
</Snackbar>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import { namespace } from 'vuex-class'
import logTrackerEvent, { setLoggerUser } from '~/utils/logger'
const walletModule = namespace('wallet')
export enum ErrorType {
INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE',
INSUFFICIENT_BALANCE = 'Error: INSUFFICIENT_BALANCE',
USER_NOT_ISCN_OWNER = 'Error: USER_NOT_ISCN_OWNER',
}
@Component
export default class SignFailed extends Vue {
@walletModule.State isOpenSnackbar!: boolean
@walletModule.State errorType!: string
@walletModule.Action closeSnackbar!: () => void
@walletModule.Action('disconnectWallet') disconnectWallet!: () => void
@walletModule.Action('openConnectWalletModal')
openConnectWalletModal!: (params: { language: string }) => Promise<any>
@walletModule.Action('initWallet') initWallet!: (params: {
method: any
accounts: any
offlineSigner?: any
}) => Promise<any>
get errorAlert() {
switch (this.errorType) {
case ErrorType.INSUFFICIENT_BALANCE:
return this.$t('IscnRegisterForm.error.insufficient')
return 'IscnRegisterForm.error.insufficient'
case ErrorType.USER_NOT_ISCN_OWNER:
return 'IscnRegisterForm.error.notIscnOwner'
default:
return this.errorType
}
Expand All @@ -44,5 +64,29 @@ export default class SignFailed extends Vue {
handleSnackbarClose() {
this.closeSnackbar()
}
async handleReLogin() {
const { currentRoute } = this.$router
await this.disconnectWallet()
const connection = await this.openConnectWalletModal({
language: this.$i18n.locale.split('-')[0],
})
if (connection) {
const { method, accounts } = connection
logTrackerEvent(
this,
'user',
`connected_wallet_${method}`,
're-connected_wallet',
1,
)
setLoggerUser(this, {
wallet: accounts[0].address,
method,
})
this.$router.push(currentRoute.path);
}
this.handleSnackbarClose()
}
}
</script>
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@
"IscnRegisterForm.error.buy": "Buy LikeCoin",
"IscnRegisterForm.error.descriptionIsEmpty": "Please enter the ISCN description",
"IscnRegisterForm.error.faucet": "Get faucet",
"IscnRegisterForm.error.insufficient": "Oops, Insufficient Balance. ",
"IscnRegisterForm.error.insufficient": "Oops, Insufficient Balance. {buy} ",
"IscnRegisterForm.error.missingSigner": "Missing Signer. Please connect your wallet.",
"IscnRegisterForm.error.notIscnOwner": "Oops, User is not the current ISCN owner. {login}",
"IscnRegisterForm.error.reLogIn": "Re-Login",
"IscnRegisterForm.error.numbersProtocol": "Oops. Unable to register asset to Numbers Protocol. Please try again later.",
"IscnRegisterForm.error.requiredField": "This field is required",
"IscnRegisterForm.error.timeout": "Oops, the server connection timeout, please try again.",
Expand Down
6 changes: 3 additions & 3 deletions pages/nft/url/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export default class FetchIndex extends Vue {
if (res) {
const iscnOwner = res.owner
if (iscnOwner !== this.address) {
this.toggleSnackbar('USER_NOT_ISCN_OWNER')
this.toggleSnackbar(ErrorType.USER_NOT_ISCN_OWNER)
}
}
}
Expand Down Expand Up @@ -557,7 +557,7 @@ export default class FetchIndex extends Vue {
this.balance = (await getAccountBalance(this.address)) as string
}
if (this.balance === '0') {
throw new Error('INSUFFICIENT_BALANCE')
throw new Error(ErrorType.INSUFFICIENT_BALANCE)
}
switch (this.state) {
case State.INIT: {
Expand Down Expand Up @@ -754,7 +754,7 @@ export default class FetchIndex extends Vue {
async registerISCN(): Promise<void> {
await this.initIfNecessary()
if (!this.signer) {
throw new Error('MISSING_SIGNER')
throw new Error(ErrorType.MISSING_SIGNER)
}
let res
try {
Expand Down

0 comments on commit c8a1247

Please sign in to comment.