BuildOnViction / tomox-sdk

SDK to build a Decentralized Exchange on TomoX protocol
MIT License
36 stars 18 forks source link

Refactor getOrderCount #92

Closed thanhson1085 closed 5 years ago

thanhson1085 commented 5 years ago

Currently, we get order nonce by count the number of order in orders table https://github.com/tomochain/tomox-sdk/blob/b31b7926a4a888d2abc73275cf44871786c60687/endpoints/order.go#L87 It is not correct if user create 2 orders with nonce 1 and 10. getOrderCount will return 2, but the correct value is 10.

So the correct value is max of nonce of order

thanhson1085 commented 5 years ago

To be perfect, we should get nonce from a node via RPC e.g tomoX.getOrderNonce("0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037") https://github.com/tomochain/tomochain/pull/700

nghiatomo commented 5 years ago

fixed in commit 9a209fe028e960532c99443b55a497c5e5bb878e