Skip to content

Commit

Permalink
feat: solowallet withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Dec 2, 2024
1 parent 9adaf79 commit d6219a6
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 105 deletions.
22 changes: 16 additions & 6 deletions apps/api/src/solowallet/solowallet.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
DepositFundsRequestDto,
FindUserTxsRequestDto,
UserTxsRequestDto,
WithdrawFundsRequestDto,
} from '@bitsacco/common';
import { Body, Controller, Logger, Post } from '@nestjs/common';
import { ApiOperation, ApiBody } from '@nestjs/swagger';
Expand All @@ -23,12 +24,21 @@ export class SolowalletController {
return this.walletService.depositFunds(req);
}

@Post('user-deposits')
@ApiOperation({ summary: 'Find Solowallet user deposits' })
@Post('withdraw')
@ApiOperation({ summary: 'Withdraw funds from Solowallet' })
@ApiBody({
type: FindUserTxsRequestDto,
type: WithdrawFundsRequestDto,
})
findUserDeposits(@Body() req: FindUserTxsRequestDto) {
return this.walletService.findUserDeposits(req);
withdrawFunds(@Body() req: WithdrawFundsRequestDto) {
return this.walletService.withdrawFunds(req);
}

@Post('transactions')
@ApiOperation({ summary: 'Find Solowallet user transactions' })
@ApiBody({
type: UserTxsRequestDto,
})
userTransactions(@Body() req: UserTxsRequestDto) {
return this.walletService.userTransactions(req);
}
}
11 changes: 8 additions & 3 deletions apps/api/src/solowallet/solowallet.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
DepositFundsRequestDto,
FindUserTxsRequestDto,
UserTxsRequestDto,
SOLOWALLET_SERVICE_NAME,
SolowalletServiceClient,
WithdrawFundsRequestDto,
} from '@bitsacco/common';
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
import { type ClientGrpc } from '@nestjs/microservices';
Expand All @@ -25,7 +26,11 @@ export class SolowalletService implements OnModuleInit {
return this.client.depositFunds(req);
}

findUserDeposits(req: FindUserTxsRequestDto) {
return this.client.findUserDeposits(req);
userTransactions(req: UserTxsRequestDto) {
return this.client.userTransactions(req);
}

withdrawFunds(req: WithdrawFundsRequestDto) {
return this.client.withdrawFunds(req);
}
}
13 changes: 12 additions & 1 deletion apps/solowallet/src/db/solowallet.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { AbstractDocument, TransactionStatus } from '@bitsacco/common';
import {
AbstractDocument,
TransactionStatus,
TransactionType,
} from '@bitsacco/common';

@Schema({ versionKey: false })
export class SolowalletDocument extends AbstractDocument {
Expand All @@ -12,6 +16,13 @@ export class SolowalletDocument extends AbstractDocument {
@Prop({ type: Number, required: false })
amountFiat?: number;

@Prop({
type: String,
required: true,
enum: Object.values(TransactionType),
})
type: TransactionType;

@Prop({
type: String,
required: true,
Expand Down
12 changes: 9 additions & 3 deletions apps/solowallet/src/solowallet.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { GrpcMethod } from '@nestjs/microservices';
import {
SolowalletServiceControllerMethods,
DepositFundsRequestDto,
FindUserTxsRequestDto,
UserTxsRequestDto,
WithdrawFundsRequestDto,
} from '@bitsacco/common';
import { SolowalletService } from './solowallet.service';

Expand All @@ -18,7 +19,12 @@ export class SolowalletController {
}

@GrpcMethod()
findUserDeposits(request: FindUserTxsRequestDto) {
return this.solowalletService.findUserDeposits(request);
userTransactions(request: UserTxsRequestDto) {
return this.solowalletService.userTransactions(request);
}

@GrpcMethod()
withdrawFunds(request: WithdrawFundsRequestDto) {
return this.solowalletService.withdrawFunds(request);
}
}
Loading

0 comments on commit d6219a6

Please sign in to comment.