Skip to content

Commit

Permalink
incorpodate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Jun 11, 2024
1 parent 2fd0ef1 commit 2507b4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/evm/src/opcodes/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,8 @@ export const handlers: Map<number, OpHandler> = new Map([
return
}

const expectedAddress = new Address(bigIntToAddressBytes(authority))
// we don't want strick check here on authority being in address range just last 20 bytes
const expectedAddress = new Address(bigIntToAddressBytes(authority, false))
const account = (await runState.stateManager.getAccount(expectedAddress)) ?? new Account()

if (account.isContract()) {
Expand Down
9 changes: 7 additions & 2 deletions packages/util/src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,13 @@ export const bigIntToUnpaddedBytes = (value: bigint): Uint8Array => {
return unpadBytes(bigIntToBytes(value))
}

export const bigIntToAddressBytes = (value: bigint): Uint8Array => {
return setLengthLeft(bigIntToBytes(value), 20).slice(-20)
export const bigIntToAddressBytes = (value: bigint, strict: boolean = true): Uint8Array => {
const addressBytes = setLengthLeft(bigIntToBytes(value), 20)
if (strict && addressBytes.length > 20) {
throw Error(`Invalid address bytes length=${addressBytes.length} strict=${strict}`)
}

return addressBytes.slice(-20)
}

/**
Expand Down

0 comments on commit 2507b4a

Please sign in to comment.