File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
packages/thirdweb/src/chains Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " thirdweb " : patch
3
+ ---
4
+
5
+ Read RPC url from viem chain in viem chain adapter
Original file line number Diff line number Diff line change
1
+ import { defineChain as viemChain } from "viem" ;
2
+ import { describe , expect , it } from "vitest" ;
3
+ import { defineChain } from "./utils.js" ;
4
+
5
+ describe ( "defineChain" , ( ) => {
6
+ it ( "should convert viem chain to thirdweb chain" , ( ) => {
7
+ const zoraViem = viemChain ( {
8
+ id : 7777777 ,
9
+ name : "Zora" ,
10
+ nativeCurrency : {
11
+ decimals : 18 ,
12
+ name : "Ether" ,
13
+ symbol : "ETH" ,
14
+ } ,
15
+ rpcUrls : {
16
+ default : {
17
+ http : [ "https://rpc.zora.energy" ] ,
18
+ webSocket : [ "wss://rpc.zora.energy" ] ,
19
+ } ,
20
+ } ,
21
+ blockExplorers : {
22
+ default : { name : "Explorer" , url : "https://explorer.zora.energy" } ,
23
+ } ,
24
+ } ) ;
25
+ const thirdwebViem = defineChain ( zoraViem ) ;
26
+
27
+ expect ( thirdwebViem . id ) . toEqual ( zoraViem . id ) ;
28
+ expect ( thirdwebViem . name ) . toEqual ( zoraViem . name ) ;
29
+ expect ( thirdwebViem . nativeCurrency ) . toEqual ( zoraViem . nativeCurrency ) ;
30
+ expect ( thirdwebViem . rpc ) . toEqual ( zoraViem . rpcUrls . default . http [ 0 ] ) ;
31
+ } ) ;
32
+ } ) ;
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ function convertViemChain(viemChain: ViemChain): Chain {
91
91
symbol : viemChain . nativeCurrency . symbol ,
92
92
decimals : viemChain . nativeCurrency . decimals ,
93
93
} ,
94
+ rpc :
95
+ viemChain . rpcUrls . default . http [ 0 ] ??
96
+ `https://${ viemChain . id } .rpc.thirdweb.com` ,
94
97
blockExplorers : viemChain ?. blockExplorers
95
98
? Object . values ( viemChain ?. blockExplorers ) . map ( ( explorer ) => {
96
99
return {
You can’t perform that action at this time.
0 commit comments