Skip to content

Commit

Permalink
vm: fix test encoding of authorization lists [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Aug 12, 2024
1 parent 5e8e756 commit ad3effb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/vm/test/api/EIPs/eip-7702.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Address,
BIGINT_1,
KECCAK256_NULL,
bigIntToBytes,
bigIntToUnpaddedBytes,
concatBytes,
createAddressFromString,
ecsign,
Expand Down Expand Up @@ -49,14 +49,22 @@ function getAuthorizationListItem(opts: GetAuthListOpts): AuthorizationListBytes
const { chainId, nonce, address, pkey } = actualOpts

const chainIdBytes = unpadBytes(hexToBytes(`0x${chainId.toString(16)}`))
const nonceBytes = nonce !== undefined ? [unpadBytes(hexToBytes(`0x${nonce.toString(16)}`))] : []
const nonceBytes =
nonce !== undefined ? unpadBytes(hexToBytes(`0x${nonce.toString(16)}`)) : new Uint8Array()
const addressBytes = address.toBytes()

const rlpdMsg = RLP.encode([chainIdBytes, addressBytes, nonceBytes])
const msgToSign = keccak256(concatBytes(new Uint8Array([5]), rlpdMsg))
const signed = ecsign(msgToSign, pkey)

return [chainIdBytes, addressBytes, nonceBytes, bigIntToBytes(signed.v), signed.r, signed.s]
return [
chainIdBytes,
addressBytes,
nonceBytes,
bigIntToUnpaddedBytes(signed.v - BigInt(27)),
signed.r,
signed.s,
]
}

async function runTest(
Expand Down

0 comments on commit ad3effb

Please sign in to comment.