Update Vending Minter helpers

This commit is contained in:
Serkan Reis 2023-03-03 12:17:16 +03:00
parent e1dd8dadc2
commit 58a186e2ab

View File

@ -48,6 +48,8 @@ export interface VendingMinterInstance {
withdraw: (senderAddress: string) => Promise<string>
airdrop: (senderAddress: string, recipients: string[]) => Promise<string>
burnRemaining: (senderAddress: string) => Promise<string>
updateDiscountPrice: (senderAddress: string, price: string) => Promise<string>
removeDiscountPrice: (senderAddress: string) => Promise<string>
}
export interface VendingMinterMessages {
@ -66,6 +68,8 @@ export interface VendingMinterMessages {
withdraw: () => WithdrawMessage
airdrop: (recipients: string[]) => CustomMessage
burnRemaining: () => BurnRemainingMessage
updateDiscountPrice: (price: string) => UpdateDiscountPriceMessage
removeDiscountPrice: () => RemoveDiscountPriceMessage
}
export interface MintMessage {
@ -97,6 +101,26 @@ export interface UpdateMintPriceMessage {
funds: Coin[]
}
export interface UpdateDiscountPriceMessage {
sender: string
contract: string
msg: {
update_discount_price: {
price: string
}
}
funds: Coin[]
}
export interface RemoveDiscountPriceMessage {
sender: string
contract: string
msg: {
remove_discount_price: Record<string, never>
}
funds: Coin[]
}
export interface SetWhitelistMessage {
sender: string
contract: string
@ -326,6 +350,36 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
return res.transactionHash
}
const updateDiscountPrice = async (senderAddress: string, price: string): Promise<string> => {
const res = await client.execute(
senderAddress,
contractAddress,
{
update_discount_price: {
price: (Number(price) * 1000000).toString(),
},
},
'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
}
const setWhitelist = async (senderAddress: string, whitelist: string): Promise<string> => {
const res = await client.execute(
senderAddress,
@ -552,6 +606,8 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
mint,
purge,
updateMintPrice,
updateDiscountPrice,
removeDiscountPrice,
setWhitelist,
updateStartTime,
updateStartTradingTime,
@ -633,6 +689,30 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
}
}
const updateDiscountPrice = (price: string): UpdateDiscountPriceMessage => {
return {
sender: txSigner,
contract: contractAddress,
msg: {
update_discount_price: {
price: (Number(price) * 1000000).toString(),
},
},
funds: [],
}
}
const removeDiscountPrice = (): RemoveDiscountPriceMessage => {
return {
sender: txSigner,
contract: contractAddress,
msg: {
remove_discount_price: {},
},
funds: [],
}
}
const setWhitelist = (whitelist: string): SetWhitelistMessage => {
return {
sender: txSigner,
@ -795,6 +875,8 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
mint,
purge,
updateMintPrice,
updateDiscountPrice,
removeDiscountPrice,
setWhitelist,
updateStartTime,
updateStartTradingTime,