-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: solowallet api * chore: bump africastalking * fix: bootstrap solowallet * refactor: use shared transaction state definition * feat: solowallet depends on swap service * feat: onramp to solowallet
- Loading branch information
Showing
25 changed files
with
382 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TestingModule } from '@nestjs/testing'; | ||
import { createTestingModuleWithValidation } from '@bitsacco/testing'; | ||
import { SolowalletController } from './solowallet.controller'; | ||
import { SolowalletService } from './solowallet.service'; | ||
|
||
describe('SolowalletController', () => { | ||
let controller: SolowalletController; | ||
let walletService: SolowalletService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await createTestingModuleWithValidation({ | ||
controllers: [SolowalletController], | ||
providers: [ | ||
{ | ||
provide: SolowalletService, | ||
useValue: { | ||
depositFunds: jest.fn(), | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
controller = module.get<SolowalletController>(SolowalletController); | ||
walletService = module.get<SolowalletService>(SolowalletService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
expect(walletService).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { DepositFundsRequestDto } from '@bitsacco/common'; | ||
import { Body, Controller, Logger, Post } from '@nestjs/common'; | ||
import { ApiOperation, ApiBody } from '@nestjs/swagger'; | ||
import { SolowalletService } from './solowallet.service'; | ||
|
||
@Controller('solowallet') | ||
export class SolowalletController { | ||
private readonly logger = new Logger(SolowalletController.name); | ||
|
||
constructor(private readonly walletService: SolowalletService) { | ||
this.logger.log('SolowalletController initialized'); | ||
} | ||
|
||
@Post('deposit') | ||
@ApiOperation({ summary: 'Deposit funds to Solowallet' }) | ||
@ApiBody({ | ||
type: DepositFundsRequestDto, | ||
}) | ||
depositFunds(@Body() req: DepositFundsRequestDto) { | ||
return this.walletService.depositFunds(req); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TestingModule } from '@nestjs/testing'; | ||
import { ClientGrpc } from '@nestjs/microservices'; | ||
import { SolowalletServiceClient } from '@bitsacco/common'; | ||
import { createTestingModuleWithValidation } from '@bitsacco/testing'; | ||
import { SolowalletService } from './solowallet.service'; | ||
|
||
describe('SolowalletService', () => { | ||
let service: SolowalletService; | ||
let serviceGenerator: ClientGrpc; | ||
let mockSolowalletServiceClient: Partial<SolowalletServiceClient>; | ||
|
||
beforeEach(async () => { | ||
serviceGenerator = { | ||
getService: jest.fn().mockReturnValue(mockSolowalletServiceClient), | ||
getClientByServiceName: jest | ||
.fn() | ||
.mockReturnValue(mockSolowalletServiceClient), | ||
}; | ||
|
||
const module: TestingModule = await createTestingModuleWithValidation({ | ||
providers: [ | ||
{ | ||
provide: SolowalletService, | ||
useFactory: () => { | ||
return new SolowalletService(serviceGenerator); | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
service = module.get<SolowalletService>(SolowalletService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
DepositFundsRequestDto, | ||
SOLOWALLET_SERVICE_NAME, | ||
SolowalletServiceClient, | ||
} from '@bitsacco/common'; | ||
import { Inject, Injectable, OnModuleInit } from '@nestjs/common'; | ||
import { type ClientGrpc } from '@nestjs/microservices'; | ||
|
||
@Injectable() | ||
export class SolowalletService implements OnModuleInit { | ||
private client: SolowalletServiceClient; | ||
|
||
constructor( | ||
@Inject(SOLOWALLET_SERVICE_NAME) private readonly grpc: ClientGrpc, | ||
) {} | ||
|
||
onModuleInit() { | ||
this.client = this.grpc.getService<SolowalletServiceClient>( | ||
SOLOWALLET_SERVICE_NAME, | ||
); | ||
} | ||
|
||
depositFunds(req: DepositFundsRequestDto) { | ||
return this.client.depositFunds(req); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV='development' | ||
SOLOWALLET_GRPC_URL='0.0.0.0:4080' | ||
DATABASE_URL=mongodb://bs:password@mongodb:27017 | ||
SWAP_GRPC_URL='0.0.0.0:4040' | ||
DATABASE_URL=mongodb://bs:[email protected]:27017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ async function bootstrap() { | |
|
||
await app.startAllMicroservices(); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { SolowalletService } from './solowallet.service'; | ||
import { Controller } from '@nestjs/common'; | ||
import { GrpcMethod } from '@nestjs/microservices'; | ||
import { SolowalletServiceControllerMethods } from '@bitsacco/common'; | ||
import { DepositFundsRequestDto } from 'libs/common/src/dto/solowallet.dto'; | ||
import { | ||
SolowalletServiceControllerMethods, | ||
DepositFundsRequestDto, | ||
} from '@bitsacco/common'; | ||
import { SolowalletService } from './solowallet.service'; | ||
|
||
@Controller() | ||
@SolowalletServiceControllerMethods() | ||
export class SolowalletController { | ||
constructor(private readonly solowalletService: SolowalletService) {} | ||
|
||
@GrpcMethod() | ||
depositFunds(request: DepositFundsRequestDto): string { | ||
depositFunds(request: DepositFundsRequestDto) { | ||
return this.solowalletService.depositFunds(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.