diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-26 07:38:29 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:11 +0800 |
commit | dd8bb6d08b6e837304a76e9707b79e070f951e4e (patch) | |
tree | 959c99e619d9ca8bd20e89d7fbfcf03c132b8b0e /packages/utils/src/abi_encoder/abstract_data_types | |
parent | dc7092e1eb11ff9844efe02e367ef37592f38c55 (diff) | |
download | dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar.gz dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar.bz2 dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar.lz dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar.xz dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.tar.zst dexon-0x-contracts-dd8bb6d08b6e837304a76e9707b79e070f951e4e.zip |
Made default encoding/decoding rules global to all modules in encoder
Diffstat (limited to 'packages/utils/src/abi_encoder/abstract_data_types')
-rw-r--r-- | packages/utils/src/abi_encoder/abstract_data_types/data_type.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts index c83f2085e..dd166b19c 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts @@ -2,13 +2,12 @@ import { DataItem } from 'ethereum-types'; import * as _ from 'lodash'; import { Calldata, CalldataBlock, RawCalldata } from '../calldata'; +import * as Constants from '../utils/constants'; import { DecodingRules, EncodingRules } from '../utils/rules'; import { DataTypeFactory } from './interfaces'; export abstract class DataType { - private static readonly _DEFAULT_ENCODING_RULES: EncodingRules = { optimize: false, annotate: false }; - private static readonly _DEFAULT_DECODING_RULES: DecodingRules = { structsAsObjects: false }; private readonly _dataItem: DataItem; private readonly _factory: DataTypeFactory; @@ -26,7 +25,7 @@ export abstract class DataType { } public encode(value: any, rules?: EncodingRules, selector?: string): string { - const rules_ = rules ? rules : DataType._DEFAULT_ENCODING_RULES; + const rules_ = rules ? rules : Constants.DEFAULT_ENCODING_RULES; const calldata = new Calldata(rules_); if (selector) { calldata.setSelector(selector); @@ -39,7 +38,7 @@ export abstract class DataType { public decode(calldata: string, rules?: DecodingRules, hasSelector: boolean = false): any { const rawCalldata = new RawCalldata(calldata, hasSelector); - const rules_ = rules ? rules : DataType._DEFAULT_DECODING_RULES; + const rules_ = rules ? rules : Constants.DEFAULT_DECODING_RULES; const value = this.generateValue(rawCalldata, rules_); return value; } |