UNPKG

xud

Version:
73 lines 2.75 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Packet_1 = __importStar(require("../Packet")); const PacketType_1 = __importDefault(require("../PacketType")); const pb = __importStar(require("../../../proto/xudp2p_pb")); let SanitySwapInitPacket = /** @class */ (() => { class SanitySwapInitPacket extends Packet_1.default { constructor() { super(...arguments); this.serialize = () => { const msg = new pb.SanitySwapInitPacket(); msg.setId(this.header.id); msg.setCurrency(this.body.currency); msg.setRHash(this.body.rHash); return msg.serializeBinary(); }; } get type() { return PacketType_1.default.SanitySwap; } get direction() { return Packet_1.PacketDirection.Request; } get responseType() { return PacketType_1.default.SanitySwapAck; } } SanitySwapInitPacket.deserialize = (binary) => { const obj = pb.SanitySwapInitPacket.deserializeBinary(binary).toObject(); return SanitySwapInitPacket.validate(obj) ? SanitySwapInitPacket.convert(obj) : obj; }; SanitySwapInitPacket.validate = (obj) => { return !!(obj.id && obj.currency && obj.rHash); }; SanitySwapInitPacket.convert = (obj) => { return new SanitySwapInitPacket({ header: { id: obj.id, }, body: { currency: obj.currency, rHash: obj.rHash, }, }); }; return SanitySwapInitPacket; })(); exports.default = SanitySwapInitPacket; //# sourceMappingURL=SanitySwapInitPacket.js.map