Update vending minter contract helpers
This commit is contained in:
parent
9742ec6d04
commit
1b6f429843
@ -5,6 +5,7 @@ import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
|
|||||||
import { useSG721Contract } from 'contracts/sg721'
|
import { useSG721Contract } from 'contracts/sg721'
|
||||||
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
import { useVendingMinterContract } from 'contracts/vendingMinter'
|
import { useVendingMinterContract } from 'contracts/vendingMinter'
|
||||||
|
import type { AirdropAllocation } from 'utils/isValidAccountsFile'
|
||||||
|
|
||||||
import type { BaseMinterInstance } from '../../../contracts/baseMinter/contract'
|
import type { BaseMinterInstance } from '../../../contracts/baseMinter/contract'
|
||||||
|
|
||||||
@ -243,6 +244,7 @@ export interface DispatchExecuteArgs {
|
|||||||
limit: number
|
limit: number
|
||||||
tokenIds: string
|
tokenIds: string
|
||||||
recipients: string[]
|
recipients: string[]
|
||||||
|
tokenRecipients: AirdropAllocation[]
|
||||||
collectionInfo: CollectionInfo | undefined
|
collectionInfo: CollectionInfo | undefined
|
||||||
baseUri: string
|
baseUri: string
|
||||||
}
|
}
|
||||||
@ -325,6 +327,9 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
case 'airdrop': {
|
case 'airdrop': {
|
||||||
return vendingMinterMessages.airdrop(txSigner, args.recipients)
|
return vendingMinterMessages.airdrop(txSigner, args.recipients)
|
||||||
}
|
}
|
||||||
|
case 'airdrop_specific': {
|
||||||
|
return vendingMinterMessages.airdropSpecificTokens(txSigner, args.tokenRecipients)
|
||||||
|
}
|
||||||
case 'burn_remaining': {
|
case 'burn_remaining': {
|
||||||
return vendingMinterMessages.burnRemaining(txSigner)
|
return vendingMinterMessages.burnRemaining(txSigner)
|
||||||
}
|
}
|
||||||
@ -415,6 +420,9 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
|||||||
case 'airdrop': {
|
case 'airdrop': {
|
||||||
return vendingMinterMessages(minterContract)?.airdrop(args.recipients)
|
return vendingMinterMessages(minterContract)?.airdrop(args.recipients)
|
||||||
}
|
}
|
||||||
|
case 'airdrop_specific': {
|
||||||
|
return vendingMinterMessages(minterContract)?.airdropSpecificTokens(args.tokenRecipients)
|
||||||
|
}
|
||||||
case 'burn_remaining': {
|
case 'burn_remaining': {
|
||||||
return vendingMinterMessages(minterContract)?.burnRemaining()
|
return vendingMinterMessages(minterContract)?.burnRemaining()
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { coin } from '@cosmjs/proto-signing'
|
|||||||
import type { logs } from '@cosmjs/stargate'
|
import type { logs } from '@cosmjs/stargate'
|
||||||
import type { Timestamp } from '@stargazezone/types/contracts/minter/shared-types'
|
import type { Timestamp } from '@stargazezone/types/contracts/minter/shared-types'
|
||||||
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx'
|
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx'
|
||||||
|
import type { AirdropAllocation } from 'utils/isValidAccountsFile'
|
||||||
|
|
||||||
export interface InstantiateResponse {
|
export interface InstantiateResponse {
|
||||||
readonly contractAddress: string
|
readonly contractAddress: string
|
||||||
@ -47,6 +48,7 @@ export interface VendingMinterInstance {
|
|||||||
shuffle: (senderAddress: string) => Promise<string>
|
shuffle: (senderAddress: string) => Promise<string>
|
||||||
withdraw: (senderAddress: string) => Promise<string>
|
withdraw: (senderAddress: string) => Promise<string>
|
||||||
airdrop: (senderAddress: string, recipients: string[]) => Promise<string>
|
airdrop: (senderAddress: string, recipients: string[]) => Promise<string>
|
||||||
|
airdropSpecificTokens: (senderAddress: string, tokenRecipients: AirdropAllocation[]) => Promise<string>
|
||||||
burnRemaining: (senderAddress: string) => Promise<string>
|
burnRemaining: (senderAddress: string) => Promise<string>
|
||||||
updateDiscountPrice: (senderAddress: string, price: string) => Promise<string>
|
updateDiscountPrice: (senderAddress: string, price: string) => Promise<string>
|
||||||
removeDiscountPrice: (senderAddress: string) => Promise<string>
|
removeDiscountPrice: (senderAddress: string) => Promise<string>
|
||||||
@ -67,6 +69,7 @@ export interface VendingMinterMessages {
|
|||||||
shuffle: () => ShuffleMessage
|
shuffle: () => ShuffleMessage
|
||||||
withdraw: () => WithdrawMessage
|
withdraw: () => WithdrawMessage
|
||||||
airdrop: (recipients: string[]) => CustomMessage
|
airdrop: (recipients: string[]) => CustomMessage
|
||||||
|
airdropSpecificTokens: (recipients: AirdropAllocation[]) => CustomMessage
|
||||||
burnRemaining: () => BurnRemainingMessage
|
burnRemaining: () => BurnRemainingMessage
|
||||||
updateDiscountPrice: (price: string) => UpdateDiscountPriceMessage
|
updateDiscountPrice: (price: string) => UpdateDiscountPriceMessage
|
||||||
removeDiscountPrice: () => RemoveDiscountPriceMessage
|
removeDiscountPrice: () => RemoveDiscountPriceMessage
|
||||||
@ -553,6 +556,29 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
return res.transactionHash
|
return res.transactionHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const airdropSpecificTokens = async (senderAddress: string, recipients: AirdropAllocation[]): Promise<string> => {
|
||||||
|
const executeContractMsgs: MsgExecuteContractEncodeObject[] = []
|
||||||
|
for (let i = 0; i < recipients.length; i++) {
|
||||||
|
const msg = {
|
||||||
|
mint_for: { recipient: recipients[i].address, token_id: Number(recipients[i].tokenId) },
|
||||||
|
}
|
||||||
|
const executeContractMsg: MsgExecuteContractEncodeObject = {
|
||||||
|
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
||||||
|
value: MsgExecuteContract.fromPartial({
|
||||||
|
sender: senderAddress,
|
||||||
|
contract: contractAddress,
|
||||||
|
msg: toUtf8(JSON.stringify(msg)),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
executeContractMsgs.push(executeContractMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await client.signAndBroadcast(senderAddress, executeContractMsgs, 'auto', 'airdrop_specific_tokens')
|
||||||
|
|
||||||
|
return res.transactionHash
|
||||||
|
}
|
||||||
|
|
||||||
const shuffle = async (senderAddress: string): Promise<string> => {
|
const shuffle = async (senderAddress: string): Promise<string> => {
|
||||||
const res = await client.execute(
|
const res = await client.execute(
|
||||||
senderAddress,
|
senderAddress,
|
||||||
@ -617,6 +643,7 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
batchMintFor,
|
batchMintFor,
|
||||||
batchMint,
|
batchMint,
|
||||||
airdrop,
|
airdrop,
|
||||||
|
airdropSpecificTokens,
|
||||||
shuffle,
|
shuffle,
|
||||||
withdraw,
|
withdraw,
|
||||||
burnRemaining,
|
burnRemaining,
|
||||||
@ -838,6 +865,19 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const airdropSpecificTokens = (recipients: AirdropAllocation[]): CustomMessage => {
|
||||||
|
const msg: Record<string, unknown>[] = []
|
||||||
|
for (let i = 0; i < recipients.length; i++) {
|
||||||
|
msg.push({ mint_for: { recipient: recipients[i].address, token_id: recipients[i].tokenId } })
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
sender: txSigner,
|
||||||
|
contract: contractAddress,
|
||||||
|
msg,
|
||||||
|
funds: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const shuffle = (): ShuffleMessage => {
|
const shuffle = (): ShuffleMessage => {
|
||||||
return {
|
return {
|
||||||
sender: txSigner,
|
sender: txSigner,
|
||||||
@ -886,6 +926,7 @@ export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
batchMintFor,
|
batchMintFor,
|
||||||
batchMint,
|
batchMint,
|
||||||
airdrop,
|
airdrop,
|
||||||
|
airdropSpecificTokens,
|
||||||
shuffle,
|
shuffle,
|
||||||
withdraw,
|
withdraw,
|
||||||
burnRemaining,
|
burnRemaining,
|
||||||
|
Loading…
Reference in New Issue
Block a user