Skip to content

Commit

Permalink
feat(api): use generated code by version from akash-api
Browse files Browse the repository at this point in the history
Also remove relevant local barrel index files.

refs akash-network/support#184
  • Loading branch information
ygrishajev committed May 6, 2024
1 parent bc02691 commit 7cf4757
Show file tree
Hide file tree
Showing 15 changed files with 1,758 additions and 3,541 deletions.
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
4 changes: 2 additions & 2 deletions deploy-web/src/utils/customRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Registry } from "@cosmjs/proto-signing";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { MsgGrant, MsgRevoke, MsgGrantAllowance, MsgRevokeAllowance } from "./proto/grant";
import * as v1beta3 from "./proto/v1beta3";
import * as v1beta4 from "./proto/v1beta4";
import * as v1beta3 from "@akashnetwork/akash-api/v1beta3";
import * as v1beta4 from "@akashnetwork/akash-api/v1beta4";

export const customRegistry = new Registry();

Expand Down
10 changes: 6 additions & 4 deletions deploy-web/src/utils/proto/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as v1beta3 from "./v1beta3";
import * as v1beta4 from "./v1beta4";
import * as v1beta3 from "@akashnetwork/akash-api/v1beta3";
import * as v1beta4 from "@akashnetwork/akash-api/v1beta4";
import { mainnetId, testnetId, sandboxId } from "../constants";
import omit from "lodash/omit";

const mainnetTypes = { ...v1beta3, ...v1beta4 };
const sandboxTypes = { ...v1beta3, ...v1beta4 };
const commonTypes = { ...omit(v1beta3, "GPU"), ...v1beta4 };
const mainnetTypes = commonTypes;
const sandboxTypes = commonTypes;

export let protoTypes;

Expand Down
8 changes: 0 additions & 8 deletions deploy-web/src/utils/proto/v1beta1.ts

This file was deleted.

7 changes: 0 additions & 7 deletions deploy-web/src/utils/proto/v1beta2.ts

This file was deleted.

9 changes: 0 additions & 9 deletions deploy-web/src/utils/proto/v1beta3.ts

This file was deleted.

1 change: 0 additions & 1 deletion deploy-web/src/utils/proto/v1beta4.ts

This file was deleted.

0 comments on commit 7cf4757

Please sign in to comment.