@@ -12,6 +12,7 @@ import {
12
12
parsePermissionData ,
13
13
parsePriceData ,
14
14
parseProductData ,
15
+ Product ,
15
16
} from "@pythnetwork/client" ;
16
17
import {
17
18
findDetermisticAccountAddress ,
@@ -68,10 +69,10 @@ function checkSizeOfProductInstruction(
68
69
/**
69
70
* Sort object by keys
70
71
*/
71
- const sortObjectByKeys = < T extends Record < string , unknown > > ( obj : T ) : T =>
72
- Object . fromEntries (
73
- Object . entries ( obj ) . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) ) ,
74
- ) as T ;
72
+ const sortObjectByKeys = < T extends Record < string , unknown > > (
73
+ obj : T ,
74
+ ) : Array < [ string , unknown ] > =>
75
+ Object . entries ( obj ) . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) ) ;
75
76
76
77
/**
77
78
* Sort configuration data for consistent output
@@ -81,9 +82,14 @@ function sortData(data: DownloadableConfig): DownloadableConfig {
81
82
const keys = Object . keys ( data ) . sort ( ) ;
82
83
for ( const key of keys ) {
83
84
const productData = data [ key ] ;
85
+ const sortedKeyValues = sortObjectByKeys ( productData . metadata ) ;
86
+
84
87
const sortedInnerData : DownloadableProduct = {
85
88
address : productData . address ,
86
- metadata : sortObjectByKeys ( productData . metadata ) ,
89
+ metadata : Object . fromEntries ( sortedKeyValues ) as Omit <
90
+ Product ,
91
+ "price_account"
92
+ > ,
87
93
priceAccounts : [ ] ,
88
94
} ;
89
95
0 commit comments