From 2bc3e1d28721319cb95d957fa045c337a0505564 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 23 May 2024 11:23:31 +0200 Subject: [PATCH] Error if wallet is not connected --- .github/workflows/app.yml | 2 +- apps/api/src/app/services/PoolService.ts | 2 ++ apps/api/src/app/services/RewardService.ts | 1 - apps/app/src/stores/Wallet.ts | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml index 55d6c03d8..2058e2d03 100644 --- a/.github/workflows/app.yml +++ b/.github/workflows/app.yml @@ -156,4 +156,4 @@ jobs: DISCORD_WEBHOOK: ${{ env.DISCORD_WEBHOOK }} uses: Ilshidur/action-discord@master with: - args: "${{ needs.autodeploy.result == 'success' && '✅' || '⛔' }} Released App `${{ env.PACKAGE_VERSION }}`" + args: "${{ needs.autodeploy.result == 'success' && '✅' || '⛔' }} Released App `v${{ env.PACKAGE_VERSION }}-app`" diff --git a/apps/api/src/app/services/PoolService.ts b/apps/api/src/app/services/PoolService.ts index 9d63ce88c..98582ce8b 100644 --- a/apps/api/src/app/services/PoolService.ts +++ b/apps/api/src/app/services/PoolService.ts @@ -281,6 +281,8 @@ async function findParticipants(pool: PoolDocument, page: number, limit: number, try { account = accounts.find((a) => a.sub === participant.sub); + if (!account) throw new Error('Account not found'); + account.tokens = await Promise.all( account.tokens.map(async (token: TToken) => ParticipantService.findUser(token, { userId: token.userId, guildId: guild && guild.id }), diff --git a/apps/api/src/app/services/RewardService.ts b/apps/api/src/app/services/RewardService.ts index c15c10ab4..98f564b90 100644 --- a/apps/api/src/app/services/RewardService.ts +++ b/apps/api/src/app/services/RewardService.ts @@ -17,7 +17,6 @@ import RewardDiscordRoleService from './RewardDiscordRoleService'; import RewardCustomService from './RewardCustomService'; import RewardGalachainService from './RewardGalachainService'; import PoolService from './PoolService'; -import WalletService from './WalletService'; import THXService from './THXService'; const serviceMap = { diff --git a/apps/app/src/stores/Wallet.ts b/apps/app/src/stores/Wallet.ts index 18f4f86a7..e53a816f4 100644 --- a/apps/app/src/stores/Wallet.ts +++ b/apps/app/src/stores/Wallet.ts @@ -151,6 +151,9 @@ export const useWalletStore = defineStore('wallet', { return switchChain(wagmiConfig, { chainId }); }, signMessage(message: string) { + if (!this.account || !this.account.isConnected) { + throw new Error('Please connect your wallet first.'); + } return signMessage(wagmiConfig, { message }); }, async connect() {