|
1 | | -import { BadRequestException, Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; |
2 | | -import { validateSignin, validateSignup } from '@projectlibertylabs/siwfv1'; |
| 1 | +import { Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; |
3 | 2 | import { BlockchainRpcQueryService } from '#blockchain/blockchain-rpc-query.service'; |
4 | 3 | import { EnqueueService } from '#account-lib/services/enqueue-request.service'; |
5 | | -import { WalletLoginRequestDto } from '#types/dtos/account/wallet.login.request.dto'; |
6 | | -import { WalletLoginResponseDto } from '#types/dtos/account/wallet.login.response.dto'; |
7 | 4 | import { |
8 | 5 | AccountResponseDto, |
9 | 6 | MsaIdResponseDto, |
10 | 7 | RetireMsaPayloadResponseDto, |
11 | 8 | } from '#types/dtos/account/accounts.response.dto'; |
12 | | -import { WalletLoginConfigResponseDto } from '#types/dtos/account/wallet.login.config.response.dto'; |
13 | | -import { |
14 | | - PublishRetireMsaRequestDto, |
15 | | - PublishSIWFSignupRequestDto, |
16 | | - RetireMsaRequestDto, |
17 | | - TransactionResponse, |
18 | | -} from '#types/dtos/account'; |
| 9 | +import { PublishRetireMsaRequestDto, RetireMsaRequestDto, TransactionResponse } from '#types/dtos/account'; |
19 | 10 | import { TransactionType } from '#types/account-webhook'; |
20 | 11 | import apiConfig, { IAccountApiConfig } from '#account-api/api.config'; |
21 | 12 | import blockchainConfig, { IBlockchainConfig } from '#blockchain/blockchain.config'; |
@@ -59,53 +50,6 @@ export class AccountsService { |
59 | 50 | return null; |
60 | 51 | } |
61 | 52 |
|
62 | | - async getSIWFConfig(): Promise<WalletLoginConfigResponseDto> { |
63 | | - const { siwfNodeRpcUrl, siwfUrl }: IAccountApiConfig = this.apiCOnf; |
64 | | - const { providerId } = this.blockchainConf; |
65 | | - return { |
66 | | - providerId: providerId.toString(), |
67 | | - siwfUrl: siwfUrl.toString(), |
68 | | - frequencyRpcUrl: siwfNodeRpcUrl?.toString(), |
69 | | - }; |
70 | | - } |
71 | | - |
72 | | - // eslint-disable-next-line class-methods-use-this |
73 | | - async signInWithFrequency(request: WalletLoginRequestDto): Promise<WalletLoginResponseDto> { |
74 | | - const api = (await this.blockchainService.getApi()) as ApiPromise; |
75 | | - const { providerId } = this.blockchainConf; |
76 | | - if (request.signUp) { |
77 | | - try { |
78 | | - const siwfPayload = await validateSignup(api, request.signUp, providerId.toString()); |
79 | | - // Pass all this data to the transaction publisher queue |
80 | | - const referenceId: WalletLoginResponseDto = |
81 | | - await this.enqueueService.enqueueRequest<PublishSIWFSignupRequestDto>({ |
82 | | - ...siwfPayload, |
83 | | - type: TransactionType.SIWF_SIGNUP, |
84 | | - }); |
85 | | - return referenceId; |
86 | | - } catch (e: any) { |
87 | | - this.logger.error(`Failed Signup validation ${e.toString()}`); |
88 | | - throw new UnprocessableEntityException('Failed to sign up'); |
89 | | - } |
90 | | - } else if (request.signIn) { |
91 | | - try { |
92 | | - const parsedSignin = await validateSignin(api, request.signIn, 'localhost'); |
93 | | - const response: WalletLoginResponseDto = { |
94 | | - referenceId: '0', |
95 | | - msaId: parsedSignin.msaId, |
96 | | - publicKey: parsedSignin.publicKey, |
97 | | - }; |
98 | | - return response; |
99 | | - } catch (e) { |
100 | | - this.logger.error(`Error during SIWF signin request: ${e}`); |
101 | | - const { cause } = e as any; |
102 | | - this.logger.error(`cause: ${cause}`); |
103 | | - throw new UnprocessableEntityException('Failed to Sign In With Frequency'); |
104 | | - } |
105 | | - } |
106 | | - throw new BadRequestException('Invalid Sign In With Frequency Request'); |
107 | | - } |
108 | | - |
109 | 53 | async getRetireMsaPayload(accountId: string): Promise<RetireMsaPayloadResponseDto | null> { |
110 | 54 | try { |
111 | 55 | const msaId = await this.getMsaIdForAccountId(accountId); |
|
0 commit comments