// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet, GeneratedType } from "@cosmjs/proto-signing"; import { Api } from "./rest"; import { MsgUnstake } from "./types/crescent/farming/v1beta1/tx"; import { MsgCreateRatioPlan } from "./types/crescent/farming/v1beta1/tx"; import { MsgHarvest } from "./types/crescent/farming/v1beta1/tx"; import { MsgRemovePlan } from "./types/crescent/farming/v1beta1/tx"; import { MsgAdvanceEpoch } from "./types/crescent/farming/v1beta1/tx"; import { MsgCreateFixedAmountPlan } from "./types/crescent/farming/v1beta1/tx"; import { MsgStake } from "./types/crescent/farming/v1beta1/tx"; export const MsgTypes:Array<[string, GeneratedType]> = [ ["/crescent.farming.v1beta1.MsgUnstake", MsgUnstake], ["/crescent.farming.v1beta1.MsgCreateRatioPlan", MsgCreateRatioPlan], ["/crescent.farming.v1beta1.MsgHarvest", MsgHarvest], ["/crescent.farming.v1beta1.MsgRemovePlan", MsgRemovePlan], ["/crescent.farming.v1beta1.MsgAdvanceEpoch", MsgAdvanceEpoch], ["/crescent.farming.v1beta1.MsgCreateFixedAmountPlan", MsgCreateFixedAmountPlan], ["/crescent.farming.v1beta1.MsgStake", MsgStake], ]; export const MissingWalletError = new Error("wallet is required"); export const registry = new Registry(MsgTypes); const defaultFee = { amount: [], gas: "200000", }; interface TxClientOptions { addr: string } interface SignAndBroadcastOptions { fee: StdFee, memo?: string } const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = { addr: "http://localhost:26657" }) => { if (!wallet) throw MissingWalletError; let client; if (addr) { client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry }); }else{ client = await SigningStargateClient.offline( wallet, { registry }); } const { address } = (await wallet.getAccounts())[0]; return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), msgUnstake: (data: MsgUnstake): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgUnstake", value: MsgUnstake.fromPartial( data ) }), msgCreateRatioPlan: (data: MsgCreateRatioPlan): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgCreateRatioPlan", value: MsgCreateRatioPlan.fromPartial( data ) }), msgHarvest: (data: MsgHarvest): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgHarvest", value: MsgHarvest.fromPartial( data ) }), msgRemovePlan: (data: MsgRemovePlan): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgRemovePlan", value: MsgRemovePlan.fromPartial( data ) }), msgAdvanceEpoch: (data: MsgAdvanceEpoch): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgAdvanceEpoch", value: MsgAdvanceEpoch.fromPartial( data ) }), msgCreateFixedAmountPlan: (data: MsgCreateFixedAmountPlan): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgCreateFixedAmountPlan", value: MsgCreateFixedAmountPlan.fromPartial( data ) }), msgStake: (data: MsgStake): EncodeObject => ({ typeUrl: "/crescent.farming.v1beta1.MsgStake", value: MsgStake.fromPartial( data ) }), }; }; interface QueryClientOptions { addr: string } const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { return new Api({ baseUrl: addr }); }; export { txClient, queryClient, };