Skip to content

Commit

Permalink
Merge pull request scaffold-eth#592 from dvinubius/bignumbers-in-disp…
Browse files Browse the repository at this point in the history
…layvariable

displayvariable: improve readability for bignumbers within arrays/tuples
  • Loading branch information
codenamejason committed Dec 5, 2021
2 parents 2b3f034 + fd5a9fa commit 88aa63f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react-app/src/components/Contract/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const tryToDisplay = (thing, asText = false) => {
if (thing && thing.indexOf && thing.indexOf("0x") === 0 && thing.length === 42) {
return asText ? thing : <Address address={thing} fontSize={22} />;
}
if (thing && thing.constructor && thing.constructor.name == "Array") {
const mostReadable = v => (["number", "boolean"].includes(typeof v) ? v : tryToDisplay(v));
return JSON.stringify(thing.map(mostReadable));
}
return JSON.stringify(thing);
};

Expand Down

0 comments on commit 88aa63f

Please sign in to comment.