aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/utils/index.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-12-13 08:49:01 +0800
committerGitHub <noreply@github.com>2018-12-13 08:49:01 +0800
commit3a8f3e01b611f666afd8769b532f8576ca5b5e14 (patch)
treeca4e4998e6b32522f79502a3da18453e520291c2 /packages/pipeline/src/utils/index.ts
parentf9d436cd213a6d9800aa528c9bac5415230378f4 (diff)
downloaddexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar.gz
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar.bz2
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar.lz
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar.xz
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.tar.zst
dexon-0x-contracts-3a8f3e01b611f666afd8769b532f8576ca5b5e14.zip
Fix bug that occurs when token metadata decimals is undefined. (#1426)
* Fix bug that occurs when token metadata decimals is undefined. * move toBigNumberOrNull to utils
Diffstat (limited to 'packages/pipeline/src/utils/index.ts')
-rw-r--r--packages/pipeline/src/utils/index.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/pipeline/src/utils/index.ts b/packages/pipeline/src/utils/index.ts
index 2096a0a39..094c0178e 100644
--- a/packages/pipeline/src/utils/index.ts
+++ b/packages/pipeline/src/utils/index.ts
@@ -15,6 +15,21 @@ export function bigNumbertoStringOrNull(n: BigNumber): string | null {
}
/**
+ * If value is null or undefined, returns null. Otherwise converts value to a
+ * BigNumber.
+ * @param value A string or number to be converted to a BigNumber
+ */
+export function toBigNumberOrNull(value: string | number | null): BigNumber | null {
+ switch (value) {
+ case null:
+ case undefined:
+ return null;
+ default:
+ return new BigNumber(value);
+ }
+}
+
+/**
* Logs an error by intelligently checking for `message` and `stack` properties.
* Intended for use with top-level immediately invoked asynchronous functions.
* @param e the error to log.