stargaze-studio/contracts/baseFactory/messages/execute.ts

30 lines
957 B
TypeScript
Raw Normal View History

import type { Coin } from '@cosmjs/proto-signing'
import type { BaseFactoryInstance } from '../index'
import { useBaseFactoryContract } from '../index'
/** @see {@link VendingFactoryInstance} */
export interface DispatchExecuteArgs {
contract: string
messages?: BaseFactoryInstance
txSigner: string
msg: Record<string, unknown>
funds: Coin[]
2023-02-26 10:08:03 +00:00
updatable?: boolean
}
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
const { messages, txSigner } = args
if (!messages) {
throw new Error('cannot dispatch execute, messages is not defined')
}
2023-02-26 10:08:03 +00:00
return messages.createBaseMinter(txSigner, args.msg, args.funds, args.updatable)
}
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { messages } = useBaseFactoryContract()
const { contract } = args
return messages(contract)?.createBaseMinter(args.msg, args.funds, args.updatable)
}