Fix address coder to prepare non-hexdatastring addresses as hexdatastring (#1906).

This commit is contained in:
Richard Moore 2021-08-24 14:33:04 -03:00
parent accb85268c
commit 017b1feba2
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
2 changed files with 12 additions and 1 deletions

@ -17,7 +17,7 @@ export class AddressCoder extends Coder {
encode(writer: Writer, value: string): number { encode(writer: Writer, value: string): number {
try { try {
getAddress(value); value = getAddress(value)
} catch (error) { } catch (error) {
this._throwError(error.message, value); this._throwError(error.message, value);
} }

@ -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);
});
});