File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @hyperbitjs/chains" ,
3
- "version" : " 1.7.2 " ,
3
+ "version" : " 1.8.0 " ,
4
4
"license" : " MIT" ,
5
5
"main" : " dist/index.js" ,
6
6
"typings" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ export function findNetworkById(id: string): Network | undefined {
69
69
return undefined ;
70
70
}
71
71
72
- export function getChainIds ( network : string ) : string [ ] {
72
+ export function getChainIds ( symbol : string ) : string [ ] {
73
73
return Object . keys ( chains ) . reduce < string [ ] > ( ( acc : string [ ] , key : string ) => {
74
- const n = chains [ key ] [ network ] ;
74
+ const n = chains [ key ] [ symbol ] ;
75
75
if ( n ) {
76
76
return [ ...acc , n . id ] ;
77
77
}
@@ -86,11 +86,23 @@ export function getChainNames(): string[] {
86
86
} , [ ] ) ;
87
87
}
88
88
89
- export function getChainsByNetwork ( network : string ) : Network [ ] {
89
+ /**
90
+ * Return Networks by the blockchain symbol. If network is provided, return only the network with the given network.
91
+ * @param symbol e.g. btc
92
+ * @param network e.g. mainnet
93
+ * @returns Network[]
94
+ */
95
+ export function getChainsByNetwork ( symbol : string , network ?: string ) : Network [ ] {
90
96
return Object . keys ( chains ) . reduce < Network [ ] > (
91
97
( acc : Network [ ] , key : string ) => {
92
- const n = chains [ key ] [ network ] ;
98
+ const n = chains [ key ] [ symbol ] ;
93
99
if ( n ) {
100
+ if ( network ) {
101
+ if ( n . network === network ) {
102
+ return [ ...acc , n ] ;
103
+ }
104
+ return acc ;
105
+ }
94
106
return [ ...acc , n ] ;
95
107
}
96
108
return acc ;
You can’t perform that action at this time.
0 commit comments