aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-07-12 08:45:46 +0800
committerGitHub <noreply@github.com>2017-07-12 08:45:46 +0800
commit89236fff410563c0d290e0a8090864cf21bae62e (patch)
tree04781f5e1e7887f3375e7d4d17b490110760a67e
parent98e8a6dd706f0a630402d9009ad3dcf9b0ff872d (diff)
parent6c62c92f0c26ec1da688097cfb3d63161281d87d (diff)
downloaddexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar.gz
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar.bz2
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar.lz
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar.xz
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.tar.zst
dexon-sol-tools-89236fff410563c0d290e0a8090864cf21bae62e.zip
Merge pull request #107 from 0xProject/static-get-order-hash-hex
Static get order hash hex
-rw-r--r--CHANGELOG.md29
-rw-r--r--src/0x.ts20
-rw-r--r--test/0x.js_test.ts2
-rw-r--r--test/exchange_wrapper_test.ts18
-rw-r--r--test/utils/order_factory.ts2
5 files changed, 36 insertions, 35 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6675dedfb..8e9d8e9b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,33 +2,34 @@
v0.9.0 - TBD
------------------------
- * Remove the ability to call methods on multiple authorized Exchange smart contracts (#106)
- * Cache `net_version` requests and invalidate the cache on calls to `setProvider` (#95)
- * Rename `zeroEx.exchange.batchCancelOrderAsync` to `zeroEx.exchange.batchCancelOrdersAsync`
- * Rename `zeroEx.exchange.batchFillOrderAsync` to `zeroEx.exchange.batchFillOrdersAsync`
+ * Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
+ * Made `zeroEx.getOrderHashHex` a static method (#107)
+ * Cached `net_version` requests and invalidate the cache on calls to `setProvider` (#95)
+ * Renamed `zeroEx.exchange.batchCancelOrderAsync` to `zeroEx.exchange.batchCancelOrdersAsync`
+ * Renamed `zeroEx.exchange.batchFillOrderAsync` to `zeroEx.exchange.batchFillOrdersAsync`
v0.8.0 - _Jul. 4, 2017_
------------------------
- * Add the ability to call methods on different authorized versions of the Exchange smart contract (#82)
- * Update contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
- * Add `zeroEx.proxy.isAuthorizedAsync` and `zeroEx.proxy.getAuthorizedAddressesAsync` (#89)
- * Add `zeroEx.token.subscribeAsync` (#90)
- * Make contract invalidation functions private (#90)
+ * Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
+ * Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
+ * Added `zeroEx.proxy.isAuthorizedAsync` and `zeroEx.proxy.getAuthorizedAddressesAsync` (#89)
+ * Added `zeroEx.token.subscribeAsync` (#90)
+ * Made contract invalidation functions private (#90)
* `zeroEx.token.invalidateContractInstancesAsync`
* `zeroEx.exchange.invalidateContractInstancesAsync`
* `zeroEx.proxy.invalidateContractInstance`
* `zeroEx.tokenRegistry.invalidateContractInstance`
- * Fix the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
+ * Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
v0.7.1 - _Jun. 26, 2017_
------------------------
- * Add the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
+ * Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
v0.7.0 - _Jun. 22, 2017_
------------------------
- * Add Kovan smart contract artifacts (#78)
- * Return fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
- * Return cancelledAmount from `cancelOrderAsync` (#72)
+ * Added Kovan smart contract artifacts (#78)
+ * Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
+ * Started returning cancelledAmount from `cancelOrderAsync` (#72)
* Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
v0.6.2 - _Jun. 21, 2017_
diff --git a/src/0x.ts b/src/0x.ts
index aeed7b042..3d1e8745f 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -150,6 +150,16 @@ export class ZeroEx {
return baseUnitAmount;
}
/**
+ * Computes the orderHash for a supplied order.
+ * @param order An object that conforms to the Order or SignedOrder interface definitions.
+ * @return The resulting orderHash from hashing the supplied order.
+ */
+ public static getOrderHashHex(order: Order|SignedOrder): string {
+ assert.doesConformToSchema('order', order, orderSchema);
+ const orderHashHex = utils.getOrderHashHex(order);
+ return orderHashHex;
+ }
+ /**
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
* @param provider The Web3.js Provider instance you would like the 0x.js library to use for interacting with
* the Ethereum network.
@@ -185,16 +195,6 @@ export class ZeroEx {
return availableAddresses;
}
/**
- * Computes the orderHash for a supplied order.
- * @param order An object that conforms to the Order or SignedOrder interface definitions.
- * @return The resulting orderHash from hashing the supplied order.
- */
- public getOrderHashHex(order: Order|SignedOrder): string {
- assert.doesConformToSchema('order', order, orderSchema);
- const orderHashHex = utils.getOrderHashHex(order);
- return orderHashHex;
- }
- /**
* 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 orderHash Hex encoded orderHash to sign.
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts
index c6ede843f..3d9aa105b 100644
--- a/test/0x.js_test.ts
+++ b/test/0x.js_test.ts
@@ -142,7 +142,7 @@ describe('ZeroEx library', () => {
expirationUnixTimestampSec: new BigNumber(0),
};
it('calculates the order hash', async () => {
- const orderHash = zeroEx.getOrderHashHex(order);
+ const orderHash = ZeroEx.getOrderHashHex(order);
expect(orderHash).to.be.equal(expectedOrderHash);
});
});
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index d8af9d1cd..eb07b09ba 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -396,11 +396,11 @@ describe('ExchangeWrapper', () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- signedOrderHashHex = zeroEx.getOrderHashHex(signedOrder);
+ signedOrderHashHex = ZeroEx.getOrderHashHex(signedOrder);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- anotherOrderHashHex = zeroEx.getOrderHashHex(anotherSignedOrder);
+ anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
orderFillBatch = [
{
signedOrder,
@@ -436,11 +436,11 @@ describe('ExchangeWrapper', () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- signedOrderHashHex = zeroEx.getOrderHashHex(signedOrder);
+ signedOrderHashHex = ZeroEx.getOrderHashHex(signedOrder);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- anotherOrderHashHex = zeroEx.getOrderHashHex(anotherSignedOrder);
+ anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
signedOrders = [signedOrder, anotherSignedOrder];
});
describe('successful batch fills', () => {
@@ -484,7 +484,7 @@ describe('ExchangeWrapper', () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- orderHashHex = zeroEx.getOrderHashHex(signedOrder);
+ orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
});
describe('#cancelOrderAsync', () => {
describe('failed cancels', () => {
@@ -499,7 +499,7 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
fillableAmount, expirationInPast,
);
- orderHashHex = zeroEx.getOrderHashHex(expiredSignedOrder);
+ orderHashHex = ZeroEx.getOrderHashHex(expiredSignedOrder);
return expect(zeroEx.exchange.cancelOrderAsync(expiredSignedOrder, cancelAmount))
.to.be.rejectedWith(ExchangeContractErrs.ORDER_CANCEL_EXPIRED);
});
@@ -529,7 +529,7 @@ describe('ExchangeWrapper', () => {
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- anotherOrderHashHex = zeroEx.getOrderHashHex(anotherSignedOrder);
+ anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
cancelBatch = [
{
order: signedOrder,
@@ -588,7 +588,7 @@ describe('ExchangeWrapper', () => {
signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
);
- orderHash = zeroEx.getOrderHashHex(signedOrder);
+ orderHash = ZeroEx.getOrderHashHex(signedOrder);
});
describe('#getUnavailableTakerAmountAsync', () => {
it('should throw if passed an invalid orderHash', async () => {
@@ -782,7 +782,7 @@ describe('ExchangeWrapper', () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- const orderHash = zeroEx.getOrderHashHex(signedOrder);
+ const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const orderHashFromContract = await (zeroEx.exchange as any)
._getOrderHashHexUsingContractCallAsync(signedOrder);
expect(orderHash).to.equal(orderHashFromContract);
diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts
index 22bf44c0f..fc4adebd9 100644
--- a/test/utils/order_factory.ts
+++ b/test/utils/order_factory.ts
@@ -34,7 +34,7 @@ export const orderFactory = {
feeRecipient,
expirationUnixTimestampSec,
};
- const orderHash = zeroEx.getOrderHashHex(order);
+ const orderHash = ZeroEx.getOrderHashHex(order);
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker);
const signedOrder: SignedOrder = _.assign(order, {ecSignature});
return signedOrder;