Skip to content

Commit 60d9d24

Browse files
committed
sync: align ValidOffer.ts formatting with main
1 parent c392b74 commit 60d9d24

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/app/offers/ValidOffer.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@ import Offer from "./Offer"
33
import { PaymentSendStatus } from "@domain/bitcoin/lightning"
44
import { LedgerServiceError } from "@domain/ledger"
55
import { ValidationError } from "@domain/shared"
6-
import { accountLevel, isActiveAccount, isUsd, hasSufficientBalance, transferMin, validate, walletBelongsToAccount, transferMax, isBeforeExpiry } from "./Validations"
7-
// import { sendBetweenAccounts } from "@services/ibex/send-between-accounts"
6+
import {
7+
accountLevel,
8+
isActiveAccount,
9+
isUsd,
10+
hasSufficientBalance,
11+
transferMin,
12+
validate,
13+
walletBelongsToAccount,
14+
transferMax,
15+
isBeforeExpiry,
16+
} from "./Validations"
817
import { RepositoryError } from "@domain/errors"
918
import { AccountsRepository, WalletsRepository } from "@services/mongoose"
1019
import Ibex from "@services/ibex/client"
1120
import { EmailService } from "@services/email"
1221
import { CashoutDetails, ValidationInputs } from "./types"
1322

14-
// Only way to construct a ValidOffer is using the static method which contains validations
23+
// Only way to construct a ValidOffer is using the static method which contains validations
1524
class ValidOffer extends Offer {
1625
readonly wallet: Wallet
1726
readonly account: Account
@@ -23,24 +32,26 @@ class ValidOffer extends Offer {
2332
this.account = account
2433
}
2534

26-
static from = async (details: CashoutDetails): Promise<ValidOffer | ValidationError> => {
35+
static from = async (
36+
details: CashoutDetails,
37+
): Promise<ValidOffer | ValidationError> => {
2738
const wallet = await WalletsRepository().findById(details.ibexTrx.userAcct)
2839
if (wallet instanceof RepositoryError) return new ValidationError(wallet)
29-
40+
3041
const account = await AccountsRepository().findById(wallet.accountId)
3142
if (account instanceof RepositoryError) return new ValidationError(account)
3243

3344
const inputs: ValidationInputs = { ...details, wallet, account }
3445
const validationErrs = await validate(inputs, [
35-
isUsd,
46+
isUsd,
3647
transferMin,
3748
transferMax,
3849
isActiveAccount,
3950
accountLevel,
4051
walletBelongsToAccount,
4152
hasSufficientBalance,
4253
isBeforeExpiry,
43-
// TODO daily/weekly/monthly volume limits
54+
// TODO daily/weekly/monthly volume limits
4455
])
4556
if (validationErrs.length > 0) return new ValidationError(validationErrs)
4657

@@ -49,19 +60,19 @@ class ValidOffer extends Offer {
4960

5061
async execute(): Promise<PaymentSendStatus | Error> {
5162
const resp = await Ibex.payInvoice({
52-
accountId: this.details.ibexTrx.userAcct,
53-
invoice: this.details.ibexTrx.invoice.paymentRequest as unknown as Bolt11
63+
accountId: this.details.ibexTrx.userAcct,
64+
invoice: this.details.ibexTrx.invoice.paymentRequest as unknown as Bolt11,
5465
})
55-
if (resp instanceof Error) return resp
66+
if (resp instanceof Error) return resp
5667

5768
// balance the diff
5869
// const ibexResp = await sendBetweenAccounts(
59-
// IbexAccount.fromWallet(this.wallet),
70+
// IbexAccount.fromWallet(this.wallet),
6071
// flashWallet,
6172
// this.details.ibexTransfer,
6273
// "Withdraw to bank",
63-
// )
64-
// if (ibexResp instanceof Error) return ibexResp
74+
// )
75+
// if (ibexResp instanceof Error) return ibexResp
6576

6677
const ledgerResp = await LedgerService().recordCashOut(this.details)
6778
if (ledgerResp instanceof LedgerServiceError) {
@@ -75,4 +86,4 @@ class ValidOffer extends Offer {
7586
}
7687
}
7788

78-
export default ValidOffer
89+
export default ValidOffer

0 commit comments

Comments
 (0)