Skip to content

Commit e29b4d9

Browse files
committed
refactor: replace fetch with contract method for block number retrieval
1 parent 9bc0901 commit e29b4d9

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/models/site.model.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CharacterOperatorPermission } from "crossbell"
1+
import { CharacterOperatorPermission, createContract } from "crossbell"
22
import type { Address } from "viem"
33

44
import type { useContract } from "@crossbell/contract"
@@ -502,20 +502,9 @@ export async function checkDomain(domain: string, handle: string) {
502502
return check.data
503503
}
504504

505+
const contract = createContract()
506+
505507
export async function getBlockNumber() {
506-
const result = await (
507-
await fetch("https://scan.crossbell.io/api/eth-rpc", {
508-
method: "POST",
509-
headers: {
510-
"Content-Type": "application/json",
511-
},
512-
body: JSON.stringify({
513-
jsonrpc: "2.0",
514-
method: "eth_blockNumber",
515-
params: [],
516-
id: 0,
517-
}),
518-
})
519-
).json()
520-
return Number(BigInt(result.result))
508+
const result = await contract.publicClient.getBlockNumber()
509+
return Number(result)
521510
}

0 commit comments

Comments
 (0)