Skip to content

Commit

Permalink
chore: develop -> main (#397)
Browse files Browse the repository at this point in the history
* fix: setting eth addresses to raw bytes (uint8array) via proto-gen script (#396)

* fix: adding sed to adjust for raw bytes eth addr

* chore: removing local test

* fix: test fail

* chore: remove local test script

* chore: ran proto-gen on lastest from main nibiru

* chore: ran proto-gen on latest v2.0.0-rc.21

* fix: failing tests
  • Loading branch information
CalicoNino authored Feb 4, 2025
1 parent f3e8c23 commit 0babc26
Show file tree
Hide file tree
Showing 16 changed files with 430 additions and 488 deletions.
2 changes: 1 addition & 1 deletion nibiru
Submodule nibiru updated 335 files
20 changes: 12 additions & 8 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ echo "Removing old src files"
rm -rf $PKG_OUT_DIR/
mkdir -p $PKG_OUT_DIR/

for dir in $(find $NIBIRU_REPO/proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | uniq | sort); do \
for dir in $(find $NIBIRU_REPO/proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | uniq | sort); do
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
echo "Generating ts proto code for $file"
buf generate --template $NIBIRU_REPO/proto/buf.gen.ts.yaml -o $PKG_OUT_DIR $file
done
done;
done

yarn generate-barrels
# # the `descriptor.ts` file is only used for gogoproto, and it causes issues with TS-generated code
Expand All @@ -42,9 +42,13 @@ rm $PKG_OUT_DIR/index.amino.ts
rm $PKG_OUT_DIR/index.cosmos.msg.v1.ts
rm $PKG_OUT_DIR/index.cosmos.msg.ts

sed 's/export \* as gogoproto from \"\.\/index\.gogoproto\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* as amino from \"\.\/index\.amino\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* as google from \"\.\/index\.google\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* from \"\.\/google\/api\/annotations\"\;//' $PKG_OUT_DIR/index.google.api.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.api.ts
sed 's/export \* as protobuf from \"\.\/index.google.protobuf\"\;//' $PKG_OUT_DIR/index.google.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.ts
sed 's/export \* as msg from \"\.\/index.cosmos.msg\"\;//' $PKG_OUT_DIR/index.cosmos.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.cosmos.ts
sed 's/export \* as gogoproto from \"\.\/index\.gogoproto\"\;//' $PKG_OUT_DIR/index.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* as amino from \"\.\/index\.amino\"\;//' $PKG_OUT_DIR/index.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* as google from \"\.\/index\.google\"\;//' $PKG_OUT_DIR/index.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts
sed 's/export \* from \"\.\/google\/api\/annotations\"\;//' $PKG_OUT_DIR/index.google.api.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.api.ts
sed 's/export \* as protobuf from \"\.\/index.google.protobuf\"\;//' $PKG_OUT_DIR/index.google.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.ts
sed 's/export \* as msg from \"\.\/index.cosmos.msg\"\;//' $PKG_OUT_DIR/index.cosmos.ts >tmpfile && mv tmpfile $PKG_OUT_DIR/index.cosmos.ts

# Adding custom seds to fix golang & protojs types
sed -i 's/\(\s*\)message\.erc20Addr = reader\.string();/\1\/\/ Converting raw bytes to string\n\1const bytes = reader.bytes()\n\1message.erc20Addr = "0x" + Buffer.from(bytes).toString("hex");/' "$PKG_OUT_DIR/eth/evm/v1/evm.ts"
sed -i 's/\(\s*\)writer\.uint32(10)\.string(message\.toEthAddr);/\1\/\/ Converting string to raw bytes\n\1const bytes = new Uint8Array(\n\1message.toEthAddr.match(\/.{1,2}\/g)!.map((byte) => parseInt(byte, 16))\n\1)\n\1writer.uint32(10).bytes(bytes)/' "$PKG_OUT_DIR/eth/evm/v1/tx.ts"
39 changes: 20 additions & 19 deletions src/protojs/eth/evm/v1/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Long from "long";
import _m0 from "protobufjs/minimal";
import { Coin } from "../../../cosmos/base/v1beta1/coin";
import { Log } from "./evm";

/** Copyright (c) 2023-2024 Nibi, Inc. */

Expand All @@ -19,14 +20,14 @@ export interface EventEthereumTx {
hash: string;
/** recipient of the transaction */
recipient: string;
/** eth_tx_failed contains a VM error should it occur */
ethTxFailed: string;
/** vm_error contains a VM error should it occur */
vmError: string;
}

/** EventTxLog defines the event for an Ethereum transaction log */
export interface EventTxLog {
/** tx_logs is an array of transaction logs */
txLogs: string[];
logs: Log[];
}

/** EventBlockBloom defines an Ethereum block bloom filter event */
Expand Down Expand Up @@ -71,7 +72,7 @@ export interface EventContractExecuted {
}

function createBaseEventEthereumTx(): EventEthereumTx {
return { amount: "", ethHash: "", index: "", gasUsed: "", hash: "", recipient: "", ethTxFailed: "" };
return { amount: "", ethHash: "", index: "", gasUsed: "", hash: "", recipient: "", vmError: "" };
}

export const EventEthereumTx = {
Expand All @@ -94,8 +95,8 @@ export const EventEthereumTx = {
if (message.recipient !== "") {
writer.uint32(50).string(message.recipient);
}
if (message.ethTxFailed !== "") {
writer.uint32(58).string(message.ethTxFailed);
if (message.vmError !== "") {
writer.uint32(58).string(message.vmError);
}
return writer;
},
Expand Down Expand Up @@ -154,7 +155,7 @@ export const EventEthereumTx = {
break;
}

message.ethTxFailed = reader.string();
message.vmError = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
Expand All @@ -173,7 +174,7 @@ export const EventEthereumTx = {
gasUsed: isSet(object.gasUsed) ? String(object.gasUsed) : "",
hash: isSet(object.hash) ? String(object.hash) : "",
recipient: isSet(object.recipient) ? String(object.recipient) : "",
ethTxFailed: isSet(object.ethTxFailed) ? String(object.ethTxFailed) : "",
vmError: isSet(object.vmError) ? String(object.vmError) : "",
};
},

Expand All @@ -185,7 +186,7 @@ export const EventEthereumTx = {
message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed);
message.hash !== undefined && (obj.hash = message.hash);
message.recipient !== undefined && (obj.recipient = message.recipient);
message.ethTxFailed !== undefined && (obj.ethTxFailed = message.ethTxFailed);
message.vmError !== undefined && (obj.vmError = message.vmError);
return obj;
},

Expand All @@ -201,19 +202,19 @@ export const EventEthereumTx = {
message.gasUsed = object.gasUsed ?? "";
message.hash = object.hash ?? "";
message.recipient = object.recipient ?? "";
message.ethTxFailed = object.ethTxFailed ?? "";
message.vmError = object.vmError ?? "";
return message;
},
};

function createBaseEventTxLog(): EventTxLog {
return { txLogs: [] };
return { logs: [] };
}

export const EventTxLog = {
encode(message: EventTxLog, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.txLogs) {
writer.uint32(10).string(v!);
for (const v of message.logs) {
Log.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
Expand All @@ -230,7 +231,7 @@ export const EventTxLog = {
break;
}

message.txLogs.push(reader.string());
message.logs.push(Log.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
Expand All @@ -242,15 +243,15 @@ export const EventTxLog = {
},

fromJSON(object: any): EventTxLog {
return { txLogs: Array.isArray(object?.txLogs) ? object.txLogs.map((e: any) => String(e)) : [] };
return { logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => Log.fromJSON(e)) : [] };
},

toJSON(message: EventTxLog): unknown {
const obj: any = {};
if (message.txLogs) {
obj.txLogs = message.txLogs.map((e) => e);
if (message.logs) {
obj.logs = message.logs.map((e) => e ? Log.toJSON(e) : undefined);
} else {
obj.txLogs = [];
obj.logs = [];
}
return obj;
},
Expand All @@ -261,7 +262,7 @@ export const EventTxLog = {

fromPartial<I extends Exact<DeepPartial<EventTxLog>, I>>(object: I): EventTxLog {
const message = createBaseEventTxLog();
message.txLogs = object.txLogs?.map((e) => e) || [];
message.logs = object.logs?.map((e) => Log.fromPartial(e)) || [];
return message;
},
};
Expand Down
Loading

1 comment on commit 0babc26

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 95%
95.51% (895/937) 80.66% (171/212) 89.82% (300/334)

Please sign in to comment.