From 58a186e2abd20351c53c722b92b03602d4525917 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Fri, 3 Mar 2023 12:17:16 +0300 Subject: [PATCH] Update Vending Minter helpers --- contracts/vendingMinter/contract.ts | 82 +++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/contracts/vendingMinter/contract.ts b/contracts/vendingMinter/contract.ts index f159f44..8483fa3 100644 --- a/contracts/vendingMinter/contract.ts +++ b/contracts/vendingMinter/contract.ts @@ -48,6 +48,8 @@ export interface VendingMinterInstance { withdraw: (senderAddress: string) => Promise airdrop: (senderAddress: string, recipients: string[]) => Promise burnRemaining: (senderAddress: string) => Promise + updateDiscountPrice: (senderAddress: string, price: string) => Promise + removeDiscountPrice: (senderAddress: string) => Promise } 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 + } + 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 => { + 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 => { + const res = await client.execute( + senderAddress, + contractAddress, + { + remove_discount_price: {}, + }, + 'auto', + '', + ) + + return res.transactionHash + } + const setWhitelist = async (senderAddress: string, whitelist: string): Promise => { 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,