zksync-sdk / zksync2-js

MIT License
25 stars 29 forks source link

Fix createAddress and create2Address #30

Closed hbriese closed 9 months ago

hbriese commented 9 months ago

What :computer:

Fixes #29

Why :hand:

createAddress and create2Address produce incorrect addresses

Notes :memo:

The error seems to have occured in the ethers v5 -> v6 migration, where ethers.utils.zeroPad, which zero-pads left bits (docs), was incorrectly replaced with ethers.utils.zeroPadBytes, which zero-pads the right bits (docs). The correct replacement being ethers.utils.zeroPadValue (docs)

hbriese commented 9 months ago

A quick search reveals several other functions that use zeroPadBytes which previously used zeroPad

danijelTxFusion commented 9 months ago

@hbriese Thank you for finding this bug. Obviously the bug is present because functions are not covered with tests. Also feel free to add test here.

Also update your commit message to follow convetional commits as mentioned here. So the message should look like:

fix: resolve padding bugs in `createAccount` and `createAccount2`
hbriese commented 9 months ago

I've added some tests. Are there any more that you would recommend?

danijelTxFusion commented 9 months ago

LGTM!