UNPKG

@swtc/serializer

Version:
28 lines 1.08 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const SerializedType_1 = __importDefault(require("./SerializedType")); const STAccount = new SerializedType_1.default({ id: 8, serialize(so, val) { const byte_data = this.KeyPair.convertAddressToBytes(val); SerializedType_1.default.serialize_varint(so, byte_data.length); so.append(byte_data); }, parse(so) { const len = this.parse_varint(so); if (len !== 20) { throw new Error("Non-standard-length account ID"); } const result = this.KeyPair.convertBytesToAddress(so.read(len)); // UInt160.from_bytes(so.read(len)); // result.set_version(Base.VER_ACCOUNT_ID); // if (false && !result.is_valid()) { // throw new Error('Invalid Account'); // } return result; } }); exports.default = STAccount; //# sourceMappingURL=STAccount.js.map