/* eslint-disable */ import _m0 from "protobufjs/minimal"; import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Grant } from "./feegrant"; export const protobufPackage = "cosmos.feegrant.v1beta1"; /** Since: cosmos-sdk 0.43 */ /** QueryAllowanceRequest is the request type for the Query/Allowance RPC method. */ export interface QueryAllowanceRequest { /** granter is the address of the user granting an allowance of their funds. */ granter: string; /** grantee is the address of the user being granted an allowance of another user's funds. */ grantee: string; } /** QueryAllowanceResponse is the response type for the Query/Allowance RPC method. */ export interface QueryAllowanceResponse { /** allowance is a allowance granted for grantee by granter. */ allowance: Grant | undefined; } /** QueryAllowancesRequest is the request type for the Query/Allowances RPC method. */ export interface QueryAllowancesRequest { grantee: string; /** pagination defines an pagination for the request. */ pagination: PageRequest | undefined; } /** QueryAllowancesResponse is the response type for the Query/Allowances RPC method. */ export interface QueryAllowancesResponse { /** allowances are allowance's granted for grantee by granter. */ allowances: Grant[]; /** pagination defines an pagination for the response. */ pagination: PageResponse | undefined; } /** * QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. * * Since: cosmos-sdk 0.46 */ export interface QueryAllowancesByGranterRequest { granter: string; /** pagination defines an pagination for the request. */ pagination: PageRequest | undefined; } /** * QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. * * Since: cosmos-sdk 0.46 */ export interface QueryAllowancesByGranterResponse { /** allowances that have been issued by the granter. */ allowances: Grant[]; /** pagination defines an pagination for the response. */ pagination: PageResponse | undefined; } function createBaseQueryAllowanceRequest(): QueryAllowanceRequest { return { granter: "", grantee: "" }; } export const QueryAllowanceRequest = { encode(message: QueryAllowanceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.granter !== "") { writer.uint32(10).string(message.granter); } if (message.grantee !== "") { writer.uint32(18).string(message.grantee); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowanceRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowanceRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.granter = reader.string(); break; case 2: message.grantee = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowanceRequest { return { granter: isSet(object.granter) ? String(object.granter) : "", grantee: isSet(object.grantee) ? String(object.grantee) : "", }; }, toJSON(message: QueryAllowanceRequest): unknown { const obj: any = {}; message.granter !== undefined && (obj.granter = message.granter); message.grantee !== undefined && (obj.grantee = message.grantee); return obj; }, fromPartial, I>>(object: I): QueryAllowanceRequest { const message = createBaseQueryAllowanceRequest(); message.granter = object.granter ?? ""; message.grantee = object.grantee ?? ""; return message; }, }; function createBaseQueryAllowanceResponse(): QueryAllowanceResponse { return { allowance: undefined }; } export const QueryAllowanceResponse = { encode(message: QueryAllowanceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.allowance !== undefined) { Grant.encode(message.allowance, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowanceResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowanceResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.allowance = Grant.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowanceResponse { return { allowance: isSet(object.allowance) ? Grant.fromJSON(object.allowance) : undefined }; }, toJSON(message: QueryAllowanceResponse): unknown { const obj: any = {}; message.allowance !== undefined && (obj.allowance = message.allowance ? Grant.toJSON(message.allowance) : undefined); return obj; }, fromPartial, I>>(object: I): QueryAllowanceResponse { const message = createBaseQueryAllowanceResponse(); message.allowance = (object.allowance !== undefined && object.allowance !== null) ? Grant.fromPartial(object.allowance) : undefined; return message; }, }; function createBaseQueryAllowancesRequest(): QueryAllowancesRequest { return { grantee: "", pagination: undefined }; } export const QueryAllowancesRequest = { encode(message: QueryAllowancesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.grantee !== "") { writer.uint32(10).string(message.grantee); } if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowancesRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowancesRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.grantee = reader.string(); break; case 2: message.pagination = PageRequest.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowancesRequest { return { grantee: isSet(object.grantee) ? String(object.grantee) : "", pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryAllowancesRequest): unknown { const obj: any = {}; message.grantee !== undefined && (obj.grantee = message.grantee); message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); return obj; }, fromPartial, I>>(object: I): QueryAllowancesRequest { const message = createBaseQueryAllowancesRequest(); message.grantee = object.grantee ?? ""; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageRequest.fromPartial(object.pagination) : undefined; return message; }, }; function createBaseQueryAllowancesResponse(): QueryAllowancesResponse { return { allowances: [], pagination: undefined }; } export const QueryAllowancesResponse = { encode(message: QueryAllowancesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.allowances) { Grant.encode(v!, writer.uint32(10).fork()).ldelim(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowancesResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowancesResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.allowances.push(Grant.decode(reader, reader.uint32())); break; case 2: message.pagination = PageResponse.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowancesResponse { return { allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryAllowancesResponse): unknown { const obj: any = {}; if (message.allowances) { obj.allowances = message.allowances.map((e) => e ? Grant.toJSON(e) : undefined); } else { obj.allowances = []; } message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); return obj; }, fromPartial, I>>(object: I): QueryAllowancesResponse { const message = createBaseQueryAllowancesResponse(); message.allowances = object.allowances?.map((e) => Grant.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; return message; }, }; function createBaseQueryAllowancesByGranterRequest(): QueryAllowancesByGranterRequest { return { granter: "", pagination: undefined }; } export const QueryAllowancesByGranterRequest = { encode(message: QueryAllowancesByGranterRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.granter !== "") { writer.uint32(10).string(message.granter); } if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowancesByGranterRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowancesByGranterRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.granter = reader.string(); break; case 2: message.pagination = PageRequest.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowancesByGranterRequest { return { granter: isSet(object.granter) ? String(object.granter) : "", pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryAllowancesByGranterRequest): unknown { const obj: any = {}; message.granter !== undefined && (obj.granter = message.granter); message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); return obj; }, fromPartial, I>>( object: I, ): QueryAllowancesByGranterRequest { const message = createBaseQueryAllowancesByGranterRequest(); message.granter = object.granter ?? ""; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageRequest.fromPartial(object.pagination) : undefined; return message; }, }; function createBaseQueryAllowancesByGranterResponse(): QueryAllowancesByGranterResponse { return { allowances: [], pagination: undefined }; } export const QueryAllowancesByGranterResponse = { encode(message: QueryAllowancesByGranterResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.allowances) { Grant.encode(v!, writer.uint32(10).fork()).ldelim(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllowancesByGranterResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryAllowancesByGranterResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.allowances.push(Grant.decode(reader, reader.uint32())); break; case 2: message.pagination = PageResponse.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryAllowancesByGranterResponse { return { allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryAllowancesByGranterResponse): unknown { const obj: any = {}; if (message.allowances) { obj.allowances = message.allowances.map((e) => e ? Grant.toJSON(e) : undefined); } else { obj.allowances = []; } message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); return obj; }, fromPartial, I>>( object: I, ): QueryAllowancesByGranterResponse { const message = createBaseQueryAllowancesByGranterResponse(); message.allowances = object.allowances?.map((e) => Grant.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; return message; }, }; /** Query defines the gRPC querier service. */ export interface Query { /** Allowance returns fee granted to the grantee by the granter. */ Allowance(request: QueryAllowanceRequest): Promise; /** Allowances returns all the grants for address. */ Allowances(request: QueryAllowancesRequest): Promise; /** * AllowancesByGranter returns all the grants given by an address * * Since: cosmos-sdk 0.46 */ AllowancesByGranter(request: QueryAllowancesByGranterRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; constructor(rpc: Rpc) { this.rpc = rpc; this.Allowance = this.Allowance.bind(this); this.Allowances = this.Allowances.bind(this); this.AllowancesByGranter = this.AllowancesByGranter.bind(this); } Allowance(request: QueryAllowanceRequest): Promise { const data = QueryAllowanceRequest.encode(request).finish(); const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "Allowance", data); return promise.then((data) => QueryAllowanceResponse.decode(new _m0.Reader(data))); } Allowances(request: QueryAllowancesRequest): Promise { const data = QueryAllowancesRequest.encode(request).finish(); const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "Allowances", data); return promise.then((data) => QueryAllowancesResponse.decode(new _m0.Reader(data))); } AllowancesByGranter(request: QueryAllowancesByGranterRequest): Promise { const data = QueryAllowancesByGranterRequest.encode(request).finish(); const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "AllowancesByGranter", data); return promise.then((data) => QueryAllowancesByGranterResponse.decode(new _m0.Reader(data))); } } interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { return value !== null && value !== undefined; }