From 096a5dc77f71f1450100865caed4847b77986282 Mon Sep 17 00:00:00 2001 From: Samet Sahin Date: Wed, 1 Nov 2023 16:14:48 +0300 Subject: [PATCH 1/3] use getOrThrow to get some environment vars, add log statements --- apps/charge-apps-service/src/charge-api/charge-api.module.ts | 2 +- .../charge-apps-service/src/charge-api/charge-api.service.ts | 5 +++-- .../src/smart-wallets/services/smart-wallets-aa.service.ts | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/charge-apps-service/src/charge-api/charge-api.module.ts b/apps/charge-apps-service/src/charge-api/charge-api.module.ts index 8a802a46..6a8d3fab 100644 --- a/apps/charge-apps-service/src/charge-api/charge-api.module.ts +++ b/apps/charge-apps-service/src/charge-api/charge-api.module.ts @@ -14,7 +14,7 @@ import configuration from '@app/apps-service/common/config/configuration' useFactory: async (configService: ConfigService) => ({ headers: { 'Content-Type': 'application/json', - 'API-SECRET': `${configService.get('CHARGE_SECRET_KEY')}` + 'API-SECRET': `${configService.getOrThrow('CHARGE_SECRET_KEY')}` } }), inject: [ConfigService] diff --git a/apps/charge-apps-service/src/charge-api/charge-api.service.ts b/apps/charge-apps-service/src/charge-api/charge-api.service.ts index 73f66652..64947772 100644 --- a/apps/charge-apps-service/src/charge-api/charge-api.service.ts +++ b/apps/charge-apps-service/src/charge-api/charge-api.service.ts @@ -26,7 +26,7 @@ export class ChargeApiService { } get chargeBaseUrl () { - return this.configService.get('CHARGE_BASE_URL') + return this.configService.getOrThrow('CHARGE_BASE_URL') } get unmarshalBaseUrl () { @@ -38,7 +38,7 @@ export class ChargeApiService { } get chargePublicKey () { - return this.configService.get('CHARGE_PUBLIC_KEY') + return this.configService.getOrThrow('CHARGE_PUBLIC_KEY') } get chargeWebhookId () { @@ -163,6 +163,7 @@ export class ChargeApiService { } async addWebhookAddress (params: { walletAddress: string, webhookId: string }) { + console.log('Adding address to the webhook...') const url = `${this.chargeBaseUrl}/api/v0/notifications/webhook/add-addresses?apiKey=${this.chargePublicKey}` const requestBody = { webhookId: params.webhookId, diff --git a/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts b/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts index e0dae556..e03e5e78 100644 --- a/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts +++ b/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts @@ -51,8 +51,10 @@ export class SmartWalletsAAService implements SmartWalletService { } private async subscribeWalletToNotifications (walletAddress: string) { + console.log('Subscribing wallets to notifications...') + const webhookId = - this.configService.get('INCOMING_TOKEN_TRANSFERS_WEBHOOK_ID') + this.configService.getOrThrow('INCOMING_TOKEN_TRANSFERS_WEBHOOK_ID') return this.chargeApiService.addWebhookAddress({ walletAddress, webhookId }) } From a409816b1081fdc150a398d267cdc6de5fb0ece5 Mon Sep 17 00:00:00 2001 From: Samet Sahin Date: Wed, 1 Nov 2023 16:18:33 +0300 Subject: [PATCH 2/3] delete an env var description --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index f453ea99..9de2745f 100644 --- a/.env.example +++ b/.env.example @@ -70,7 +70,7 @@ SMART_WALLETS_PORT=5007 SMART_WALLETS_TCP_PORT=8882 SMART_WALLETS_MONGO_URI=mongodb://mongo:27017/charge-smart-wallets SMART_WALLETS_JWT_SECRET=smart_wallets_jwt_secret -INCOMING_TOKEN_TRANSFERS_WEBHOOK_ID=put_incoming_token_transfers_webhook_id_here +INCOMING_TOKEN_TRANSFERS_WEBHOOK_ID= FUSE_WALLET_BACKEND_JWT=fuse_wallet_backend_jwt CENTRIFUGO_URI=ws://centrifugo:8000/connection/websocket CENTRIFUGO_JWT= From 45e3ace74c3b8e109affff03eeda90fecb1bbcbc Mon Sep 17 00:00:00 2001 From: Samet Sahin Date: Wed, 1 Nov 2023 16:18:50 +0300 Subject: [PATCH 3/3] remove unused lines, fields --- .../src/smart-wallets/services/smart-wallets-aa.service.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts b/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts index e03e5e78..35a49fb8 100644 --- a/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts +++ b/apps/charge-smart-wallets-service/src/smart-wallets/services/smart-wallets-aa.service.ts @@ -3,11 +3,8 @@ import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common' import { JwtService } from '@nestjs/jwt' import { arrayify, computeAddress, hashMessage, recoverPublicKey } from 'nestjs-ethers' import { SmartWalletService } from '@app/smart-wallets-service/smart-wallets/interfaces/smart-wallets.interface' -import { NotificationsService } from '@app/api-service/notifications/notifications.service' import { ConfigService } from '@nestjs/config' import { ChargeApiService } from '@app/apps-service/charge-api/charge-api.service' -// import { ISmartWalletUser } from '@app/common/interfaces/smart-wallet.interface' -// import CentrifugoAPIService from '@app/common/services/centrifugo.service' @Injectable() export class SmartWalletsAAService implements SmartWalletService { @@ -15,10 +12,8 @@ export class SmartWalletsAAService implements SmartWalletService { constructor ( private readonly jwtService: JwtService, - private readonly notificationsService: NotificationsService, private configService: ConfigService, private chargeApiService: ChargeApiService - // private readonly centrifugoAPIService: CentrifugoAPIService, ) { } async auth (smartWalletsAuthDto: SmartWalletsAuthDto) {