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

Pack of "address" as Uint8Array(20) #4528

Open
adraffy opened this issue Jan 3, 2024 · 0 comments
Open

Pack of "address" as Uint8Array(20) #4528

adraffy opened this issue Jan 3, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@adraffy
Copy link

adraffy commented Jan 3, 2024

Ethers Version

6.9.2

Search Terms

abi

Describe the Problem

pack() of "address" with a bytes20-equivalent should just pack directly.

export function solidityPacked(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string {
assertArgument(types.length === values.length, "wrong number of values; expected ${ types.length }", "values", values);
const tight: Array<Uint8Array> = [];
types.forEach(function(type, index) {
tight.push(_pack(type, values[index]));
});

function _pack(type: string, value: any, isArray?: boolean): Uint8Array {
switch(type) {
case "address":
if (isArray) { return getBytes(zeroPadValue(value, 32)); }
return getBytes(getAddress(value));

Code Snippet

ethers.solidityPackedKeccak256(['address'], [new Uint8Array(20]);

Contract ABI

No response

Errors

TypeError: invalid address (argument="address", value=0x0000000000000000000000000000000000000000, code=INVALID_ARGUMENT, version=6.9.2)

Environment

node.js (v12 or newer)

Environment (Other)

No response

@adraffy adraffy added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Jan 3, 2024
@adraffy adraffy changed the title Add Bug Title Here Pack of "address" as Uint8Array(20) Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants