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

Update protobuf to latest version #108

Merged
merged 2 commits into from
Nov 11, 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
46 changes: 34 additions & 12 deletions libs/proto-messages/gen/sedachain/pubkey/v1/pubkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@

/* eslint-disable */
import _m0 from "protobufjs/minimal";
import { Any } from "../../../google/protobuf/any";

/** IndexPubKeyPair defines an index - public key pair. */
export interface IndexedPubKey {
index: number;
pubKey: Any | undefined;
pubKey: Uint8Array;
}

function createBaseIndexedPubKey(): IndexedPubKey {
return { index: 0, pubKey: undefined };
return { index: 0, pubKey: new Uint8Array(0) };
}

export const IndexedPubKey = {
encode(message: IndexedPubKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.index !== 0) {
writer.uint32(8).uint32(message.index);
}
if (message.pubKey !== undefined) {
Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim();
if (message.pubKey.length !== 0) {
writer.uint32(18).bytes(message.pubKey);
}
return writer;
},
Expand All @@ -48,7 +47,7 @@ export const IndexedPubKey = {
break;
}

message.pubKey = Any.decode(reader, reader.uint32());
message.pubKey = reader.bytes();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
Expand All @@ -62,7 +61,7 @@ export const IndexedPubKey = {
fromJSON(object: any): IndexedPubKey {
return {
index: isSet(object.index) ? globalThis.Number(object.index) : 0,
pubKey: isSet(object.pubKey) ? Any.fromJSON(object.pubKey) : undefined,
pubKey: isSet(object.pubKey) ? bytesFromBase64(object.pubKey) : new Uint8Array(0),
};
},

Expand All @@ -71,8 +70,8 @@ export const IndexedPubKey = {
if (message.index !== 0) {
obj.index = Math.round(message.index);
}
if (message.pubKey !== undefined) {
obj.pubKey = Any.toJSON(message.pubKey);
if (message.pubKey.length !== 0) {
obj.pubKey = base64FromBytes(message.pubKey);
}
return obj;
},
Expand All @@ -83,13 +82,36 @@ export const IndexedPubKey = {
fromPartial(object: DeepPartial<IndexedPubKey>): IndexedPubKey {
const message = createBaseIndexedPubKey();
message.index = object.index ?? 0;
message.pubKey = (object.pubKey !== undefined && object.pubKey !== null)
? Any.fromPartial(object.pubKey)
: undefined;
message.pubKey = object.pubKey ?? new Uint8Array(0);
return message;
},
};

function bytesFromBase64(b64: string): Uint8Array {
if ((globalThis as any).Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
} else {
const bin = globalThis.atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
}
return arr;
}
}

function base64FromBytes(arr: Uint8Array): string {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
arr.forEach((byte) => {
bin.push(globalThis.String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(""));
}
}

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

type DeepPartial<T> = T extends Builtin ? T
Expand Down
2 changes: 1 addition & 1 deletion libs/proto-messages/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@seda-protocol/proto-messages",
"type": "module",
"version": "0.4.0-dev.1",
"version": "0.4.0-dev.2",
"scripts": {
"build": "bunx buf generate",
"prepublish": "bun run build"
Expand Down
20 changes: 10 additions & 10 deletions libs/proto-messages/proto/sedachain/batching/v1/batching.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ message Params {
// DataResult represents the result of a resolved data request.
message DataResult {
// id is the Keccack-256 hash of the data result.
string id = 1;
string id = 1 [ (gogoproto.jsontag) = "id" ];
// dr_id is the data request identifier.
string dr_id = 2;
string dr_id = 2 [ (gogoproto.jsontag) = "dr_id" ];
// version is a semantic version string.
string version = 3;
string version = 3 [ (gogoproto.jsontag) = "version" ];
// block_height is the height at which the data request was tallied.
uint64 block_height = 4;
uint64 block_height = 4 [ (gogoproto.jsontag) = "block_height" ];
// exit_code is the exit code of the tally wasm binary execution.
uint32 exit_code = 5;
uint32 exit_code = 5 [ (gogoproto.jsontag) = "exit_code" ];
// gas_used is the gas used by the data request execution.
uint64 gas_used = 6;
uint64 gas_used = 6 [ (gogoproto.jsontag) = "gas_used" ];
// result is the result of the tally wasm binary execution.
bytes result = 7;
bytes result = 7 [ (gogoproto.jsontag) = "result" ];
// payback_address is the payback address set by the relayer.
string payback_address = 8;
string payback_address = 8 [ (gogoproto.jsontag) = "payback_address" ];
// seda_payload is the payload set by SEDA Protocol (e.g. OEV-enabled
// data requests)
string seda_payload = 9;
string seda_payload = 9 [ (gogoproto.jsontag) = "seda_payload" ];
// consensus indicates whether consensus was reached in the tally
// process.
bool consensus = 10;
bool consensus = 10 [ (gogoproto.jsontag) = "consensus" ];
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ message QueryDataResultRequest { string data_request_id = 1; }

// The response message for QueryDataResult RPC.
message QueryDataResultResponse {
DataResult data_result = 1 [ (gogoproto.nullable) = false ];
DataResult data_result = 1 [ (gogoproto.nullable) = true ];
}

// The request message for QueryBatchAssignment RPC.
Expand Down
3 changes: 1 addition & 2 deletions libs/proto-messages/proto/sedachain/pubkey/v1/pubkey.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// IndexPubKeyPair defines an index - public key pair.
message IndexedPubKey {
uint32 index = 1;
google.protobuf.Any pub_key = 2
bytes pub_key = 2
[ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"fmt": "bunx biome check --write .",
"test": "nx run-many --all --target=test",
"docs": "bun run tools/typedoc/generate.ts",
"cli:generate": "cd libs/cli/proto && npx buf generate"
"proto:generate": "cd libs/proto-messages/proto && npx buf generate"
},
"private": true,
"type": "module",
Expand Down
Loading