aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 04:14:18 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 04:14:18 +0800
commit7dddf2010e16167260f7ffbb7c7d2fd83609d8a0 (patch)
tree9e5ceec9bba32b24a8e4542076ddbba844787760 /src/contract_wrappers/exchange_wrapper.ts
parent34de5986421cca90d37b30a1b64678a8a5149b57 (diff)
downloaddexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.gz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.bz2
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.lz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.xz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.zst
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.zip
Add getExchangeInstanceOrThrowAsync && getSenderAddressOrThrowAsync
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index f0f153c2b..e18b6d35e 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -16,11 +16,8 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('ecSignature', ecSignature, ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
- const senderAddressIfExists = await this.web3Wrapper.getSenderAddressIfExistsAsync();
- assert.assert(!_.isUndefined(senderAddressIfExists), ZeroExError.USER_HAS_NO_ASSOCIATED_ADDRESSES);
-
- const contractInstance = await this.instantiateContractIfExistsAsync((ExchangeArtifacts as any));
- const exchangeInstance = contractInstance as ExchangeContract;
+ const senderAddress = await this.web3Wrapper.getSenderAddressOrThrowAsync();
+ const exchangeInstance = await this.getExchangeInstanceOrThrowAsync();
const isValidSignature = await exchangeInstance.isValidSignature.call(
signerAddressHex,
@@ -29,9 +26,13 @@ export class ExchangeWrapper extends ContractWrapper {
ecSignature.r,
ecSignature.s,
{
- from: senderAddressIfExists,
+ from: senderAddress,
},
);
return isValidSignature;
}
+ private async getExchangeInstanceOrThrowAsync(): Promise<ExchangeContract> {
+ const contractInstance = await this.instantiateContractIfExistsAsync((ExchangeArtifacts as any));
+ return contractInstance as ExchangeContract;
+ }
}