add update and remove discount price
This commit is contained in:
parent
2340657020
commit
fae92e5483
@ -43,6 +43,8 @@ export interface MinterInstance {
|
||||
shuffle: (senderAddress: string) => Promise<string>
|
||||
withdraw: (senderAddress: string) => Promise<string>
|
||||
airdrop: (senderAddress: string, recipients: string[]) => Promise<string>
|
||||
updateDiscountPrice: (senderAddress: string, price: string) => Promise<string>
|
||||
removeDiscountPrice: (senderAddress: string) => Promise<string>
|
||||
}
|
||||
|
||||
export interface MinterMessages {
|
||||
@ -56,6 +58,26 @@ export interface MinterMessages {
|
||||
shuffle: () => ShuffleMessage
|
||||
withdraw: () => WithdrawMessage
|
||||
airdrop: (recipients: string[]) => CustomMessage
|
||||
updateDiscountPrice: (price: string) => UpdateDiscountPriceMessage
|
||||
removeDiscountPrice: () => RemoveDiscountPriceMessage
|
||||
}
|
||||
|
||||
export interface UpdateDiscountPriceMessage {
|
||||
sender: string
|
||||
contract: string
|
||||
msg: {
|
||||
update_discount_price: Record<string, unknown>
|
||||
}
|
||||
funds: Coin[]
|
||||
}
|
||||
|
||||
export interface RemoveDiscountPriceMessage {
|
||||
sender: string
|
||||
contract: string
|
||||
msg: {
|
||||
remove_discount_price: Record<string, never>
|
||||
}
|
||||
funds: Coin[]
|
||||
}
|
||||
|
||||
export interface MintMessage {
|
||||
@ -366,6 +388,35 @@ export const minter = (client: SigningCosmWasmClient, txSigner: string): MinterC
|
||||
return res.transactionHash
|
||||
}
|
||||
|
||||
const updateDiscountPrice = async (senderAddress: string, price: string): Promise<string> => {
|
||||
const res = await client.execute(
|
||||
senderAddress,
|
||||
contractAddress,
|
||||
{
|
||||
update_discount_price: {
|
||||
price,
|
||||
},
|
||||
},
|
||||
'auto',
|
||||
'',
|
||||
)
|
||||
|
||||
return res.transactionHash
|
||||
}
|
||||
|
||||
const removeDiscountPrice = async (senderAddress: string): Promise<string> => {
|
||||
const res = await client.execute(
|
||||
senderAddress,
|
||||
contractAddress,
|
||||
{
|
||||
remove_discount_price: {},
|
||||
},
|
||||
'auto',
|
||||
'',
|
||||
)
|
||||
|
||||
return res.transactionHash
|
||||
}
|
||||
return {
|
||||
contractAddress,
|
||||
getConfig,
|
||||
@ -383,6 +434,8 @@ export const minter = (client: SigningCosmWasmClient, txSigner: string): MinterC
|
||||
airdrop,
|
||||
shuffle,
|
||||
withdraw,
|
||||
updateDiscountPrice,
|
||||
removeDiscountPrice,
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,6 +592,28 @@ export const minter = (client: SigningCosmWasmClient, txSigner: string): MinterC
|
||||
funds: [],
|
||||
}
|
||||
}
|
||||
const updateDiscountPrice = (price: string): UpdateDiscountPriceMessage => {
|
||||
return {
|
||||
sender: txSigner,
|
||||
contract: contractAddress,
|
||||
msg: {
|
||||
update_discount_price: {
|
||||
price,
|
||||
},
|
||||
},
|
||||
funds: [],
|
||||
}
|
||||
}
|
||||
const removeDiscountPrice = (): RemoveDiscountPriceMessage => {
|
||||
return {
|
||||
sender: txSigner,
|
||||
contract: contractAddress,
|
||||
msg: {
|
||||
remove_discount_price: {},
|
||||
},
|
||||
funds: [],
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
mint,
|
||||
@ -551,6 +626,8 @@ export const minter = (client: SigningCosmWasmClient, txSigner: string): MinterC
|
||||
airdrop,
|
||||
shuffle,
|
||||
withdraw,
|
||||
updateDiscountPrice,
|
||||
removeDiscountPrice,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,8 @@ export const EXECUTE_TYPES = [
|
||||
'mint_for',
|
||||
'shuffle',
|
||||
'withdraw',
|
||||
'update_discount_price',
|
||||
'remove_discount_price',
|
||||
] as const
|
||||
|
||||
export interface ExecuteListItem {
|
||||
@ -56,6 +58,16 @@ export const EXECUTE_LIST: ExecuteListItem[] = [
|
||||
name: 'Shuffle',
|
||||
description: `Shuffle the token IDs`,
|
||||
},
|
||||
{
|
||||
id: 'update_discount_price',
|
||||
name: 'Update Discount Price',
|
||||
description: `Updates discount price`,
|
||||
},
|
||||
{
|
||||
id: 'remove_discount_price',
|
||||
name: 'Remove Discount Price',
|
||||
description: `Removes discount price`,
|
||||
},
|
||||
]
|
||||
|
||||
export interface DispatchExecuteProps {
|
||||
@ -80,6 +92,8 @@ export type DispatchExecuteArgs = {
|
||||
| { type: Select<'mint_for'>; recipient: string; tokenId: number }
|
||||
| { type: Select<'shuffle'> }
|
||||
| { type: Select<'withdraw'> }
|
||||
| { type: Select<'update_discount_price'>; price: string }
|
||||
| { type: Select<'remove_discount_price'> }
|
||||
)
|
||||
|
||||
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||
@ -112,6 +126,12 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||
case 'withdraw': {
|
||||
return messages.withdraw(txSigner)
|
||||
}
|
||||
case 'update_discount_price': {
|
||||
return messages.updateDiscountPrice(txSigner, args.price === '' ? '0' : args.price)
|
||||
}
|
||||
case 'remove_discount_price': {
|
||||
return messages.removeDiscountPrice(txSigner)
|
||||
}
|
||||
default: {
|
||||
throw new Error('unknown execute type')
|
||||
}
|
||||
@ -147,6 +167,12 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||
case 'withdraw': {
|
||||
return messages(contract)?.withdraw()
|
||||
}
|
||||
case 'update_discount_price': {
|
||||
return messages(contract)?.updateDiscountPrice(args.price === '' ? '0' : args.price)
|
||||
}
|
||||
case 'remove_discount_price': {
|
||||
return messages(contract)?.removeDiscountPrice()
|
||||
}
|
||||
default: {
|
||||
return {}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ const MinterExecutePage: NextPage = () => {
|
||||
const showLimitField = type === 'update_per_address_limit'
|
||||
const showTokenIdField = type === 'mint_for'
|
||||
const showRecipientField = isEitherType(type, ['mint_to', 'mint_for'])
|
||||
const showPriceField = type === 'mint'
|
||||
const showPriceField = isEitherType(type, ['mint', 'update_discount_price'])
|
||||
|
||||
const messages = useMemo(() => contract?.use(contractState.value), [contract, wallet.address, contractState.value])
|
||||
const payload: DispatchExecuteArgs = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user