aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/stores
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-25 23:42:58 +0800
committerFabio Berger <me@fabioberger.com>2018-01-25 23:42:58 +0800
commit71d68f975cd7bc089f0cbef4e5888a73eab4ee42 (patch)
tree9482602fc23d2baec3fff1fb97750ad45adc6eca /packages/0x.js/src/stores
parentec3d8a034fe763d8255935985b1fb97aff6c177b (diff)
parentf58f0ddb67555c3f0c7252ea3e003824984c48ad (diff)
downloaddexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.gz
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.bz2
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.lz
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.xz
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.zst
dexon-sol-tools-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.zip
Merge branch 'development' into feature/portal-ledger-support
* development: (437 commits) Publish Update yarn.lock Update the CHANGELOG Fix the bug making it impossible to specify the custom ZRX address Fix fill/cancel order by looking for NoError instead of empty blockchainErr given the BlockchainErrs type refactor Add a comment about a yarn bug Add our mainnet and kovan nodes as backups for Portal requests Fix bug hiding the user info from topBar Add dev-utils package to top level README Prettier newline Prettier Allow Token symbols to be alphanumeric Update CHANGELOG, rebase on development Should not -> cannot Reject negative amounts in isValidBaseUnitAmount Re-add changelog for 0x.js Fix prettier Update yarn.lock Move tests to a separate folder Change file layout ... # Conflicts: # packages/website/README.md
Diffstat (limited to 'packages/0x.js/src/stores')
-rw-r--r--packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts75
-rw-r--r--packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts43
2 files changed, 59 insertions, 59 deletions
diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
index 6225e9e72..33feea105 100644
--- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
+++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
@@ -1,85 +1,86 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {BlockParamLiteral} from '../types';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
+import { BlockParamLiteral } from '../types';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
*/
export class BalanceAndProxyAllowanceLazyStore {
- private token: TokenWrapper;
- private defaultBlock: BlockParamLiteral;
- private balance: {
+ private _token: TokenWrapper;
+ private _defaultBlock: BlockParamLiteral;
+ private _balance: {
[tokenAddress: string]: {
[userAddress: string]: BigNumber;
};
};
- private proxyAllowance: {
+ private _proxyAllowance: {
[tokenAddress: string]: {
[userAddress: string]: BigNumber;
};
};
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
- this.token = token;
- this.defaultBlock = defaultBlock;
- this.balance = {};
- this.proxyAllowance = {};
+ this._token = token;
+ this._defaultBlock = defaultBlock;
+ this._balance = {};
+ this._proxyAllowance = {};
}
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
- if (_.isUndefined(this.balance[tokenAddress]) || _.isUndefined(this.balance[tokenAddress][userAddress])) {
+ if (_.isUndefined(this._balance[tokenAddress]) || _.isUndefined(this._balance[tokenAddress][userAddress])) {
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock: this._defaultBlock,
};
- const balance = await this.token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
+ const balance = await this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
this.setBalance(tokenAddress, userAddress, balance);
}
- const cachedBalance = this.balance[tokenAddress][userAddress];
+ const cachedBalance = this._balance[tokenAddress][userAddress];
return cachedBalance;
}
public setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void {
- if (_.isUndefined(this.balance[tokenAddress])) {
- this.balance[tokenAddress] = {};
+ if (_.isUndefined(this._balance[tokenAddress])) {
+ this._balance[tokenAddress] = {};
}
- this.balance[tokenAddress][userAddress] = balance;
+ this._balance[tokenAddress][userAddress] = balance;
}
public deleteBalance(tokenAddress: string, userAddress: string): void {
- if (!_.isUndefined(this.balance[tokenAddress])) {
- delete this.balance[tokenAddress][userAddress];
- if (_.isEmpty(this.balance[tokenAddress])) {
- delete this.balance[tokenAddress];
+ if (!_.isUndefined(this._balance[tokenAddress])) {
+ delete this._balance[tokenAddress][userAddress];
+ if (_.isEmpty(this._balance[tokenAddress])) {
+ delete this._balance[tokenAddress];
}
}
}
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
- if (_.isUndefined(this.proxyAllowance[tokenAddress]) ||
- _.isUndefined(this.proxyAllowance[tokenAddress][userAddress])) {
+ if (
+ _.isUndefined(this._proxyAllowance[tokenAddress]) ||
+ _.isUndefined(this._proxyAllowance[tokenAddress][userAddress])
+ ) {
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock: this._defaultBlock,
};
- const proxyAllowance = await this.token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
+ const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
}
- const cachedProxyAllowance = this.proxyAllowance[tokenAddress][userAddress];
+ const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
return cachedProxyAllowance;
}
public setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void {
- if (_.isUndefined(this.proxyAllowance[tokenAddress])) {
- this.proxyAllowance[tokenAddress] = {};
+ if (_.isUndefined(this._proxyAllowance[tokenAddress])) {
+ this._proxyAllowance[tokenAddress] = {};
}
- this.proxyAllowance[tokenAddress][userAddress] = proxyAllowance;
+ this._proxyAllowance[tokenAddress][userAddress] = proxyAllowance;
}
public deleteProxyAllowance(tokenAddress: string, userAddress: string): void {
- if (!_.isUndefined(this.proxyAllowance[tokenAddress])) {
- delete this.proxyAllowance[tokenAddress][userAddress];
- if (_.isEmpty(this.proxyAllowance[tokenAddress])) {
- delete this.proxyAllowance[tokenAddress];
+ if (!_.isUndefined(this._proxyAllowance[tokenAddress])) {
+ delete this._proxyAllowance[tokenAddress][userAddress];
+ if (_.isEmpty(this._proxyAllowance[tokenAddress])) {
+ delete this._proxyAllowance[tokenAddress];
}
}
}
public deleteAll(): void {
- this.balance = {};
- this.proxyAllowance = {};
+ this._balance = {};
+ this._proxyAllowance = {};
}
}
diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
index 28b32f9e2..e22364c09 100644
--- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
@@ -1,62 +1,61 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {BlockParamLiteral} from '../types';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import { BlockParamLiteral } from '../types';
/**
* Copy on read store for filled/cancelled taker amounts
*/
export class OrderFilledCancelledLazyStore {
- private exchange: ExchangeWrapper;
- private filledTakerAmount: {
+ private _exchange: ExchangeWrapper;
+ private _filledTakerAmount: {
[orderHash: string]: BigNumber;
};
- private cancelledTakerAmount: {
+ private _cancelledTakerAmount: {
[orderHash: string]: BigNumber;
};
constructor(exchange: ExchangeWrapper) {
- this.exchange = exchange;
- this.filledTakerAmount = {};
- this.cancelledTakerAmount = {};
+ this._exchange = exchange;
+ this._filledTakerAmount = {};
+ this._cancelledTakerAmount = {};
}
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
- if (_.isUndefined(this.filledTakerAmount[orderHash])) {
+ if (_.isUndefined(this._filledTakerAmount[orderHash])) {
const methodOpts = {
defaultBlock: BlockParamLiteral.Pending,
};
- const filledTakerAmount = await this.exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
+ const filledTakerAmount = await this._exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
this.setFilledTakerAmount(orderHash, filledTakerAmount);
}
- const cachedFilled = this.filledTakerAmount[orderHash];
+ const cachedFilled = this._filledTakerAmount[orderHash];
return cachedFilled;
}
public setFilledTakerAmount(orderHash: string, filledTakerAmount: BigNumber): void {
- this.filledTakerAmount[orderHash] = filledTakerAmount;
+ this._filledTakerAmount[orderHash] = filledTakerAmount;
}
public deleteFilledTakerAmount(orderHash: string): void {
- delete this.filledTakerAmount[orderHash];
+ delete this._filledTakerAmount[orderHash];
}
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
- if (_.isUndefined(this.cancelledTakerAmount[orderHash])) {
+ if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
const methodOpts = {
defaultBlock: BlockParamLiteral.Pending,
};
- const cancelledTakerAmount = await this.exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
+ const cancelledTakerAmount = await this._exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
}
- const cachedCancelled = this.cancelledTakerAmount[orderHash];
+ const cachedCancelled = this._cancelledTakerAmount[orderHash];
return cachedCancelled;
}
public setCancelledTakerAmount(orderHash: string, cancelledTakerAmount: BigNumber): void {
- this.cancelledTakerAmount[orderHash] = cancelledTakerAmount;
+ this._cancelledTakerAmount[orderHash] = cancelledTakerAmount;
}
public deleteCancelledTakerAmount(orderHash: string): void {
- delete this.cancelledTakerAmount[orderHash];
+ delete this._cancelledTakerAmount[orderHash];
}
public deleteAll(): void {
- this.filledTakerAmount = {};
- this.cancelledTakerAmount = {};
+ this._filledTakerAmount = {};
+ this._cancelledTakerAmount = {};
}
}