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: Ensure proto defaults in JSON #133

Merged
merged 2 commits into from
Jun 26, 2024
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
2 changes: 1 addition & 1 deletion scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ for x in ${FILES}; do
--plugin="./node_modules/.bin/protoc-gen-ts_proto" \
--ts_proto_out="${OUT_DIR}" \
--proto_path="${PROTO_PATH}" \
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=messages,useDate=false,snakeToCamel=false" \
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=messages,useDate=false,snakeToCamel=false,emitDefaultValues=json-methods" \
${x}
done
24 changes: 16 additions & 8 deletions src/proto/gno/bank.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.180.0
// protoc v5.27.1
// source: gno/bank.proto

/* eslint-disable */
import Long from 'long';
import _m0 from 'protobufjs/minimal';
Expand Down Expand Up @@ -76,22 +82,24 @@ export const MsgSend = {
fromJSON(object: any): MsgSend {
return {
from_address: isSet(object.from_address)
? String(object.from_address)
? globalThis.String(object.from_address)
: '',
to_address: isSet(object.to_address)
? globalThis.String(object.to_address)
: '',
to_address: isSet(object.to_address) ? String(object.to_address) : '',
amount: isSet(object.amount) ? String(object.amount) : '',
amount: isSet(object.amount) ? globalThis.String(object.amount) : '',
};
},

toJSON(message: MsgSend): unknown {
const obj: any = {};
if (message.from_address !== '') {
if (message.from_address !== undefined) {
obj.from_address = message.from_address;
}
if (message.to_address !== '') {
if (message.to_address !== undefined) {
obj.to_address = message.to_address;
}
if (message.amount !== '') {
if (message.amount !== undefined) {
obj.amount = message.amount;
}
return obj;
Expand Down Expand Up @@ -122,8 +130,8 @@ export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
Expand Down
70 changes: 39 additions & 31 deletions src/proto/gno/vm.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.180.0
// protoc v5.27.1
// source: gno/vm.proto

/* eslint-disable */
import Long from 'long';
import _m0 from 'protobufjs/minimal';
Expand Down Expand Up @@ -43,7 +49,7 @@ export interface MsgRun {
caller: string;
/** the amount of funds to be deposited to the package, if any ("<amount><denomination>") */
send: string;
/** the package being execute */
/** the package being executed */
package?: MemPackage | undefined;
}

Expand Down Expand Up @@ -156,28 +162,30 @@ export const MsgCall = {

fromJSON(object: any): MsgCall {
return {
caller: isSet(object.caller) ? String(object.caller) : '',
send: isSet(object.send) ? String(object.send) : '',
pkg_path: isSet(object.pkg_path) ? String(object.pkg_path) : '',
func: isSet(object.func) ? String(object.func) : '',
args: Array.isArray(object?.args)
? object.args.map((e: any) => String(e))
caller: isSet(object.caller) ? globalThis.String(object.caller) : '',
send: isSet(object.send) ? globalThis.String(object.send) : '',
pkg_path: isSet(object.pkg_path)
? globalThis.String(object.pkg_path)
: '',
func: isSet(object.func) ? globalThis.String(object.func) : '',
args: globalThis.Array.isArray(object?.args)
? object.args.map((e: any) => globalThis.String(e))
: null,
};
},

toJSON(message: MsgCall): unknown {
const obj: any = {};
if (message.caller !== '') {
if (message.caller !== undefined) {
obj.caller = message.caller;
}
if (message.send !== '') {
if (message.send !== undefined) {
obj.send = message.send;
}
if (message.pkg_path !== '') {
if (message.pkg_path !== undefined) {
obj.pkg_path = message.pkg_path;
}
if (message.func !== '') {
if (message.func !== undefined) {
obj.func = message.func;
}
if (message.args?.length) {
Expand Down Expand Up @@ -263,23 +271,23 @@ export const MsgAddPackage = {

fromJSON(object: any): MsgAddPackage {
return {
creator: isSet(object.creator) ? String(object.creator) : '',
creator: isSet(object.creator) ? globalThis.String(object.creator) : '',
package: isSet(object.package)
? MemPackage.fromJSON(object.package)
: undefined,
deposit: isSet(object.deposit) ? String(object.deposit) : '',
deposit: isSet(object.deposit) ? globalThis.String(object.deposit) : '',
};
},

toJSON(message: MsgAddPackage): unknown {
const obj = createBaseMsgAddPackage();
if (message.creator !== '') {
if (message.creator !== undefined) {
obj.creator = message.creator;
}
if (message.package !== undefined) {
obj.package = MemPackage.toJSON(message.package) as MemPackage;
}
if (message.deposit !== '') {
if (message.deposit !== undefined) {
obj.deposit = message.deposit;
}
return obj;
Expand Down Expand Up @@ -365,8 +373,8 @@ export const MsgRun = {

fromJSON(object: any): MsgRun {
return {
caller: isSet(object.caller) ? String(object.caller) : '',
send: isSet(object.send) ? String(object.send) : '',
caller: isSet(object.caller) ? globalThis.String(object.caller) : '',
send: isSet(object.send) ? globalThis.String(object.send) : '',
package: isSet(object.package)
? MemPackage.fromJSON(object.package)
: undefined,
Expand All @@ -375,10 +383,10 @@ export const MsgRun = {

toJSON(message: MsgRun): unknown {
const obj: any = {};
if (message.caller !== '') {
if (message.caller !== undefined) {
obj.caller = message.caller;
}
if (message.send !== '') {
if (message.send !== undefined) {
obj.send = message.send;
}
if (message.package !== undefined) {
Expand Down Expand Up @@ -463,20 +471,20 @@ export const MemPackage = {

fromJSON(object: any): MemPackage {
return {
name: isSet(object.Name) ? String(object.Name) : '',
path: isSet(object.Path) ? String(object.Path) : '',
files: Array.isArray(object?.files)
? object.files.map((e: any) => MemFile.fromJSON(e))
name: isSet(object.Name) ? globalThis.String(object.Name) : '',
path: isSet(object.Path) ? globalThis.String(object.Path) : '',
files: globalThis.Array.isArray(object?.Files)
? object.Files.map((e: any) => MemFile.fromJSON(e))
: [],
};
},

toJSON(message: MemPackage): unknown {
const obj: any = {};
if (message.name !== '') {
if (message.name !== undefined) {
obj.Name = message.name;
}
if (message.path !== '') {
if (message.path !== undefined) {
obj.Path = message.path;
}
if (message.files?.length) {
Expand Down Expand Up @@ -550,17 +558,17 @@ export const MemFile = {

fromJSON(object: any): MemFile {
return {
name: isSet(object.Name) ? String(object.Name) : '',
body: isSet(object.Body) ? String(object.Body) : '',
name: isSet(object.Name) ? globalThis.String(object.Name) : '',
body: isSet(object.Body) ? globalThis.String(object.Body) : '',
};
},

toJSON(message: MemFile): unknown {
const obj: any = {};
if (message.name !== '') {
if (message.name !== undefined) {
obj.Name = message.name;
}
if (message.body !== '') {
if (message.body !== undefined) {
obj.Body = message.body;
}
return obj;
Expand Down Expand Up @@ -590,8 +598,8 @@ export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
Expand Down
Loading