File tree Expand file tree Collapse file tree 1 file changed +75
-0
lines changed
packages/vue/src/composables Expand file tree Collapse file tree 1 file changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { createConfig } from '@wagmi/core'
2
+ import { http , webSocket } from 'viem'
3
+ import { mainnet , optimism } from 'viem/chains'
4
+ import { expectTypeOf , test } from 'vitest'
5
+
6
+ import type { DeepUnwrapRef } from '../types/ref.js'
7
+ import {
8
+ type UseWatchBlockNumberParameters ,
9
+ useWatchBlockNumber ,
10
+ } from './useWatchBlockNumber.js'
11
+
12
+ test ( 'default' , ( ) => {
13
+ useWatchBlockNumber ( {
14
+ poll : false ,
15
+ onBlockNumber ( ) { } ,
16
+ } )
17
+ } )
18
+
19
+ test ( 'differing transports' , ( ) => {
20
+ const config = createConfig ( {
21
+ chains : [ mainnet , optimism ] ,
22
+ transports : {
23
+ [ mainnet . id ] : http ( ) ,
24
+ [ optimism . id ] : webSocket ( ) ,
25
+ } ,
26
+ } )
27
+
28
+ type Result = DeepUnwrapRef <
29
+ UseWatchBlockNumberParameters <
30
+ typeof config ,
31
+ typeof mainnet . id | typeof optimism . id
32
+ >
33
+ >
34
+ expectTypeOf < Result [ 'poll' ] > ( ) . toEqualTypeOf < boolean | undefined > ( )
35
+ useWatchBlockNumber ( {
36
+ config,
37
+ poll : false ,
38
+ onBlockNumber ( ) { } ,
39
+ } )
40
+
41
+ type Result2 = DeepUnwrapRef <
42
+ UseWatchBlockNumberParameters < typeof config , typeof mainnet . id >
43
+ >
44
+ expectTypeOf < Result2 [ 'poll' ] > ( ) . toEqualTypeOf < true | undefined > ( )
45
+ useWatchBlockNumber ( {
46
+ config,
47
+ chainId : mainnet . id ,
48
+ poll : true ,
49
+ onBlockNumber ( ) { } ,
50
+ } )
51
+ useWatchBlockNumber ( {
52
+ config,
53
+ chainId : mainnet . id ,
54
+ // @ts -expect-error
55
+ poll : false ,
56
+ onBlockNumber ( ) { } ,
57
+ } )
58
+
59
+ type Result3 = DeepUnwrapRef <
60
+ UseWatchBlockNumberParameters < typeof config , typeof optimism . id >
61
+ >
62
+ expectTypeOf < Result3 [ 'poll' ] > ( ) . toEqualTypeOf < boolean | undefined > ( )
63
+ useWatchBlockNumber ( {
64
+ config,
65
+ chainId : optimism . id ,
66
+ poll : true ,
67
+ onBlockNumber ( ) { } ,
68
+ } )
69
+ useWatchBlockNumber ( {
70
+ config,
71
+ chainId : optimism . id ,
72
+ poll : false ,
73
+ onBlockNumber ( ) { } ,
74
+ } )
75
+ } )
You can’t perform that action at this time.
0 commit comments