Skip to content

Commit

Permalink
change rpc cosmoshub
Browse files Browse the repository at this point in the history
  • Loading branch information
perfogic committed May 6, 2024
1 parent 989d0e2 commit cdbba4a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
33 changes: 15 additions & 18 deletions packages/ibc-routing/src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export const submitRouting = async (res: HttpResponse, req: HttpRequest, im: Int
async (obj: any) => {
const txHash = obj.txHash;
const chainId = obj.chainId;
let message = "Success";
let isError = false;
try {
switch (chainId) {
case ChainIdEnum.Ethereum:
Expand Down Expand Up @@ -138,27 +140,22 @@ export const submitRouting = async (res: HttpResponse, req: HttpRequest, im: Int
]);
}
} catch (err) {
res
.writeStatus("500 Internal Server Error")
.writeHeader("Content-Type", "application/json")
.end(
JSON.stringify({
message: err?.message || "Something went wrong",
data: []
})
);
isError = true;
message = err?.message || "Something went wrong";
}

if (!res.aborted) {
res
.writeStatus("200 OK")
.writeHeader("Content-Type", "application/json")
.end(
JSON.stringify({
message: "Success",
data: []
})
);
res.cork(() => {
res
.writeStatus(!isError ? "200 OK" : "500 Internal Server Error")
.writeHeader("Content-Type", "application/json")
.end(
JSON.stringify({
message,
data: []
})
);
});
}
},
(err: any) => {
Expand Down
1 change: 1 addition & 0 deletions packages/ibc-routing/src/event-handlers/cosmos.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class CosmosHandler extends EventHandler {
if (!decodedProtoMemo.destinationReceiver.includes("oraib")) {
return;
}

// create new machine so we start a new context for the transaction
const intepreter = createCosmosIntepreter(this.db);
this.im.appendIntepreter(intepreter);
Expand Down
9 changes: 8 additions & 1 deletion packages/ibc-routing/src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ export const getSendToCosmosEvent = async (txHash: string, evmChainPrefix: EvmCh
};

export const getCosmosTxEvent = async (txHash: any, chainId: string): Promise<TxEvent> => {
const chainMetadata = chainInfos.find((item) => item.chainId === chainId);
let chainMetadata = chainInfos.find((item) => item.chainId === chainId);

if (chainId === "cosmoshub-4") {
chainMetadata = {
...chainMetadata,
rpc: "https://rpc-cosmoshub.keplr.app"
};
}

if (!chainMetadata) {
throw new Error("chain id does not exist!");
Expand Down
2 changes: 1 addition & 1 deletion packages/ibc-routing/test/search-tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Testing searchTx using rpc", () => {
const queryTags: QueryTag[] = [
{
key: `send_packet.packet_sequence`,
value: `${"22866"}`
value: `${"22865"}`
},
{
key: `send_packet.packet_src_channel`,
Expand Down

0 comments on commit cdbba4a

Please sign in to comment.