@@ -9,6 +9,7 @@ import { CredentialStore, LncConfig, WasmGlobal } from './types/lnc';
99import LncCredentialStore from './util/credentialStore' ;
1010import { wasmLog as log } from './util/log' ;
1111import { camelKeysToSnake , isObject , snakeKeysToCamel } from './util/objects' ;
12+ import { JS_RESERVED_WORDS } from './util/reservedWords' ;
1213
1314/** The default values for the LncConfig options */
1415const DEFAULT_CONFIG = {
@@ -292,9 +293,7 @@ export default class LNC {
292293 mapKeys : string [ ] = [
293294 'leaseDurationBuckets' , // poolrpc.Trader.LeaseDurations
294295 'leaseDurations' , // poolrpc.Trader.LeaseDurations
295- 'matchedMarkets' , // poolrpc.Trader.BatchSnapshot
296- 'matchedOrders' , // poolrpc.Trader.BatchSnapshot
297- 'routes' // lnrpc.Lightning.QueryRoutes
296+ 'matchedMarkets' // poolrpc.Trader.BatchSnapshot
298297 ] ;
299298
300299 /**
@@ -305,22 +304,28 @@ export default class LNC {
305304 hackListsAndMaps ( response : any ) {
306305 const o : Record < string , any > = { } ;
307306 return Object . entries < any > ( response ) . reduce ( ( updated , [ key , value ] ) => {
308- if ( Array . isArray ( value ) ) {
309- updated [ `${ key } List` ] = value ;
310- } else if ( this . mapKeys . includes ( key ) ) {
307+ if ( this . mapKeys . includes ( key ) ) {
311308 // convert Maps from an object to an array of arrays
312309 // leaseDurationBuckets: { 2016: "MARKET_OPEN", 4032: "MARKET_OPEN" }
313310 // leaseDurationBucketsMap: [ [2016, 3], [4032, 3] ]
314311 updated [ `${ key } Map` ] = Object . entries < any > ( value ) . reduce (
315312 ( all , [ k , v ] ) => {
313+ const j = isNaN ( parseInt ( k , 10 ) ) ? k : parseInt ( k , 10 ) ;
316314 all . push ( [
317- k ,
315+ j ,
318316 isObject ( v ) ? this . hackListsAndMaps ( v ) : v
319317 ] ) ;
320318 return all ;
321319 } ,
322320 [ ] as any [ ]
323321 ) ;
322+ } else if ( Array . isArray ( value ) ) {
323+ updated [ `${ key } List` ] = ( value as any [ ] ) . map ( ( v ) =>
324+ isObject ( v ) ? this . hackListsAndMaps ( v ) : v
325+ ) ;
326+ } else if ( JS_RESERVED_WORDS . includes ( key ) ) {
327+ // add the 'pb_' prefix for keys that are a JS reserved word
328+ updated [ `pb_${ key } ` ] = value ;
324329 } else if ( isObject ( value ) ) {
325330 // recurse into nested objects
326331 updated [ key ] = this . hackListsAndMaps ( value ) ;
0 commit comments