aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-11 19:41:06 +0800
committerGitHub <noreply@github.com>2017-06-11 19:41:06 +0800
commit7838e1964f112b8df63422c23a675a7946c7b9e3 (patch)
treeaebb4110745c7bc1752fcff46729c301695e601a
parent8b9d8ad1b625967fe264fe87e617af1089e1d0e9 (diff)
parent6b41ef680c90ec19fabc603e9288bde7ec3bc6b1 (diff)
downloaddexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar.gz
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar.bz2
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar.lz
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar.xz
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.tar.zst
dexon-sol-tools-7838e1964f112b8df63422c23a675a7946c7b9e3.zip
Merge pull request #61 from 0xProject/names-hex
Remove Hex suffix from public functions parameters names
-rw-r--r--src/0x.js.ts44
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts28
2 files changed, 36 insertions, 36 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index b1e4e25ff..b641739ac 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -36,18 +36,18 @@ export class ZeroEx {
private web3Wrapper: Web3Wrapper;
/**
* Verifies that the elliptic curve signature `signature` was generated
- * by signing `dataHex` with the private key corresponding to the `signerAddressHex` address.
- * @param dataHex The hex encoded data signed by the supplied signature.
- * @param signature A JS object containing the elliptic curve signature parameters.
- * @param signerAddressHex The hex encoded address that signed the dataHex, producing the supplied signature.
- * @return Whether the signature is valid for the supplied signerAddressHex and dataHex.
+ * by signing `data` with the private key corresponding to the `signerAddress` address.
+ * @param data The hex encoded data signed by the supplied signature.
+ * @param signature A JS object containing the elliptic curve signature parameters.
+ * @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
+ * @return Whether the signature is valid for the supplied signerAddress and data.
*/
- public static isValidSignature(dataHex: string, signature: ECSignature, signerAddressHex: string): boolean {
- assert.isHexString('dataHex', dataHex);
+ public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
+ assert.isHexString('data', data);
assert.doesConformToSchema('signature', signature, ecSignatureSchema);
- assert.isETHAddressHex('signerAddressHex', signerAddressHex);
+ assert.isETHAddressHex('signerAddress', signerAddress);
- const dataBuff = ethUtil.toBuffer(dataHex);
+ const dataBuff = ethUtil.toBuffer(data);
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
try {
const pubKey = ethUtil.ecrecover(
@@ -56,7 +56,7 @@ export class ZeroEx {
ethUtil.toBuffer(signature.r),
ethUtil.toBuffer(signature.s));
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
- return retrievedAddress === signerAddressHex;
+ return retrievedAddress === signerAddress;
} catch (err) {
return false;
}
@@ -79,14 +79,14 @@ export class ZeroEx {
* Checks if the supplied hex encoded order hash is valid.
* Note: Valid means it has the expected format, not that an order with the orderHash exists.
* Use this method when processing orderHashes submitted as user input.
- * @param orderHashHex Hex encoded orderHash.
- * @return Whether the supplied orderHashHex has the expected format.
+ * @param orderHash Hex encoded orderHash.
+ * @return Whether the supplied orderHash has the expected format.
*/
- public static isValidOrderHash(orderHashHex: string): boolean {
+ public static isValidOrderHash(orderHash: string): boolean {
// Since this method can be called to check if any arbitrary string conforms to an orderHash's
// format, we only assert that we were indeed passed a string.
- assert.isString('orderHashHex', orderHashHex);
- const isValidOrderHash = utils.isValidOrderHash(orderHashHex);
+ assert.isString('orderHash', orderHash);
+ const isValidOrderHash = utils.isValidOrderHash(orderHash);
return isValidOrderHash;
}
/**
@@ -167,13 +167,13 @@ export class ZeroEx {
/**
* Signs an orderHash and returns it's elliptic curve signature.
* This method currently supports TestRPC, Geth and Parity above and below V1.6.6
- * @param orderHashHex Hex encoded orderHash to sign.
+ * @param orderHash Hex encoded orderHash to sign.
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
* must be available via the Web3.Provider supplied to 0x.js.
- * @return A JS object containing the Elliptic curve signature parameters generated by signing the orderHashHex.
+ * @return A JS object containing the Elliptic curve signature parameters generated by signing the orderHash.
*/
- public async signOrderHashAsync(orderHashHex: string, signerAddress: string): Promise<ECSignature> {
- assert.isHexString('orderHashHex', orderHashHex);
+ public async signOrderHashAsync(orderHash: string, signerAddress: string): Promise<ECSignature> {
+ assert.isHexString('orderHash', orderHash);
await assert.isSenderAddressAsync('signerAddress', signerAddress, this.web3Wrapper);
let msgHashHex;
@@ -181,9 +181,9 @@ export class ZeroEx {
const isParityNode = utils.isParityNode(nodeVersion);
if (isParityNode) {
// Parity node adds the personalMessage prefix itself
- msgHashHex = orderHashHex;
+ msgHashHex = orderHash;
} else {
- const orderHashBuff = ethUtil.toBuffer(orderHashHex);
+ const orderHashBuff = ethUtil.toBuffer(orderHash);
const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff);
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
}
@@ -218,7 +218,7 @@ export class ZeroEx {
r: ethUtil.bufferToHex(r),
s: ethUtil.bufferToHex(s),
};
- const isValidSignature = ZeroEx.isValidSignature(orderHashHex, ecSignature, signerAddress);
+ const isValidSignature = ZeroEx.isValidSignature(orderHash, ecSignature, signerAddress);
if (!isValidSignature) {
throw new Error(ZeroExError.INVALID_SIGNATURE);
}
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 76f86e464..9e1eb609f 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -79,44 +79,44 @@ export class ExchangeWrapper extends ContractWrapper {
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
* amount that has been filled or cancelled. The remaining takerAmount can be calculated by
* subtracting the unavailable amount from the total order takerAmount.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the
- * unavailable takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the
+ * unavailable takerAmount.
* @return The amount of the order (in taker tokens) that has either been filled or canceled.
*/
- public async getUnavailableTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this.getExchangeContractAsync();
- let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex);
+ let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
unavailableAmountInBaseUnits = new BigNumber(unavailableAmountInBaseUnits);
return unavailableAmountInBaseUnits;
}
/**
* Retrieve the takerAmount of an order that has already been filled.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the filled takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the filled takerAmount.
* @return The amount of the order (in taker tokens) that has already been filled.
*/
- public async getFilledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this.getExchangeContractAsync();
- let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex);
+ let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
return fillAmountInBaseUnits;
}
/**
* Retrieve the takerAmount of an order that has been cancelled.
- * @param orderHashHex The hex encoded orderHash for which you would like to retrieve the
- * cancelled takerAmount.
+ * @param orderHash The hex encoded orderHash for which you would like to retrieve the
+ * cancelled takerAmount.
* @return The amount of the order (in taker tokens) that has been cancelled.
*/
- public async getCanceledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
- assert.isValidOrderHash('orderHashHex', orderHashHex);
+ public async getCanceledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHash', orderHash);
const exchangeContract = await this.getExchangeContractAsync();
- let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex);
+ let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
return cancelledAmountInBaseUnits;