Skip to content

Commit

Permalink
returns string if exception when handling values (MystenLabs#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
apburnie authored Jun 7, 2022
1 parent 45111db commit 6115512
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdk/typescript/src/rpc/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export class JsonRpcClient {
const text = await res.text();
const result = JSON.stringify(LosslessJSON.parse(text, (key : string, value : any) => {
if (key === "balance") return value.toString();
if (value.isLosslessNumber) return value.valueOf();
try {
if (value.isLosslessNumber) return value.valueOf();
} catch {
return value.toString();
}
return value;
}
));
Expand Down

0 comments on commit 6115512

Please sign in to comment.