ethers.js/packages/abi/src.ts/coders/null.ts

21 lines
484 B
TypeScript
Raw Permalink Normal View History

2019-05-14 18:25:46 -04:00
"use strict";
import { Coder, Reader, Writer } from "./abstract-coder";
export class NullCoder extends Coder {
constructor(localName: string) {
super("null", "", localName, false);
}
encode(writer: Writer, value: any): number {
if (value != null) { this._throwError("not null", value); }
return writer.writeBytes([ ]);
}
decode(reader: Reader): any {
reader.readBytes(0);
return reader.coerce(this.name, null);
}
}