aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-02-01 07:30:09 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-02-01 07:30:09 +0800
commit03cb7233dc5b8556952b4481f87a292e0fca1acf (patch)
tree4c203211a7ce7b0f44ebc45bb6c40621d4ee5b7e /packages/0x.js
parent3a1ca32ff172f735e4b69f125fea4237c83643f0 (diff)
parent6682abf89dcdf566f05f8d88cb6af06c4bb1f6a2 (diff)
downloaddexon-0x-contracts-03cb7233dc5b8556952b4481f87a292e0fca1acf.tar.gz
dexon-0x-contracts-03cb7233dc5b8556952b4481f87a292e0fca1acf.tar.zst
dexon-0x-contracts-03cb7233dc5b8556952b4481f87a292e0fca1acf.zip
Merge branch 'development' into feature/testnet-faucets/order-dispenser
* development: (49 commits) Prettier Updated contract generation in 0x to new abi-gen CLI Add PR number to changelog Fix lint errors Removed deprecated CLI options Add protected keyword to underscore lint rule Remove unused prop Fix prettier Uppercase Networks enum values Make default gasPrice more readable Fix prettier mess Fix linter errors Shrink img Fix all setState calls after unmounted errors. Decided to create our own flag rather then using a cancellablePromise since there was little to be gained from this alternative Fix bug where we were return undefined instead of the empty object Default the derivation path to that found in the Ledger subprovider Add browser data to dialog info Add Rinkeby support Pass in whether we want the personal message prefix appended and never append it for Ledger. This fixes signing when Ledger is used and the backing node is not Parity Wholesale replace the tokenByAddress and de-dup properly ...
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/contract_templates/contract.handlebars (renamed from packages/0x.js/contract_templates/contract.mustache)2
-rw-r--r--packages/0x.js/contract_templates/partials/call.handlebars (renamed from packages/0x.js/contract_templates/partials/call.mustache)4
-rw-r--r--packages/0x.js/contract_templates/partials/params.handlebars (renamed from packages/0x.js/contract_templates/partials/params.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/return_type.handlebars (renamed from packages/0x.js/contract_templates/partials/return_type.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/tx.handlebars (renamed from packages/0x.js/contract_templates/partials/tx.mustache)10
-rw-r--r--packages/0x.js/contract_templates/partials/typed_params.handlebars (renamed from packages/0x.js/contract_templates/partials/typed_params.mustache)0
-rw-r--r--packages/0x.js/package.json2
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts2
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts6
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts6
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/base_contract.ts12
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts6
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts2
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts2
-rw-r--r--packages/0x.js/test/subscription_test.ts4
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts2
16 files changed, 30 insertions, 30 deletions
diff --git a/packages/0x.js/contract_templates/contract.mustache b/packages/0x.js/contract_templates/contract.handlebars
index 3e501cce6..d3fe1b8cc 100644
--- a/packages/0x.js/contract_templates/contract.mustache
+++ b/packages/0x.js/contract_templates/contract.handlebars
@@ -20,6 +20,6 @@ export class {{contractName}}Contract extends BaseContract {
{{/each}}
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
+ classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']);
}
} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/contract_templates/partials/call.mustache b/packages/0x.js/contract_templates/partials/call.handlebars
index ef4bda724..0475136f0 100644
--- a/packages/0x.js/contract_templates/partials/call.mustache
+++ b/packages/0x.js/contract_templates/partials/call.handlebars
@@ -5,8 +5,8 @@ public {{this.name}} = {
): Promise<{{> return_type outputs=outputs}}> {
const self = this as {{contractName}}Contract;
const result = await promisify<{{> return_type outputs=outputs}}>(
- self.web3ContractInstance.{{this.name}}.call,
- self.web3ContractInstance,
+ self._web3ContractInstance.{{this.name}}.call,
+ self._web3ContractInstance,
)(
{{> params inputs=inputs}}
);
diff --git a/packages/0x.js/contract_templates/partials/params.mustache b/packages/0x.js/contract_templates/partials/params.handlebars
index ac5d4ae85..ac5d4ae85 100644
--- a/packages/0x.js/contract_templates/partials/params.mustache
+++ b/packages/0x.js/contract_templates/partials/params.handlebars
diff --git a/packages/0x.js/contract_templates/partials/return_type.mustache b/packages/0x.js/contract_templates/partials/return_type.handlebars
index 383961a40..383961a40 100644
--- a/packages/0x.js/contract_templates/partials/return_type.mustache
+++ b/packages/0x.js/contract_templates/partials/return_type.handlebars
diff --git a/packages/0x.js/contract_templates/partials/tx.mustache b/packages/0x.js/contract_templates/partials/tx.handlebars
index 8a43e5319..9df83266a 100644
--- a/packages/0x.js/contract_templates/partials/tx.mustache
+++ b/packages/0x.js/contract_templates/partials/tx.handlebars
@@ -9,7 +9,7 @@ public {{this.name}} = {
{{/this.payable}}
): Promise<string> {
const self = this as {{contractName}}Contract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
+ const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
txData,
self.{{this.name}}.estimateGasAsync.bind(
self,
@@ -17,7 +17,7 @@ public {{this.name}} = {
),
);
const txHash = await promisify<string>(
- self.web3ContractInstance.{{this.name}}, self.web3ContractInstance,
+ self._web3ContractInstance.{{this.name}}, self._web3ContractInstance,
)(
{{> params inputs=inputs}}
txDataWithDefaults,
@@ -29,11 +29,11 @@ public {{this.name}} = {
txData: TxData = {},
): Promise<number> {
const self = this as {{contractName}}Contract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
+ const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
txData,
);
const gas = await promisify<number>(
- self.web3ContractInstance.{{this.name}}.estimateGas, self.web3ContractInstance,
+ self._web3ContractInstance.{{this.name}}.estimateGas, self._web3ContractInstance,
)(
{{> params inputs=inputs}}
txDataWithDefaults,
@@ -45,7 +45,7 @@ public {{this.name}} = {
txData: TxData = {},
): string {
const self = this as {{contractName}}Contract;
- const abiEncodedTransactionData = self.web3ContractInstance.{{this.name}}.getData();
+ const abiEncodedTransactionData = self._web3ContractInstance.{{this.name}}.getData();
return abiEncodedTransactionData;
},
};
diff --git a/packages/0x.js/contract_templates/partials/typed_params.mustache b/packages/0x.js/contract_templates/partials/typed_params.handlebars
index 3ea4b2e95..3ea4b2e95 100644
--- a/packages/0x.js/contract_templates/partials/typed_params.mustache
+++ b/packages/0x.js/contract_templates/partials/typed_params.handlebars
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 9cce372a5..32063aab2 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -12,7 +12,7 @@
"upload_docs_json":
"aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"generate_contract_wrappers":
- "node ../abi-gen/lib/index.js --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --templates contract_templates --output src/contract_wrappers/generated",
+ "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage report_test_coverage",
"test": "run-s clean test:commonjs",
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 5f11d810a..873489dc9 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -52,7 +52,7 @@ export class ContractWrapper {
this._onLogAddedSubscriptionToken = undefined;
this._onLogRemovedSubscriptionToken = undefined;
}
- protected unsubscribeAll(): void {
+ protected _unsubscribeAll(): void {
const filterTokens = _.keys(this._filterCallbacks);
_.each(filterTokens, filterToken => {
this._unsubscribe(filterToken);
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index 8fa7aa78b..cbafcfe94 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -159,11 +159,11 @@ export class EtherTokenWrapper extends ContractWrapper {
/**
* Cancels all existing subscriptions
*/
- public unsubscribeAll(): void {
- super.unsubscribeAll();
+ public _unsubscribeAll(): void {
+ super._unsubscribeAll();
}
private _invalidateContractInstance(): void {
- this.unsubscribeAll();
+ this._unsubscribeAll();
this._etherTokenContractsByAddress = {};
}
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<EtherTokenContract> {
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index fceab851a..63c0d073a 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -678,8 +678,8 @@ export class ExchangeWrapper extends ContractWrapper {
/**
* Cancels all existing subscriptions
*/
- public unsubscribeAll(): void {
- super.unsubscribeAll();
+ public _unsubscribeAll(): void {
+ super._unsubscribeAll();
}
/**
* Gets historical logs without creating a subscription
@@ -861,7 +861,7 @@ export class ExchangeWrapper extends ContractWrapper {
return contractAddress;
}
private _invalidateContractInstances(): void {
- this.unsubscribeAll();
+ this._unsubscribeAll();
delete this._exchangeContractIfExists;
}
private async _isValidSignatureUsingContractCallAsync(
diff --git a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts b/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
index 28a7e2f52..d8fac7eea 100644
--- a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
+++ b/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
@@ -3,9 +3,9 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
export class BaseContract {
- protected web3ContractInstance: Web3.ContractInstance;
- protected defaults: Partial<TxData>;
- protected async applyDefaultsToTxDataAsync<T extends TxData|TxDataPayable>(
+ protected _web3ContractInstance: Web3.ContractInstance;
+ protected _defaults: Partial<TxData>;
+ protected async _applyDefaultsToTxDataAsync<T extends TxData|TxDataPayable>(
txData: T,
estimateGasAsync?: (txData: T) => Promise<number>,
): Promise<TxData> {
@@ -15,7 +15,7 @@ export class BaseContract {
// 3. Gas estimate calculation + safety margin
const removeUndefinedProperties = _.pickBy;
const txDataWithDefaults = {
- ...removeUndefinedProperties(this.defaults),
+ ...removeUndefinedProperties(this._defaults),
...removeUndefinedProperties(txData as any),
// HACK: TS can't prove that T is spreadable.
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
@@ -27,7 +27,7 @@ export class BaseContract {
return txDataWithDefaults;
}
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- this.web3ContractInstance = web3ContractInstance;
- this.defaults = defaults;
+ this._web3ContractInstance = web3ContractInstance;
+ this._defaults = defaults;
}
}
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 4216ff462..98c24d059 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -342,8 +342,8 @@ export class TokenWrapper extends ContractWrapper {
/**
* Cancels all existing subscriptions
*/
- public unsubscribeAll(): void {
- super.unsubscribeAll();
+ public _unsubscribeAll(): void {
+ super._unsubscribeAll();
}
/**
* Gets historical logs without creating a subscription
@@ -374,7 +374,7 @@ export class TokenWrapper extends ContractWrapper {
return logs;
}
private _invalidateContractInstances(): void {
- this.unsubscribeAll();
+ this._unsubscribeAll();
this._tokenContractsByAddress = {};
}
private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
diff --git a/packages/0x.js/test/ether_token_wrapper_test.ts b/packages/0x.js/test/ether_token_wrapper_test.ts
index 6069b42bf..9716abab8 100644
--- a/packages/0x.js/test/ether_token_wrapper_test.ts
+++ b/packages/0x.js/test/ether_token_wrapper_test.ts
@@ -144,7 +144,7 @@ describe('EtherTokenWrapper', () => {
etherTokenAddress = etherToken.address;
});
afterEach(() => {
- zeroEx.etherToken.unsubscribeAll();
+ zeroEx.etherToken._unsubscribeAll();
});
// Hack: Mocha does not allow a test to be both async and have a `done` callback
// Since we need to await the receipt of the event in the `subscribe` callback,
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index c15cd65a9..044298601 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -921,7 +921,7 @@ describe('ExchangeWrapper', () => {
);
});
afterEach(async () => {
- zeroEx.exchange.unsubscribeAll();
+ zeroEx.exchange._unsubscribeAll();
});
// Hack: Mocha does not allow a test to be both async and have a `done` callback
// Since we need to await the receipt of the event in the `subscribe` callback,
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index f485bf84b..337e2effa 100644
--- a/packages/0x.js/test/subscription_test.ts
+++ b/packages/0x.js/test/subscription_test.ts
@@ -49,7 +49,7 @@ describe('SubscriptionTest', () => {
tokenAddress = token.address;
});
afterEach(() => {
- zeroEx.token.unsubscribeAll();
+ zeroEx.token._unsubscribeAll();
_.each(stubs, s => s.restore());
stubs = [];
});
@@ -76,7 +76,7 @@ describe('SubscriptionTest', () => {
const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
- zeroEx.token.unsubscribeAll();
+ zeroEx.token._unsubscribeAll();
done();
})().catch(done);
});
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index 070d6ec47..34ebe30c2 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -377,7 +377,7 @@ describe('TokenWrapper', () => {
tokenAddress = token.address;
});
afterEach(() => {
- zeroEx.token.unsubscribeAll();
+ zeroEx.token._unsubscribeAll();
});
// Hack: Mocha does not allow a test to be both async and have a `done` callback
// Since we need to await the receipt of the event in the `subscribe` callback,