ethers.js/packages/abi/lib/coders/string.js
2022-04-11 17:14:19 -04:00

18 lines
559 B
JavaScript

import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings";
import { Typed } from "../typed.js";
import { DynamicBytesCoder } from "./bytes.js";
export class StringCoder extends DynamicBytesCoder {
constructor(localName) {
super("string", localName);
}
defaultValue() {
return "";
}
encode(writer, _value) {
return super.encode(writer, toUtf8Bytes(Typed.dereference(_value, "string")));
}
decode(reader) {
return toUtf8String(super.decode(reader));
}
}
//# sourceMappingURL=string.js.map