@@ -34,10 +34,12 @@ interface ChainJSON {
34
34
35
35
export class Chain implements ChainJSON {
36
36
constructor (
37
+ public readonly name : string ,
37
38
public readonly id : number ,
38
39
public rpcEndpoints : RPCEndpoint [ ] ,
39
40
public contracts : Contracts ,
40
41
) {
42
+ this . name = name
41
43
this . id = id
42
44
this . rpcEndpoints = new Array < RPCEndpoint > ( )
43
45
for ( const rpcEndpoint of rpcEndpoints ) {
@@ -48,6 +50,7 @@ export class Chain implements ChainJSON {
48
50
this . contracts [ key ] = contracts [ key ]
49
51
}
50
52
}
53
+
51
54
getRPCEndpointsByProtocol ( protocol : RPCProtocol ) : RPCEndpoint [ ] {
52
55
const endpoints = new Array < RPCEndpoint > ( )
53
56
for ( const rpcEndpoint of this . rpcEndpoints ) {
@@ -63,6 +66,10 @@ export class Chain implements ChainJSON {
63
66
}
64
67
return endpoints
65
68
}
69
+
70
+ toString ( ) : string {
71
+ return this . name
72
+ }
66
73
}
67
74
68
75
interface ChainsJSON {
@@ -92,7 +99,7 @@ class ChainsFactory {
92
99
for ( const key of Object . keys ( chainJson . contracts ) ) {
93
100
contracts [ key ] = chainJson . contracts [ key ]
94
101
}
95
- chains [ key ] = new Chain ( chainJson . id , rpcEndpoints , contracts )
102
+ chains [ key ] = new Chain ( key , chainJson . id , rpcEndpoints , contracts )
96
103
}
97
104
return chains
98
105
}
0 commit comments