You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockvote/node_modules/@ethersproject/abi/src.ts/coders/string.ts

26 lines
576 B

"use strict";
import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings";
import { Reader, Writer } from "./abstract-coder";
import { DynamicBytesCoder } from "./bytes";
export class StringCoder extends DynamicBytesCoder {
constructor(localName: string) {
super("string", localName);
}
defaultValue(): string {
return "";
}
encode(writer: Writer, value: any): number {
return super.encode(writer, toUtf8Bytes(value));
}
decode(reader: Reader): any {
return toUtf8String(super.decode(reader));
}
}