Skip to content

Commit

Permalink
fix: HashLock.getMerkleLeaves (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk authored Aug 13, 2024
1 parent d9f68f3 commit 5d9dd8a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/cross-chain-order/hash-lock/hash-lock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('HashLock', () => {

const leaves = HashLock.getMerkleLeaves(secrets)
expect(HashLock.forMultipleFills(leaves).toString()).toEqual(
'0x0004450ad51097012ff74f91e1ff6fb3f5bd8e8e2cd6a91a513f03bcb89a76f7'
'0x000592766d9172e4b4983ee4d4b6d511cdbcbef175c7e3e1b1554d513e1ab724'
)
})

Expand Down Expand Up @@ -49,8 +49,7 @@ describe('HashLock', () => {
const leaves = HashLock.getMerkleLeaves(secrets)

expect(HashLock.getProof(leaves, 0)).toEqual([
'0x3009d711fa0454e4a4f0d553fcfa67f20e0d67571d7e06f2105814c6b123ba55',
'0x70e897a17a55b03df83541f6420507b3482da14f2489ef7ea4d9a94cf30d1c06'
'0x540daf363747246d40b31da95b3ef1c1497e22e9a56b70d117c835839822c95f'
])
})
})
2 changes: 1 addition & 1 deletion src/cross-chain-order/hash-lock/hash-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class HashLock {
return secrets.map(
(s, idx) =>
solidityPackedKeccak256(
['uint256', 'bytes32'],
['uint64', 'bytes32'],
[idx, HashLock.hashSecret(s)]
) as MerkleLeaf
)
Expand Down
19 changes: 10 additions & 9 deletions src/escrow-factory/escrow-factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Address, Interaction} from '@1inch/fusion-sdk'
import {AbiCoder, getCreate2Address, keccak256} from 'ethers'
import {getBytesCount, isHexBytes, trim0x} from '@1inch/byte-utils'
import {add0x, getBytesCount, isHexBytes, trim0x} from '@1inch/byte-utils'
import assert from 'assert'
import {Immutables, DstImmutablesComplement} from '../immutables'
import {MerkleLeaf} from '../cross-chain-order/hash-lock/hash-lock'
Expand Down Expand Up @@ -109,18 +109,19 @@ export class EscrowFactory {
idx: number,
secretHash: string
): Interaction {
return new Interaction(
this.address,
AbiCoder.defaultAbiCoder().encode(
[
`(
const data = AbiCoder.defaultAbiCoder().encode(
[
`(
bytes32[] proof,
uint256 idx,
bytes32 secretHash,
)`
],
[{proof, idx, secretHash}]
)
],
[{proof, idx, secretHash}]
)

const dataNoOffset = add0x(data.slice(66))

return new Interaction(this.address, dataNoOffset)
}
}

0 comments on commit 5d9dd8a

Please sign in to comment.