ethers.js/lib.commonjs/abi/coders/string.js

25 lines
749 B
JavaScript
Raw Permalink Normal View History

2022-09-05 16:57:11 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringCoder = void 0;
const utf8_js_1 = require("../../utils/utf8.js");
const typed_js_1 = require("../typed.js");
const bytes_js_1 = require("./bytes.js");
2022-11-30 15:44:23 -05:00
/**
* @_ignore
*/
2022-09-05 16:57:11 -04:00
class StringCoder extends bytes_js_1.DynamicBytesCoder {
constructor(localName) {
super("string", localName);
}
defaultValue() {
return "";
}
encode(writer, _value) {
return super.encode(writer, (0, utf8_js_1.toUtf8Bytes)(typed_js_1.Typed.dereference(_value, "string")));
}
decode(reader) {
return (0, utf8_js_1.toUtf8String)(super.decode(reader));
}
}
exports.StringCoder = StringCoder;
//# sourceMappingURL=string.js.map