// @generated by protobuf-ts 2.9.0 // @generated from protobuf file "response.proto" (package "pb", syntax proto3) // tslint:disable import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import { WireType } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; import { UnknownFieldHandler } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; /** * * Response structure for API v1 * * @generated from protobuf message pb.Response */ export interface Response { /** * Response body * * @generated from protobuf field: bytes body = 1; */ body: Uint8Array; /** * Response code * * @generated from protobuf field: pb.Code responseCode = 2; */ responseCode: Code; /** * Used gas for executing request * * @generated from protobuf field: uint32 gas = 3; */ gas: number; /** * CDN public key * * @generated from protobuf field: bytes publicKey = 4; */ publicKey: Uint8Array; /** * CDN signature sign(CID(varint body + body + varint response code + varint resources)) * * @generated from protobuf field: bytes signature = 5; */ signature: Uint8Array; /** * The name of the signature scheme (sr25519, ed25519). * Default and recommended value: "" or "sr25519". * * @generated from protobuf field: string scheme = 6; */ scheme: string; /** * The ID of the hashing algorithm as per multiformats/multihash. * Default and recommended value: 0 or 0xb220, meaning blake2b-256. * * @generated from protobuf field: uint64 multiHashType = 7; */ multiHashType: bigint; } /** * * Response codes * * @generated from protobuf enum pb.Code */ export enum Code { /** * @generated from protobuf enum value: SUCCESS = 0; */ SUCCESS = 0, /** * @generated from protobuf enum value: CREATED = 1; */ CREATED = 1, /** * @generated from protobuf enum value: NOT_FOUND = 2; */ NOT_FOUND = 2, /** * @generated from protobuf enum value: FAILED_READ_BODY = 3; */ FAILED_READ_BODY = 3, /** * @generated from protobuf enum value: FAILED_UNMARSHAL_BODY = 4; */ FAILED_UNMARSHAL_BODY = 4, /** * @generated from protobuf enum value: FAILED_MARSHAL_BODY = 5; */ FAILED_MARSHAL_BODY = 5, /** * @generated from protobuf enum value: FAILED_GET_BLOCKCHAIN_DATA = 6; */ FAILED_GET_BLOCKCHAIN_DATA = 6, /** * @generated from protobuf enum value: BUCKET_RENT_EXPIRED = 7; */ BUCKET_RENT_EXPIRED = 7, /** * @generated from protobuf enum value: INVALID_PUBLIC_KEY = 8; */ INVALID_PUBLIC_KEY = 8, /** * @generated from protobuf enum value: INVALID_SIGNATURE = 9; */ INVALID_SIGNATURE = 9, /** * @generated from protobuf enum value: INVALID_PARAMETER = 10; */ INVALID_PARAMETER = 10, /** * @generated from protobuf enum value: BUCKET_NO_ACCESS = 11; */ BUCKET_NO_ACCESS = 11, /** * @generated from protobuf enum value: INTERNAL_ERROR = 12; */ INTERNAL_ERROR = 12, /** * @generated from protobuf enum value: BAD_GATEWAY = 13; */ BAD_GATEWAY = 13, /** * @generated from protobuf enum value: INVALID_SESSION_ID = 14; */ INVALID_SESSION_ID = 14, /** * @generated from protobuf enum value: ACCOUNT_DEPOSIT_REQUIRED = 15; */ ACCOUNT_DEPOSIT_REQUIRED = 15, /** * @generated from protobuf enum value: GAS_EXPIRED = 16; */ GAS_EXPIRED = 16, /** * @generated from protobuf enum value: REQUEST_TOO_LARGE = 17; */ REQUEST_TOO_LARGE = 17 } // @generated message type with reflection information, may provide speed optimized methods class Response$Type extends MessageType { constructor() { super("pb.Response", [ { no: 1, name: "body", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "responseCode", kind: "enum", T: () => ["pb.Code", Code] }, { no: 3, name: "gas", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 4, name: "publicKey", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 5, name: "signature", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 6, name: "scheme", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 7, name: "multiHashType", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } ]); } create(value?: PartialMessage): Response { const message = { body: new Uint8Array(0), responseCode: 0, gas: 0, publicKey: new Uint8Array(0), signature: new Uint8Array(0), scheme: "", multiHashType: 0n }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Response): Response { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* bytes body */ 1: message.body = reader.bytes(); break; case /* pb.Code responseCode */ 2: message.responseCode = reader.int32(); break; case /* uint32 gas */ 3: message.gas = reader.uint32(); break; case /* bytes publicKey */ 4: message.publicKey = reader.bytes(); break; case /* bytes signature */ 5: message.signature = reader.bytes(); break; case /* string scheme */ 6: message.scheme = reader.string(); break; case /* uint64 multiHashType */ 7: message.multiHashType = reader.uint64().toBigInt(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: Response, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* bytes body = 1; */ if (message.body.length) writer.tag(1, WireType.LengthDelimited).bytes(message.body); /* pb.Code responseCode = 2; */ if (message.responseCode !== 0) writer.tag(2, WireType.Varint).int32(message.responseCode); /* uint32 gas = 3; */ if (message.gas !== 0) writer.tag(3, WireType.Varint).uint32(message.gas); /* bytes publicKey = 4; */ if (message.publicKey.length) writer.tag(4, WireType.LengthDelimited).bytes(message.publicKey); /* bytes signature = 5; */ if (message.signature.length) writer.tag(5, WireType.LengthDelimited).bytes(message.signature); /* string scheme = 6; */ if (message.scheme !== "") writer.tag(6, WireType.LengthDelimited).string(message.scheme); /* uint64 multiHashType = 7; */ if (message.multiHashType !== 0n) writer.tag(7, WireType.Varint).uint64(message.multiHashType); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Response */ export const Response = new Response$Type();