Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Conversation

@xiaowheat
Copy link
Contributor

No description provided.

await loopringProtocolImpl.setTradingPairCutoff(new BigNumber(1508566125), order.params.amountS, order.params.amountB, {from: order1Owner});
const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order.params.amountS, order1Owner);

// TODO: how to implment the assert when getTradingPairId is an internal function?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dong77 Could you help me with the implementation of the assert? Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to reimplement the method using JS. Check out this one:

https://github.com/jimmychang851129/solidity_test/blob/27891dd41d1bd403eabf795613d3587880fce846/ethereum/contract/setjson.js

// var keccak256 = require('js-sha3').keccak256;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also change "setCutoff" to "cancelOrders" and "setTradingPairCutoff" to "cancelOrders" as well if overloading is permitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truffle does not support function overloading. ConsenSys-archive/truffle#737 So I keep "setCutoff" unchanged and change "setTradingPairCutoff" to "cancelOrders"

@xiaowheat
Copy link
Contributor Author

#219

const tradingPairId = web3.toHex(tradingPairIdBigInt.toString(10));
const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order1Owner, tradingPairId);

// FIXME: tradingPairCutoff.toNumber() is 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dong77 I tried to use keccak256 in the test. Could you help me with the PR? It seems that I didn't implement the method to get trading pair id correctly. Thank you.

const token1_256 = keccak256(order.params.tokenS);
const token2_256 = keccak256(order.params.tokenB);
const combinedTokenHash = xor(new Buffer(token1_256), new Buffer(token2_256));
const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order1Owner, [...combinedTokenHash]); //, combinedTokenHash.toString("hex"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covert a Buffer to bytes array.

@dong77 dong77 closed this Jan 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants