Skip to content

Commit

Permalink
Merge pull request #2574 from kaloudis/embedded-lnd-longs
Browse files Browse the repository at this point in the history
Embedded LND: handle Long values
  • Loading branch information
kaloudis authored Dec 1, 2024
2 parents c31754f + a032ac2 commit 2f1e146
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import 'react-native-gesture-handler';
// polyfills
import 'react-native-get-random-values';
import { TextDecoder } from 'text-encoding';
import Long from 'long';
import protobuf from 'protobufjs';
global.TextDecoder = TextDecoder;

protobuf.util.Long = Long;
protobuf.configure();

import {AppRegistry} from 'react-native';
import './shim.js'
import App from './App.tsx';
Expand Down
10 changes: 9 additions & 1 deletion models/BaseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
export default class BaseModel {
constructor(data?: any) {
Object.keys(data).forEach((field: any) => {
this[field] = data[field];
// Handle Longs
if (
data[field].high !== undefined &&
data[field].low !== undefined
) {
this[field] = data[field].toString();
} else {
this[field] = data[field];
}
});
}
}

0 comments on commit 2f1e146

Please sign in to comment.