diff options
-rw-r--r-- | src/0x.js.ts | 2 | ||||
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 2 | ||||
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 6 | ||||
-rw-r--r-- | src/utils/assert.ts | 16 | ||||
-rw-r--r-- | test/assert_test.ts | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts index 19e74b484..0f437e039 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -163,7 +163,7 @@ export class ZeroEx { */ public async signOrderHashAsync(orderHashHex: string, signerAddress: string): Promise<ECSignature> { assert.isHexString('orderHashHex', orderHashHex); - await assert.isSenderAddressHexAsync('signerAddress', signerAddress, this.web3Wrapper); + await assert.isSenderAddressAsync('signerAddress', signerAddress, this.web3Wrapper); let msgHashHex; const nodeVersion = await this.web3Wrapper.getNodeVersionAsync(); diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index dd06830aa..08e592729 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -121,7 +121,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrderSchema); assert.isBigNumber('fillTakerAmount', fillTakerAmount); assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer); - await assert.isSenderAddressHexAsync('takerAddress', takerAddress, this.web3Wrapper); + await assert.isSenderAddressAsync('takerAddress', takerAddress, this.web3Wrapper); const exchangeInstance = await this.getExchangeContractAsync(); await this.validateFillOrderAndThrowIfInvalidAsync(signedOrder, fillTakerAmount, takerAddress); diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 34697d97c..d30645548 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -38,7 +38,7 @@ export class TokenWrapper extends ContractWrapper { */ public async setAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string, amountInBaseUnits: BigNumber.BigNumber): Promise<void> { - await assert.isSenderAddressHexAsync('ownerAddress', ownerAddress, this.web3Wrapper); + await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this.web3Wrapper); assert.isETHAddressHex('spenderAddress', spenderAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); @@ -97,7 +97,7 @@ export class TokenWrapper extends ContractWrapper { public async transferAsync(tokenAddress: string, fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber.BigNumber): Promise<void> { assert.isETHAddressHex('tokenAddress', tokenAddress); - await assert.isSenderAddressHexAsync('fromAddress', fromAddress, this.web3Wrapper); + await assert.isSenderAddressAsync('fromAddress', fromAddress, this.web3Wrapper); assert.isETHAddressHex('toAddress', toAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); @@ -123,7 +123,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isETHAddressHex('fromAddress', fromAddress); assert.isETHAddressHex('toAddress', toAddress); - await assert.isSenderAddressHexAsync('senderAddress', senderAddress, this.web3Wrapper); + await assert.isSenderAddressAsync('senderAddress', senderAddress, this.web3Wrapper); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this.getTokenContractAsync(tokenAddress); diff --git a/src/utils/assert.ts b/src/utils/assert.ts index aee53f30c..621c11eda 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -26,16 +26,16 @@ export const assert = { const web3 = new Web3(); this.assert(web3.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value)); }, - async isSenderAddressHexAsync(variableName: string, senderAddress: string, - web3Wrapper: Web3Wrapper): Promise<void> { - assert.isETHAddressHex(variableName, senderAddress); - await assert.isSenderAddressAvailableAsync(web3Wrapper, variableName, senderAddress); + async isSenderAddressAsync(variableName: string, senderAddressHex: string, + web3Wrapper: Web3Wrapper): Promise<void> { + assert.isETHAddressHex(variableName, senderAddressHex); + await assert.isSenderAddressAvailableAsync(web3Wrapper, variableName, senderAddressHex); }, async isSenderAddressAvailableAsync(web3Wrapper: Web3Wrapper, variableName: string, - senderAddress: string): Promise<void> { - const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddress); - assert.assert(isSenderAddressAvailable, `Specified ${variableName} ${senderAddress} isn't available through the \ - supplied web3 instance`); + senderAddressHex: string): Promise<void> { + const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex); + assert.assert(isSenderAddressAvailable, `Specified ${variableName} ${senderAddressHex} isn't available \ + through the supplied web3 instance`); }, isNumber(variableName: string, value: number): void { this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value)); diff --git a/test/assert_test.ts b/test/assert_test.ts index ff15d6cf6..560ef06d4 100644 --- a/test/assert_test.ts +++ b/test/assert_test.ts @@ -13,20 +13,20 @@ describe('Assertion library', () => { it('throws when address is invalid', async () => { const address = '0xdeadbeef'; const varName = 'address'; - return expect(assert.isSenderAddressHexAsync(varName, address, (zeroEx as any).web3Wrapper)) + return expect(assert.isSenderAddressAsync(varName, address, (zeroEx as any).web3Wrapper)) .to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`); }); it('throws when address is unavailable', async () => { const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42'; const varName = 'address'; - return expect(assert.isSenderAddressHexAsync(varName, validUnrelatedAddress, (zeroEx as any).web3Wrapper)) + return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any).web3Wrapper)) .to.be.rejectedWith(`Specified ${varName} ${validUnrelatedAddress} \ isn't available through the supplied web3 instance`); }); it('doesn\'t throw if address is available', async () => { const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0]; const varName = 'address'; - return expect(assert.isSenderAddressHexAsync(varName, availableAddress, (zeroEx as any).web3Wrapper)) + return expect(assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any).web3Wrapper)) .to.become(undefined); }); }); |