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: use proto from cosmos-sdk directly #78

Closed
wants to merge 2 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion common/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"client/"
],
"dependencies": {
"@protobufs/cosmos": "^0.0.11",
"@protobufs/gogoproto": "^0.0.10",
"@protobufs/google": "^0.0.10",
"nx": "^14.4.3",
Expand Down
26 changes: 25 additions & 1 deletion common/types/scripts/proto-gen.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
#!/bin/bash
rm -rf temp
mkdir temp

# clone cosmos-sdk repo
COSMOS_SDK_REPO="[email protected]:KYVENetwork/cosmos-sdk.git"
COSMOS_SDK_VERSION="v0.46.13-kyve"

git -C ./temp clone -b ${COSMOS_SDK_VERSION} --single-branch ${COSMOS_SDK_REPO}

# clone chain repo
KYVE_CHAIN_REPO="[email protected]:KYVENetwork/chain.git"
KYVE_CHAIN_VERSION="v1.3.0"

git -C ./temp clone -b ${KYVE_CHAIN_VERSION} --single-branch ${KYVE_CHAIN_REPO}

# create proto dir
mkdir temp/proto

cp -r ../../node_modules/@protobufs/* temp/proto/

git -C ./temp clone --single-branch [email protected]:cosmos/cosmos-proto.git
cp -r temp/cosmos-proto/proto/cosmos_proto temp/proto/cosmos_proto

cp -r temp/cosmos-sdk/proto/amino temp/proto/amino
cp -r temp/cosmos-sdk/proto/cosmos temp/proto/cosmos
cp -r temp/cosmos-sdk/proto/tendermint temp/proto/tendermint

# clean destination folder
rm -rf ./src/client
rm -rf ./src/lcd
mkdir ./src/client
mkdir ./src/lcd

# generate TypeScript proto
PROTO_DIR="../../node_modules/@protobufs"
PROTO_DIR="temp/proto"
PROTOC_GEN_TS_PROTO_PATH="./node_modules/.bin/protoc-gen-ts_proto"
OUT_DIR="./src/client"
KYVE_PROTO='./temp/chain/proto'
Expand Down
63 changes: 63 additions & 0 deletions common/types/src/client/cosmos/app/module/v1alpha1/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-disable */
import _m0 from "protobufjs/minimal";

export const protobufPackage = "cosmos.app.module.v1alpha1";

/** Module is the module config object for the cosmos.app v1 app module. */
export interface Module {
}

function createBaseModule(): Module {
return {};
}

export const Module = {
encode(_: Module, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): Module {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseModule();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},

fromJSON(_: any): Module {
return {};
},

toJSON(_: Module): unknown {
const obj: any = {};
return obj;
},

create<I extends Exact<DeepPartial<Module>, I>>(base?: I): Module {
return Module.fromPartial(base ?? {});
},

fromPartial<I extends Exact<DeepPartial<Module>, I>>(_: I): Module {
const message = createBaseModule();
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
60 changes: 42 additions & 18 deletions common/types/src/client/cosmos/app/v1alpha1/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface ModuleConfig {
* config is the config object for the module. Module config messages should
* define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension.
*/
config?: Any;
config?: Any | undefined;
}

function createBaseConfig(): Config {
Expand All @@ -53,19 +53,24 @@ export const Config = {
},

decode(input: _m0.Reader | Uint8Array, length?: number): Config {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseConfig();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}

message.modules.push(ModuleConfig.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand All @@ -76,14 +81,16 @@ export const Config = {

toJSON(message: Config): unknown {
const obj: any = {};
if (message.modules) {
obj.modules = message.modules.map((e) => e ? ModuleConfig.toJSON(e) : undefined);
} else {
obj.modules = [];
if (message.modules?.length) {
obj.modules = message.modules.map((e) => ModuleConfig.toJSON(e));
}
return obj;
},

create<I extends Exact<DeepPartial<Config>, I>>(base?: I): Config {
return Config.fromPartial(base ?? {});
},

fromPartial<I extends Exact<DeepPartial<Config>, I>>(object: I): Config {
const message = createBaseConfig();
message.modules = object.modules?.map((e) => ModuleConfig.fromPartial(e)) || [];
Expand All @@ -107,22 +114,31 @@ export const ModuleConfig = {
},

decode(input: _m0.Reader | Uint8Array, length?: number): ModuleConfig {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseModuleConfig();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}

message.name = reader.string();
break;
continue;
case 2:
if (tag !== 18) {
break;
}

message.config = Any.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand All @@ -136,11 +152,19 @@ export const ModuleConfig = {

toJSON(message: ModuleConfig): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.config !== undefined && (obj.config = message.config ? Any.toJSON(message.config) : undefined);
if (message.name !== "") {
obj.name = message.name;
}
if (message.config !== undefined) {
obj.config = Any.toJSON(message.config);
}
return obj;
},

create<I extends Exact<DeepPartial<ModuleConfig>, I>>(base?: I): ModuleConfig {
return ModuleConfig.fromPartial(base ?? {});
},

fromPartial<I extends Exact<DeepPartial<ModuleConfig>, I>>(object: I): ModuleConfig {
const message = createBaseModuleConfig();
message.name = object.name ?? "";
Expand Down
Loading
Loading