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(2712): remove the accounting service interface from rafiki #2743

Merged
merged 9 commits into from
May 27, 2024
33 changes: 1 addition & 32 deletions packages/backend/src/payment-method/ilp/connector/core/rafiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ import { Errors } from 'ilp-packet'
import { Redis } from 'ioredis'
import Koa, { Middleware } from 'koa'
import { Logger } from 'pino'
//import { Router } from './services/router'
import {
CreateAccountError,
TransferError
} from '../../../../accounting/errors'
import {
LiquidityAccount,
LiquidityAccountType,
Transaction
AccountingService
} from '../../../../accounting/service'
import { AssetOptions } from '../../../../asset/service'
import { IncomingPaymentService } from '../../../../open_payments/payment/incoming/service'
Expand Down Expand Up @@ -61,14 +55,6 @@ export interface TransferOptions {
timeout: number
}

export interface AccountingService {
createTransfer(options: TransferOptions): Promise<Transaction | TransferError>
createLiquidityAccount(
account: LiquidityAccount,
type: LiquidityAccountType
): Promise<LiquidityAccount | CreateAccountError>
}

export interface RafikiServices {
//router: Router
accounting: AccountingService
Expand Down Expand Up @@ -115,7 +101,6 @@ export type ILPContext<T = any> = {
}

export class Rafiki<T = any> {
//private _router?: Router
private streamServer: StreamServer
private redis: Redis

Expand All @@ -128,18 +113,11 @@ export class Rafiki<T = any> {
//this._router = config && config.router ? config.router : undefined
this.redis = config.redis
const logger = config.logger
//const routerOrThrow = (): Router => {
// if (this._router) return this._router
// throw new Error('No router service provided to the app')
//}

this.streamServer = config.streamServer
const { redis, streamServer } = this
// Set global context that exposes services
this.publicServer.context.services = {
//get router(): Router {
// return routerOrThrow()
//},
get incomingPayments(): IncomingPaymentService {
return config.incomingPayments
},
Expand All @@ -164,7 +142,6 @@ export class Rafiki<T = any> {
get telemetry(): TelemetryService | undefined {
return config.telemetry
},

logger
}

Expand Down Expand Up @@ -210,14 +187,6 @@ export class Rafiki<T = any> {
return response.rawReply
}

//public get router(): Router | undefined {
koekiebox marked this conversation as resolved.
Show resolved Hide resolved
// return this._router
//}

//public set router(router: Router | undefined) {
// this._router = router
//}

public get logger(): Logger {
return this.publicServer.context.services.logger
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { IncomingAccount, OutgoingAccount } from '../../rafiki'

import {
Transaction,
AccountingService,
IncomingAccount,
OutgoingAccount
} from '../../rafiki'

import { Transaction } from '../../../../../../accounting/service'
Deposit,
Withdrawal
} from '../../../../../../accounting/service'
import {
CreateAccountError,
TransferError
} from '../../../../../../accounting/errors'
import { CreateAccountError as CreateAccountErrorCode } from 'tigerbeetle-node'
import { TransactionOrKnex } from 'objection'

interface MockAccount {
id: string
Expand Down Expand Up @@ -133,4 +135,78 @@ export class MockAccountingService implements AccountingService {
}
return account
}

createDeposit(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
deposit: Deposit,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
trx?: TransactionOrKnex
): Promise<void | TransferError> {
return Promise.resolve(undefined)
koekiebox marked this conversation as resolved.
Show resolved Hide resolved
}

createSettlementAccount(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ledger: number,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
trx?: TransactionOrKnex
): Promise<void> {
return Promise.resolve(undefined)
}

createWithdrawal(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
withdrawal: Withdrawal
): Promise<void | TransferError> {
return Promise.resolve(undefined)
}

getAccountsTotalReceived(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ids: string[]
): Promise<(bigint | undefined)[]> {
return Promise.resolve([])
}

getAccountsTotalSent(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ids: string[]
): Promise<(bigint | undefined)[]> {
return Promise.resolve([])
}

getSettlementBalance(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ledger: number
): Promise<bigint | undefined> {
return Promise.resolve(undefined)
}

getTotalReceived(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: string
): Promise<bigint | undefined> {
return Promise.resolve(undefined)
}

getTotalSent(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: string
): Promise<bigint | undefined> {
return Promise.resolve(undefined)
}

postWithdrawal(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: string
): Promise<void | TransferError> {
return Promise.resolve(undefined)
}

voidWithdrawal(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: string
): Promise<void | TransferError> {
return Promise.resolve(undefined)
}
}
Loading