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

25 lines
749 B
JavaScript
Raw Normal View History

2022-09-05 23:57:11 +03: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 23:44:23 +03:00
/**
* @_ignore
*/
2022-09-05 23:57:11 +03: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