Skip to content

Commit

Permalink
Fix address coder to prepare non-hexdatastring addresses as hexdatast…
Browse files Browse the repository at this point in the history
…ring (#1906).
  • Loading branch information
ricmoo committed Aug 24, 2021
1 parent accb852 commit 017b1fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/abi/src.ts/coders/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AddressCoder extends Coder {

encode(writer: Writer, value: string): number {
try {
getAddress(value);
value = getAddress(value)
} catch (error) {
this._throwError(error.message, value);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/tests/src.ts/test-contract-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,14 @@ describe('Test EIP-838 Error Codes', function() {
}
});
});

describe("Additional test cases", function() {
// See: #1906
it("allows addresses without the 0x", function() {
const iface = new ethers.utils.Interface([
"function test(address foo) view returns (bool)"
]);
const tx = iface.encodeFunctionData("test", [ "c1912fee45d61c87cc5ea59dae31190fffff232d" ]);
console.log(tx);
});
});

0 comments on commit 017b1fe

Please sign in to comment.