2019-08-25 02:39:20 -04:00
|
|
|
"use strict";
|
|
|
|
import { getAddress } from "@ethersproject/address";
|
|
|
|
import { hexZeroPad } from "@ethersproject/bytes";
|
|
|
|
import { Coder } from "./abstract-coder";
|
|
|
|
export class AddressCoder extends Coder {
|
|
|
|
constructor(localName) {
|
|
|
|
super("address", "address", localName, false);
|
|
|
|
}
|
2020-11-23 03:43:28 -05:00
|
|
|
defaultValue() {
|
|
|
|
return "0x0000000000000000000000000000000000000000";
|
|
|
|
}
|
2019-08-25 02:39:20 -04:00
|
|
|
encode(writer, value) {
|
|
|
|
try {
|
2021-08-24 16:15:51 -03:00
|
|
|
value = getAddress(value);
|
2019-08-25 02:39:20 -04:00
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
this._throwError(error.message, value);
|
|
|
|
}
|
|
|
|
return writer.writeValue(value);
|
|
|
|
}
|
|
|
|
decode(reader) {
|
|
|
|
return getAddress(hexZeroPad(reader.readValue().toHexString(), 20));
|
|
|
|
}
|
|
|
|
}
|
2020-07-13 08:03:56 -04:00
|
|
|
//# sourceMappingURL=address.js.map
|