Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace rapyd with gatehub #1612

Merged
merged 14 commits into from
Sep 19, 2024
7 changes: 4 additions & 3 deletions docker/dev/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
RAPYD_ACCESS_KEY=
RAPYD_SECRET_KEY=
RAPYD_SETTLEMENT_EWALLET=
SEND_EMAIL=
FROM_EMAIL=
SENDGRID_API_KEY=
Expand All @@ -9,6 +6,10 @@ AUTH_COOKIE_KEY=
RATE_API_KEY=
GATEHUB_ACCESS_KEY=
GATEHUB_SECRET_KEY=
GATEHUB_GATEWAY_UUID=
GATEHUB_VAULT_UUID_EUR=
GATEHUB_VAULT_UUID_USD=
GATEHUB_SETTLEMENT_WALLET_ADDRESS=

# commerce env variables
# encoded base 64 private key
Expand Down
8 changes: 4 additions & 4 deletions docker/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ services:
COOKIE_NAME: testnet.cookie
COOKIE_PASSWORD: testnet.cookie.password.super.secret.ilp
COOKIE_TTL: 2630000
RAPYD_API: https://sandboxapi.rapyd.net/v1
RAPYD_ACCESS_KEY: ${RAPYD_ACCESS_KEY}
RAPYD_SETTLEMENT_EWALLET: ${RAPYD_SETTLEMENT_EWALLET}
RAPYD_SECRET_KEY: ${RAPYD_SECRET_KEY}
OPEN_PAYMENTS_HOST: https://rafiki-backend
GRAPHQL_ENDPOINT: http://rafiki-backend:3001/graphql
AUTH_GRAPHQL_ENDPOINT: http://rafiki-auth:3008/graphql
Expand All @@ -56,6 +52,10 @@ services:
KRATOS_ADMIN_URL: 'http://kratos:4434/admin'
GATEHUB_ACCESS_KEY: ${GATEHUB_ACCESS_KEY}
GATEHUB_SECRET_KEY: ${GATEHUB_SECRET_KEY}
GATEHUB_GATEWAY_UUID: ${GATEHUB_GATEWAY_UUID}
GATEHUB_VAULT_UUID_EUR: ${GATEHUB_VAULT_UUID_EUR}
GATEHUB_VAULT_UUID_USD: ${GATEHUB_VAULT_UUID_USD}
GATEHUB_SETTLEMENT_WALLET_ADDRESS: ${GATEHUB_SETTLEMENT_WALLET_ADDRESS}
restart: always
networks:
- testnet
Expand Down
8 changes: 4 additions & 4 deletions docker/prod/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ WALLET_BACKEND_REDIS_URL=
WALLET_BACKEND_COOKIE_NAME=
WALLET_BACKEND_COOKIE_PASSWORD=
WALLET_BACKEND_COOKIE_TTL=
WALLET_BACKEND_RAPYD_API=
WALLET_BACKEND_RAPYD_ACCESS_KEY=
WALLET_BACKEND_RAPYD_SECRET_KEY=
WALLET_BACKEND_RAPYD_SETTLEMENT_EWALLET=
WALLET_BACKEND_OPEN_PAYMENTS_HOST=
WALLET_BACKEND_GRAPHQL_ENDPOINT=
WALLET_BACKEND_RAFIKI_MONEY_FRONTEND_HOST=
Expand All @@ -33,6 +29,10 @@ WALLET_BACKEND_AUTH_DOMAIN=
WALLET_BACKEND_RATE_API_KEY=
WALLET_BACKEND_GATEHUB_ACCESS_KEY=
WALLET_BACKEND_GATEHUB_SECRET_KEY=
WALLET_BACKEND_GATEHUB_GATEWAY_UUID=
WALLET_BACKEND_GATEHUB_VAULT_UUID_EUR=
WALLET_BACKEND_GATEHUB_VAULT_UUID_USD=
WALLET_BACKEND_GATEHUB_SETTLEMENT_WALLET_ADDRESS=

