From e97ad6487beac70cd8436cb7244067912f30ffff Mon Sep 17 00:00:00 2001 From: Maxime Cyr <2829180+Redm4x@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:43:18 -0500 Subject: [PATCH] Prepare for v0.28.1 upgrade (#52) * Add support for v1beta4 in deploy tool * Fix createLease version * Update akashjs in deploy tool * Update indexer * Prepare api for v0.28.1 upgrade * Show resource offer on MsgBidCreate * Remove old comment --- api/package-lock.json | 14 +++--- api/package.json | 2 +- api/src/proto/akash/v1beta4.ts | 2 + api/src/providers/apiNodeProvider.ts | 5 ++- api/src/utils/protobuf.ts | 13 +++--- deploy-web/package-lock.json | 4 +- deploy-web/package.json | 4 +- .../components/newDeploymentWizard/BidRow.tsx | 2 + .../shared/TxMessages/TxMessageRow.tsx | 21 +++++++++ .../TxMessages/akash/v1beta4/MsgCloseBid.tsx | 25 +++++++++++ .../akash/v1beta4/MsgCloseLease.tsx | 27 ++++++++++++ .../TxMessages/akash/v1beta4/MsgCreateBid.tsx | 32 ++++++++++++++ .../akash/v1beta4/MsgCreateLease.tsx | 25 +++++++++++ .../akash/v1beta4/MsgWithdrawLease.tsx | 24 +++++++++++ deploy-web/src/types/deployment.ts | 1 - .../src/utils/TransactionMessageData.ts | 5 ++- deploy-web/src/utils/apiUtils.ts | 6 +-- deploy-web/src/utils/constants.ts | 7 ++- deploy-web/src/utils/customRegistry.ts | 43 ++++++++++--------- deploy-web/src/utils/init.ts | 2 - deploy-web/src/utils/proto/index.ts | 11 ++++- deploy-web/src/utils/proto/v1beta4.ts | 2 + indexer/package-lock.json | 14 +++--- indexer/package.json | 2 +- indexer/src/indexers/akashStatsIndexer.ts | 32 +++++++++++++- indexer/src/proto/akash/v1beta4.ts | 2 + indexer/src/shared/utils/protobuf.ts | 13 +++--- 27 files changed, 275 insertions(+), 65 deletions(-) create mode 100644 api/src/proto/akash/v1beta4.ts create mode 100644 deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseBid.tsx create mode 100644 deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseLease.tsx create mode 100644 deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateBid.tsx create mode 100644 deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateLease.tsx create mode 100644 deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgWithdrawLease.tsx create mode 100644 deploy-web/src/utils/proto/v1beta4.ts create mode 100644 indexer/src/proto/akash/v1beta4.ts diff --git a/api/package-lock.json b/api/package-lock.json index 6a02ecaa4..8cdea1be4 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -9,7 +9,7 @@ "version": "2.8.1", "license": "Apache-2.0", "dependencies": { - "@akashnetwork/akashjs": "0.4.11", + "@akashnetwork/akashjs": "0.5.0", "@chain-registry/assets": "^0.7.1", "@cosmjs/crypto": "^0.28.11", "@cosmjs/encoding": "^0.28.11", @@ -84,9 +84,9 @@ } }, "node_modules/@akashnetwork/akashjs": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.4.11.tgz", - "integrity": "sha512-6q3Fn0pBpU1O931RPj1YdtbW3XrWeg5YQ+K+o79xa0ydrvQ7YKuNXthQETY/AvHrYXKDxWG6/wBHA93tugiQew==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.5.0.tgz", + "integrity": "sha512-PRErEdbDZHNjVSFQ+2Hc0WnZdW+h9zWJBFr/T468VDTdxUlQx/88vX+7s5Fo4T9+HkBhFDtaEj5nl7dTr38PNw==", "dependencies": { "@cosmjs/launchpad": "^0.27.0", "@cosmjs/proto-signing": "^0.28.11", @@ -16555,9 +16555,9 @@ }, "dependencies": { "@akashnetwork/akashjs": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.4.11.tgz", - "integrity": "sha512-6q3Fn0pBpU1O931RPj1YdtbW3XrWeg5YQ+K+o79xa0ydrvQ7YKuNXthQETY/AvHrYXKDxWG6/wBHA93tugiQew==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.5.0.tgz", + "integrity": "sha512-PRErEdbDZHNjVSFQ+2Hc0WnZdW+h9zWJBFr/T468VDTdxUlQx/88vX+7s5Fo4T9+HkBhFDtaEj5nl7dTr38PNw==", "requires": { "@cosmjs/launchpad": "^0.27.0", "@cosmjs/proto-signing": "^0.28.11", diff --git a/api/package.json b/api/package.json index 8ca36bed1..2d3734dc5 100644 --- a/api/package.json +++ b/api/package.json @@ -15,7 +15,7 @@ "url": "git+https://github.com/akash-network/cloudmos" }, "dependencies": { - "@akashnetwork/akashjs": "0.4.11", + "@akashnetwork/akashjs": "0.5.0", "@chain-registry/assets": "^0.7.1", "@cosmjs/crypto": "^0.28.11", "@cosmjs/encoding": "^0.28.11", diff --git a/api/src/proto/akash/v1beta4.ts b/api/src/proto/akash/v1beta4.ts new file mode 100644 index 000000000..2204c7026 --- /dev/null +++ b/api/src/proto/akash/v1beta4.ts @@ -0,0 +1,2 @@ +export { MsgCreateBid, MsgCloseBid } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/bid"; +export { MsgCreateLease, MsgWithdrawLease, MsgCloseLease } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/lease"; diff --git a/api/src/providers/apiNodeProvider.ts b/api/src/providers/apiNodeProvider.ts index f2a8389dd..fcc70e8c7 100644 --- a/api/src/providers/apiNodeProvider.ts +++ b/api/src/providers/apiNodeProvider.ts @@ -19,6 +19,7 @@ const defaultNodeUrlMapping = { const apiNodeUrl = env.RestApiNodeUrl ?? defaultNodeUrlMapping[env.Network] ?? defaultNodeUrlMapping.mainnet; const betaTypeVersion = "v1beta3"; +const betaTypeVersionMarket = env.Network === "sandbox" ? "v1beta4" : "v1beta3"; // TODO Change after v0.28.1 upgrade export async function getChainStats() { const result: { communityPool: number; inflation: number; communityTax: number; bondedTokens: number; totalSupply: number } = await cacheResponse( @@ -318,7 +319,9 @@ export async function getProposal(id: number) { export async function getDeployment(owner: string, dseq: string) { const deploymentQuery = fetch(`${apiNodeUrl}/akash/deployment/${betaTypeVersion}/deployments/info?id.owner=${owner}&id.dseq=${dseq}`); - const leasesQuery = fetch(`${apiNodeUrl}/akash/market/${betaTypeVersion}/leases/list?filters.owner=${owner}&filters.dseq=${dseq}&pagination.limit=1000`); + const leasesQuery = fetch( + `${apiNodeUrl}/akash/market/${betaTypeVersionMarket}/leases/list?filters.owner=${owner}&filters.dseq=${dseq}&pagination.limit=1000` + ); const relatedMessagesQuery = getDeploymentRelatedMessages(owner, dseq); const [deploymentResponse, leasesResponse, relatedMessages] = await Promise.all([deploymentQuery, leasesQuery, relatedMessagesQuery]); diff --git a/api/src/utils/protobuf.ts b/api/src/utils/protobuf.ts index 425c1cbdc..1dfde7ca9 100644 --- a/api/src/utils/protobuf.ts +++ b/api/src/utils/protobuf.ts @@ -5,11 +5,14 @@ import { MsgUnjail } from "cosmjs-types/cosmos/slashing/v1beta1/tx"; import * as v1beta1 from "../proto/akash/v1beta1"; import * as v1beta2 from "../proto/akash/v1beta2"; import * as v1beta3 from "../proto/akash/v1beta3"; - -const akashTypes: ReadonlyArray<[string, GeneratedType]> = [...Object.values(v1beta1), ...Object.values(v1beta2), ...Object.values(v1beta3)].map((x) => [ - "/" + x.$type, - x -]); +import * as v1beta4 from "../proto/akash/v1beta4"; + +const akashTypes: ReadonlyArray<[string, GeneratedType]> = [ + ...Object.values(v1beta1), + ...Object.values(v1beta2), + ...Object.values(v1beta3), + ...Object.values(v1beta4) +].map((x) => ["/" + x.$type, x]); const missingTypes: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail]]; export function decodeMsg(type: string, msg: Uint8Array) { diff --git a/deploy-web/package-lock.json b/deploy-web/package-lock.json index 9aed34051..5633b7903 100644 --- a/deploy-web/package-lock.json +++ b/deploy-web/package-lock.json @@ -1,12 +1,12 @@ { "name": "cloudmos-app", - "version": "1.9.4", + "version": "1.10.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cloudmos-app", - "version": "1.9.4", + "version": "1.10.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/deploy-web/package.json b/deploy-web/package.json index b17e5645e..5e8d2ab31 100644 --- a/deploy-web/package.json +++ b/deploy-web/package.json @@ -1,6 +1,6 @@ { "name": "cloudmos-app", - "version": "1.9.4", + "version": "1.10.0", "description": "Web UI to deploy on the Akash Network and view statistic about network usage.", "author": "Cloudmos", "private": true, @@ -14,7 +14,7 @@ "postinstall": "patch-package" }, "dependencies": { - "@akashnetwork/akashjs": "0.4.17", + "@akashnetwork/akashjs": "0.5.0", "@auth0/nextjs-auth0": "^3.1.0", "@cosmjs/encoding": "^0.29.5", "@cosmjs/stargate": "^0.29.5", diff --git a/deploy-web/src/components/newDeploymentWizard/BidRow.tsx b/deploy-web/src/components/newDeploymentWizard/BidRow.tsx index 2ed21152a..c57335e32 100644 --- a/deploy-web/src/components/newDeploymentWizard/BidRow.tsx +++ b/deploy-web/src/components/newDeploymentWizard/BidRow.tsx @@ -114,6 +114,8 @@ export const BidRow: React.FunctionComponent = ({ bid, selectedBid, handl } }; + if (!provider) return null; + return ( = ({ message }) => { case "/akash.market.v1beta3.MsgWithdrawLease": // F5DC09219E604843E55C49B8B66E1DAD9EF417EF8AD8207BB696CF3863985446 return ; + // ******************* + // AKASH V4 TYPES + // ******************* + + case "/akash.market.v1beta4.MsgCloseBid": + return ; + case "/akash.market.v1beta4.MsgCloseLease": + return ; + case "/akash.market.v1beta4.MsgCreateBid": + return ; + case "/akash.market.v1beta4.MsgCreateLease": + return ; + case "/akash.market.v1beta4.MsgWithdrawLease": + return ; + default: return ; } diff --git a/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseBid.tsx b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseBid.tsx new file mode 100644 index 000000000..25e2aea20 --- /dev/null +++ b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseBid.tsx @@ -0,0 +1,25 @@ +import { AddressLink } from "@src/components/shared/AddressLink"; +import { TransactionMessage } from "@src/types"; +import { UrlService } from "@src/utils/urlUtils"; +import Link from "next/link"; +import { LabelValue } from "../../../LabelValue"; + +type TxMessageProps = { + message: TransactionMessage; +}; + +export const MsgCloseBid: React.FunctionComponent = ({ message }) => { + return ( + <> + {message?.data?.bidId?.provider}} /> + {/* TODO: Add link to provider page */} + } /> + {message?.data?.bidId?.dseq}} + /> + + + + ); +}; diff --git a/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseLease.tsx b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseLease.tsx new file mode 100644 index 000000000..0c1b4a697 --- /dev/null +++ b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCloseLease.tsx @@ -0,0 +1,27 @@ +import { AddressLink } from "@src/components/shared/AddressLink"; +import { TransactionMessage } from "@src/types"; +import { UrlService } from "@src/utils/urlUtils"; +import Link from "next/link"; +import { LabelValue } from "../../../LabelValue"; + +type TxMessageProps = { + message: TransactionMessage; +}; + +export const MsgCloseLease: React.FunctionComponent = ({ message }) => { + return ( + <> + } /> + {message?.data?.leaseId?.dseq} + } + /> + + + {message?.data?.leaseId?.provider}} /> + {/* TODO: Add link to provider page */} + + ); +}; diff --git a/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateBid.tsx b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateBid.tsx new file mode 100644 index 000000000..e87e25cd5 --- /dev/null +++ b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateBid.tsx @@ -0,0 +1,32 @@ +import { AddressLink } from "@src/components/shared/AddressLink"; +import { AKTAmount } from "@src/components/shared/AKTAmount"; +import { TransactionMessage } from "@src/types"; +import { coinsToAmount } from "@src/utils/mathHelpers"; +import { UrlService } from "@src/utils/urlUtils"; +import Link from "next/link"; +import { LabelValue } from "../../../LabelValue"; +import { DynamicReactJson } from "@src/components/shared/DynamicJsonView"; + +type TxMessageProps = { + message: TransactionMessage; +}; + +export const MsgCreateBid: React.FunctionComponent = ({ message }) => { + console.log(message); + return ( + <> + {message?.data?.provider}} /> + {/* TODO: Add link to provider page */} + } /> + {message?.data?.order?.dseq}} + /> + + + } /> + } /> + } /> + + ); +}; diff --git a/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateLease.tsx b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateLease.tsx new file mode 100644 index 000000000..8923a1e47 --- /dev/null +++ b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgCreateLease.tsx @@ -0,0 +1,25 @@ +import { AddressLink } from "@src/components/shared/AddressLink"; +import { TransactionMessage } from "@src/types"; +import { UrlService } from "@src/utils/urlUtils"; +import Link from "next/link"; +import { LabelValue } from "../../../LabelValue"; + +type TxMessageProps = { + message: TransactionMessage; +}; + +export const MsgCreateLease: React.FunctionComponent = ({ message }) => { + return ( + <> + {message?.data?.bidId?.provider}} /> + {/* TODO: Add link to provider page */} + } /> + {message?.data?.bidId?.dseq}} + /> + + + + ); +}; diff --git a/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgWithdrawLease.tsx b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgWithdrawLease.tsx new file mode 100644 index 000000000..6b3633560 --- /dev/null +++ b/deploy-web/src/components/shared/TxMessages/akash/v1beta4/MsgWithdrawLease.tsx @@ -0,0 +1,24 @@ +import { AddressLink } from "@src/components/shared/AddressLink"; +import { TransactionMessage } from "@src/types"; +import { UrlService } from "@src/utils/urlUtils"; +import Link from "next/link"; +import { LabelValue } from "../../../LabelValue"; + +type TxMessageProps = { + message: TransactionMessage; +}; + +export const MsgWithdrawLease: React.FunctionComponent = ({ message }) => { + return ( + <> + } /> + {message?.data?.bidId?.provider}} /> + {message?.data?.bidId?.dseq}} + /> + + + + ); +}; diff --git a/deploy-web/src/types/deployment.ts b/deploy-web/src/types/deployment.ts index c72ad3415..24a1bd013 100644 --- a/deploy-web/src/types/deployment.ts +++ b/deploy-web/src/types/deployment.ts @@ -56,7 +56,6 @@ export interface RpcDeployment { escrow_account: EscrowAccount; } -// TODO Change after mainnet6 upgrade type DeploymentGroup = DeploymentGroup_v2 | DeploymentGroup_v3; interface DeploymentGroup_v2 { diff --git a/deploy-web/src/utils/TransactionMessageData.ts b/deploy-web/src/utils/TransactionMessageData.ts index b5f2467f5..930b5e763 100644 --- a/deploy-web/src/utils/TransactionMessageData.ts +++ b/deploy-web/src/utils/TransactionMessageData.ts @@ -1,4 +1,4 @@ -import { networkVersion } from "./constants"; +import { networkVersion, networkVersionMarket } from "./constants"; import { BidDto } from "@src/types/deployment"; import { BasicAllowance, MsgGrant, MsgGrantAllowance, MsgRevoke, MsgRevokeAllowance } from "./proto/grant"; import { longify } from "@cosmjs/stargate/build/queryclient"; @@ -10,7 +10,7 @@ export function setMessageTypes() { TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT = `/akash.deployment.${networkVersion}.MsgDepositDeployment`; TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT_AUTHZ = `/akash.deployment.${networkVersion}.DepositDeploymentAuthorization`; TransactionMessageData.Types.MSG_UPDATE_DEPLOYMENT = `/akash.deployment.${networkVersion}.MsgUpdateDeployment`; - TransactionMessageData.Types.MSG_CREATE_LEASE = `/akash.market.${networkVersion}.MsgCreateLease`; + TransactionMessageData.Types.MSG_CREATE_LEASE = `/akash.market.${networkVersionMarket}.MsgCreateLease`; TransactionMessageData.Types.MSG_REVOKE_CERTIFICATE = `/akash.cert.${networkVersion}.MsgRevokeCertificate`; TransactionMessageData.Types.MSG_CREATE_CERTIFICATE = `/akash.cert.${networkVersion}.MsgCreateCertificate`; @@ -68,6 +68,7 @@ export class TransactionMessageData { } static getCreateLeaseMsg(bid: BidDto) { + debugger; const message = { typeUrl: TransactionMessageData.Types.MSG_CREATE_LEASE, value: { diff --git a/deploy-web/src/utils/apiUtils.ts b/deploy-web/src/utils/apiUtils.ts index 1c56d44b1..e7dd4689a 100644 --- a/deploy-web/src/utils/apiUtils.ts +++ b/deploy-web/src/utils/apiUtils.ts @@ -1,4 +1,4 @@ -import { networkVersion, BASE_API_URL } from "./constants"; +import { networkVersion, BASE_API_URL, networkVersionMarket } from "./constants"; import axios from "axios"; import { appendSearchParams } from "./urlUtils"; @@ -10,10 +10,10 @@ export class ApiUrlService { return `${apiEndpoint}/akash/deployment/${networkVersion}/deployments/info?id.owner=${address}&id.dseq=${dseq}`; } static bidList(apiEndpoint: string, address: string, dseq: string) { - return `${apiEndpoint}/akash/market/${networkVersion}/bids/list?filters.owner=${address}&filters.dseq=${dseq}`; + return `${apiEndpoint}/akash/market/${networkVersionMarket}/bids/list?filters.owner=${address}&filters.dseq=${dseq}`; } static leaseList(apiEndpoint: string, address: string, dseq: string) { - return `${apiEndpoint}/akash/market/${networkVersion}/leases/list?filters.owner=${address}${dseq ? "&filters.dseq=" + dseq : ""}`; + return `${apiEndpoint}/akash/market/${networkVersionMarket}/leases/list?filters.owner=${address}${dseq ? "&filters.dseq=" + dseq : ""}`; } static providers(apiEndpoint: string) { return `${apiEndpoint}/akash/provider/${networkVersion}/providers`; diff --git a/deploy-web/src/utils/constants.ts b/deploy-web/src/utils/constants.ts index 5cb13351f..9eb520077 100644 --- a/deploy-web/src/utils/constants.ts +++ b/deploy-web/src/utils/constants.ts @@ -129,7 +129,8 @@ export let selectedNetworkId = ""; // 5AKT aka 5000000uakt export const defaultInitialDeposit = 5000000; -export let networkVersion: "v1beta2" | "v1beta3"; +export let networkVersion: "v1beta2" | "v1beta3" | "v1beta4"; +export let networkVersionMarket: "v1beta2" | "v1beta3" | "v1beta4"; export function setNetworkVersion() { const _selectedNetworkId = localStorage.getItem("selectedNetworkId"); @@ -137,19 +138,23 @@ export function setNetworkVersion() { switch (_selectedNetworkId) { case mainnetId: networkVersion = "v1beta3"; + networkVersionMarket = "v1beta3"; // TODO Change after v0.28.1 upgrade selectedNetworkId = mainnetId; break; case testnetId: networkVersion = "v1beta3"; + networkVersionMarket = "v1beta3"; selectedNetworkId = testnetId; break; case sandboxId: networkVersion = "v1beta3"; + networkVersionMarket = "v1beta4"; selectedNetworkId = sandboxId; break; default: networkVersion = "v1beta3"; + networkVersionMarket = "v1beta3"; selectedNetworkId = mainnetId; break; } diff --git a/deploy-web/src/utils/customRegistry.ts b/deploy-web/src/utils/customRegistry.ts index d01d23548..802629110 100644 --- a/deploy-web/src/utils/customRegistry.ts +++ b/deploy-web/src/utils/customRegistry.ts @@ -1,27 +1,28 @@ import { Registry } from "@cosmjs/proto-signing"; import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; -import { protoTypes } from "./proto"; -import { TransactionMessageData } from "./TransactionMessageData"; import { MsgGrant, MsgRevoke, MsgGrantAllowance, MsgRevokeAllowance } from "./proto/grant"; +import * as v1beta3 from "./proto/v1beta3"; +import * as v1beta4 from "./proto/v1beta4"; -export let customRegistry: Registry; +export const customRegistry = new Registry(); -export function registerTypes() { - const registry = new Registry(); - registry.register(TransactionMessageData.Types.MSG_CLOSE_DEPLOYMENT, protoTypes.MsgCloseDeployment); - registry.register(TransactionMessageData.Types.MSG_CREATE_DEPLOYMENT, protoTypes.MsgCreateDeployment); - registry.register(TransactionMessageData.Types.MSG_UPDATE_DEPLOYMENT, protoTypes.MsgUpdateDeployment); - registry.register(TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT, protoTypes.MsgDepositDeployment); - registry.register(TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT_AUTHZ, protoTypes.DepositDeploymentAuthorization); - registry.register(TransactionMessageData.Types.MSG_CREATE_LEASE, protoTypes.MsgCreateLease); - registry.register(TransactionMessageData.Types.MSG_REVOKE_CERTIFICATE, protoTypes.MsgRevokeCertificate); - registry.register(TransactionMessageData.Types.MSG_CREATE_CERTIFICATE, protoTypes.MsgCreateCertificate); - registry.register(TransactionMessageData.Types.MSG_UPDATE_PROVIDER, protoTypes.MsgUpdateProvider); - registry.register(TransactionMessageData.Types.MSG_GRANT, MsgGrant); - registry.register(TransactionMessageData.Types.MSG_REVOKE, MsgRevoke); - registry.register(TransactionMessageData.Types.MSG_SEND_TOKENS, MsgSend); - registry.register(TransactionMessageData.Types.MSG_GRANT_ALLOWANCE, MsgGrantAllowance); - registry.register(TransactionMessageData.Types.MSG_REVOKE_ALLOWANCE, MsgRevokeAllowance); +// Akash v1beta3 +customRegistry.register("/akash.deployment.v1beta3.MsgCloseDeployment", v1beta3.MsgCloseDeployment); +customRegistry.register("/akash.deployment.v1beta3.MsgCreateDeployment", v1beta3.MsgCreateDeployment); +customRegistry.register("/akash.deployment.v1beta3.MsgUpdateDeployment", v1beta3.MsgUpdateDeployment); +customRegistry.register("/akash.deployment.v1beta3.MsgDepositDeployment", v1beta3.MsgDepositDeployment); +customRegistry.register("/akash.deployment.v1beta3.DepositDeploymentAuthorization", v1beta3.DepositDeploymentAuthorization); +customRegistry.register("/akash.market.v1beta3.MsgCreateLease", v1beta3.MsgCreateLease); +customRegistry.register("/akash.cert.v1beta3.MsgRevokeCertificate", v1beta3.MsgRevokeCertificate); +customRegistry.register("/akash.cert.v1beta3.MsgCreateCertificate", v1beta3.MsgCreateCertificate); +customRegistry.register("/akash.provider.v1beta3.MsgUpdateProvider", v1beta3.MsgUpdateProvider); - customRegistry = registry; -} +// Akash v1beta4 +customRegistry.register("/akash.market.v1beta4.MsgCreateLease", v1beta4.MsgCreateLease); + +// Cosmos SDK +customRegistry.register("/cosmos.authz.v1beta1.MsgGrant", MsgGrant); +customRegistry.register("/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke); +customRegistry.register("/cosmos.bank.v1beta1.MsgSend", MsgSend); +customRegistry.register("/cosmos.feegrant.v1beta1.MsgGrantAllowance", MsgGrantAllowance); +customRegistry.register("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", MsgRevokeAllowance); diff --git a/deploy-web/src/utils/init.ts b/deploy-web/src/utils/init.ts index 2521d5f52..0245671db 100644 --- a/deploy-web/src/utils/init.ts +++ b/deploy-web/src/utils/init.ts @@ -1,5 +1,4 @@ import { setNetworkVersion } from "./constants"; -import { registerTypes } from "./customRegistry"; import { initDeploymentData } from "./deploymentData"; import { initProtoTypes } from "./proto"; import { setMessageTypes } from "./TransactionMessageData"; @@ -8,6 +7,5 @@ export const initAppTypes = () => { setNetworkVersion(); initProtoTypes(); setMessageTypes(); - registerTypes(); initDeploymentData(); }; diff --git a/deploy-web/src/utils/proto/index.ts b/deploy-web/src/utils/proto/index.ts index 314e59a27..227ff6bd7 100644 --- a/deploy-web/src/utils/proto/index.ts +++ b/deploy-web/src/utils/proto/index.ts @@ -1,6 +1,10 @@ import * as v1beta3 from "./v1beta3"; +import * as v1beta4 from "./v1beta4"; import { mainnetId, testnetId, sandboxId } from "../constants"; +const mainnetTypes = v1beta3; // TODO Change after v0.28.1 upgrade +const sandboxTypes = { ...v1beta3, ...v1beta4 }; + export let protoTypes; export function initProtoTypes() { @@ -9,12 +13,15 @@ export function initProtoTypes() { switch (selectedNetworkId) { case mainnetId: case testnetId: + protoTypes = mainnetTypes; + break; + case sandboxId: - protoTypes = v1beta3; + protoTypes = sandboxTypes; break; default: - protoTypes = v1beta3; + protoTypes = mainnetTypes; break; } } diff --git a/deploy-web/src/utils/proto/v1beta4.ts b/deploy-web/src/utils/proto/v1beta4.ts new file mode 100644 index 000000000..2204c7026 --- /dev/null +++ b/deploy-web/src/utils/proto/v1beta4.ts @@ -0,0 +1,2 @@ +export { MsgCreateBid, MsgCloseBid } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/bid"; +export { MsgCreateLease, MsgWithdrawLease, MsgCloseLease } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/lease"; diff --git a/indexer/package-lock.json b/indexer/package-lock.json index 87ee6efad..245ba912a 100644 --- a/indexer/package-lock.json +++ b/indexer/package-lock.json @@ -9,7 +9,7 @@ "version": "1.5.1", "license": "Apache-2.0", "dependencies": { - "@akashnetwork/akashjs": "0.4.11", + "@akashnetwork/akashjs": "0.5.0", "@cosmjs/crypto": "^0.31.1", "@cosmjs/encoding": "^0.31.1", "@cosmjs/math": "^0.31.1", @@ -68,9 +68,9 @@ } }, "node_modules/@akashnetwork/akashjs": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.4.11.tgz", - "integrity": "sha512-6q3Fn0pBpU1O931RPj1YdtbW3XrWeg5YQ+K+o79xa0ydrvQ7YKuNXthQETY/AvHrYXKDxWG6/wBHA93tugiQew==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.5.0.tgz", + "integrity": "sha512-PRErEdbDZHNjVSFQ+2Hc0WnZdW+h9zWJBFr/T468VDTdxUlQx/88vX+7s5Fo4T9+HkBhFDtaEj5nl7dTr38PNw==", "dependencies": { "@cosmjs/launchpad": "^0.27.0", "@cosmjs/proto-signing": "^0.28.11", @@ -15886,9 +15886,9 @@ }, "dependencies": { "@akashnetwork/akashjs": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.4.11.tgz", - "integrity": "sha512-6q3Fn0pBpU1O931RPj1YdtbW3XrWeg5YQ+K+o79xa0ydrvQ7YKuNXthQETY/AvHrYXKDxWG6/wBHA93tugiQew==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@akashnetwork/akashjs/-/akashjs-0.5.0.tgz", + "integrity": "sha512-PRErEdbDZHNjVSFQ+2Hc0WnZdW+h9zWJBFr/T468VDTdxUlQx/88vX+7s5Fo4T9+HkBhFDtaEj5nl7dTr38PNw==", "requires": { "@cosmjs/launchpad": "^0.27.0", "@cosmjs/proto-signing": "^0.28.11", diff --git a/indexer/package.json b/indexer/package.json index d78030292..e7b75b4af 100644 --- a/indexer/package.json +++ b/indexer/package.json @@ -19,7 +19,7 @@ }, "homepage": "https://github.com/akash-network/cloudmos", "dependencies": { - "@akashnetwork/akashjs": "0.4.11", + "@akashnetwork/akashjs": "0.5.0", "@cosmjs/crypto": "^0.31.1", "@cosmjs/encoding": "^0.31.1", "@cosmjs/math": "^0.31.1", diff --git a/indexer/src/indexers/akashStatsIndexer.ts b/indexer/src/indexers/akashStatsIndexer.ts index 0382f7d7a..015ba6b19 100644 --- a/indexer/src/indexers/akashStatsIndexer.ts +++ b/indexer/src/indexers/akashStatsIndexer.ts @@ -2,6 +2,7 @@ import * as benchmark from "../shared/utils/benchmark"; 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 uuid from "uuid"; import { uint8arrayToString } from "@src/shared/utils/protobuf"; import { accountSettle } from "@src/shared/utils/akashPaymentSettle"; @@ -106,7 +107,12 @@ export class AkashStatsIndexer extends Indexer { "/akash.provider.v1beta3.MsgUpdateProvider": this.handleUpdateProvider, "/akash.provider.v1beta3.MsgDeleteProvider": this.handleDeleteProvider, "/akash.audit.v1beta3.MsgSignProviderAttributes": this.handleSignProviderAttributes, - "/akash.audit.v1beta3.MsgDeleteProviderAttributes": this.handleDeleteSignProviderAttributes + "/akash.audit.v1beta3.MsgDeleteProviderAttributes": this.handleDeleteSignProviderAttributes, + // Akash v1beta4 types + "/akash.market.v1beta4.MsgCreateLease": this.handleCreateLease, + "/akash.market.v1beta4.MsgCloseLease": this.handleCloseLease, + "/akash.market.v1beta4.MsgCreateBid": this.handleCreateBidV4, + "/akash.market.v1beta4.MsgCloseBid": this.handleCloseBid }; } @@ -247,7 +253,12 @@ export class AkashStatsIndexer extends Indexer { "/akash.market.v1beta3.MsgCloseLease", "/akash.market.v1beta3.MsgCloseBid", "/akash.deployment.v1beta3.MsgDepositDeployment", - "/akash.market.v1beta3.MsgWithdrawLease" + "/akash.market.v1beta3.MsgWithdrawLease", + // v1beta4 + "/akash.market.v1beta4.MsgCreateLease", + "/akash.market.v1beta4.MsgCloseLease", + "/akash.market.v1beta4.MsgCloseBid", + "/akash.market.v1beta4.MsgWithdrawLease" ].includes(msg.type); } @@ -633,6 +644,23 @@ export class AkashStatsIndexer extends Indexer { msg.relatedDeploymentId = this.getDeploymentIdFromCache(decodedMessage.order.owner, decodedMessage.order.dseq.toString()); } + private async handleCreateBidV4(decodedMessage: v1beta4.MsgCreateBid, height: number, blockGroupTransaction: DbTransaction, msg: Message) { + await Bid.create( + { + owner: decodedMessage.order.owner, + dseq: decodedMessage.order.dseq.toString(), + gseq: decodedMessage.order.gseq, + oseq: decodedMessage.order.oseq, + provider: decodedMessage.provider, + price: parseFloat(decodedMessage.price.amount), + createdHeight: height + }, + { transaction: blockGroupTransaction } + ); + + msg.relatedDeploymentId = this.getDeploymentIdFromCache(decodedMessage.order.owner, decodedMessage.order.dseq.toString()); + } + private async handleCloseBid( decodedMessage: v1beta1.MsgCloseBid | v1beta2.MsgCloseBid | v1beta3.MsgCloseBid, height: number, diff --git a/indexer/src/proto/akash/v1beta4.ts b/indexer/src/proto/akash/v1beta4.ts new file mode 100644 index 000000000..2204c7026 --- /dev/null +++ b/indexer/src/proto/akash/v1beta4.ts @@ -0,0 +1,2 @@ +export { MsgCreateBid, MsgCloseBid } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/bid"; +export { MsgCreateLease, MsgWithdrawLease, MsgCloseLease } from "@akashnetwork/akashjs/build/protobuf/akash/market/v1beta4/lease"; diff --git a/indexer/src/shared/utils/protobuf.ts b/indexer/src/shared/utils/protobuf.ts index aa5dd4b98..c5b39693a 100644 --- a/indexer/src/shared/utils/protobuf.ts +++ b/indexer/src/shared/utils/protobuf.ts @@ -5,11 +5,14 @@ import { MsgUnjail } from "cosmjs-types/cosmos/slashing/v1beta1/tx"; import * as v1beta1 from "../../proto/akash/v1beta1"; import * as v1beta2 from "../../proto/akash/v1beta2"; import * as v1beta3 from "../../proto/akash/v1beta3"; - -const akashTypes: ReadonlyArray<[string, GeneratedType]> = [...Object.values(v1beta1), ...Object.values(v1beta2), ...Object.values(v1beta3)].map((x) => [ - "/" + x.$type, - x -]); +import * as v1beta4 from "../../proto/akash/v1beta4"; + +const akashTypes: ReadonlyArray<[string, GeneratedType]> = [ + ...Object.values(v1beta1), + ...Object.values(v1beta2), + ...Object.values(v1beta3), + ...Object.values(v1beta4) +].map((x) => ["/" + x.$type, x]); const missingTypes: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail]]; export function decodeMsg(type: string, msg: Uint8Array) {