fix sync flush looping and batch size, add alchemy call logging
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
getTransactionDetails,
|
||||
getCachedTransactionHistory,
|
||||
} from './lib/transactions'
|
||||
import { syncTransactionHistory } from './lib/sync'
|
||||
import { migrate } from 'drizzle-orm/bun-sqlite/migrator'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { db } from './lib/db'
|
||||
@@ -185,6 +186,10 @@ type RPC = {
|
||||
}
|
||||
response: TxEntry[]
|
||||
}
|
||||
syncTxHistory: {
|
||||
params: { address: string; chainid: string }
|
||||
response: void
|
||||
}
|
||||
fetchTokenBalances: {
|
||||
params: {
|
||||
address: string
|
||||
@@ -573,6 +578,13 @@ const rpc = BrowserView.defineRPC<RPC>({
|
||||
const transfers = getCachedTransactionHistory(chainid, address)
|
||||
return transfers.map(mapTransfer)
|
||||
},
|
||||
syncTxHistory: async ({ address, chainid }) => {
|
||||
const key = await Bun.secrets.get({ service: 'koins', name: 'alchemy_key' })
|
||||
if (!key) return
|
||||
syncTransactionHistory(key, chainid, address).catch((e) =>
|
||||
console.error('[sync] error:', e),
|
||||
)
|
||||
},
|
||||
fetchTokenBalances: async ({ address, chainid }) => {
|
||||
const key = await Bun.secrets.get({
|
||||
service: 'koins',
|
||||
|
||||
Reference in New Issue
Block a user