read tx history from db cache instead of alchemy api

This commit is contained in:
2026-05-21 17:18:45 +08:00
parent 1aa723db46
commit 8f3495ab40
6 changed files with 50 additions and 57 deletions
+12
View File
@@ -14,6 +14,7 @@ import { tryCatch } from '@koins/utils'
import {
getTransactionHistory,
getTransactionDetails,
getCachedTransactionHistory,
} from './lib/transactions'
import { migrate } from 'drizzle-orm/bun-sqlite/migrator'
import { eq } from 'drizzle-orm'
@@ -177,6 +178,13 @@ type RPC = {
}
response: TxEntry[]
}
fetchCachedTxHistory: {
params: {
address: string
chainid: string
}
response: TxEntry[]
}
fetchTokenBalances: {
params: {
address: string
@@ -561,6 +569,10 @@ const rpc = BrowserView.defineRPC<RPC>({
return combined
},
fetchCachedTxHistory: async ({ address, chainid }) => {
const transfers = getCachedTransactionHistory(chainid, address)
return transfers.map(mapTransfer)
},
fetchTokenBalances: async ({ address, chainid }) => {
const key = await Bun.secrets.get({
service: 'koins',