File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Thirdweb.Tests/Thirdweb.Utils Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -584,4 +584,33 @@ public async Task GetAddressFromENS_ReturnsAddress_WhenENSNameIsValid()
584
584
result = await Utils . GetAddressFromENS ( this . Client , validENSName ) ;
585
585
Assert . Equal ( expectedAddress . ToChecksumAddress ( ) , result ) ;
586
586
}
587
+
588
+ /*
589
+ public static async Task<bool> IsDeployed(ThirdwebClient client, BigInteger chainId, string address)
590
+ {
591
+ var rpc = ThirdwebRPC.GetRpcInstance(client, chainId);
592
+ var code = await rpc.SendRequestAsync<string>("eth_getCode", address, "latest");
593
+ return code != "0x";
594
+ }
595
+ */
596
+
597
+ [ Fact ( Timeout = 120000 ) ]
598
+ public async Task IsDeployed_ReturnsTrue_WhenContractIsDeployed ( )
599
+ {
600
+ var chainId = new BigInteger ( 1 ) ;
601
+ var address = "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" ;
602
+ var isDeployed = await Utils . IsDeployed ( this . Client , chainId , address ) ;
603
+
604
+ Assert . True ( isDeployed ) ;
605
+ }
606
+
607
+ [ Fact ( Timeout = 120000 ) ]
608
+ public async Task IsDeployed_ReturnsFalse_WhenContractIsNotDeployed ( )
609
+ {
610
+ var chainId = new BigInteger ( 1 ) ;
611
+ var address = await Utils . GetAddressFromENS ( this . Client , "vitalik.eth" ) ;
612
+ var isDeployed = await Utils . IsDeployed ( this . Client , chainId , address ) ;
613
+
614
+ Assert . False ( isDeployed ) ;
615
+ }
587
616
}
Original file line number Diff line number Diff line change @@ -835,4 +835,11 @@ private static string NameHash(string name)
835
835
}
836
836
return node . EnsureHexPrefix ( ) ;
837
837
}
838
+
839
+ public static async Task < bool > IsDeployed ( ThirdwebClient client , BigInteger chainId , string address )
840
+ {
841
+ var rpc = ThirdwebRPC . GetRpcInstance ( client , chainId ) ;
842
+ var code = await rpc . SendRequestAsync < string > ( "eth_getCode" , address , "latest" ) ;
843
+ return code != "0x" ;
844
+ }
838
845
}
You can’t perform that action at this time.
0 commit comments