Skip to content

Commit

Permalink
Update wasmd protobufs and fix contract grant authz decoding (#1439)
Browse files Browse the repository at this point in the history
* Updated wasm protobufs.

* Fixed contract grant authz decoding.
  • Loading branch information
NoahSaso authored Nov 1, 2023
1 parent bbd4d37 commit e28e739
Show file tree
Hide file tree
Showing 15 changed files with 4,399 additions and 889 deletions.
51 changes: 44 additions & 7 deletions packages/protobuf/codegen/cosmos/authz/v1beta1/authz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Any, AnyProtoMsg, AnyAmino, AnySDKType } from "../../../google/protobuf
import { Timestamp } from "../../../google/protobuf/timestamp";
import { SendAuthorization, SendAuthorizationProtoMsg, SendAuthorizationSDKType } from "../../bank/v1beta1/authz";
import { StakeAuthorization, StakeAuthorizationProtoMsg, StakeAuthorizationSDKType } from "../../staking/v1beta1/authz";
import { StoreCodeAuthorization, StoreCodeAuthorizationProtoMsg, StoreCodeAuthorizationSDKType, ContractExecutionAuthorization, ContractExecutionAuthorizationProtoMsg, ContractExecutionAuthorizationSDKType, ContractMigrationAuthorization, ContractMigrationAuthorizationProtoMsg, ContractMigrationAuthorizationSDKType } from "../../../cosmwasm/wasm/v1/authz";
import { TransferAuthorization, TransferAuthorizationProtoMsg, TransferAuthorizationSDKType } from "../../../ibc/applications/transfer/v1/authz";
import { BinaryReader, BinaryWriter } from "../../../binary";
import { toTimestamp, fromTimestamp } from "../../../helpers";
Expand Down Expand Up @@ -44,7 +45,7 @@ export interface GenericAuthorizationSDKType {
* the provide method with expiration time.
*/
export interface Grant {
authorization: (GenericAuthorization & SendAuthorization & StakeAuthorization & TransferAuthorization & Any) | undefined;
authorization: (GenericAuthorization & SendAuthorization & StakeAuthorization & StoreCodeAuthorization & ContractExecutionAuthorization & ContractMigrationAuthorization & TransferAuthorization & Any) | undefined;
/**
* time when the grant will expire and will be pruned. If null, then the grant
* doesn't have a time expiration (other conditions in `authorization`
Expand All @@ -57,7 +58,7 @@ export interface GrantProtoMsg {
value: Uint8Array;
}
export type GrantEncoded = Omit<Grant, "authorization"> & {
authorization?: GenericAuthorizationProtoMsg | SendAuthorizationProtoMsg | StakeAuthorizationProtoMsg | TransferAuthorizationProtoMsg | AnyProtoMsg | undefined;
authorization?: GenericAuthorizationProtoMsg | SendAuthorizationProtoMsg | StakeAuthorizationProtoMsg | StoreCodeAuthorizationProtoMsg | ContractExecutionAuthorizationProtoMsg | ContractMigrationAuthorizationProtoMsg | TransferAuthorizationProtoMsg | AnyProtoMsg | undefined;
};
/**
* Grant gives permissions to execute
Expand All @@ -81,7 +82,7 @@ export interface GrantAminoMsg {
* the provide method with expiration time.
*/
export interface GrantSDKType {
authorization: GenericAuthorizationSDKType | SendAuthorizationSDKType | StakeAuthorizationSDKType | TransferAuthorizationSDKType | AnySDKType | undefined;
authorization: GenericAuthorizationSDKType | SendAuthorizationSDKType | StakeAuthorizationSDKType | StoreCodeAuthorizationSDKType | ContractExecutionAuthorizationSDKType | ContractMigrationAuthorizationSDKType | TransferAuthorizationSDKType | AnySDKType | undefined;
expiration?: Date | undefined;
}
/**
Expand All @@ -91,15 +92,15 @@ export interface GrantSDKType {
export interface GrantAuthorization {
granter: string;
grantee: string;
authorization: (GenericAuthorization & SendAuthorization & StakeAuthorization & TransferAuthorization & Any) | undefined;
authorization: (GenericAuthorization & SendAuthorization & StakeAuthorization & StoreCodeAuthorization & ContractExecutionAuthorization & ContractMigrationAuthorization & TransferAuthorization & Any) | undefined;
expiration: Date | undefined;
}
export interface GrantAuthorizationProtoMsg {
typeUrl: "/cosmos.authz.v1beta1.GrantAuthorization";
value: Uint8Array;
}
export type GrantAuthorizationEncoded = Omit<GrantAuthorization, "authorization"> & {
authorization?: GenericAuthorizationProtoMsg | SendAuthorizationProtoMsg | StakeAuthorizationProtoMsg | TransferAuthorizationProtoMsg | AnyProtoMsg | undefined;
authorization?: GenericAuthorizationProtoMsg | SendAuthorizationProtoMsg | StakeAuthorizationProtoMsg | StoreCodeAuthorizationProtoMsg | ContractExecutionAuthorizationProtoMsg | ContractMigrationAuthorizationProtoMsg | TransferAuthorizationProtoMsg | AnyProtoMsg | undefined;
};
/**
* GrantAuthorization extends a grant with both the addresses of the grantee and granter.
Expand All @@ -122,7 +123,7 @@ export interface GrantAuthorizationAminoMsg {
export interface GrantAuthorizationSDKType {
granter: string;
grantee: string;
authorization: GenericAuthorizationSDKType | SendAuthorizationSDKType | StakeAuthorizationSDKType | TransferAuthorizationSDKType | AnySDKType | undefined;
authorization: GenericAuthorizationSDKType | SendAuthorizationSDKType | StakeAuthorizationSDKType | StoreCodeAuthorizationSDKType | ContractExecutionAuthorizationSDKType | ContractMigrationAuthorizationSDKType | TransferAuthorizationSDKType | AnySDKType | undefined;
expiration: Date | undefined;
}
/** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */
Expand Down Expand Up @@ -460,7 +461,7 @@ export const GrantQueueItem = {
};
}
};
export const Cosmos_authzv1beta1Authorization_InterfaceDecoder = (input: BinaryReader | Uint8Array): GenericAuthorization | SendAuthorization | StakeAuthorization | TransferAuthorization | Any => {
export const Cosmos_authzv1beta1Authorization_InterfaceDecoder = (input: BinaryReader | Uint8Array): GenericAuthorization | SendAuthorization | StakeAuthorization | StoreCodeAuthorization | ContractExecutionAuthorization | ContractMigrationAuthorization | TransferAuthorization | Any => {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const data = Any.decode(reader, reader.uint32());
switch (data.typeUrl) {
Expand All @@ -470,6 +471,12 @@ export const Cosmos_authzv1beta1Authorization_InterfaceDecoder = (input: BinaryR
return SendAuthorization.decode(data.value);
case "/cosmos.staking.v1beta1.StakeAuthorization":
return StakeAuthorization.decode(data.value);
case "/cosmwasm.wasm.v1.StoreCodeAuthorization":
return StoreCodeAuthorization.decode(data.value);
case "/cosmwasm.wasm.v1.ContractExecutionAuthorization":
return ContractExecutionAuthorization.decode(data.value);
case "/cosmwasm.wasm.v1.ContractMigrationAuthorization":
return ContractMigrationAuthorization.decode(data.value);
case "/ibc.applications.transfer.v1.TransferAuthorization":
return TransferAuthorization.decode(data.value);
default:
Expand All @@ -493,6 +500,21 @@ export const Cosmos_authzv1beta1Authorization_FromAmino = (content: AnyAmino) =>
typeUrl: "/cosmos.staking.v1beta1.StakeAuthorization",
value: StakeAuthorization.encode(StakeAuthorization.fromPartial(StakeAuthorization.fromAmino(content.value))).finish()
});
case "wasm/StoreCodeAuthorization":
return Any.fromPartial({
typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
value: StoreCodeAuthorization.encode(StoreCodeAuthorization.fromPartial(StoreCodeAuthorization.fromAmino(content.value))).finish()
});
case "wasm/ContractExecutionAuthorization":
return Any.fromPartial({
typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
value: ContractExecutionAuthorization.encode(ContractExecutionAuthorization.fromPartial(ContractExecutionAuthorization.fromAmino(content.value))).finish()
});
case "wasm/ContractMigrationAuthorization":
return Any.fromPartial({
typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
value: ContractMigrationAuthorization.encode(ContractMigrationAuthorization.fromPartial(ContractMigrationAuthorization.fromAmino(content.value))).finish()
});
case "cosmos-sdk/TransferAuthorization":
return Any.fromPartial({
typeUrl: "/ibc.applications.transfer.v1.TransferAuthorization",
Expand All @@ -519,6 +541,21 @@ export const Cosmos_authzv1beta1Authorization_ToAmino = (content: Any) => {
type: "cosmos-sdk/StakeAuthorization",
value: StakeAuthorization.toAmino(StakeAuthorization.decode(content.value))
};
case "/cosmwasm.wasm.v1.StoreCodeAuthorization":
return {
type: "wasm/StoreCodeAuthorization",
value: StoreCodeAuthorization.toAmino(StoreCodeAuthorization.decode(content.value))
};
case "/cosmwasm.wasm.v1.ContractExecutionAuthorization":
return {
type: "wasm/ContractExecutionAuthorization",
value: ContractExecutionAuthorization.toAmino(ContractExecutionAuthorization.decode(content.value))
};
case "/cosmwasm.wasm.v1.ContractMigrationAuthorization":
return {
type: "wasm/ContractMigrationAuthorization",
value: ContractMigrationAuthorization.toAmino(ContractMigrationAuthorization.decode(content.value))
};
case "/ibc.applications.transfer.v1.TransferAuthorization":
return {
type: "cosmos-sdk/TransferAuthorization",
Expand Down
Loading

2 comments on commit e28e739

@vercel
Copy link

@vercel vercel bot commented on e28e739 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e28e739 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.