-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
844 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { type EIP1193RequestFn, type EIP1474Methods, hexToBigInt } from "viem"; | ||
|
||
export async function eth_blockNumber( | ||
request: EIP1193RequestFn<EIP1474Methods>, | ||
): Promise<bigint> { | ||
const blockNumberHex = await request({ | ||
method: "eth_blockNumber", | ||
}); | ||
return hexToBigInt(blockNumberHex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
type BlockTag, | ||
numberToHex, | ||
type EIP1193RequestFn, | ||
type EIP1474Methods, | ||
type RpcTransactionRequest, | ||
type Hex, | ||
} from "viem"; | ||
|
||
export async function eth_call( | ||
request: EIP1193RequestFn<EIP1474Methods>, | ||
params: Partial<RpcTransactionRequest> & { | ||
blockNumber?: bigint | number; | ||
blockTag?: BlockTag; | ||
}, | ||
): Promise<Hex> { | ||
const { blockNumber, blockTag, ...txRequest } = params; | ||
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined; | ||
// TODO: per RPC spec omitting the block is allowed, however for some reason our RPCs don't like it, so we default to "latest" here | ||
const block = blockNumberHex || blockTag || "latest"; | ||
|
||
return await request({ | ||
method: "eth_call", | ||
params: block | ||
? [txRequest as Partial<RpcTransactionRequest>, block] | ||
: [txRequest as Partial<RpcTransactionRequest>], | ||
}); | ||
} |
Oops, something went wrong.