Skip to content

Commit

Permalink
Merge pull request #929 from graphprotocol/pcv/fix-leading-zeros-alias
Browse files Browse the repository at this point in the history
fix: ensure L2 aliased addresses are the correct length
  • Loading branch information
pcarranzav committed Jan 25, 2024
2 parents 7b9766d + c5641c5 commit 726bfb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/ten-moons-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphprotocol/sdk": patch
---

Ensure L2 aliased addresses are the correct length
3 changes: 2 additions & 1 deletion packages/sdk/src/utils/arbitrum/address.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hexZeroPad } from 'ethers/lib/utils'
import { toBN } from '../units'

// Adapted from:
Expand All @@ -8,5 +9,5 @@ export const applyL1ToL2Alias = (l1Address: string): string => {
const l2AddressAsNumber = l1AddressAsNumber.add(offset)

const mask = toBN(2).pow(160)
return l2AddressAsNumber.mod(mask).toHexString()
return hexZeroPad(l2AddressAsNumber.mod(mask).toHexString(), 20)
}

0 comments on commit 726bfb2

Please sign in to comment.