Adding vesting module to stargate

This commit is contained in:
Milan Steiner 2022-04-06 10:44:55 +02:00
parent 9633f5807b
commit 8da37cd2e5
4 changed files with 70 additions and 0 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to
- @cosmjs/stargate: Added the ability to specify a custom account parser for
`StargateClient`
- @cosmjs/stargate: Added support for vesting messages.
### Fixed

View File

@ -86,3 +86,9 @@ export {
} from "./staking/messages";
export { setupStakingExtension, StakingExtension } from "./staking/queries";
export { setupTxExtension, TxExtension } from "./tx/queries";
export {
AminoMsgCreateVestingAccount,
createVestingAminoConverters,
isAminoMsgCreateVestingAccount,
} from "./vesting/aminomessages";
export { vestingTypes } from "./vesting/messages";

View File

@ -0,0 +1,57 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, Coin } from "@cosmjs/amino";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
import Long from "long";
import { AminoConverters } from "../../aminotypes";
export interface AminoMsgCreateVestingAccount extends AminoMsg {
readonly type: "cosmos-sdk/MsgCreateVestingAccount";
readonly value: {
/** Bech32 account address */
readonly from_address: string;
/** Bech32 account address */
readonly to_address: string;
readonly amount: readonly Coin[];
readonly end_time: Long;
readonly delayed: boolean;
};
}
export function isAminoMsgCreateVestingAccount(msg: AminoMsg): msg is AminoMsgCreateVestingAccount {
return msg.type === "cosmos-sdk/MsgCreateVestingAccount";
}
export function createVestingAminoConverters(): AminoConverters {
return {
"/cosmos.vesting.v1beta1.MsgCreateVestingAccount": {
aminoType: "cosmos-sdk/MsgCreateVestingAccount",
toAmino: ({
fromAddress,
toAddress,
amount,
endTime,
delayed,
}: MsgCreateVestingAccount): AminoMsgCreateVestingAccount["value"] => ({
from_address: fromAddress,
to_address: toAddress,
amount: [...amount],
end_time: endTime,
delayed: delayed,
}),
fromAmino: ({
from_address,
to_address,
amount,
end_time,
delayed,
}: AminoMsgCreateVestingAccount["value"]): MsgCreateVestingAccount => ({
fromAddress: from_address,
toAddress: to_address,
amount: [...amount],
endTime: end_time,
delayed: delayed,
}),
},
};
}

View File

@ -0,0 +1,6 @@
import { GeneratedType } from "@cosmjs/proto-signing";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
export const vestingTypes: ReadonlyArray<[string, GeneratedType]> = [
["/cosmos.vesting.v1beta1.MsgCreateVestingAccount", MsgCreateVestingAccount],
];