diff options
author | Fabio Berger <me@fabioberger.com> | 2018-11-09 07:46:32 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-11-09 07:46:32 +0800 |
commit | eb5f514d25e9392a9226cb778e94c5d7dd6e47f7 (patch) | |
tree | 40cc8c6d7481c01057d5c690f6423cc9938b27e5 /packages/utils/src/configured_bignumber.ts | |
parent | 57318a6ef22876a8c73321b7cc281302bbd67a3b (diff) | |
parent | 117e2f583ff44bdb63340a2134edea0f3ecb77b3 (diff) | |
download | dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar.gz dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar.bz2 dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar.lz dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar.xz dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.tar.zst dexon-sol-tools-eb5f514d25e9392a9226cb778e94c5d7dd6e47f7.zip |
Merge branch 'development' into fixOrderValidation
* development: (51 commits)
[instant] Viewport specific errors (#1228)
Added more comments
Include wholeNumberSchema in sra-spec schemas
chore(instant): fix linter
Fix isNode
fix(instant): update buy quote at start up in the case of default amount
chore(instant): increase max bundle size for bundle watch
Small code review tweaks
fix: apply css reset to overlay as well
fix(website): turn off production flag when building locally
feat(instant): add Account to the ProviderState
feat(instant): fallback to an empty wallet provider when none is injected
[order_utils.py] is_signature_valid, via Exchange contract (#1216)
chore: linter
fix: progress bar
fix: use fontSize prop in button
feat: make instant resistant to external styles
chore(instant): update OrderState enum to follow capitalization conventions
feat: add faux externall css file
Take out unneeded conditionals
...
Diffstat (limited to 'packages/utils/src/configured_bignumber.ts')
-rw-r--r-- | packages/utils/src/configured_bignumber.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index 2b22b6938..34b57d303 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -11,4 +11,27 @@ BigNumber.config({ DECIMAL_PLACES: 78, }); +// Set a debug print function for NodeJS +// Upstream issue: https://github.com/MikeMcl/bignumber.js/issues/188 +import isNode = require('detect-node'); +if (isNode) { + // Dynamically load a NodeJS specific module. + // Typescript requires all imports to be global, so we need to use + // `const` here and disable the tslint warning. + // tslint:disable-next-line: no-var-requires + const util = require('util'); + + // Set a custom util.inspect function + // HACK: We add a function to the BigNumber class by assigning to the + // prototype. The function name is a symbol provided by Node. + (BigNumber.prototype as any)[util.inspect.custom] = function(): string { + // HACK: When executed, `this` will refer to the BigNumber instance. + // This is also why we need a function expression instead of an + // arrow function, as the latter does not have a `this`. + // Return the readable string representation + // tslint:disable-next-line: no-invalid-this + return this.toString(); + }; +} + export { BigNumber }; |