Skip to content

Commit 93ffac2

Browse files
authored
feat: bring asset response type into shared package (#1361)
* - Bring asset response type into shared package * Fix import assets * Fix import assets * implemented shared asset response types * bring rate response in separated file change response names * bring rate response in separated file change response names * fix ci * fix ci * fix ci
1 parent cc2038d commit 93ffac2

File tree

23 files changed

+44
-40
lines changed

23 files changed

+44
-40
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
steps:
7474
- uses: actions/checkout@v4
7575
- uses: ./.github/workflows/setup
76-
- run: pnpm wallet:backend test --detectOpenHandles --forceExit
76+
- run: pnpm wallet:backend build && pnpm wallet:backend test --detectOpenHandles --forceExit
7777

7878
test-boutique-backend:
7979
name: BOUTIQUE - Test backend

packages/wallet/backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@wallet/backend",
33
"scripts": {
44
"start": "node -r tsconfig-paths/register dist/index.js",
5-
"build:deps": "pnpm --filter @shared/backend build",
5+
"build:deps": "pnpm --filter @shared/backend build && pnpm --filter @wallet/shared build",
66
"build": "pnpm build:deps && tsc --build tsconfig.build.json && tsc-alias -p tsconfig.build.json",
77
"test": "jest --passWithNoTests --maxWorkers=75%",
88
"generate": "graphql-codegen --config codegen.yml"
@@ -11,6 +11,7 @@
1111
"@google-cloud/logging-winston": "^6.0.0",
1212
"@sendgrid/mail": "^8.1.3",
1313
"@shared/backend": "workspace:*",
14+
"@wallet/shared": "workspace:*",
1415
"awilix": "^10.0.2",
1516
"axios": "^1.7.2",
1617
"cors": "^2.8.5",

packages/wallet/backend/src/asset/controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { NextFunction, Request } from 'express'
2-
import { Asset } from '@/rafiki/backend/generated/graphql'
32
import { RafikiClient } from '@/rafiki/rafiki-client'
43
import { Controller, toSuccessResponse } from '@shared/backend'
4+
import { AssetResponse } from '@wallet/shared'
55

66
interface IAssetController {
7-
list: Controller<Asset[]>
7+
list: Controller<AssetResponse[]>
88
}
99

1010
export class AssetController implements IAssetController {
1111
constructor(private rafikiClient: RafikiClient) {}
1212

1313
list = async (
1414
_req: Request,
15-
res: CustomResponse<Asset[]>,
15+
res: CustomResponse<AssetResponse[]>,
1616
next: NextFunction
1717
) => {
1818
try {

packages/wallet/backend/src/rafiki/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { NextFunction, Request, Response } from 'express'
22
import { Logger } from 'winston'
3-
import { RatesResponse, RatesService } from '@/rates/service'
3+
import { RatesService } from '@/rates/service'
44
import { validate } from '@/shared/validate'
55
import { RafikiService } from './service'
66
import { ratesSchema, webhookSchema } from './validation'
7+
import { RatesResponse } from '@wallet/shared'
78

89
interface IRafikiController {
910
getRates: (

packages/wallet/backend/src/rates/service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import axios from 'axios'
22
import NodeCache from 'node-cache'
33
import { Env } from '@/config/env'
4-
5-
export type RatesResponse = {
6-
base: string
7-
rates: Record<string, number>
8-
}
4+
import { RatesResponse } from '@wallet/shared'
95

106
export interface IRatesService {
117
getRates: (base: string) => Promise<RatesResponse>

packages/wallet/frontend/src/components/ExchangeRate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { AssetOP, ExchangeRates } from '@/lib/api/asset'
21
import { getCurrencySymbol } from '@/utils/helpers'
32
import { memo } from 'react'
43
import { SimpleArrow } from './icons/Arrow'
4+
import { AssetOP, ExchangeRates } from '@/lib/api/asset'
55

66
type ExchangeRateProps = {
77
convertAmount: number

packages/wallet/frontend/src/components/dialogs/FundAccountDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useZodForm } from '@/lib/hooks/useZodForm'
1111
import { Form } from '@/ui/forms/Form'
1212
import { useRouter } from 'next/router'
1313
import { useOnboardingContext } from '@/lib/context/onboarding'
14-
import { fundAccountSchema } from '@wallet/shared/src/responses'
14+
import { fundAccountSchema } from '@wallet/shared'
1515

1616
type FundAccountDialogProps = Pick<DialogProps, 'onClose'> & {
1717
account: Account

packages/wallet/frontend/src/components/dialogs/WithdrawFundsDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getCurrencySymbol, getObjectKeys } from '@/utils/helpers'
1010
import { useZodForm } from '@/lib/hooks/useZodForm'
1111
import { Form } from '@/ui/forms/Form'
1212
import { useRouter } from 'next/router'
13-
import { withdrawFundsSchema } from '@wallet/shared/src/responses'
13+
import { withdrawFundsSchema } from '@wallet/shared'
1414

1515
type WithdrawFundsDialogProps = Pick<DialogProps, 'onClose'> & {
1616
account: Account

packages/wallet/frontend/src/lib/api/account.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { acceptQuoteSchema, Quote } from './transfers'
99
import { WalletAddress } from './walletAddress'
1010
import {
1111
createAccountSchema,
12-
exchangeAssetSchema,
1312
fundAccountSchema,
14-
withdrawFundsSchema
15-
} from '@wallet/shared/src/responses'
13+
withdrawFundsSchema,
14+
exchangeAssetSchema
15+
} from '@wallet/shared'
1616

1717
export type Account = {
1818
id: string

packages/wallet/frontend/src/lib/api/asset.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,18 @@ import {
44
httpClient,
55
type SuccessResponse
66
} from '../httpClient'
7-
8-
export type Asset = {
9-
id: string
10-
code: string
11-
scale: number
12-
withdrawalThreshold?: bigint
13-
createdAt: string
14-
}
15-
16-
export type Rates = {
17-
base: string
18-
rates: Record<string, number>
19-
}
7+
import { AssetResponse, RatesResponse } from '@wallet/shared'
208

219
export type AssetOP = {
2210
assetCode: string
2311
assetScale: number
2412
}
2513

26-
type ListAssetsResult = SuccessResponse<Asset[]>
14+
export type ExchangeRates = Record<string, number>
15+
16+
type ListAssetsResult = SuccessResponse<AssetResponse[]>
2717
type ListAssetsResponse = ListAssetsResult | ErrorResponse
2818

29-
export type ExchangeRates = Record<string, number>
3019
type GetExchangeRatesResponse = SuccessResponse<ExchangeRates> | ErrorResponse
3120

3221
interface AssetService {
@@ -54,7 +43,7 @@ const createAssetService = (): AssetService => ({
5443
try {
5544
const response = await httpClient
5645
.get(`rates?base=${assetCode}`)
57-
.json<Rates>()
46+
.json<RatesResponse>()
5847

5948
const rates = {
6049
[response.base]: 1,

0 commit comments

Comments
 (0)