Skip to content

Commit

Permalink
fix: handle proto generator default values issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Nov 30, 2024
1 parent 3322841 commit 2e2f06e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/api/src/debug/settle-pending-onchain-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const processPayment = async (payment: LedgerTransaction<WalletCurrency>) => {
if (payout instanceof Error) {
return new Error(`Failed to get payout: ${payout.name} - ${payout.message}`)
}
if (!payout.batchId || !payout.txId || !payout.vout) {
if (!payout.batchId || !payout.txId || payout.vout === undefined) {
return new Error("Missing required payout details")
}

Expand Down
6 changes: 4 additions & 2 deletions core/api/src/services/bria/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,15 @@ export const OnChainService = (): IOnChainService => {
const foundPayout = response.getPayout()
if (foundPayout === undefined) return new PayoutNotFoundError()

//fix issue with proto gen default values
const txId = (foundPayout.getTxId() as OnChainTxHash) || undefined
return {
id: foundPayout.getId() as PayoutId,
journalId: foundPayout.getExternalId() as LedgerJournalId,
batchInclusionEstimatedAt: foundPayout.getBatchInclusionEstimatedAt(),
batchId: foundPayout.getBatchId() as BatchId,
txId: foundPayout.getTxId() as OnChainTxHash,
vout: foundPayout.getVout() as OnChainTxVout,
txId,
vout: txId ? (foundPayout.getVout() as OnChainTxVout) : undefined,
}
} catch (err) {
if (
Expand Down
11 changes: 11 additions & 0 deletions core/api/src/services/ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,21 @@ export const LedgerService = (): ILedgerService => {
| AsyncGenerator<LedgerTransaction<WalletCurrency>>
| LedgerServiceError {
try {
const bankOwnerWalletId = await caching.getBankOwnerWalletId()
const dealerUsdWalletId = await caching.getDealerUsdWalletId()
const dealerBtcWalletId = await caching.getDealerBtcWalletId()

const excludedAccounts = [
toLiabilitiesWalletId(bankOwnerWalletId),
toLiabilitiesWalletId(dealerUsdWalletId),
toLiabilitiesWalletId(dealerBtcWalletId),
]

const transactions = Transaction.find({
type: LedgerTransactionType.OnchainPayment,
pending: true,
account_path: liabilitiesMainAccount,
accounts: { $nin: excludedAccounts },

Check warning on line 514 in core/api/src/services/ledger/index.ts

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"nin" should be "inn" or "min" or "bin" or "nine".
}).cursor({ batchSize: 100 })

for await (const tx of transactions) {
Expand Down

0 comments on commit 2e2f06e

Please sign in to comment.