Update vending factory contract helpers
This commit is contained in:
parent
5cdcc66611
commit
0945bcf927
@ -1,7 +1,9 @@
|
|||||||
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||||
|
/* eslint-disable no-nested-ternary */
|
||||||
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
|
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
|
||||||
import type { Coin } from '@cosmjs/proto-signing'
|
import type { Coin } from '@cosmjs/proto-signing'
|
||||||
import type { logs } from '@cosmjs/stargate'
|
import type { logs } from '@cosmjs/stargate'
|
||||||
import { VENDING_FACTORY_ADDRESS } from 'utils/constants'
|
import { VENDING_FACTORY_ADDRESS, VENDING_FACTORY_FLEX_ADDRESS } from 'utils/constants'
|
||||||
|
|
||||||
import { VENDING_FACTORY_UPDATABLE_ADDRESS } from '../../utils/constants'
|
import { VENDING_FACTORY_UPDATABLE_ADDRESS } from '../../utils/constants'
|
||||||
|
|
||||||
@ -23,11 +25,17 @@ export interface VendingFactoryInstance {
|
|||||||
msg: Record<string, unknown>,
|
msg: Record<string, unknown>,
|
||||||
funds: Coin[],
|
funds: Coin[],
|
||||||
updatable?: boolean,
|
updatable?: boolean,
|
||||||
|
flex?: boolean,
|
||||||
) => Promise<CreateVendingMinterResponse>
|
) => Promise<CreateVendingMinterResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VendingFactoryMessages {
|
export interface VendingFactoryMessages {
|
||||||
createVendingMinter: (msg: Record<string, unknown>, funds: Coin[], updatable?: boolean) => CreateVendingMinterMessage
|
createVendingMinter: (
|
||||||
|
msg: Record<string, unknown>,
|
||||||
|
funds: Coin[],
|
||||||
|
updatable?: boolean,
|
||||||
|
flex?: boolean,
|
||||||
|
) => CreateVendingMinterMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateVendingMinterMessage {
|
export interface CreateVendingMinterMessage {
|
||||||
@ -53,10 +61,11 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
msg: Record<string, unknown>,
|
msg: Record<string, unknown>,
|
||||||
funds: Coin[],
|
funds: Coin[],
|
||||||
updatable?: boolean,
|
updatable?: boolean,
|
||||||
|
flex?: boolean,
|
||||||
): Promise<CreateVendingMinterResponse> => {
|
): Promise<CreateVendingMinterResponse> => {
|
||||||
const result = await client.execute(
|
const result = await client.execute(
|
||||||
senderAddress,
|
senderAddress,
|
||||||
updatable ? VENDING_FACTORY_UPDATABLE_ADDRESS : VENDING_FACTORY_ADDRESS,
|
flex ? VENDING_FACTORY_FLEX_ADDRESS : updatable ? VENDING_FACTORY_UPDATABLE_ADDRESS : VENDING_FACTORY_ADDRESS,
|
||||||
msg,
|
msg,
|
||||||
'auto',
|
'auto',
|
||||||
'',
|
'',
|
||||||
@ -82,6 +91,7 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
msg: Record<string, unknown>,
|
msg: Record<string, unknown>,
|
||||||
funds: Coin[],
|
funds: Coin[],
|
||||||
updatable?: boolean,
|
updatable?: boolean,
|
||||||
|
flex?: boolean,
|
||||||
): CreateVendingMinterMessage => {
|
): CreateVendingMinterMessage => {
|
||||||
return {
|
return {
|
||||||
sender: txSigner,
|
sender: txSigner,
|
||||||
|
@ -11,6 +11,7 @@ export interface DispatchExecuteArgs {
|
|||||||
msg: Record<string, unknown>
|
msg: Record<string, unknown>
|
||||||
funds: Coin[]
|
funds: Coin[]
|
||||||
updatable?: boolean
|
updatable?: boolean
|
||||||
|
flex?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||||
@ -18,12 +19,12 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
if (!messages) {
|
if (!messages) {
|
||||||
throw new Error('cannot dispatch execute, messages is not defined')
|
throw new Error('cannot dispatch execute, messages is not defined')
|
||||||
}
|
}
|
||||||
return messages.createVendingMinter(txSigner, args.msg, args.funds, args.updatable)
|
return messages.createVendingMinter(txSigner, args.msg, args.funds, args.updatable, args.flex)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages } = useVendingFactoryContract()
|
const { messages } = useVendingFactoryContract()
|
||||||
const { contract } = args
|
const { contract } = args
|
||||||
return messages(contract)?.createVendingMinter(args.msg, args.funds, args.updatable)
|
return messages(contract)?.createVendingMinter(args.msg, args.funds, args.updatable, args.flex)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user