2022-09-05 16:57:11 -04:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.BytesCoder = exports.DynamicBytesCoder = void 0;
|
2022-09-15 22:58:45 -04:00
|
|
|
const index_js_1 = require("../../utils/index.js");
|
2022-09-05 16:57:11 -04:00
|
|
|
const abstract_coder_js_1 = require("./abstract-coder.js");
|
2022-11-30 15:44:23 -05:00
|
|
|
/**
|
|
|
|
* @_ignore
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
class DynamicBytesCoder extends abstract_coder_js_1.Coder {
|
|
|
|
constructor(type, localName) {
|
|
|
|
super(type, type, localName, true);
|
|
|
|
}
|
|
|
|
defaultValue() {
|
|
|
|
return "0x";
|
|
|
|
}
|
|
|
|
encode(writer, value) {
|
2022-09-15 22:58:45 -04:00
|
|
|
value = (0, index_js_1.getBytesCopy)(value);
|
2022-09-05 16:57:11 -04:00
|
|
|
let length = writer.writeValue(value.length);
|
|
|
|
length += writer.writeBytes(value);
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
decode(reader) {
|
|
|
|
return reader.readBytes(reader.readIndex(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.DynamicBytesCoder = DynamicBytesCoder;
|
2022-11-30 15:44:23 -05:00
|
|
|
/**
|
|
|
|
* @_ignore
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
class BytesCoder extends DynamicBytesCoder {
|
|
|
|
constructor(localName) {
|
|
|
|
super("bytes", localName);
|
|
|
|
}
|
|
|
|
decode(reader) {
|
2022-09-15 22:58:45 -04:00
|
|
|
return (0, index_js_1.hexlify)(super.decode(reader));
|
2022-09-05 16:57:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.BytesCoder = BytesCoder;
|
|
|
|
//# sourceMappingURL=bytes.js.map
|