Skip to content

Commit

Permalink
Prepare for v0.28.1 upgrade (#52)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Redm4x authored Nov 17, 2023
1 parent c88aa62 commit e97ad64
Show file tree
Hide file tree
Showing 27 changed files with 275 additions and 65 deletions.
14 changes: 7 additions & 7 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions api/src/proto/akash/v1beta4.ts
Original file line number Diff line number Diff line change
@@ -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";
5 changes: 4 additions & 1 deletion api/src/providers/apiNodeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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]);
Expand Down
13 changes: 8 additions & 5 deletions api/src/utils/protobuf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions deploy-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions deploy-web/package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions deploy-web/src/components/newDeploymentWizard/BidRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const BidRow: React.FunctionComponent<Props> = ({ bid, selectedBid, handl
}
};

if (!provider) return null;

return (
<CustomTableRow
key={bid.id}
Expand Down
21 changes: 21 additions & 0 deletions deploy-web/src/components/shared/TxMessages/TxMessageRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ import { MsgStartGroup as MsgStartGroup_v3 } from "./akash/v1beta3/MsgStartGroup
import { MsgUpdateDeployment as MsgUpdateDeployment_v3 } from "./akash/v1beta3/MsgUpdateDeployment";
import { MsgWithdrawLease as MsgWithdrawLease_v3 } from "./akash/v1beta3/MsgWithdrawLease";
import { MsgUpdateProvider as MsgUpdateProvider_v3 } from "./akash/v1beta3/MsgUpdateProvider";
// v1beta4
import { MsgCloseBid as MsgCloseBid_v4 } from "./akash/v1beta4/MsgCloseBid";
import { MsgCloseLease as MsgCloseLease_v4 } from "./akash/v1beta4/MsgCloseLease";
import { MsgCreateBid as MsgCreateBid_v4 } from "./akash/v1beta4/MsgCreateBid";
import { MsgCreateLease as MsgCreateLease_v4 } from "./akash/v1beta4/MsgCreateLease";
import { MsgWithdrawLease as MsgWithdrawLease_v4 } from "./akash/v1beta4/MsgWithdrawLease";

type Props = {
message: TransactionMessage;
Expand Down Expand Up @@ -329,6 +335,21 @@ const TxMessage: React.FunctionComponent<TxMessageProps> = ({ message }) => {
case "/akash.market.v1beta3.MsgWithdrawLease": // F5DC09219E604843E55C49B8B66E1DAD9EF417EF8AD8207BB696CF3863985446
return <MsgWithdrawLease_v3 message={message} />;

// *******************
// AKASH V4 TYPES
// *******************

case "/akash.market.v1beta4.MsgCloseBid":
return <MsgCloseBid_v4 message={message} />;
case "/akash.market.v1beta4.MsgCloseLease":
return <MsgCloseLease_v4 message={message} />;
case "/akash.market.v1beta4.MsgCreateBid":
return <MsgCreateBid_v4 message={message} />;
case "/akash.market.v1beta4.MsgCreateLease":
return <MsgCreateLease_v4 message={message} />;
case "/akash.market.v1beta4.MsgWithdrawLease":
return <MsgWithdrawLease_v4 message={message} />;

default:
return <DynamicReactJson src={JSON.parse(JSON.stringify(message?.data))} />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<TxMessageProps> = ({ message }) => {
return (
<>
<LabelValue label="Provider" value={<Link href={UrlService.address(message?.data?.bidId?.provider)}>{message?.data?.bidId?.provider}</Link>} />
{/* TODO: Add link to provider page */}
<LabelValue label="Owner" value={<AddressLink address={message?.data?.bidId?.owner} />} />
<LabelValue
label="dseq"
value={<Link href={UrlService.publicDeploymentDetails(message?.data?.bidId?.owner, message?.data?.bidId?.dseq)}>{message?.data?.bidId?.dseq}</Link>}
/>
<LabelValue label="gseq" value={message?.data?.bidId?.gseq} />
<LabelValue label="oseq" value={message?.data?.bidId?.oseq} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -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<TxMessageProps> = ({ message }) => {
return (
<>
<LabelValue label="Owner" value={<AddressLink address={message?.data?.leaseId?.owner} />} />
<LabelValue
label="dseq"
value={
<Link href={UrlService.publicDeploymentDetails(message?.data?.leaseId?.owner, message?.data?.leaseId?.dseq)}>{message?.data?.leaseId?.dseq}</Link>
}
/>
<LabelValue label="gseq" value={message?.data?.leaseId?.gseq} />
<LabelValue label="oseq" value={message?.data?.leaseId?.oseq} />
<LabelValue label="Provider" value={<Link href={UrlService.address(message?.data?.leaseId?.provider)}>{message?.data?.leaseId?.provider}</Link>} />
{/* TODO: Add link to provider page */}
</>
);
};
Original file line number Diff line number Diff line change
@@ -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<TxMessageProps> = ({ message }) => {
console.log(message);
return (
<>
<LabelValue label="Provider" value={<Link href={UrlService.address(message?.data?.provider)}>{message?.data?.provider}</Link>} />
{/* TODO: Add link to provider page */}
<LabelValue label="Owner" value={<AddressLink address={message?.data?.order?.owner} />} />
<LabelValue
label="dseq"
value={<Link href={UrlService.publicDeploymentDetails(message?.data?.order?.owner, message?.data?.order?.dseq)}>{message?.data?.order?.dseq}</Link>}
/>
<LabelValue label="gseq" value={message?.data?.order?.gseq} />
<LabelValue label="oseq" value={message?.data?.order?.oseq} />
<LabelValue label="Price" value={<AKTAmount uakt={coinsToAmount(message?.data?.price, "uakt")} showAKTLabel showUSD />} />
<LabelValue label="Deposit" value={<AKTAmount uakt={coinsToAmount(message?.data?.deposit, "uakt")} showAKTLabel showUSD />} />
<LabelValue label="Resources Offer" value={<DynamicReactJson src={JSON.parse(JSON.stringify(message?.data?.resourcesOffer))} />} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -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<TxMessageProps> = ({ message }) => {
return (
<>
<LabelValue label="Provider" value={<Link href={UrlService.address(message?.data?.bidId?.provider)}>{message?.data?.bidId?.provider}</Link>} />
{/* TODO: Add link to provider page */}
<LabelValue label="Owner" value={<AddressLink address={message?.data?.bidId?.owner} />} />
<LabelValue
label="dseq"
value={<Link href={UrlService.publicDeploymentDetails(message?.data?.bidId?.owner, message?.data?.bidId?.dseq)}>{message?.data?.bidId?.dseq}</Link>}
/>
<LabelValue label="gseq" value={message?.data?.bidId?.gseq} />
<LabelValue label="oseq" value={message?.data?.bidId?.oseq} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -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<TxMessageProps> = ({ message }) => {
return (
<>
<LabelValue label="Owner" value={<AddressLink address={message?.data?.bidId?.owner} />} />
<LabelValue label="Provider" value={<Link href={UrlService.address(message?.data?.bidId?.provider)}>{message?.data?.bidId?.provider}</Link>} />
<LabelValue
label="dseq"
value={<Link href={UrlService.publicDeploymentDetails(message?.data?.bidId?.owner, message?.data?.bidId?.dseq)}>{message?.data?.bidId?.dseq}</Link>}
/>
<LabelValue label="gseq" value={message?.data?.bidId?.gseq} />
<LabelValue label="oseq" value={message?.data?.bidId?.oseq} />
</>
);
};
1 change: 0 additions & 1 deletion deploy-web/src/types/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export interface RpcDeployment {
escrow_account: EscrowAccount;
}

// TODO Change after mainnet6 upgrade
type DeploymentGroup = DeploymentGroup_v2 | DeploymentGroup_v3;

interface DeploymentGroup_v2 {
Expand Down
5 changes: 3 additions & 2 deletions deploy-web/src/utils/TransactionMessageData.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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`;

Expand Down Expand Up @@ -68,6 +68,7 @@ export class TransactionMessageData {
}

static getCreateLeaseMsg(bid: BidDto) {
debugger;
const message = {
typeUrl: TransactionMessageData.Types.MSG_CREATE_LEASE,
value: {
Expand Down
6 changes: 3 additions & 3 deletions deploy-web/src/utils/apiUtils.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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`;
Expand Down
7 changes: 6 additions & 1 deletion deploy-web/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,32 @@ 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");

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;
}
Expand Down
Loading

0 comments on commit e97ad64

Please sign in to comment.