diff --git a/packages/cosmic-proto/dist/agoric/vstorage/query.d.ts b/packages/cosmic-proto/dist/agoric/vstorage/query.d.ts new file mode 100644 index 00000000000..2a7a4265016 --- /dev/null +++ b/packages/cosmic-proto/dist/agoric/vstorage/query.d.ts @@ -0,0 +1,438 @@ +import Long from 'long'; +import _m0 from 'protobufjs/minimal.js'; +import { + PageRequest, + PageResponse, +} from '../../cosmos/base/query/v1beta1/pagination.js'; +export declare const protobufPackage = 'agoric.vstorage'; +/** QueryDataRequest is the vstorage path data query. */ +export interface QueryDataRequest { + path: string; +} +/** QueryDataResponse is the vstorage path data response. */ +export interface QueryDataResponse { + value: string; +} +/** QueryChildrenRequest is the vstorage path children query. */ +export interface QueryChildrenRequest { + path: string; + pagination?: PageRequest; +} +/** QueryChildrenResponse is the vstorage path children response. */ +export interface QueryChildrenResponse { + children: string[]; + pagination?: PageResponse; +} +export declare const QueryDataRequest: { + encode(message: QueryDataRequest, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDataRequest; + fromJSON(object: any): QueryDataRequest; + toJSON(message: QueryDataRequest): unknown; + fromPartial< + I extends { + path?: string | undefined; + } & { + path?: string | undefined; + } & { [K in Exclude]: never }, + >( + object: I, + ): QueryDataRequest; +}; +export declare const QueryDataResponse: { + encode(message: QueryDataResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDataResponse; + fromJSON(object: any): QueryDataResponse; + toJSON(message: QueryDataResponse): unknown; + fromPartial< + I extends { + value?: string | undefined; + } & { + value?: string | undefined; + } & { [K in Exclude]: never }, + >( + object: I, + ): QueryDataResponse; +}; +export declare const QueryChildrenRequest: { + encode(message: QueryChildrenRequest, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChildrenRequest; + fromJSON(object: any): QueryChildrenRequest; + toJSON(message: QueryChildrenRequest): unknown; + fromPartial< + I extends { + path?: string | undefined; + pagination?: + | { + key?: Uint8Array | undefined; + offset?: string | number | Long | undefined; + limit?: string | number | Long | undefined; + countTotal?: boolean | undefined; + reverse?: boolean | undefined; + } + | undefined; + } & { + path?: string | undefined; + pagination?: + | ({ + key?: Uint8Array | undefined; + offset?: string | number | Long | undefined; + limit?: string | number | Long | undefined; + countTotal?: boolean | undefined; + reverse?: boolean | undefined; + } & { + key?: Uint8Array | undefined; + offset?: + | string + | number + | (Long & { + high: number; + low: number; + unsigned: boolean; + add: (addend: string | number | Long) => Long; + and: (other: string | number | Long) => Long; + compare: (other: string | number | Long) => number; + comp: (other: string | number | Long) => number; + divide: (divisor: string | number | Long) => Long; + div: (divisor: string | number | Long) => Long; + equals: (other: string | number | Long) => boolean; + eq: (other: string | number | Long) => boolean; + getHighBits: () => number; + getHighBitsUnsigned: () => number; + getLowBits: () => number; + getLowBitsUnsigned: () => number; + getNumBitsAbs: () => number; + greaterThan: (other: string | number | Long) => boolean; + gt: (other: string | number | Long) => boolean; + greaterThanOrEqual: ( + other: string | number | Long, + ) => boolean; + gte: (other: string | number | Long) => boolean; + ge: (other: string | number | Long) => boolean; + isEven: () => boolean; + isNegative: () => boolean; + isOdd: () => boolean; + isPositive: () => boolean; + isZero: () => boolean; + eqz: () => boolean; + lessThan: (other: string | number | Long) => boolean; + lt: (other: string | number | Long) => boolean; + lessThanOrEqual: (other: string | number | Long) => boolean; + lte: (other: string | number | Long) => boolean; + le: (other: string | number | Long) => boolean; + modulo: (other: string | number | Long) => Long; + mod: (other: string | number | Long) => Long; + rem: (other: string | number | Long) => Long; + multiply: (multiplier: string | number | Long) => Long; + mul: (multiplier: string | number | Long) => Long; + negate: () => Long; + neg: () => Long; + not: () => Long; + countLeadingZeros: () => number; + clz: () => number; + countTrailingZeros: () => number; + ctz: () => number; + notEquals: (other: string | number | Long) => boolean; + neq: (other: string | number | Long) => boolean; + ne: (other: string | number | Long) => boolean; + or: (other: string | number | Long) => Long; + shiftLeft: (numBits: number | Long) => Long; + shl: (numBits: number | Long) => Long; + shiftRight: (numBits: number | Long) => Long; + shr: (numBits: number | Long) => Long; + shiftRightUnsigned: (numBits: number | Long) => Long; + shru: (numBits: number | Long) => Long; + shr_u: (numBits: number | Long) => Long; + rotateLeft: (numBits: number | Long) => Long; + rotl: (numBits: number | Long) => Long; + rotateRight: (numBits: number | Long) => Long; + rotr: (numBits: number | Long) => Long; + subtract: (subtrahend: string | number | Long) => Long; + sub: (subtrahend: string | number | Long) => Long; + toInt: () => number; + toNumber: () => number; + toBytes: (le?: boolean | undefined) => number[]; + toBytesLE: () => number[]; + toBytesBE: () => number[]; + toSigned: () => Long; + toString: (radix?: number | undefined) => string; + toUnsigned: () => Long; + xor: (other: string | number | Long) => Long; + } & { + [K in Exclude< + keyof I['pagination']['offset'], + keyof Long + >]: never; + }) + | undefined; + limit?: + | string + | number + | (Long & { + high: number; + low: number; + unsigned: boolean; + add: (addend: string | number | Long) => Long; + and: (other: string | number | Long) => Long; + compare: (other: string | number | Long) => number; + comp: (other: string | number | Long) => number; + divide: (divisor: string | number | Long) => Long; + div: (divisor: string | number | Long) => Long; + equals: (other: string | number | Long) => boolean; + eq: (other: string | number | Long) => boolean; + getHighBits: () => number; + getHighBitsUnsigned: () => number; + getLowBits: () => number; + getLowBitsUnsigned: () => number; + getNumBitsAbs: () => number; + greaterThan: (other: string | number | Long) => boolean; + gt: (other: string | number | Long) => boolean; + greaterThanOrEqual: ( + other: string | number | Long, + ) => boolean; + gte: (other: string | number | Long) => boolean; + ge: (other: string | number | Long) => boolean; + isEven: () => boolean; + isNegative: () => boolean; + isOdd: () => boolean; + isPositive: () => boolean; + isZero: () => boolean; + eqz: () => boolean; + lessThan: (other: string | number | Long) => boolean; + lt: (other: string | number | Long) => boolean; + lessThanOrEqual: (other: string | number | Long) => boolean; + lte: (other: string | number | Long) => boolean; + le: (other: string | number | Long) => boolean; + modulo: (other: string | number | Long) => Long; + mod: (other: string | number | Long) => Long; + rem: (other: string | number | Long) => Long; + multiply: (multiplier: string | number | Long) => Long; + mul: (multiplier: string | number | Long) => Long; + negate: () => Long; + neg: () => Long; + not: () => Long; + countLeadingZeros: () => number; + clz: () => number; + countTrailingZeros: () => number; + ctz: () => number; + notEquals: (other: string | number | Long) => boolean; + neq: (other: string | number | Long) => boolean; + ne: (other: string | number | Long) => boolean; + or: (other: string | number | Long) => Long; + shiftLeft: (numBits: number | Long) => Long; + shl: (numBits: number | Long) => Long; + shiftRight: (numBits: number | Long) => Long; + shr: (numBits: number | Long) => Long; + shiftRightUnsigned: (numBits: number | Long) => Long; + shru: (numBits: number | Long) => Long; + shr_u: (numBits: number | Long) => Long; + rotateLeft: (numBits: number | Long) => Long; + rotl: (numBits: number | Long) => Long; + rotateRight: (numBits: number | Long) => Long; + rotr: (numBits: number | Long) => Long; + subtract: (subtrahend: string | number | Long) => Long; + sub: (subtrahend: string | number | Long) => Long; + toInt: () => number; + toNumber: () => number; + toBytes: (le?: boolean | undefined) => number[]; + toBytesLE: () => number[]; + toBytesBE: () => number[]; + toSigned: () => Long; + toString: (radix?: number | undefined) => string; + toUnsigned: () => Long; + xor: (other: string | number | Long) => Long; + } & { + [K_1 in Exclude< + keyof I['pagination']['limit'], + keyof Long + >]: never; + }) + | undefined; + countTotal?: boolean | undefined; + reverse?: boolean | undefined; + } & { + [K_2 in Exclude]: never; + }) + | undefined; + } & { [K_3 in Exclude]: never }, + >( + object: I, + ): QueryChildrenRequest; +}; +export declare const QueryChildrenResponse: { + encode(message: QueryChildrenResponse, writer?: _m0.Writer): _m0.Writer; + decode( + input: _m0.Reader | Uint8Array, + length?: number, + ): QueryChildrenResponse; + fromJSON(object: any): QueryChildrenResponse; + toJSON(message: QueryChildrenResponse): unknown; + fromPartial< + I extends { + children?: string[] | undefined; + pagination?: + | { + nextKey?: Uint8Array | undefined; + total?: string | number | Long | undefined; + } + | undefined; + } & { + children?: + | (string[] & + string[] & { + [K in Exclude]: never; + }) + | undefined; + pagination?: + | ({ + nextKey?: Uint8Array | undefined; + total?: string | number | Long | undefined; + } & { + nextKey?: Uint8Array | undefined; + total?: + | string + | number + | (Long & { + high: number; + low: number; + unsigned: boolean; + add: (addend: string | number | Long) => Long; + and: (other: string | number | Long) => Long; + compare: (other: string | number | Long) => number; + comp: (other: string | number | Long) => number; + divide: (divisor: string | number | Long) => Long; + div: (divisor: string | number | Long) => Long; + equals: (other: string | number | Long) => boolean; + eq: (other: string | number | Long) => boolean; + getHighBits: () => number; + getHighBitsUnsigned: () => number; + getLowBits: () => number; + getLowBitsUnsigned: () => number; + getNumBitsAbs: () => number; + greaterThan: (other: string | number | Long) => boolean; + gt: (other: string | number | Long) => boolean; + greaterThanOrEqual: ( + other: string | number | Long, + ) => boolean; + gte: (other: string | number | Long) => boolean; + ge: (other: string | number | Long) => boolean; + isEven: () => boolean; + isNegative: () => boolean; + isOdd: () => boolean; + isPositive: () => boolean; + isZero: () => boolean; + eqz: () => boolean; + lessThan: (other: string | number | Long) => boolean; + lt: (other: string | number | Long) => boolean; + lessThanOrEqual: (other: string | number | Long) => boolean; + lte: (other: string | number | Long) => boolean; + le: (other: string | number | Long) => boolean; + modulo: (other: string | number | Long) => Long; + mod: (other: string | number | Long) => Long; + rem: (other: string | number | Long) => Long; + multiply: (multiplier: string | number | Long) => Long; + mul: (multiplier: string | number | Long) => Long; + negate: () => Long; + neg: () => Long; + not: () => Long; + countLeadingZeros: () => number; + clz: () => number; + countTrailingZeros: () => number; + ctz: () => number; + notEquals: (other: string | number | Long) => boolean; + neq: (other: string | number | Long) => boolean; + ne: (other: string | number | Long) => boolean; + or: (other: string | number | Long) => Long; + shiftLeft: (numBits: number | Long) => Long; + shl: (numBits: number | Long) => Long; + shiftRight: (numBits: number | Long) => Long; + shr: (numBits: number | Long) => Long; + shiftRightUnsigned: (numBits: number | Long) => Long; + shru: (numBits: number | Long) => Long; + shr_u: (numBits: number | Long) => Long; + rotateLeft: (numBits: number | Long) => Long; + rotl: (numBits: number | Long) => Long; + rotateRight: (numBits: number | Long) => Long; + rotr: (numBits: number | Long) => Long; + subtract: (subtrahend: string | number | Long) => Long; + sub: (subtrahend: string | number | Long) => Long; + toInt: () => number; + toNumber: () => number; + toBytes: (le?: boolean | undefined) => number[]; + toBytesLE: () => number[]; + toBytesBE: () => number[]; + toSigned: () => Long; + toString: (radix?: number | undefined) => string; + toUnsigned: () => Long; + xor: (other: string | number | Long) => Long; + } & { + [K_1 in Exclude< + keyof I['pagination']['total'], + keyof Long + >]: never; + }) + | undefined; + } & { + [K_2 in Exclude]: never; + }) + | undefined; + } & { [K_3 in Exclude]: never }, + >( + object: I, + ): QueryChildrenResponse; +}; +/** Query defines the gRPC querier service */ +export interface Query { + /** Return an arbitrary vstorage datum. */ + Data(request: QueryDataRequest): Promise; + /** Return the children of a given vstorage path. */ + Children(request: QueryChildrenRequest): Promise; +} +export declare class QueryClientImpl implements Query { + private readonly rpc; + private readonly service; + constructor( + rpc: Rpc, + opts?: { + service?: string; + }, + ); + Data(request: QueryDataRequest): Promise; + Children(request: QueryChildrenRequest): Promise; +} +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array, + ): Promise; +} +declare type Builtin = + | Date + | Function + | Uint8Array + | string + | number + | boolean + | undefined; +export declare type DeepPartial = T extends Builtin + ? T + : T extends Long + ? string | number | Long + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { + [K in keyof T]?: DeepPartial; + } + : Partial; +declare type KeysOfUnion = T extends T ? keyof T : never; +export declare type Exact = P extends Builtin + ? P + : P & { + [K in keyof P]: Exact; + } & { + [K in Exclude>]: never; + }; +export {}; diff --git a/packages/cosmic-proto/dist/agoric/vstorage/query.js b/packages/cosmic-proto/dist/agoric/vstorage/query.js new file mode 100644 index 00000000000..8d795ca8c03 --- /dev/null +++ b/packages/cosmic-proto/dist/agoric/vstorage/query.js @@ -0,0 +1,250 @@ +/* eslint-disable */ +import Long from 'long'; +import _m0 from 'protobufjs/minimal.js'; +import { + PageRequest, + PageResponse, +} from '../../cosmos/base/query/v1beta1/pagination.js'; +export const protobufPackage = 'agoric.vstorage'; +function createBaseQueryDataRequest() { + return { path: '' }; +} +export const QueryDataRequest = { + encode(message, writer = _m0.Writer.create()) { + if (message.path !== '') { + writer.uint32(10).string(message.path); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDataRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object) { + return { path: isSet(object.path) ? String(object.path) : '' }; + }, + toJSON(message) { + const obj = {}; + message.path !== undefined && (obj.path = message.path); + return obj; + }, + fromPartial(object) { + const message = createBaseQueryDataRequest(); + message.path = object.path ?? ''; + return message; + }, +}; +function createBaseQueryDataResponse() { + return { value: '' }; +} +export const QueryDataResponse = { + encode(message, writer = _m0.Writer.create()) { + if (message.value !== '') { + writer.uint32(10).string(message.value); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDataResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object) { + return { value: isSet(object.value) ? String(object.value) : '' }; + }, + toJSON(message) { + const obj = {}; + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object) { + const message = createBaseQueryDataResponse(); + message.value = object.value ?? ''; + return message; + }, +}; +function createBaseQueryChildrenRequest() { + return { path: '', pagination: undefined }; +} +export const QueryChildrenRequest = { + encode(message, writer = _m0.Writer.create()) { + if (message.path !== '') { + writer.uint32(10).string(message.path); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryChildrenRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object) { + return { + path: isSet(object.path) ? String(object.path) : '', + pagination: isSet(object.pagination) + ? PageRequest.fromJSON(object.pagination) + : undefined, + }; + }, + toJSON(message) { + const obj = {}; + message.path !== undefined && (obj.path = message.path); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + fromPartial(object) { + const message = createBaseQueryChildrenRequest(); + message.path = object.path ?? ''; + message.pagination = + object.pagination !== undefined && object.pagination !== null + ? PageRequest.fromPartial(object.pagination) + : undefined; + return message; + }, +}; +function createBaseQueryChildrenResponse() { + return { children: [], pagination: undefined }; +} +export const QueryChildrenResponse = { + encode(message, writer = _m0.Writer.create()) { + for (const v of message.children) { + writer.uint32(10).string(v); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork(), + ).ldelim(); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryChildrenResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.children.push(reader.string()); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object) { + return { + children: Array.isArray(object?.children) + ? object.children.map((e) => String(e)) + : [], + pagination: isSet(object.pagination) + ? PageResponse.fromJSON(object.pagination) + : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.children) { + obj.children = message.children.map((e) => e); + } else { + obj.children = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + fromPartial(object) { + const message = createBaseQueryChildrenResponse(); + message.children = object.children?.map((e) => e) || []; + message.pagination = + object.pagination !== undefined && object.pagination !== null + ? PageResponse.fromPartial(object.pagination) + : undefined; + return message; + }, +}; +export class QueryClientImpl { + rpc; + service; + constructor(rpc, opts) { + this.service = opts?.service || 'agoric.vstorage.Query'; + this.rpc = rpc; + this.Data = this.Data.bind(this); + this.Children = this.Children.bind(this); + } + Data(request) { + const data = QueryDataRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, 'Data', data); + return promise.then((data) => + QueryDataResponse.decode(new _m0.Reader(data)), + ); + } + Children(request) { + const data = QueryChildrenRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, 'Children', data); + return promise.then((data) => + QueryChildrenResponse.decode(new _m0.Reader(data)), + ); + } +} +if (_m0.util.Long !== Long) { + _m0.util.Long = Long; + _m0.configure(); +} +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/packages/cosmic-proto/package.json b/packages/cosmic-proto/package.json index 4b8fec2f7b2..41abb5eb132 100644 --- a/packages/cosmic-proto/package.json +++ b/packages/cosmic-proto/package.json @@ -24,6 +24,10 @@ "types": "./dist/agoric/swingset/query.d.ts", "default": "./dist/agoric/swingset/query.js" }, + "./vstorage/query.js": { + "types": "./dist/agoric/vstorage/query.d.ts", + "default": "./dist/agoric/vstorage/query.js" + }, "./swingset/swingset.js": { "types": "./dist/agoric/swingset/swingset.d.ts", "default": "./dist/agoric/swingset/swingset.js" @@ -32,7 +36,7 @@ "scripts": { "build": "echo Use yarn rebuild to update dist output", "rebuild": "rm -rf gen && mkdir -p gen && yarn generate && tsc --build && yarn prettier -w dist/agoric && rm -rf gen", - "generate": "protoc --plugin=node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt='esModuleInterop=true,forceLong=long,useOptionals=messages' --ts_proto_out=./gen --ts_proto_opt=importSuffix=.js ./proto/agoric/swingset/msgs.proto ./proto/agoric/swingset/query.proto -I./proto", + "generate": "protoc --plugin=node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt='esModuleInterop=true,forceLong=long,useOptionals=messages' --ts_proto_out=./gen --ts_proto_opt=importSuffix=.js ./proto/agoric/swingset/msgs.proto ./proto/agoric/swingset/query.proto ./proto/agoric/vstorage/query.proto -I./proto", "test": "node test/sanity-test.js", "test:xs": "exit 0", "lint": "exit 0", diff --git a/packages/cosmic-proto/test/sanity-test.js b/packages/cosmic-proto/test/sanity-test.js index db3495231a8..96487d96409 100644 --- a/packages/cosmic-proto/test/sanity-test.js +++ b/packages/cosmic-proto/test/sanity-test.js @@ -1,3 +1,4 @@ /* eslint-disable import/no-extraneous-dependencies -- bug in rule thinks this package depends on itself */ import '@agoric/cosmic-proto/swingset/msgs.js'; import '@agoric/cosmic-proto/swingset/query.js'; +import '@agoric/cosmic-proto/vstorage/query.js';