diff --git a/src/cross-chain-order/hash-lock/hash-lock.spec.ts b/src/cross-chain-order/hash-lock/hash-lock.spec.ts index ac81fe6..7287f30 100644 --- a/src/cross-chain-order/hash-lock/hash-lock.spec.ts +++ b/src/cross-chain-order/hash-lock/hash-lock.spec.ts @@ -21,7 +21,7 @@ describe('HashLock', () => { const leaves = HashLock.getMerkleLeaves(secrets) expect(HashLock.forMultipleFills(leaves).toString()).toEqual( - '0x0006450ad51097012ff74f91e1ff6fb3f5bd8e8e2cd6a91a513f03bcb89a76f7' + '0x0004450ad51097012ff74f91e1ff6fb3f5bd8e8e2cd6a91a513f03bcb89a76f7' ) }) diff --git a/src/cross-chain-order/hash-lock/hash-lock.ts b/src/cross-chain-order/hash-lock/hash-lock.ts index 7ab6111..0d86a7e 100644 --- a/src/cross-chain-order/hash-lock/hash-lock.ts +++ b/src/cross-chain-order/hash-lock/hash-lock.ts @@ -48,11 +48,14 @@ export class HashLock { } public static forMultipleFills(leaves: MerkleLeaf[]): HashLock { - assert(leaves.length > 1, 'leaves array must be greater than 1') + assert( + leaves.length > 2, + 'leaves array must be greater than 2. Or use HashLock.forSingleFill' + ) const root = SimpleMerkleTree.of(leaves).root const rootWithCount = BN.fromHex(root).setMask( new BitMask(241n, 256n), - BigInt(leaves.length) + BigInt(leaves.length - 1) ) return new HashLock(rootWithCount.toHex(64))