# BOUTIQUE
BOUTIQUE_BACKEND_PORT=
Expand Down
8 changes: 4 additions & 4 deletions docker/prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ services:
COOKIE_NAME: ${WALLET_BACKEND_COOKIE_NAME}
COOKIE_PASSWORD: ${WALLET_BACKEND_COOKIE_PASSWORD}
COOKIE_TTL: ${WALLET_BACKEND_COOKIE_TTL}
RAPYD_API: ${WALLET_BACKEND_RAPYD_API}
RAPYD_ACCESS_KEY: ${WALLET_BACKEND_RAPYD_ACCESS_KEY}
RAPYD_SETTLEMENT_EWALLET: ${WALLET_BACKEND_RAPYD_SETTLEMENT_EWALLET}
RAPYD_SECRET_KEY: ${WALLET_BACKEND_RAPYD_SECRET_KEY}
OPEN_PAYMENTS_HOST: ${WALLET_BACKEND_OPEN_PAYMENTS_HOST}
GRAPHQL_ENDPOINT: ${WALLET_BACKEND_GRAPHQL_ENDPOINT}
RAFIKI_MONEY_FRONTEND_HOST: ${WALLET_BACKEND_RAFIKI_MONEY_FRONTEND_HOST}
Expand All @@ -68,6 +64,10 @@ services:
REDIS_URL: ${WALLET_BACKEND_REDIS_URL}
GATEHUB_ACCESS_KEY: ${WALLET_BACKEND_GATEHUB_ACCESS_KEY}
GATEHUB_SECRET_KEY: ${WALLET_BACKEND_GATEHUB_SECRET_KEY}
GATEHUB_GATEWAY_UUID: ${WALLET_BACKEND_GATEHUB_GATEWAY_UUID}
GATEHUB_VAULT_UUID_EUR: ${WALLET_BACKEND_GATEHUB_VAULT_UUID_EUR}
GATEHUB_VAULT_UUID_USD: ${WALLET_BACKEND_GATEHUB_VAULT_UUID_USD}
GATEHUB_SETTLEMENT_WALLET_ADDRESS: ${WALLET_BACKEND_GATEHUB_SETTLEMENT_WALLET_ADDRESS}
networks:
- testnet
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ exports.up = function (knex) {
table.string('firstName')
table.string('address')
table.string('country')
table.string('rapydReferenceId')
table.string('rapydWalletId')
table.string('rapydContactId')
table.string('kycId')
table.string('kycId') // TODO: replace with GateHub kyc check

table.string('gateHubUserId')

table.timestamp('createdAt').notNullable()
table.timestamp('updatedAt').notNullable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.up = function (knex) {
table.integer('assetScale').notNullable()
table.bigint('balance').notNullable().defaultTo(0n)

table.string('virtualAccountId').notNullable() // Rapyd Virtual Account ID - used to fund the account
table.string('gateHubWalletId').notNullable()

table.timestamp('createdAt').notNullable()
table.timestamp('updatedAt').notNullable()
Expand Down
48 changes: 1 addition & 47 deletions packages/wallet/backend/src/account/controller.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { NextFunction, Request } from 'express'
import { validate } from '@/shared/validate'
import { AccountService } from './service'
import { accountSchema, fundSchema, withdrawFundsSchema } from './validation'
import { accountSchema } from './validation'
import { Account } from '@/account/model'
import { Controller, toSuccessResponse } from '@shared/backend'

interface IAccountController {
createAccount: Controller<Account>
listAccounts: Controller<Account[]>
getAccountById: Controller<Account>
fundAccount: Controller
withdrawFunds: Controller
}

export class AccountController implements IAccountController {
Expand Down Expand Up @@ -87,48 +85,4 @@ export class AccountController implements IAccountController {
next(e)
}
}

fundAccount = async (
req: Request,
res: CustomResponse,
next: NextFunction
) => {
try {
const {
body: { amount, accountId }
} = await validate(fundSchema, req)

const userId = req.session.user.id

await this.accountService.fundAccount({ userId, amount, accountId })

res.status(200).json(toSuccessResponse(undefined, 'Account funded'))
} catch (e) {
next(e)
}
}

withdrawFunds = async (
req: Request,
res: CustomResponse,
next: NextFunction
) => {
try {
const {
body: { amount, accountId }
} = await validate(withdrawFundsSchema, req)

const userId = req.session.user.id

await this.accountService.withdrawFunds({
userId,
amount,
accountId
})

res.status(200).json(toSuccessResponse(undefined, 'Funds withdrawn'))
} catch (e) {
next(e)
}
}
}
2 changes: 1 addition & 1 deletion packages/wallet/backend/src/account/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Account extends BaseModel {

public name!: string
public balance!: bigint
public virtualAccountId!: string
public gateHubWalletId!: string
public readonly assetId!: string
public readonly assetCode!: string
public readonly assetScale!: number
Expand Down
Loading
Loading