Skip to content

Commit e7892eb

Browse files
Fix missing return and improve error logging
Add missing return in fake plugin getBalance for token balance. Improve @ts-expect-error comment and log swap quote close errors. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 66e9b1d commit e7892eb

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/core/account/account-api.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ export function makeAccountApi(ai: ApiInput, accountId: string): EdgeAccount {
768768
: undefined,
769769

770770
// Added for backward compatibility for plugins using core 1.x
771-
// @ts-expect-error
771+
// @ts-expect-error - paymentTokenId/paymentWallet are deprecated but still used by old plugins
772772
paymentTokenId: paymentInfo?.tokenId,
773773
paymentWallet: wallet
774774
})
@@ -796,7 +796,9 @@ export function makeAccountApi(ai: ApiInput, accountId: string): EdgeAccount {
796796

797797
// Close unused quotes:
798798
for (const otherQuote of otherQuotes) {
799-
otherQuote.close().catch(() => undefined)
799+
otherQuote.close().catch((error: unknown) => {
800+
ai.props.log.warn('Failed to close unused swap quote:', error)
801+
})
800802
}
801803

802804
// Return the front quote:

test/fake/fake-currency-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class FakeCurrencyEngine implements EdgeCurrencyEngine {
217217
getBalance(opts: EdgeTokenIdOptions): string {
218218
const { tokenId = null } = opts
219219
if (tokenId == null) return this.state.balance.toString()
220-
if (tokenId === 'badf00d5') this.state.tokenBalance.toString()
220+
if (tokenId === 'badf00d5') return this.state.tokenBalance.toString()
221221
if (this.allTokens[tokenId] != null) return '0'
222222
throw new Error('Unknown currency')
223223
}

0 commit comments

Comments
 (0)