diff --git a/deploy-web/src/queries/useGrantsQuery.ts b/deploy-web/src/queries/useGrantsQuery.ts index f8ba606ad..6f0d079d6 100644 --- a/deploy-web/src/queries/useGrantsQuery.ts +++ b/deploy-web/src/queries/useGrantsQuery.ts @@ -29,7 +29,9 @@ async function getGranteeGrants(apiEndpoint: string, address: string) { const response = await axios.get(ApiUrlService.granteeGrants(apiEndpoint, address)); const filteredGrants = response.data.grants.filter( x => - x.authorization["@type"] === "/akash.deployment.v1beta2.DepositDeploymentAuthorization" || + // TODO: this is not working + // Only the v1beta3 authorization are working + // x.authorization["@type"] === "/akash.deployment.v1beta2.DepositDeploymentAuthorization" || x.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization" ); @@ -78,4 +80,4 @@ export function useAllowancesGranted(address: string, options = {}) { const { settings } = useSettings(); return useQuery(QueryKeys.getAllowancesGranted(address), () => getAllowancesGranted(settings.apiEndpoint, address), options); -} \ No newline at end of file +} diff --git a/deploy-web/src/utils/TransactionMessageData.ts b/deploy-web/src/utils/TransactionMessageData.ts index dfd1889cd..b5f2467f5 100644 --- a/deploy-web/src/utils/TransactionMessageData.ts +++ b/deploy-web/src/utils/TransactionMessageData.ts @@ -1,7 +1,8 @@ import { networkVersion } from "./constants"; import { BidDto } from "@src/types/deployment"; -import { BasicAllowance, MsgGrantAllowance, MsgRevokeAllowance } from "./proto/grant"; +import { BasicAllowance, MsgGrant, MsgGrantAllowance, MsgRevoke, MsgRevokeAllowance } from "./proto/grant"; import { longify } from "@cosmjs/stargate/build/queryclient"; +import { protoTypes } from "./proto"; export function setMessageTypes() { TransactionMessageData.Types.MSG_CLOSE_DEPLOYMENT = `/akash.deployment.${networkVersion}.MsgCloseDeployment`; @@ -162,20 +163,22 @@ export class TransactionMessageData { } static getGrantMsg(granter: string, grantee: string, spendLimit: number, expiration: Date, denom: string) { - const message = { + const grantMsg = { typeUrl: TransactionMessageData.Types.MSG_GRANT, value: { granter: granter, grantee: grantee, grant: { authorization: { - type_url: TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT_AUTHZ, - value: { - spend_limit: { - denom: denom, - amount: spendLimit.toString() - } - } + typeUrl: TransactionMessageData.Types.MSG_DEPOSIT_DEPLOYMENT_AUTHZ, + value: protoTypes.DepositDeploymentAuthorization.encode( + protoTypes.DepositDeploymentAuthorization.fromPartial({ + spendLimit: { + denom: denom, + amount: spendLimit.toString() + } + }) + ).finish() }, expiration: { seconds: Math.floor(expiration.getTime() / 1_000), // Convert milliseconds to seconds @@ -185,7 +188,7 @@ export class TransactionMessageData { } }; - return message; + return grantMsg; } static getRevokeMsg(granter: string, grantee: string, grantType: string) { @@ -194,11 +197,11 @@ export class TransactionMessageData { const message = { typeUrl: TransactionMessageData.Types.MSG_REVOKE, - value: { + value: MsgRevoke.fromPartial({ granter: granter, grantee: grantee, msgTypeUrl: msgTypeUrl - } + }) }; return message; diff --git a/deploy-web/src/utils/customRegistry.ts b/deploy-web/src/utils/customRegistry.ts index af160053f..d01d23548 100644 --- a/deploy-web/src/utils/customRegistry.ts +++ b/deploy-web/src/utils/customRegistry.ts @@ -1,9 +1,8 @@ import { Registry } from "@cosmjs/proto-signing"; import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; -import { MsgRevoke } from "cosmjs-types/cosmos/authz/v1beta1/tx"; import { protoTypes } from "./proto"; import { TransactionMessageData } from "./TransactionMessageData"; -import { MsgGrant, MsgGrantAllowance, MsgRevokeAllowance } from "./proto/grant"; +import { MsgGrant, MsgRevoke, MsgGrantAllowance, MsgRevokeAllowance } from "./proto/grant"; export let customRegistry: Registry; diff --git a/deploy-web/src/utils/proto/grant.ts b/deploy-web/src/utils/proto/grant.ts index 02b024769..f5424a577 100644 --- a/deploy-web/src/utils/proto/grant.ts +++ b/deploy-web/src/utils/proto/grant.ts @@ -1,27 +1,3 @@ -import { Field, Type } from "protobufjs"; export { MsgGrantAllowance, MsgRevokeAllowance } from "cosmjs-types/cosmos/feegrant/v1beta1/tx"; export { BasicAllowance, PeriodicAllowance, AllowedMsgAllowance } from "cosmjs-types/cosmos/feegrant/v1beta1/feegrant"; - -// TODO: Find a solution to the MsgGrant proto type not working from cosmjs-types - -const Coin = new Type("Coin").add(new Field("denom", 1, "string")).add(new Field("amount", 2, "string")); - -const Authorization = new Type("Authorization").add(Coin).add(new Field("spend_limit", 1, "Coin")); - -const AnyGrantDeposit = new Type("AnyGrantDeposit") - .add(new Field("type_url", 1, "string")) - .add(new Field("value", 2, "Authorization")) - .add(Authorization); - -const Timestamp = new Type("Timestamp").add(new Field("seconds", 1, "uint64")).add(new Field("nanos", 2, "uint32")); -const Grant = new Type("Grant") - .add(new Field("authorization", 1, "AnyGrantDeposit")) - .add(AnyGrantDeposit) - .add(new Field("expiration", 2, "Timestamp")) - .add(Timestamp); - -export const MsgGrant = new Type("MsgGrant") - .add(new Field("granter", 1, "string")) - .add(new Field("grantee", 2, "string")) - .add(new Field("grant", 3, "Grant")) - .add(Grant); +export { MsgGrant, MsgRevoke } from "cosmjs-types/cosmos/authz/v1beta1/tx";