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

feat(api): use generated code by version from akash-api #182

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5,209 changes: 1,737 additions & 3,472 deletions api/package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"url": "git+https://github.com/akash-network/cloudmos"
},
"dependencies": {
"@akashnetwork/akash-api": "^1.0.3",
"@akashnetwork/akashjs": "^0.6.1",
"@akashnetwork/akash-api": "^1.3.0",
"@chain-registry/assets": "^0.7.1",
"@cosmjs/crypto": "^0.28.11",
"@cosmjs/encoding": "^0.28.11",
Expand Down
8 changes: 0 additions & 8 deletions api/src/proto/akash/v1beta1.ts

This file was deleted.

7 changes: 0 additions & 7 deletions api/src/proto/akash/v1beta2.ts

This file was deleted.

9 changes: 0 additions & 9 deletions api/src/proto/akash/v1beta3.ts

This file was deleted.

1 change: 0 additions & 1 deletion api/src/proto/akash/v1beta4.ts

This file was deleted.

2 changes: 1 addition & 1 deletion api/src/routes/internal/gpuPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AkashMessage, Deployment, DeploymentGroup, DeploymentGroupResource } fr
import { Day, Transaction } from "@shared/dbSchemas/base";
import { cacheResponse } from "@src/caching/helpers";
import { chainDb } from "@src/db/dbConnection";
import { MsgCreateBid } from "@src/proto/akash/v1beta4";
import { MsgCreateBid } from "@akashnetwork/akash-api/akash/market/v1beta4";
import { toUTC } from "@src/utils";
import { averageBlockCountInAMonth, averageBlockCountInAnHour } from "@src/utils/constants";
import { env } from "@src/utils/env";
Expand Down
8 changes: 4 additions & 4 deletions api/src/services/db/deploymentService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as v1 from "@src/proto/akash/v1beta1";
import * as v2 from "@src/proto/akash/v1beta2";
import * as v1beta1 from "@akashnetwork/akash-api/deprecated/akash/market/v1beta1";
import * as v2beta2 from "@akashnetwork/akash-api/akash/market/v1beta2";
import { decodeMsg } from "@src/utils/protobuf";
import { Transaction } from "@shared/dbSchemas/base";
import { Deployment, Lease } from "@shared/dbSchemas/akash";
Expand Down Expand Up @@ -41,13 +41,13 @@ export async function getDeploymentRelatedMessages(owner: string, dseq: string)
const createBidMsgs = relatedMessages
.filter((msg) => msg.type.endsWith("MsgCreateBid"))
.map((msg) => ({
decoded: decodeMsg(msg.type, msg.data) as v1.MsgCreateBid | v2.MsgCreateBid,
decoded: decodeMsg(msg.type, msg.data) as v1beta1.MsgCreateBid | v2beta2.MsgCreateBid,
msg: msg
}));

const createLeaseMsgs = relatedMessages
.filter((x) => x.type.endsWith("MsgCreateLease"))
.map((msg) => decodeMsg(msg.type, msg.data) as v1.MsgCreateLease | v2.MsgCreateLease);
.map((msg) => decodeMsg(msg.type, msg.data) as v1beta1.MsgCreateLease | v2beta2.MsgCreateLease);

const acceptedBids = createBidMsgs.filter((createBidMsg) =>
createLeaseMsgs.some(
Expand Down
13 changes: 7 additions & 6 deletions api/src/utils/protobuf.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Registry, isTsProtoGeneratedType, GeneratedType } from "@cosmjs/proto-signing";
import { defaultRegistryTypes } from "@cosmjs/stargate";
import { MsgUnjail } from "cosmjs-types/cosmos/slashing/v1beta1/tx";
import omit from "lodash/omit";

import * as v1beta1 from "../proto/akash/v1beta1";
import * as v1beta2 from "../proto/akash/v1beta2";
import * as v1beta3 from "../proto/akash/v1beta3";
import * as v1beta4 from "../proto/akash/v1beta4";
import * as v1beta1 from "@akashnetwork/akash-api/v1beta1";
import * as v1beta2 from "@akashnetwork/akash-api/v1beta2";
import * as v1beta3 from "@akashnetwork/akash-api/v1beta3";
import * as v1beta4 from "@akashnetwork/akash-api/v1beta4";

const akashTypes: ReadonlyArray<[string, GeneratedType]> = [
...Object.values(v1beta1),
...Object.values(v1beta2),
...Object.values(v1beta3),
...Object.values(omit(v1beta2, "Storage")),
...Object.values(omit(v1beta3, ["DepositDeploymentAuthorization", "GPU"])),
...Object.values(v1beta4)
].map((x) => ["/" + x.$type, x]);
const missingTypes: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail]];
Expand Down
Loading
Loading