mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Adding vesting module to stargate
This commit is contained in:
parent
9633f5807b
commit
8da37cd2e5
@ -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
|
||||
|
||||
|
@ -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";
|
||||
|
57
packages/stargate/src/modules/vesting/aminomessages.ts
Normal file
57
packages/stargate/src/modules/vesting/aminomessages.ts
Normal 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,
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
6
packages/stargate/src/modules/vesting/messages.ts
Normal file
6
packages/stargate/src/modules/vesting/messages.ts
Normal 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],
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user