Skip to content

Commit

Permalink
fix(limit-order): correct salt check (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk authored Apr 15, 2024
1 parent 6ed5d66 commit 49b9def
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/limit-order/extension-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export class ExtensionBuilder implements IExtensionBuilder {
public withCustomData(data: string): this {
assert(isHexString(data), 'Custom data must be valid hex string')

this.customData = data

return this
}

Expand Down
4 changes: 3 additions & 1 deletion src/limit-order/limit-order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ describe('Limit Order', () => {
ext
)

expect(LimitOrder.fromCalldata(order.toCalldata())).toEqual(order)
expect(LimitOrder.fromDataAndExtension(order.build(), ext)).toEqual(
order
)
})
})
3 changes: 2 additions & 1 deletion src/limit-order/limit-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export class LimitOrder {
}

const hash = salt & UINT_160_MAX
const expectedHash = extension.keccak256() & UINT_160_MAX
assert(
hash === extension.keccak256(),
hash === expectedHash,
'invalid salt: lowest 160 bits should be extension hash'
)

Expand Down

0 comments on commit 49b9def

Please sign in to comment.