diff options
author | Fabio Berger <me@fabioberger.com> | 2017-12-20 05:58:06 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-12-20 05:58:06 +0800 |
commit | 41104b2d457b9b662122c139ee83bb8d0f519a51 (patch) | |
tree | 4743803be2564e0e5221b9a41e2c293a6fe52dd9 /packages/0x.js/src | |
parent | 2930537a512bdaa74181fea74ce6befdf5b305b4 (diff) | |
parent | c39ac903a972930d538f8fa3292c658201b1c5e5 (diff) | |
download | dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar.gz dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar.bz2 dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar.lz dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar.xz dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.tar.zst dexon-sol-tools-41104b2d457b9b662122c139ee83bb8d0f519a51.zip |
Merge branch 'development' into createWethPage
* development: (27 commits)
Remove re-assignment
Fix scrolling topBar on Portal
Fix overflow issue on calculated fillAmount
Fix faulty import
Introduce an identityCommandBuilder
Define types for methodID
Define types for ethereumjs-abi
Install types for yargs
Fix comments
Fix linter issues
Fix linter error
Rename SubscriptionOpts to BlockRange
Refactor remaining _.assign to spread operator
Move muiTheme into it's own module
Refactor configs and constants, standardize on uppercase/snakecase, alphebetize, rename for logical grouping
Sort colors into color spectrum
remove unused style
standarize on `grey` over `gray` spelling and other color related fixes
Standardize colors to always be in uppercase hex and consolidate material-ui greys
Consolidate all custom colors and material-ui colors into a colors module
...
# Conflicts:
# packages/website/ts/components/eth_wrappers.tsx
# packages/website/ts/components/portal.tsx
# packages/website/ts/utils/configs.ts
# packages/website/ts/utils/constants.ts
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r-- | packages/0x.js/src/contract_wrappers/contract_wrapper.ts | 6 | ||||
-rw-r--r-- | packages/0x.js/src/contract_wrappers/exchange_wrapper.ts | 10 | ||||
-rw-r--r-- | packages/0x.js/src/contract_wrappers/token_wrapper.ts | 10 | ||||
-rw-r--r-- | packages/0x.js/src/index.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/src/types.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/src/utils/filter_utils.ts | 8 |
6 files changed, 19 insertions, 19 deletions
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index 46916ebf4..3f07e4e47 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -7,6 +7,7 @@ import * as Web3 from 'web3'; import { Artifact, BlockParamLiteral, + BlockRange, ContractEventArgs, ContractEvents, EventCallback, @@ -14,7 +15,6 @@ import { InternalZeroExError, LogWithDecodedArgs, RawLog, - SubscriptionOpts, ZeroExError, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; @@ -83,9 +83,9 @@ export class ContractWrapper { return filterToken; } protected async _getLogsAsync<ArgsType extends ContractEventArgs>( - address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts, + address: string, eventName: ContractEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi): Promise<Array<LogWithDecodedArgs<ArgsType>>> { - const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, subscriptionOpts); + const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange); const logs = await this._web3Wrapper.getLogsAsync(filter); const logsWithDecodedArguments = _.map(logs, this._tryToDecodeLogOrNoop.bind(this)); return logsWithDecodedArguments; diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 3ca5695c4..df793aa06 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -7,6 +7,7 @@ import * as Web3 from 'web3'; import {artifacts} from '../artifacts'; import { BlockParamLiteral, + BlockRange, DecodedLogArgs, ECSignature, EventCallback, @@ -25,7 +26,6 @@ import { OrderTransactionOpts, OrderValues, SignedOrder, - SubscriptionOpts, ValidateOrderFillableOpts, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; @@ -616,20 +616,20 @@ export class ExchangeWrapper extends ContractWrapper { /** * Gets historical logs without creating a subscription * @param eventName The exchange contract event you would like to subscribe to. - * @param subscriptionOpts Subscriptions options that let you configure the subscription. + * @param blockRange Block range to get logs from. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters */ public async getLogsAsync<ArgsType extends ExchangeContractEventArgs>( - eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues, + eventName: ExchangeEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, ): Promise<Array<LogWithDecodedArgs<ArgsType>>> { assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents); - assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema); + assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); const exchangeContractAddress = this.getContractAddress(); const logs = await this._getLogsAsync<ArgsType>( - exchangeContractAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.ExchangeArtifact.abi, + exchangeContractAddress, eventName, blockRange, indexFilterValues, artifacts.ExchangeArtifact.abi, ); return logs; } diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index eccb74871..a9eac10e0 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -5,11 +5,11 @@ import * as _ from 'lodash'; import {artifacts} from '../artifacts'; import { + BlockRange, EventCallback, IndexedFilterValues, LogWithDecodedArgs, MethodOpts, - SubscriptionOpts, TokenContractEventArgs, TokenEvents, TransactionOpts, @@ -291,20 +291,20 @@ export class TokenWrapper extends ContractWrapper { * Gets historical logs without creating a subscription * @param tokenAddress An address of the token that emmited the logs. * @param eventName The token contract event you would like to subscribe to. - * @param subscriptionOpts Subscriptions options that let you configure the subscription. + * @param blockRange Block range to get logs from. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters */ public async getLogsAsync<ArgsType extends TokenContractEventArgs>( - tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, + tokenAddress: string, eventName: TokenEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues): Promise<Array<LogWithDecodedArgs<ArgsType>>> { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.doesBelongToStringEnum('eventName', eventName, TokenEvents); - assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema); + assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); const logs = await this._getLogsAsync<ArgsType>( - tokenAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.TokenArtifact.abi, + tokenAddress, eventName, blockRange, indexFilterValues, artifacts.TokenArtifact.abi, ); return logs; } diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 2f5296a9f..b75ca4fa3 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -12,7 +12,7 @@ export { ExchangeEvents, TokenEvents, IndexedFilterValues, - SubscriptionOpts, + BlockRange, BlockParam, OrderCancellationRequest, OrderFillRequest, diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index fb3cfa6df..844ac9ed9 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -217,7 +217,7 @@ export enum BlockParamLiteral { export type BlockParam = BlockParamLiteral|number; -export interface SubscriptionOpts { +export interface BlockRange { fromBlock: BlockParam; toBlock: BlockParam; } diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts index 57c3ee71c..65161c33e 100644 --- a/packages/0x.js/src/utils/filter_utils.ts +++ b/packages/0x.js/src/utils/filter_utils.ts @@ -4,7 +4,7 @@ import * as _ from 'lodash'; import * as uuid from 'uuid/v4'; import * as Web3 from 'web3'; -import {ContractEvents, IndexedFilterValues, SubscriptionOpts} from '../types'; +import {BlockRange, ContractEvents, IndexedFilterValues} from '../types'; const TOPIC_LENGTH = 32; @@ -14,7 +14,7 @@ export const filterUtils = { }, getFilter(address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi, - subscriptionOpts?: SubscriptionOpts): Web3.FilterObject { + blockRange?: BlockRange): Web3.FilterObject { const eventAbi = _.find(abi, {name: eventName}) as Web3.EventAbi; const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName); const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature)); @@ -24,9 +24,9 @@ export const filterUtils = { address, topics, }; - if (!_.isUndefined(subscriptionOpts)) { + if (!_.isUndefined(blockRange)) { filter = { - ...subscriptionOpts, + ...blockRange, ...filter, }; } |