Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dots in type #452

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
472 changes: 472 additions & 0 deletions __fixtures__/misc/output/binary.ts

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions __fixtures__/misc/output/extern.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This file and any referenced files were automatically generated by @cosmology/telescope@latest
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or yarn proto command to regenerate this bundle.
*/

import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from '@cosmjs/stargate'
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";

const _rpcClients: Record<string, ProtobufRpcClient> = {};

export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
return rpcEndpoint.url;
}
}

export const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
const key = getRpcEndpointKey(rpcEndpoint);
if (!key) return;
if (_rpcClients.hasOwnProperty(key)) {
return _rpcClients[key];
}
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
//@ts-ignore
const client = new QueryClient(tmClient);
const rpc = createProtobufRpcClient(client);
_rpcClients[key] = rpc;
return rpc;
}
223 changes: 223 additions & 0 deletions __fixtures__/misc/output/google/api/expr/v1alpha1/eval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import { BinaryReader, BinaryWriter } from "../../../../binary";
import { DeepPartial, isSet } from "../../../../helpers";
export const protobufPackage = "google.api.expr.v1alpha1";
export interface ExprValue {
/** The ids of the expressions with unknown values. */
exprs: IdRef[];
}
export interface ExprValueProtoMsg {
typeUrl: "/google.api.expr.v1alpha1.ExprValue";
value: Uint8Array;
}
export interface ExprValueAmino {
/** The ids of the expressions with unknown values. */
exprs: IdRefAmino[];
}
export interface ExprValueAminoMsg {
type: "/google.api.expr.v1alpha1.ExprValue";
value: ExprValueAmino;
}
export interface ExprValueSDKType {
exprs: IdRefSDKType[];
}
export interface IdRef {
/** The expression id. */
id: number;
}
export interface IdRefProtoMsg {
typeUrl: "/google.api.expr.v1alpha1.IdRef";
value: Uint8Array;
}
export interface IdRefAmino {
/** The expression id. */
id: number;
}
export interface IdRefAminoMsg {
type: "/google.api.expr.v1alpha1.IdRef";
value: IdRefAmino;
}
export interface IdRefSDKType {
id: number;
}
function createBaseExprValue(): ExprValue {
return {
exprs: []
};
}
export const ExprValue = {
encode(message: ExprValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
for (const v of message.exprs) {
IdRef.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): ExprValue {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExprValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.exprs.push(IdRef.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): ExprValue {
return {
exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromJSON(e)) : []
};
},
toJSON(message: ExprValue): unknown {
const obj: any = {};
if (message.exprs) {
obj.exprs = message.exprs.map(e => e ? IdRef.toJSON(e) : undefined);
} else {
obj.exprs = [];
}
return obj;
},
fromPartial(object: DeepPartial<ExprValue>): ExprValue {
const message = createBaseExprValue();
message.exprs = object.exprs?.map(e => IdRef.fromPartial(e)) || [];
return message;
},
fromSDK(object: ExprValueSDKType): ExprValue {
return {
exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDK(e)) : []
};
},
fromSDKJSON(object: any): ExprValueSDKType {
return {
exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDKJSON(e)) : []
};
},
toSDK(message: ExprValue): ExprValueSDKType {
const obj: any = {};
if (message.exprs) {
obj.exprs = message.exprs.map(e => e ? IdRef.toSDK(e) : undefined);
} else {
obj.exprs = [];
}
return obj;
},
fromAmino(object: ExprValueAmino): ExprValue {
return {
exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromAmino(e)) : []
};
},
toAmino(message: ExprValue): ExprValueAmino {
const obj: any = {};
if (message.exprs) {
obj.exprs = message.exprs.map(e => e ? IdRef.toAmino(e) : undefined);
} else {
obj.exprs = [];
}
return obj;
},
fromAminoMsg(object: ExprValueAminoMsg): ExprValue {
return ExprValue.fromAmino(object.value);
},
fromProtoMsg(message: ExprValueProtoMsg): ExprValue {
return ExprValue.decode(message.value);
},
toProto(message: ExprValue): Uint8Array {
return ExprValue.encode(message).finish();
},
toProtoMsg(message: ExprValue): ExprValueProtoMsg {
return {
typeUrl: "/google.api.expr.v1alpha1.ExprValue",
value: ExprValue.encode(message).finish()
};
}
};
function createBaseIdRef(): IdRef {
return {
id: 0
};
}
export const IdRef = {
encode(message: IdRef, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): IdRef {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseIdRef();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.id = reader.int32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): IdRef {
return {
id: isSet(object.id) ? Number(object.id) : 0
};
},
toJSON(message: IdRef): unknown {
const obj: any = {};
message.id !== undefined && (obj.id = Math.round(message.id));
return obj;
},
fromPartial(object: DeepPartial<IdRef>): IdRef {
const message = createBaseIdRef();
message.id = object.id ?? 0;
return message;
},
fromSDK(object: IdRefSDKType): IdRef {
return {
id: object?.id
};
},
fromSDKJSON(object: any): IdRefSDKType {
return {
id: isSet(object.id) ? Number(object.id) : 0
};
},
toSDK(message: IdRef): IdRefSDKType {
const obj: any = {};
obj.id = message.id;
return obj;
},
fromAmino(object: IdRefAmino): IdRef {
return {
id: object.id
};
},
toAmino(message: IdRef): IdRefAmino {
const obj: any = {};
obj.id = message.id;
return obj;
},
fromAminoMsg(object: IdRefAminoMsg): IdRef {
return IdRef.fromAmino(object.value);
},
fromProtoMsg(message: IdRefProtoMsg): IdRef {
return IdRef.decode(message.value);
},
toProto(message: IdRef): Uint8Array {
return IdRef.encode(message).finish();
},
toProtoMsg(message: IdRef): IdRefProtoMsg {
return {
typeUrl: "/google.api.expr.v1alpha1.IdRef",
value: IdRef.encode(message).finish()
};
}
};
10 changes: 10 additions & 0 deletions __fixtures__/misc/output/google/bundle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as _0 from "./api/expr/v1alpha1/eval";
export namespace google {
export namespace api {
export namespace expr {
export const v1alpha1 = {
..._0
};
}
}
}
Loading