@@ -7,12 +7,15 @@ import * as viem from "viem";
77
88type Eip1193Provider = Parameters < typeof viem . custom > [ 0 ] ;
99
10- export interface Chain {
10+ export interface AccountChain < A extends undefined | viem . Account > {
1111 provider : Eip1193Provider ;
1212 public : viem . PublicClient < viem . Transport , viem . Chain > ;
13- wallet : viem . WalletClient < viem . Transport , viem . Chain , viem . Account > ;
13+ wallet : viem . WalletClient < viem . Transport , viem . Chain , A > ;
1414}
1515
16+ export type Chain = AccountChain < viem . Account > ;
17+ export type AnyChain = AccountChain < undefined | viem . Account > ;
18+
1619export interface TestChain extends Chain {
1720 test : viem . TestClient < "ganache" , viem . Transport , viem . Chain > ;
1821}
@@ -140,15 +143,11 @@ function main() {
140143
141144 await blockchain . test . setAutomine ( false ) ;
142145
143- const wallet : Chain = {
146+ const unboundWallet : AccountChain < undefined > = {
144147 provider : window . ethereum ,
145148 wallet : viem . createWalletClient ( {
146149 chain,
147150 transport : viem . custom ( window . ethereum ) ,
148- account : {
149- address : await getAccount ( window . ethereum ) ,
150- type : "json-rpc" ,
151- } as viem . Account ,
152151 pollingInterval : 0 ,
153152 } ) ,
154153 public : viem . createPublicClient ( {
@@ -170,7 +169,7 @@ function main() {
170169 throw "no #container element" ;
171170 }
172171
173- glue = new ManualGlue ( glueElem , wallet ) ;
172+ glue = new ManualGlue ( glueElem , unboundWallet ) ;
174173 }
175174
176175 const uuid = crypto . randomUUID ( ) ;
@@ -272,12 +271,30 @@ function main() {
272271 } ) ;
273272 } ) ;
274273
275- await wallet . wallet . requestAddresses ( ) ;
274+ await unboundWallet . wallet . requestAddresses ( ) ;
276275 unsubscribe ( ) ;
277276 if ( requestAccountsPromise instanceof Promise ) {
278277 await requestAccountsPromise ;
279278 }
280279
280+ const wallet : Chain = {
281+ provider : window . ethereum ,
282+ wallet : viem . createWalletClient ( {
283+ chain,
284+ transport : viem . custom ( window . ethereum ) ,
285+ account : {
286+ address : await getAccount ( window . ethereum ) ,
287+ type : "json-rpc" ,
288+ } as viem . Account ,
289+ pollingInterval : 0 ,
290+ } ) ,
291+ public : viem . createPublicClient ( {
292+ chain,
293+ transport : viem . custom ( window . ethereum ) ,
294+ pollingInterval : 0 ,
295+ } ) ,
296+ } ;
297+
281298 await tests . run ( blockchain , wallet ) ;
282299 } ) ;
283300
0 commit comments