Skip to content

Commit c6e74f7

Browse files
authored
Merge pull request #106 from Loopring/v2
V2
2 parents b04e59e + dc5a0b0 commit c6e74f7

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Get public key using the private key
103103
- privateKey hex string or Buffer
104104

105105
##### Returns
106+
106107
- publickey hex string, without prefix
107108

108109
##### Example
@@ -143,7 +144,7 @@ Get keyAccount using the keystore and password
143144
##### Parameters
144145

145146
- keystore string
146-
- password string - can be empty, depending on whether the keystore requires a password to unlock it.
147+
- password string - can be empty, depending on whether the keystore requires a password to unlock it.
147148

148149
##### Returns
149150

src/ethereum/contracts/Contracts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const encodeCancelOrder = (signedOrder, amount) =>
3434
const encodeSubmitRing = (orders, feeRecipient, feeSelections) =>
3535
{
3636
validator.validate({type: 'ETH_ADDRESS', value: feeRecipient});
37-
if (feeSelections === null || feeSelections === undefined)
37+
if (!feeSelections)
3838
{
39-
feeSelections = 0;
39+
feeSelections = orders.map(item => 0);
4040
}
4141
const rate = Math.pow(orders.reduce(order => (total, order) =>
4242
{

src/relay/rpc/ring.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function getRingHash (orders, feeRecipient, feeSelections)
154154
return soliditySHA3(['string', 'address', 'uint16'], [
155155
xorReduceStr(orderHashList),
156156
feeRecipient,
157-
feeSelections
157+
feeSelectionListToNumber(feeSelections)
158158
]);
159159
}
160160

@@ -176,3 +176,14 @@ function xorReduceStr (strArr)
176176
const reduceRes = tail.reduce((a, b) => strXor(a, b), s0);
177177
return Buffer.from(reduceRes.slice(2), 'hex');
178178
}
179+
180+
function feeSelectionListToNumber (feeSelections)
181+
{
182+
let res = 0;
183+
for (let i = 0; i < feeSelections.length; i++)
184+
{
185+
res += feeSelections[i] << i;
186+
}
187+
188+
return res;
189+
}

0 commit comments

Comments
 (0)