ethers.js/lib.esm/abi/coders/boolean.js

21 lines
520 B
JavaScript
Raw Permalink Normal View History

2022-09-05 16:57:11 -04:00
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
2022-11-30 15:44:23 -05:00
/**
* @_ignore
*/
2022-09-05 16:57:11 -04:00
export class BooleanCoder extends Coder {
constructor(localName) {
super("bool", "bool", localName, false);
}
defaultValue() {
return false;
}
encode(writer, _value) {
const value = Typed.dereference(_value, "bool");
return writer.writeValue(value ? 1 : 0);
}
decode(reader) {
return !!reader.readValue();
}
}
//# sourceMappingURL=boolean.js.map