stargaze-studio/contracts/vendingFactory/contract.ts
name-user1 039b8b424b
Launchpad V2 sync (#34)
* V2 Sync

* v2 sync

* Launchpad V2 sync

* Update trading start time description

* Add explicit_content to CollectionDetails update dependencies

* Minor UI changes

* Update MintPriceMessage interface

* Add symbolState.value to CollectionDetails update dependencies

* Add external_link to Collection Details

* Remove the tab Instantiate from the minter contract dashboard

* Add price check for update_minting_price

* Implement dynamic per address limit check

* Add checks for trading start time

* Update Minter Contract Dashboard Instantiate Tab - 1

* Update Minter Contract Dashboard Instantiate Tab - 2

* Remove Instantiate tab from SG721 Contract Dashboard

* Update whitelist contract helpers

* Update whitelist instantiate fee wrt member limit

Co-authored-by: name-user1 <eray@deuslabs.fi>
Co-authored-by: Serkan Reis <serkanreis@gmail.com>
2022-10-20 19:02:52 -06:00

83 lines
2.2 KiB
TypeScript

import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import type { Coin } from '@cosmjs/proto-signing'
import { coin } from '@cosmjs/proto-signing'
import type { logs } from '@cosmjs/stargate'
import { VENDING_FACTORY_ADDRESS } from 'utils/constants'
export interface CreateMinterResponse {
readonly minterAddress: string
readonly sg721Address: string
readonly transactionHash: string
readonly logs: readonly logs.Log[]
}
export interface VendingFactoryInstance {
readonly contractAddress: string
//Query
//Execute
createMinter: (senderAddress: string, msg: Record<string, unknown>, funds: Coin[]) => Promise<CreateMinterResponse>
}
export interface VendingFactoryMessages {
createMinter: (msg: Record<string, unknown>) => CreateMinterMessage
}
export interface CreateMinterMessage {
sender: string
contract: string
msg: Record<string, unknown>
funds: Coin[]
}
export interface VendingFactoryContract {
use: (contractAddress: string) => VendingFactoryInstance
messages: (contractAddress: string) => VendingFactoryMessages
}
export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string): VendingFactoryContract => {
const use = (contractAddress: string): VendingFactoryInstance => {
//Query
//Execute
const createMinter = async (
senderAddress: string,
msg: Record<string, unknown>,
funds: Coin[],
): Promise<CreateMinterResponse> => {
const result = await client.execute(senderAddress, VENDING_FACTORY_ADDRESS, msg, 'auto', '', funds)
return {
minterAddress: result.logs[0].events[5].attributes[0].value,
sg721Address: result.logs[0].events[5].attributes[2].value,
transactionHash: result.transactionHash,
logs: result.logs,
}
}
return {
contractAddress,
createMinter,
}
}
const messages = (contractAddress: string) => {
const createMinter = (msg: Record<string, unknown>): CreateMinterMessage => {
return {
sender: txSigner,
contract: contractAddress,
msg,
funds: [coin('1000000000', 'ustars')],
}
}
return {
createMinter,
}
}
return { use, messages }
}