fix sync flush looping and batch size, add alchemy call logging

This commit is contained in:
2026-05-21 17:55:29 +08:00
parent 85c25883c6
commit edd4f6fff0
8 changed files with 226 additions and 39 deletions
@@ -23,6 +23,7 @@
import Plus from '@lucide/svelte/icons/plus'
import WalletIcon from '@lucide/svelte/icons/wallet'
import LockKeyhole from '@lucide/svelte/icons/lock-keyhole'
import ExternalLink from '@lucide/svelte/icons/external-link'
import * as Dialog from '$lib/components/ui/dialog/index.js'
import QRCode from 'qrcode'
import Loader from './loader.svelte'
@@ -267,6 +268,11 @@
<p class="font-mono text-xs break-all flex-1">
{w.address}
</p>
<button
onclick={() => electrobun.rpc?.request.openExternal({ url: w.explorerAddressUrl })}
class="shrink-0 cursor-pointer rounded-md border p-1.5 text-muted-foreground hover:bg-muted transition-colors">
<ExternalLink size={16} />
</button>
{#if qrDataUrl}
<Dialog.Root bind:open={qrDialogOpen}>
<Dialog.Trigger>
+4
View File
@@ -141,6 +141,10 @@ type RPC = {
}
response: TxEntry[]
}
syncTxHistory: {
params: { address: string; chainid: string }
response: void
}
fetchTokenBalances: {
params: {
address: string
@@ -287,6 +287,8 @@ export const EvmWallet = () => {
address = account.address
const client = createPublicClient({ transport: http(net().rpc) })
syncTxHistory()
;(async () => {
const [nativeBal] = await tryCatch(
client.getBalance({ address: account.address }),
@@ -307,11 +309,17 @@ export const EvmWallet = () => {
})()
}
const syncTxHistory = () => {
if (!address || !apiKey || !electrobun.rpc) return
electrobun.rpc.request.syncTxHistory({ address, chainid: net().chainid })
}
const saveApiKey = async (key: string) => {
await electrobun.rpc?.request.setSecret({
service: 'koins', name: 'alchemy_key', value: key,
})
apiKey = key
syncTxHistory()
if (address) await fetchTxHistory()
}
@@ -358,6 +366,7 @@ export const EvmWallet = () => {
get networkName() { return net().name },
get symbol() { return net().symbol },
get explorerUrl() { return net().explorerUrl },
get explorerAddressUrl() { return address ? `${net().explorerUrl.replace('/tx/', '/address/')}${address}` : '' },
get networks() { return networks },
get apiKey() { return apiKey },
get transactions() { return transactions },
@@ -391,6 +400,7 @@ export const EvmWallet = () => {
unlockWallet,
deleteWallet,
clearSelection,
syncTxHistory,
}
}