Skip to content

Commit

Permalink
fix: EscrowFactoryFacade.getDstEscrowAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk committed Nov 13, 2024
1 parent 3f13451 commit e4164d5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/escrow-factory/escrow-factory-facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class EscrowFactoryFacade implements EscrowFactory {
*/
implementationAddress: Address
): Address {
return this.getDstEscrowAddress(
return this.factory.getDstEscrowAddress(
srcImmutables,
complement,
blockTime,
Expand Down
53 changes: 52 additions & 1 deletion src/escrow-factory/escrow-factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Address, NetworkEnum} from '@1inch/fusion-sdk'
import {keccak256} from 'ethers'
import {EscrowFactoryFacade} from './escrow-factory-facade'
import {EscrowFactoryZksync} from './escrow-factory-zksync'
import {Immutables} from '../immutables'
import {DstImmutablesComplement, Immutables} from '../immutables'
import {HashLock, TimeLocks} from '../cross-chain-order'

describe('EscrowAddressFacade', () => {
Expand Down Expand Up @@ -33,6 +33,57 @@ describe('EscrowAddressFacade', () => {
)
})

it('Should correct calc src/dst address for Ethereum 2', () => {
const facade = new EscrowFactoryFacade(
NetworkEnum.ETHEREUM,
Address.fromBigInt(1n)
)

const immutables = Immutables.new({
maker: new Address('0x04d3b2c70208f3fb196affef78080b3cc05ee1cb'),
taker: new Address('0x9c4dffb4f7e8217a8ac0555d67e125f8769284ba'),
token: new Address('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'),
amount: 99345341n,
hashLock: HashLock.fromString(
'0x939dbeb956ac9369de8b1acaaa78a173620c2275fba501f8340b91cbceabdbf1'
),
orderHash:
'0x8ed7de0668228e00103038a7fc6a19c933d56fca27b154a3e532ebeb4a5c07bd',
timeLocks:
TimeLocks.fromBigInt(
46545443980783778519496226194286874737220106048808714334632784681655911579684n
),
safetyDeposit: 2474844692460000n
})
const srcImplAddress = Address.fromBigInt(1n)
const dstImplAddress = Address.fromBigInt(2n)

const srcAddress = facade.getSrcEscrowAddress(
immutables,
srcImplAddress
)
const dstAddress = facade.getDstEscrowAddress(
immutables,
DstImmutablesComplement.new({
amount: immutables.amount,
maker: immutables.maker,
safetyDeposit: immutables.safetyDeposit,
token: immutables.token
}),
0n,
immutables.taker,
dstImplAddress
)

expect(srcAddress).toEqual(
new Address('0xf97a2ae8f0481c1cc11bf8cb962b088bc5f6a945')
)

expect(dstAddress).toEqual(
new Address('0x5177d276a4b46b0cbb5ae98d296663fcee0138c4')
)
})

describe('zkSync', () => {
it('Should calc correct src address from immutables', () => {
const immutables = Immutables.new({
Expand Down

0 comments on commit e4164d5

Please sign in to comment.