From 1bfd1113bbeadb584193c0913133a217f8d4573f Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 31 Jul 2023 16:49:35 +0300 Subject: [PATCH] Open edition IBC minter creation success --- .../openEdition/OpenEditionMinterCreator.tsx | 26 ++++++++++++++----- config/minter.ts | 2 +- contracts/openEditionFactory/contract.ts | 13 +++------- pages/collections/create.tsx | 7 +++-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/components/openEdition/OpenEditionMinterCreator.tsx b/components/openEdition/OpenEditionMinterCreator.tsx index eab0869..15af184 100644 --- a/components/openEdition/OpenEditionMinterCreator.tsx +++ b/components/openEdition/OpenEditionMinterCreator.tsx @@ -12,6 +12,7 @@ import type { MinterType } from 'components/collections/actions/Combobox' import { Conditional } from 'components/Conditional' import { ConfirmationModal } from 'components/ConfirmationModal' import { LoadingModal } from 'components/LoadingModal' +import { openEditionMinterList } from 'config/minter' import type { TokenInfo } from 'config/token' import { useContracts } from 'contexts/contracts' import { addLogItem } from 'contexts/log' @@ -90,10 +91,6 @@ export const OpenEditionMinterCreator = ({ const { openEditionMinter: openEditionMinterContract, openEditionFactory: openEditionFactoryContract } = useContracts() - const openEditionFactoryMessages = useMemo( - () => openEditionFactoryContract?.use(OPEN_EDITION_FACTORY_ADDRESS), - [openEditionFactoryContract, wallet.address], - ) const [metadataStorageMethod, setMetadataStorageMethod] = useState('off-chain') const [imageUploadDetails, setImageUploadDetails] = useState(null) const [collectionDetails, setCollectionDetails] = useState(null) @@ -114,6 +111,21 @@ export const OpenEditionMinterCreator = ({ const [sg721ContractAddress, setSg721ContractAddress] = useState(null) const [transactionHash, setTransactionHash] = useState(null) + const factoryAddressForSelectedDenom = + openEditionMinterList.find((minter) => minter.supportedToken === mintTokenFromFactory && minter.updatable === false) + ?.factoryAddress || OPEN_EDITION_FACTORY_ADDRESS + const updatableFactoryAddressForSelectedDenom = + openEditionMinterList.find((minter) => minter.supportedToken === mintTokenFromFactory && minter.updatable === true) + ?.factoryAddress || OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS + + const openEditionFactoryMessages = useMemo( + () => + openEditionFactoryContract?.use( + collectionDetails?.updatable ? updatableFactoryAddressForSelectedDenom : factoryAddressForSelectedDenom, + ), + [openEditionFactoryContract, wallet.address], + ) + const performOpenEditionMinterChecks = () => { try { setReadyToCreate(false) @@ -528,7 +540,7 @@ export const OpenEditionMinterCreator = ({ end_time: mintingDetails?.endTime, mint_price: { amount: Number(mintingDetails?.unitPrice).toString(), - denom: 'ustars', + denom: (mintTokenFromFactory?.denom as string) || 'ustars', }, per_address_limit: mintingDetails?.perAddressLimit, payment_address: mintingDetails?.paymentAddress || null, @@ -550,9 +562,9 @@ export const OpenEditionMinterCreator = ({ } console.log('msg: ', msg) - + console.log('Using factory address: ', factoryAddressForSelectedDenom) const payload: OpenEditionFactoryDispatchExecuteArgs = { - contract: collectionDetails?.updatable ? OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS : OPEN_EDITION_FACTORY_ADDRESS, + contract: collectionDetails?.updatable ? updatableFactoryAddressForSelectedDenom : factoryAddressForSelectedDenom, messages: openEditionFactoryMessages, txSigner: wallet.address, msg, diff --git a/config/minter.ts b/config/minter.ts index 413614d..d191f14 100644 --- a/config/minter.ts +++ b/config/minter.ts @@ -58,7 +58,7 @@ export const openEditionUpdatableIbcUsdcMinter: MinterInfo = { id: 'open-edition-updatable-ibc-usdc-minter', factoryAddress: OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, supportedToken: ibcUsdc, - updatable: false, + updatable: true, } export const openEditionIbcFrenzMinter: MinterInfo = { diff --git a/contracts/openEditionFactory/contract.ts b/contracts/openEditionFactory/contract.ts index d512b8a..7f20216 100644 --- a/contracts/openEditionFactory/contract.ts +++ b/contracts/openEditionFactory/contract.ts @@ -3,7 +3,6 @@ import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' import type { Coin } from '@cosmjs/proto-signing' import type { logs } from '@cosmjs/stargate' -import { OPEN_EDITION_FACTORY_ADDRESS, OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS } from 'utils/constants' export interface CreateOpenEditionMinterResponse { readonly openEditionMinterAddress: string @@ -23,6 +22,7 @@ export interface OpenEditionFactoryInstance { msg: Record, funds: Coin[], updatable?: boolean, + selectedFactoryAddress?: string, ) => Promise } @@ -56,16 +56,9 @@ export const openEditionFactory = (client: SigningCosmWasmClient, txSigner: stri senderAddress: string, msg: Record, funds: Coin[], - updatable?: boolean, ): Promise => { - const result = await client.execute( - senderAddress, - updatable ? OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS : OPEN_EDITION_FACTORY_ADDRESS, - msg, - 'auto', - '', - funds, - ) + console.log('Contract Address: ', contractAddress) + const result = await client.execute(senderAddress, contractAddress, msg, 'auto', '', funds) return { openEditionMinterAddress: result.logs[0].events[5].attributes[0].value, diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 9493fba..42573f7 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -74,7 +74,7 @@ import type { MinterType } from '../../components/collections/actions/Combobox' import type { UploadMethod } from '../../components/collections/creation/UploadDetails' import { ConfirmationModal } from '../../components/ConfirmationModal' import type { OpenEditionMinterDetailsDataProps } from '../../components/openEdition/OpenEditionMinterCreator' -import { tokensList } from '../../config/token' +import { stars, tokensList } from '../../config/token' import { getAssetType } from '../../utils/getAssetType' import { isValidAddress } from '../../utils/isValidAddress' @@ -128,9 +128,7 @@ const CollectionCreationPage: NextPage = () => { const [minimumOpenEditionUpdatableMintPrice, setMinimumOpenEditionUpdatableMintPrice] = useState('0') const [minimumFlexMintPrice, setMinimumFlexMintPrice] = useState('0') - const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState( - undefined, - ) + const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState(stars) const [uploading, setUploading] = useState(false) const [isMintingComplete, setIsMintingComplete] = useState(false) @@ -1153,6 +1151,7 @@ const CollectionCreationPage: NextPage = () => { toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) }) + console.log('Open Edition Factory Parameters: ', openEditionFactoryParameters) setOpenEditionMinterCreationFee(openEditionFactoryParameters?.params?.creation_fee?.amount) if (!openEditionMinterDetails?.collectionDetails?.updatable) { setMinimumOpenEditionMintPrice(openEditionFactoryParameters?.params?.min_mint_price?.amount)