UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

360 lines (359 loc) 13.5 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.181.2 // protoc v3.21.12 // source: message_contents/frames.proto /* eslint-disable */ import Long from "long"; import _m0 from "protobufjs/minimal"; import { SignedPublicKeyBundle } from "./public_key.pb"; import { Signature } from "./signature.pb"; export const protobufPackage = "xmtp.message_contents"; function createBaseFrameActionBody() { return { frameUrl: "", buttonIndex: 0, timestamp: Long.UZERO, opaqueConversationIdentifier: "", unixTimestamp: 0, inputText: "", state: "", address: "", transactionId: "", }; } export const FrameActionBody = { encode(message, writer = _m0.Writer.create()) { if (message.frameUrl !== "") { writer.uint32(10).string(message.frameUrl); } if (message.buttonIndex !== 0) { writer.uint32(16).int32(message.buttonIndex); } if (!message.timestamp.equals(Long.UZERO)) { writer.uint32(24).uint64(message.timestamp); } if (message.opaqueConversationIdentifier !== "") { writer.uint32(34).string(message.opaqueConversationIdentifier); } if (message.unixTimestamp !== 0) { writer.uint32(40).uint32(message.unixTimestamp); } if (message.inputText !== "") { writer.uint32(50).string(message.inputText); } if (message.state !== "") { writer.uint32(58).string(message.state); } if (message.address !== "") { writer.uint32(66).string(message.address); } if (message.transactionId !== "") { writer.uint32(74).string(message.transactionId); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFrameActionBody(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.frameUrl = reader.string(); continue; case 2: if (tag !== 16) { break; } message.buttonIndex = reader.int32(); continue; case 3: if (tag !== 24) { break; } message.timestamp = reader.uint64(); continue; case 4: if (tag !== 34) { break; } message.opaqueConversationIdentifier = reader.string(); continue; case 5: if (tag !== 40) { break; } message.unixTimestamp = reader.uint32(); continue; case 6: if (tag !== 50) { break; } message.inputText = reader.string(); continue; case 7: if (tag !== 58) { break; } message.state = reader.string(); continue; case 8: if (tag !== 66) { break; } message.address = reader.string(); continue; case 9: if (tag !== 74) { break; } message.transactionId = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { frameUrl: isSet(object.frameUrl) ? globalThis.String(object.frameUrl) : "", buttonIndex: isSet(object.buttonIndex) ? globalThis.Number(object.buttonIndex) : 0, timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, opaqueConversationIdentifier: isSet(object.opaqueConversationIdentifier) ? globalThis.String(object.opaqueConversationIdentifier) : "", unixTimestamp: isSet(object.unixTimestamp) ? globalThis.Number(object.unixTimestamp) : 0, inputText: isSet(object.inputText) ? globalThis.String(object.inputText) : "", state: isSet(object.state) ? globalThis.String(object.state) : "", address: isSet(object.address) ? globalThis.String(object.address) : "", transactionId: isSet(object.transactionId) ? globalThis.String(object.transactionId) : "", }; }, toJSON(message) { const obj = {}; if (message.frameUrl !== "") { obj.frameUrl = message.frameUrl; } if (message.buttonIndex !== 0) { obj.buttonIndex = Math.round(message.buttonIndex); } if (!message.timestamp.equals(Long.UZERO)) { obj.timestamp = (message.timestamp || Long.UZERO).toString(); } if (message.opaqueConversationIdentifier !== "") { obj.opaqueConversationIdentifier = message.opaqueConversationIdentifier; } if (message.unixTimestamp !== 0) { obj.unixTimestamp = Math.round(message.unixTimestamp); } if (message.inputText !== "") { obj.inputText = message.inputText; } if (message.state !== "") { obj.state = message.state; } if (message.address !== "") { obj.address = message.address; } if (message.transactionId !== "") { obj.transactionId = message.transactionId; } return obj; }, create(base) { return FrameActionBody.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseFrameActionBody(); message.frameUrl = object.frameUrl ?? ""; message.buttonIndex = object.buttonIndex ?? 0; message.timestamp = (object.timestamp !== undefined && object.timestamp !== null) ? Long.fromValue(object.timestamp) : Long.UZERO; message.opaqueConversationIdentifier = object.opaqueConversationIdentifier ?? ""; message.unixTimestamp = object.unixTimestamp ?? 0; message.inputText = object.inputText ?? ""; message.state = object.state ?? ""; message.address = object.address ?? ""; message.transactionId = object.transactionId ?? ""; return message; }, }; function createBaseFrameAction() { return { signature: undefined, signedPublicKeyBundle: undefined, actionBody: new Uint8Array(0), installationSignature: new Uint8Array(0), installationId: new Uint8Array(0), inboxId: "", }; } export const FrameAction = { encode(message, writer = _m0.Writer.create()) { if (message.signature !== undefined) { Signature.encode(message.signature, writer.uint32(10).fork()).ldelim(); } if (message.signedPublicKeyBundle !== undefined) { SignedPublicKeyBundle.encode(message.signedPublicKeyBundle, writer.uint32(18).fork()).ldelim(); } if (message.actionBody.length !== 0) { writer.uint32(26).bytes(message.actionBody); } if (message.installationSignature.length !== 0) { writer.uint32(34).bytes(message.installationSignature); } if (message.installationId.length !== 0) { writer.uint32(42).bytes(message.installationId); } if (message.inboxId !== "") { writer.uint32(50).string(message.inboxId); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFrameAction(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.signature = Signature.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { break; } message.signedPublicKeyBundle = SignedPublicKeyBundle.decode(reader, reader.uint32()); continue; case 3: if (tag !== 26) { break; } message.actionBody = reader.bytes(); continue; case 4: if (tag !== 34) { break; } message.installationSignature = reader.bytes(); continue; case 5: if (tag !== 42) { break; } message.installationId = reader.bytes(); continue; case 6: if (tag !== 50) { break; } message.inboxId = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { signature: isSet(object.signature) ? Signature.fromJSON(object.signature) : undefined, signedPublicKeyBundle: isSet(object.signedPublicKeyBundle) ? SignedPublicKeyBundle.fromJSON(object.signedPublicKeyBundle) : undefined, actionBody: isSet(object.actionBody) ? bytesFromBase64(object.actionBody) : new Uint8Array(0), installationSignature: isSet(object.installationSignature) ? bytesFromBase64(object.installationSignature) : new Uint8Array(0), installationId: isSet(object.installationId) ? bytesFromBase64(object.installationId) : new Uint8Array(0), inboxId: isSet(object.inboxId) ? globalThis.String(object.inboxId) : "", }; }, toJSON(message) { const obj = {}; if (message.signature !== undefined) { obj.signature = Signature.toJSON(message.signature); } if (message.signedPublicKeyBundle !== undefined) { obj.signedPublicKeyBundle = SignedPublicKeyBundle.toJSON(message.signedPublicKeyBundle); } if (message.actionBody.length !== 0) { obj.actionBody = base64FromBytes(message.actionBody); } if (message.installationSignature.length !== 0) { obj.installationSignature = base64FromBytes(message.installationSignature); } if (message.installationId.length !== 0) { obj.installationId = base64FromBytes(message.installationId); } if (message.inboxId !== "") { obj.inboxId = message.inboxId; } return obj; }, create(base) { return FrameAction.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseFrameAction(); message.signature = (object.signature !== undefined && object.signature !== null) ? Signature.fromPartial(object.signature) : undefined; message.signedPublicKeyBundle = (object.signedPublicKeyBundle !== undefined && object.signedPublicKeyBundle !== null) ? SignedPublicKeyBundle.fromPartial(object.signedPublicKeyBundle) : undefined; message.actionBody = object.actionBody ?? new Uint8Array(0); message.installationSignature = object.installationSignature ?? new Uint8Array(0); message.installationId = object.installationId ?? new Uint8Array(0); message.inboxId = object.inboxId ?? ""; return message; }, }; function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } if (_m0.util.Long !== Long) { _m0.util.Long = Long; _m0.configure(); } function isSet(value) { return value !== null && value !== undefined; }