Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removes "@ethersproject/bytes" #457

Draft
wants to merge 2 commits into
base: dl/remove-eth-addrs
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
},
"dependencies": {
"@ethersproject/bignumber": "^5.1.1",
"@ethersproject/bytes": "^5.0.8",
"async-mutex": "^0.4.0",
"ethers": "^5.1.0",
"ethers-v6": "npm:ethers@^6.11.1"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/message/ParentToChildMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import { Provider } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer'
import { ContractTransaction } from '@ethersproject/contracts'
import { BigNumber } from '@ethersproject/bignumber'
import { concat } from '@ethersproject/bytes'
import {
ZeroAddress,
toBeArray,
encodeRlp,
zeroPadValue,
getAddress,
keccak256,
concat,
} from 'ethers-v6'

import { ArbRetryableTx__factory } from '../abi/factories/ArbRetryableTx__factory'
Expand Down
5 changes: 2 additions & 3 deletions src/lib/message/messageDataParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getAddress } from 'ethers-v6'
import { getAddress, zeroPadValue } from 'ethers-v6'
import { defaultAbiCoder } from '@ethersproject/abi'
import { BigNumber } from '@ethersproject/bignumber'
import { hexZeroPad } from '@ethersproject/bytes'

export class SubmitRetryableMessageDataParser {
/**
Expand All @@ -28,7 +27,7 @@ export class SubmitRetryableMessageDataParser {
) as BigNumber[]

const addressFromBigNumber = (bn: BigNumber) =>
getAddress(hexZeroPad(bn.toHexString(), 20))
getAddress(zeroPadValue(bn.toHexString(), 20))

const destAddress = addressFromBigNumber(parsed[0])
const l2CallValue = parsed[1]
Expand Down
13 changes: 9 additions & 4 deletions src/lib/utils/byte_serialize_params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ Arbitrum SDK includes methods for [serializing parameters](https://developer.off

import { Provider } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer'
import { isAddress as _isAddress } from 'ethers-v6'
import { concat, hexZeroPad } from '@ethersproject/bytes'
import {
isAddress as _isAddress,
concat,
toBeArray,
zeroPadValue,
} from 'ethers-v6'

import { BigNumber } from '@ethersproject/bignumber'

import { ArbAddressTable__factory } from '../abi/factories/ArbAddressTable__factory'
Expand Down Expand Up @@ -112,7 +117,7 @@ const isAddress = (input: PrimativeType) =>
typeof input === 'string' && _isAddress(input)

const toUint = (val: PrimativeType, bytes: BytesNumber) =>
hexZeroPad(BigNumber.from(val).toHexString(), bytes)
zeroPadValue(BigNumber.from(val).toHexString(), bytes)

// outputs string suitable for formatting
const formatPrimative = (value: PrimativeType) => {
Expand Down Expand Up @@ -186,5 +191,5 @@ export const serializeParams = async (
}
}
}
return concat(formattedParams)
return toBeArray(concat(formattedParams))
}
4 changes: 2 additions & 2 deletions tests/fork/inbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { SequencerInbox__factory } from '../../src/lib/abi/factories/SequencerIn
import { InboxTools } from '../../src'

import { ethers, network } from 'hardhat'
import { hexZeroPad } from '@ethersproject/bytes'
import { zeroPadValue } from 'ethers-v6'
import {
ArbitrumNetwork,
getArbitrumNetwork,
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Inbox tools', () => {
txParams.gasLimit,
txParams.maxFeePerGas,
txParams.nonce,
hexZeroPad(txParams.to, 32),
zeroPadValue(txParams.to, 32),
txParams.value,
'0x',
]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/retryableData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { assert, expect } from 'chai'
import { BigNumber } from '@ethersproject/bignumber'
import { hexlify } from '@ethersproject/bytes'
import { hexlify } from 'ethers-v6'
import { TestERC20__factory } from '../../src/lib/abi/factories/TestERC20__factory'
import { fundParentSigner, skipIfMainnet } from './testHelpers'
import { RetryableDataTools } from '../../src'
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/addressAlias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { expect } from 'chai'
import { Address } from '../../src/lib/dataEntities/address'
import { BigNumber } from 'ethers'
import { ADDRESS_ALIAS_OFFSET } from '../../src/lib/dataEntities/constants'
import { hexZeroPad } from '@ethersproject/bytes'
import { getAddress } from 'ethers-v6'
import { getAddress, zeroPadValue } from 'ethers-v6'
const offset = BigNumber.from(ADDRESS_ALIAS_OFFSET)
const maxAddr = BigNumber.from('0xffffffffffffffffffffffffffffffffffffffff')

Expand All @@ -49,7 +48,7 @@ describe('Address', () => {

it('does alias correctly below offset', async () => {
// 0xeeeeffffffffffffffffffffffffffffffffeee4
const belowOffset = hexZeroPad(
const belowOffset = zeroPadValue(
maxAddr.sub(offset).sub(10).toHexString(),
20
)
Expand All @@ -63,7 +62,7 @@ describe('Address', () => {

it('does alias correctly on', async () => {
// 0xeeeeffffffffffffffffffffffffffffffffeeee
const onOffset = hexZeroPad(maxAddr.sub(offset).add(0).toHexString(), 20)
const onOffset = zeroPadValue(maxAddr.sub(offset).add(0).toHexString(), 20)

testApplyUndo(
getAddress(onOffset),
Expand All @@ -74,7 +73,7 @@ describe('Address', () => {

it('does alias correctly above offset', async () => {
// 0xeeeeffffffffffffffffffffffffffffffffeef8
const aboveOffset = hexZeroPad(
const aboveOffset = zeroPadValue(
maxAddr.sub(offset).add(10).toHexString(),
20
)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
"@ethersproject/logger" "^5.7.0"
bn.js "^5.2.1"

"@ethersproject/[email protected]", "@ethersproject/bytes@^5.0.8":
"@ethersproject/[email protected]":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.6.1.tgz#24f916e411f82a8a60412344bf4a813b917eefe7"
integrity sha512-NwQt7cKn5+ZE4uDn+X5RAXLp46E1chXoaMmrxAyA0rblpxz8t58lVkrHXoRIn0lz1joQElQ8410GqhTqMOwc6g==
Expand Down
Loading