Minor Changes
-
#847
1e5d4545
Thanks @jxom! - NarrowedgetBlock
,watchBlocks
,getFilterChanges
,getFilterLogs
&getLogs
return types for whenblockTag
orincludeTransactions
is provided.- When
blockTag !== 'pending'
, the return type will now include some non-nullish properties if it were dependent on pending blocks. Example: ForgetBlock
, theblock.number
type is now non-nullish sinceblockTag !== 'pending'
. - On the other hand, when
blockTag: 'pending'
, some properties will be nullish. Example: ForgetBlock
, theblock.number
type is nownull
sinceblockTag === 'pending'
. - When
includeTransactions
is provided, the return type of will narrow thetransactions
property type. Example:block.transactions
will beTransaction[]
whenincludeTransactions: true
instead ofHash[] | Transaction[]
.
TLDR;
// Before const block = publicClient.getBlock({ includeTransactions: true }); block.transactions; // ^? Hash[] | Transaction[] block.transactions[0].blockNumber; // ^? bigint | null // After const block = publicClient.getBlock({ includeTransactions: true }); block.transactions; // ^? Transaction[] block.transactions[0].blockNumber; // ^? bigint // Before const block = publicClient.getBlock({ blockTag: "pending", includeTransactions: true }); block.number; // ^? number | null block.transactions[0].blockNumber; // ^? bigint | null // After const block = publicClient.getBlock({ blockTag: "pending", includeTransactions: true }); block.number; // ^? null block.transactions[0].blockNumber; // ^? null
- When
-
#847
1e5d4545
Thanks @jxom! - Type Change:TPending
has been added to slot 2 of theLog
generics.type Log< TQuantity = bigint, TIndex = number, + TPending extends boolean = boolean, TAbiEvent extends AbiEvent | undefined = undefined, TStrict extends boolean | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined, >
-
#958
f7976fd0
Thanks @jxom! - AddedcacheTime
as a parameter togetBlockNumber
&createClient
. -
28a82125
Thanks @jxom! - Exported number constants (ie.maxInt128
,maxUint256
, etc). -
#951
c75d3b60
Thanks @jxom! - Added support for multipleevents
on Filters/Log Actions:createEventFilter
getLogs
watchEvent
Example:
import { parseAbi } from "viem"; import { publicClient } from "./client"; const logs = publicClient.getLogs({ events: parseAbi([ "event Approval(address indexed owner, address indexed sender, uint256 value)", "event Transfer(address indexed from, address indexed to, uint256 value)" ]) });
-
#957
7950df80
Thanks @jxom! - AddedhexToSignature
&signatureToHex
. -
#847
1e5d4545
Thanks @jxom! - Type Change:TIncludeTransactions
&TBlockTag
has been added to slot 1 & 2 of theBlock
generics.type Block< TQuantity = bigint, + TIncludeTransactions extends boolean = boolean, + TBlockTag extends BlockTag = BlockTag, TTransaction = Transaction< bigint, number, TBlockTag extends 'pending' ? true : false >, >