Skip to content

Commit

Permalink
fix(utils): pad zeroes to left instead to right in `getHashedL2ToL1Ms…
Browse files Browse the repository at this point in the history
…g()`
  • Loading branch information
danijelTxFusion committed Jan 23, 2024
1 parent 9402345 commit 41d0ef3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export function getHashedL2ToL1Msg(sender: Address, msg: BytesLike, txNumberInBl
const encodedMsg = new Uint8Array([
0, // l2ShardId
1, // isService
...ethers.getBytes(ethers.zeroPadBytes(ethers.toBeHex(txNumberInBlock), 2)),
...ethers.getBytes(ethers.zeroPadValue(ethers.toBeHex(txNumberInBlock), 2)),
...ethers.getBytes(L1_MESSENGER_ADDRESS),
...ethers.getBytes(ethers.zeroPadBytes(sender, 32)),
...ethers.getBytes(ethers.zeroPadValue(sender, 32)),
...ethers.getBytes(ethers.keccak256(msg)),
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("utils", () => {
const withdrawETHMessage =
"0x6c0960f936615cf349d7f6344891b1e7ca7c72883f5dc04900000000000000000000000000000000000000000000000000000001a13b8600";
const withdrawETHMessageHash =
"0xd8c80ecb64619e343f57c3b133c6c6d8dd0572dd3488f1ca3276c5b7fd3a938d";
"0x521bd25904766c83fe868d6a29cbffa011afd8a1754f6c9a52b053b693e42f18";
const result = utils.getHashedL2ToL1Msg(
"0x36615Cf349d7F6344891B1e7CA7C72883F5dc049",
withdrawETHMessage,
Expand Down

0 comments on commit 41d0ef3

Please sign in to comment.