From 75fe1d33876d96a50622bee6e4cc09d17b8fa613 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 26 Jul 2023 22:26:27 +0300 Subject: [PATCH 01/24] Init TokenInfo --- config/token.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 config/token.ts diff --git a/config/token.ts b/config/token.ts new file mode 100644 index 0000000..10d815f --- /dev/null +++ b/config/token.ts @@ -0,0 +1,22 @@ +export interface TokenInfo { + id: string + denom: string + displayName: string + decimalPlaces: number + imageURL?: string + symbol?: string +} + +export const ibcAtom: TokenInfo = { + id: 'ibc-atom', + denom: 'ibc/', + displayName: 'ATOM', + decimalPlaces: 6, +} + +export const stars: TokenInfo = { + id: 'stars', + denom: 'ustars', + displayName: 'STARS', + decimalPlaces: 6, +} From 3ff3d094b405a908ee676f71f4333f9bc9e4ddb5 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Thu, 27 Jul 2023 17:26:51 +0300 Subject: [PATCH 02/24] Init minter list --- .env.example | 2 ++ config/minter.ts | 34 ++++++++++++++++++++++++++++++++++ config/token.ts | 23 ++++++++++++++++------- env.d.ts | 2 ++ utils/constants.ts | 2 ++ 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 config/minter.ts diff --git a/.env.example b/.env.example index 46be8b3..7ec8697 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,8 @@ NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftsl NEXT_PUBLIC_BASE_FACTORY_ADDRESS="stars1a45hcxty3spnmm2f0papl8v4dk5ew29s4syhn4efte8u5haex99qlkrtnx" NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS="stars100xegx2syry4tclkmejjwxk4nfqahvcqhm9qxut5wxuzhj5d9qfsh5nmym" NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS="stars1fk5dkzcylam8mcpqrn8y9spauvc3d4navtaqurcc49dc3p9f8d3qdkvymx" NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID=2579 diff --git a/config/minter.ts b/config/minter.ts new file mode 100644 index 0000000..4fa2a14 --- /dev/null +++ b/config/minter.ts @@ -0,0 +1,34 @@ +import { + OPEN_EDITION_FACTORY_ADDRESS, + OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS, + OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS, +} from 'utils/constants' + +import type { TokenInfo } from './token' +import { ibcAtom, ibcFrenz, stars } from './token' + +export interface MinterInfo { + id: string + factoryAddress: string + supportedToken: TokenInfo +} + +export const openEditionStarsMinter: MinterInfo = { + id: 'open-edition-stars-minter', + factoryAddress: OPEN_EDITION_FACTORY_ADDRESS, + supportedToken: stars, +} + +export const openEditionIbcAtomMinter: MinterInfo = { + id: 'open-edition-ibc-atom-minter', + factoryAddress: OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS, + supportedToken: ibcAtom, +} + +export const openEditionIbcFrenzMinter: MinterInfo = { + id: 'open-edition-ibc-frenz-minter', + factoryAddress: OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS, + supportedToken: ibcFrenz, +} + +export const minterList = [openEditionStarsMinter, openEditionIbcAtomMinter, openEditionIbcFrenzMinter] diff --git a/config/token.ts b/config/token.ts index 10d815f..8f64d82 100644 --- a/config/token.ts +++ b/config/token.ts @@ -7,16 +7,25 @@ export interface TokenInfo { symbol?: string } -export const ibcAtom: TokenInfo = { - id: 'ibc-atom', - denom: 'ibc/', - displayName: 'ATOM', - decimalPlaces: 6, -} - export const stars: TokenInfo = { id: 'stars', denom: 'ustars', displayName: 'STARS', decimalPlaces: 6, } + +export const ibcAtom: TokenInfo = { + id: 'ibc-atom', + denom: 'ibc/atom', + displayName: 'ATOM', + decimalPlaces: 6, +} + +export const ibcFrenz: TokenInfo = { + id: 'ibc-frenz', + denom: 'ibc/frenz', + displayName: 'FRENZ', + decimalPlaces: 6, +} + +export const tokensList = [stars, ibcAtom, ibcFrenz] diff --git a/env.d.ts b/env.d.ts index 955e661..77abe04 100644 --- a/env.d.ts +++ b/env.d.ts @@ -24,6 +24,8 @@ declare namespace NodeJS { readonly NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS: string diff --git a/utils/constants.ts b/utils/constants.ts index 097aefa..81955ff 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -15,6 +15,8 @@ export const VENDING_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACT export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS export const BASE_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS export const OPEN_EDITION_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS +export const OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS +export const OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS export const OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS export const OPEN_EDITION_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID, 10) export const SG721_NAME_ADDRESS = process.env.NEXT_PUBLIC_SG721_NAME_ADDRESS From 701369f2462e53ff1bd60b3ee37c2454c4a4c4bf Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Fri, 28 Jul 2023 23:38:45 +0300 Subject: [PATCH 03/24] Surface Open Edition Minter details --- .../openEdition/OpenEditionMinterCreator.tsx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/components/openEdition/OpenEditionMinterCreator.tsx b/components/openEdition/OpenEditionMinterCreator.tsx index 3f0fce3..eab0869 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 type { TokenInfo } from 'config/token' import { useContracts } from 'contexts/contracts' import { addLogItem } from 'contexts/log' import { useWallet } from 'contexts/wallet' @@ -47,13 +48,25 @@ import { type RoyaltyDetailsDataProps, RoyaltyDetails } from './RoyaltyDetails' export type MetadataStorageMethod = 'off-chain' | 'on-chain' +export interface OpenEditionMinterDetailsDataProps { + imageUploadDetails?: ImageUploadDetailsDataProps + collectionDetails?: CollectionDetailsDataProps + royaltyDetails?: RoyaltyDetailsDataProps + onChainMetadataInputDetails?: OnChainMetadataInputDetailsDataProps + offChainMetadataUploadDetails?: OffChainMetadataUploadDetailsDataProps + mintingDetails?: MintingDetailsDataProps + metadataStorageMethod?: MetadataStorageMethod +} + interface OpenEditionMinterCreatorProps { onChange: (data: OpenEditionMinterCreatorDataProps) => void + onDetailsChange: (data: OpenEditionMinterDetailsDataProps) => void openEditionMinterUpdatableCreationFee?: string openEditionMinterCreationFee?: string minimumMintPrice?: string minimumUpdatableMintPrice?: string minterType?: MinterType + mintTokenFromFactory?: TokenInfo | undefined } export interface OpenEditionMinterCreatorDataProps { @@ -65,11 +78,13 @@ export interface OpenEditionMinterCreatorDataProps { export const OpenEditionMinterCreator = ({ onChange, + onDetailsChange, openEditionMinterCreationFee, openEditionMinterUpdatableCreationFee, minimumMintPrice, minimumUpdatableMintPrice, minterType, + mintTokenFromFactory, }: OpenEditionMinterCreatorProps) => { const wallet = useWallet() const { openEditionMinter: openEditionMinterContract, openEditionFactory: openEditionFactoryContract } = @@ -585,6 +600,27 @@ export const OpenEditionMinterCreator = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [metadataStorageMethod, openEditionMinterContractAddress, sg721ContractAddress, transactionHash]) + useEffect(() => { + const data: OpenEditionMinterDetailsDataProps = { + imageUploadDetails: imageUploadDetails ? imageUploadDetails : undefined, + collectionDetails: collectionDetails ? collectionDetails : undefined, + royaltyDetails: royaltyDetails ? royaltyDetails : undefined, + onChainMetadataInputDetails: onChainMetadataInputDetails ? onChainMetadataInputDetails : undefined, + offChainMetadataUploadDetails: offChainMetadataUploadDetails ? offChainMetadataUploadDetails : undefined, + mintingDetails: mintingDetails ? mintingDetails : undefined, + metadataStorageMethod, + } + onDetailsChange(data) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [ + imageUploadDetails, + collectionDetails, + royaltyDetails, + onChainMetadataInputDetails, + offChainMetadataUploadDetails, + mintingDetails, + ]) + return (
{/* TODO: Cancel once we're able to index on-chain metadata */} @@ -669,6 +705,7 @@ export const OpenEditionMinterCreator = ({ ? Number(minimumUpdatableMintPrice) / 1000000 : Number(minimumMintPrice) / 1000000 } + mintTokenFromFactory={mintTokenFromFactory} onChange={setMintingDetails} uploadMethod={offChainMetadataUploadDetails?.uploadMethod as UploadMethod} /> From 000a67a2f6c517f351e584d6e3e2cce759079917 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 30 Jul 2023 21:11:10 +0300 Subject: [PATCH 04/24] Update env variables --- .env.example | 8 ++++++-- env.d.ts | 8 ++++++-- utils/constants.ts | 11 +++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 7ec8697..29d3ca6 100644 --- a/.env.example +++ b/.env.example @@ -14,9 +14,13 @@ NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftsl NEXT_PUBLIC_BASE_FACTORY_ADDRESS="stars1a45hcxty3spnmm2f0papl8v4dk5ew29s4syhn4efte8u5haex99qlkrtnx" NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS="stars100xegx2syry4tclkmejjwxk4nfqahvcqhm9qxut5wxuzhj5d9qfsh5nmym" NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" -NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" -NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS="stars1fk5dkzcylam8mcpqrn8y9spauvc3d4navtaqurcc49dc3p9f8d3qdkvymx" +NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID=2579 NEXT_PUBLIC_SG721_NAME_ADDRESS="stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr" diff --git a/env.d.ts b/env.d.ts index 77abe04..72e2935 100644 --- a/env.d.ts +++ b/env.d.ts @@ -24,9 +24,13 @@ declare namespace NodeJS { readonly NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string - readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string - readonly NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS: string readonly NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS: string diff --git a/utils/constants.ts b/utils/constants.ts index 81955ff..2f0e607 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -15,9 +15,16 @@ export const VENDING_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACT export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS export const BASE_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS export const OPEN_EDITION_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS -export const OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS -export const OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS export const OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS +export const OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS +export const OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS = + process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS +export const OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS +export const OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS = + process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS +export const OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS +export const OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS = + process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS export const OPEN_EDITION_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID, 10) export const SG721_NAME_ADDRESS = process.env.NEXT_PUBLIC_SG721_NAME_ADDRESS export const BASE_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10) From 717fd88e74506d56dba9493cb175d05a20293149 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 30 Jul 2023 21:11:37 +0300 Subject: [PATCH 05/24] Update minter and token list --- config/minter.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- config/token.ts | 9 ++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/config/minter.ts b/config/minter.ts index 4fa2a14..6260da1 100644 --- a/config/minter.ts +++ b/config/minter.ts @@ -2,33 +2,77 @@ import { OPEN_EDITION_FACTORY_ADDRESS, OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS, OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS, + OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS, + OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS, + OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS, + OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS, + OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, } from 'utils/constants' import type { TokenInfo } from './token' -import { ibcAtom, ibcFrenz, stars } from './token' +import { ibcAtom, ibcFrenz, ibcUsdc, stars } from './token' export interface MinterInfo { id: string factoryAddress: string supportedToken: TokenInfo + updatable?: boolean } export const openEditionStarsMinter: MinterInfo = { id: 'open-edition-stars-minter', factoryAddress: OPEN_EDITION_FACTORY_ADDRESS, supportedToken: stars, + updatable: false, +} + +export const openEditionUpdatableStarsMinter: MinterInfo = { + id: 'open-edition-stars-minter', + factoryAddress: OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS, + supportedToken: stars, + updatable: true, } export const openEditionIbcAtomMinter: MinterInfo = { id: 'open-edition-ibc-atom-minter', factoryAddress: OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS, supportedToken: ibcAtom, + updatable: false, +} + +export const openEditionUpdatableIbcAtomMinter: MinterInfo = { + id: 'open-edition-ibc-atom-minter', + factoryAddress: OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS, + supportedToken: ibcAtom, + updatable: true, +} + +export const openEditionIbcUsdcMinter: MinterInfo = { + id: 'open-edition-ibc-usdc-minter', + factoryAddress: OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS, + supportedToken: ibcUsdc, + updatable: false, +} + +export const openEditionUpdatableIbcUsdcMinter: MinterInfo = { + id: 'open-edition-ibc-usdc-minter', + factoryAddress: OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, + supportedToken: ibcUsdc, + updatable: false, } export const openEditionIbcFrenzMinter: MinterInfo = { id: 'open-edition-ibc-frenz-minter', factoryAddress: OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS, supportedToken: ibcFrenz, + updatable: false, } -export const minterList = [openEditionStarsMinter, openEditionIbcAtomMinter, openEditionIbcFrenzMinter] +export const openEditionUpdatableIbcFrenzMinter: MinterInfo = { + id: 'open-edition-ibc-frenz-minter', + factoryAddress: OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS, + supportedToken: ibcFrenz, + updatable: true, +} + +export const openEditionMinterList = [openEditionStarsMinter, openEditionIbcAtomMinter, openEditionIbcFrenzMinter] diff --git a/config/token.ts b/config/token.ts index 8f64d82..3119c6d 100644 --- a/config/token.ts +++ b/config/token.ts @@ -21,6 +21,13 @@ export const ibcAtom: TokenInfo = { decimalPlaces: 6, } +export const ibcUsdc: TokenInfo = { + id: 'ibc-usdc', + denom: 'ibc/usdc', + displayName: 'USDC', + decimalPlaces: 6, +} + export const ibcFrenz: TokenInfo = { id: 'ibc-frenz', denom: 'ibc/frenz', @@ -28,4 +35,4 @@ export const ibcFrenz: TokenInfo = { decimalPlaces: 6, } -export const tokensList = [stars, ibcAtom, ibcFrenz] +export const tokensList = [stars, ibcAtom, ibcUsdc, ibcFrenz] From d2d06dffae0899eb6a050123e841132e87d47e76 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 31 Jul 2023 12:25:57 +0300 Subject: [PATCH 06/24] Match selected denom and fetch open edition factory parameters --- components/openEdition/MintingDetails.tsx | 46 ++++++++- config/minter.ts | 19 +++- pages/collections/create.tsx | 108 ++++++++++++++++++---- 3 files changed, 144 insertions(+), 29 deletions(-) diff --git a/components/openEdition/MintingDetails.tsx b/components/openEdition/MintingDetails.tsx index 8b6acd5..5562c43 100644 --- a/components/openEdition/MintingDetails.tsx +++ b/components/openEdition/MintingDetails.tsx @@ -4,6 +4,9 @@ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' import { InputDateTime } from 'components/InputDateTime' +import { openEditionMinterList } from 'config/minter' +import type { TokenInfo } from 'config/token' +import { stars, tokensList } from 'config/token' import React, { useEffect, useState } from 'react' import { resolveAddress } from 'utils/resolveAddress' @@ -15,6 +18,7 @@ interface MintingDetailsProps { onChange: (data: MintingDetailsDataProps) => void uploadMethod: UploadMethod minimumMintPrice: number + mintTokenFromFactory?: TokenInfo | undefined } export interface MintingDetailsDataProps { @@ -23,19 +27,28 @@ export interface MintingDetailsDataProps { startTime: string endTime: string paymentAddress?: string + selectedMintToken?: TokenInfo } -export const MintingDetails = ({ onChange, uploadMethod, minimumMintPrice }: MintingDetailsProps) => { +export const MintingDetails = ({ + onChange, + uploadMethod, + minimumMintPrice, + mintTokenFromFactory, +}: MintingDetailsProps) => { const wallet = useWallet() const [timestamp, setTimestamp] = useState() const [endTimestamp, setEndTimestamp] = useState() + const [selectedMintToken, setSelectedMintToken] = useState(stars) const unitPriceState = useNumberInputState({ id: 'unitPrice', name: 'unitPrice', - title: 'Unit Price', - subtitle: `Price of each token (min. ${minimumMintPrice} STARS)`, + title: 'Mint Price', + subtitle: `Price of each token (min. ${minimumMintPrice} ${ + mintTokenFromFactory ? mintTokenFromFactory.displayName : 'STARS' + })`, placeholder: '50', }) @@ -76,15 +89,38 @@ export const MintingDetails = ({ onChange, uploadMethod, minimumMintPrice }: Min startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '', endTime: endTimestamp ? (endTimestamp.getTime() * 1_000_000).toString() : '', paymentAddress: paymentAddressState.value.trim(), + selectedMintToken, } onChange(data) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [unitPriceState.value, perAddressLimitState.value, timestamp, endTimestamp, paymentAddressState.value]) + }, [ + unitPriceState.value, + perAddressLimitState.value, + timestamp, + endTimestamp, + paymentAddressState.value, + selectedMintToken, + ]) return (
- +
+ + +
+ setTimestamp(date)} value={timestamp} /> diff --git a/config/minter.ts b/config/minter.ts index 6260da1..413614d 100644 --- a/config/minter.ts +++ b/config/minter.ts @@ -27,7 +27,7 @@ export const openEditionStarsMinter: MinterInfo = { } export const openEditionUpdatableStarsMinter: MinterInfo = { - id: 'open-edition-stars-minter', + id: 'open-edition-updatable-stars-minter', factoryAddress: OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS, supportedToken: stars, updatable: true, @@ -41,7 +41,7 @@ export const openEditionIbcAtomMinter: MinterInfo = { } export const openEditionUpdatableIbcAtomMinter: MinterInfo = { - id: 'open-edition-ibc-atom-minter', + id: 'open-edition-updatable-ibc-atom-minter', factoryAddress: OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS, supportedToken: ibcAtom, updatable: true, @@ -55,7 +55,7 @@ export const openEditionIbcUsdcMinter: MinterInfo = { } export const openEditionUpdatableIbcUsdcMinter: MinterInfo = { - id: 'open-edition-ibc-usdc-minter', + id: 'open-edition-updatable-ibc-usdc-minter', factoryAddress: OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, supportedToken: ibcUsdc, updatable: false, @@ -69,10 +69,19 @@ export const openEditionIbcFrenzMinter: MinterInfo = { } export const openEditionUpdatableIbcFrenzMinter: MinterInfo = { - id: 'open-edition-ibc-frenz-minter', + id: 'open-edition-updatable-ibc-frenz-minter', factoryAddress: OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS, supportedToken: ibcFrenz, updatable: true, } -export const openEditionMinterList = [openEditionStarsMinter, openEditionIbcAtomMinter, openEditionIbcFrenzMinter] +export const openEditionMinterList = [ + openEditionStarsMinter, + openEditionUpdatableStarsMinter, + openEditionUpdatableIbcAtomMinter, + openEditionIbcAtomMinter, + openEditionIbcFrenzMinter, + openEditionUpdatableIbcFrenzMinter, + openEditionIbcUsdcMinter, + openEditionUpdatableIbcUsdcMinter, +] diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 6a99323..9493fba 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -33,6 +33,8 @@ import { Conditional } from 'components/Conditional' import { LoadingModal } from 'components/LoadingModal' import type { OpenEditionMinterCreatorDataProps } from 'components/openEdition/OpenEditionMinterCreator' import { OpenEditionMinterCreator } from 'components/openEdition/OpenEditionMinterCreator' +import { openEditionMinterList } from 'config/minter' +import type { TokenInfo } from 'config/token' import { useContracts } from 'contexts/contracts' import { addLogItem } from 'contexts/log' import { useWallet } from 'contexts/wallet' @@ -71,6 +73,8 @@ import { uid } from 'utils/random' 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 { getAssetType } from '../../utils/getAssetType' import { isValidAddress } from '../../utils/isValidAddress' @@ -99,7 +103,9 @@ const CollectionCreationPage: NextPage = () => { const [uploadDetails, setUploadDetails] = useState(null) const [collectionDetails, setCollectionDetails] = useState(null) const [baseMinterDetails, setBaseMinterDetails] = useState(null) - const [openEditionMinterDetails, setOpenEditionMinterDetails] = useState( + const [openEditionMinterCreatorData, setOpenEditionMinterCreatorData] = + useState(null) + const [openEditionMinterDetails, setOpenEditionMinterDetails] = useState( null, ) const [mintingDetails, setMintingDetails] = useState(null) @@ -122,6 +128,10 @@ const CollectionCreationPage: NextPage = () => { const [minimumOpenEditionUpdatableMintPrice, setMinimumOpenEditionUpdatableMintPrice] = useState('0') const [minimumFlexMintPrice, setMinimumFlexMintPrice] = useState('0') + const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState( + undefined, + ) + const [uploading, setUploading] = useState(false) const [isMintingComplete, setIsMintingComplete] = useState(false) const [creatingCollection, setCreatingCollection] = useState(false) @@ -1043,7 +1053,7 @@ const CollectionCreationPage: NextPage = () => { } } - const fetchFactoryParameters = async () => { + const fetchInitialFactoryParameters = async () => { const client = wallet.client if (!client) return if (BASE_FACTORY_ADDRESS) { @@ -1100,6 +1110,7 @@ const CollectionCreationPage: NextPage = () => { setVendingMinterFlexCreationFee(vendingFactoryFlexParameters?.params?.creation_fee?.amount) setMinimumFlexMintPrice(vendingFactoryFlexParameters?.params?.min_mint_price?.amount) } + if (OPEN_EDITION_FACTORY_ADDRESS) { const openEditionFactoryParameters = await client .queryContractSmart(OPEN_EDITION_FACTORY_ADDRESS, { params: {} }) @@ -1122,6 +1133,59 @@ const CollectionCreationPage: NextPage = () => { } } + const fetchOpenEditionFactoryParameters = useCallback(async () => { + const client = wallet.client + if (!client) return + const factoryForSelectedDenom = openEditionMinterList.find( + (minter) => + minter.supportedToken === openEditionMinterDetails?.mintingDetails?.selectedMintToken && + minter.updatable === false, + ) + const updatableFactoryForSelectedDenom = openEditionMinterList.find( + (minter) => + minter.supportedToken === openEditionMinterDetails?.mintingDetails?.selectedMintToken && + minter.updatable === true, + ) + if (factoryForSelectedDenom?.factoryAddress) { + const openEditionFactoryParameters = await client + .queryContractSmart(factoryForSelectedDenom.factoryAddress, { params: {} }) + .catch((error) => { + toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) + addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) + }) + setOpenEditionMinterCreationFee(openEditionFactoryParameters?.params?.creation_fee?.amount) + if (!openEditionMinterDetails?.collectionDetails?.updatable) { + setMinimumOpenEditionMintPrice(openEditionFactoryParameters?.params?.min_mint_price?.amount) + setMintTokenFromOpenEditionFactory( + tokensList.find((token) => token.denom === openEditionFactoryParameters?.params?.min_mint_price?.denom), + ) + } + console.log('Selected OE Factory: ', factoryForSelectedDenom) + console.log('Selected Updatable OE Factory: ', updatableFactoryForSelectedDenom) + } + if (updatableFactoryForSelectedDenom?.factoryAddress) { + const openEditionUpdatableFactoryParameters = await client + .queryContractSmart(updatableFactoryForSelectedDenom.factoryAddress, { params: {} }) + .catch((error) => { + toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) + addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) + }) + setOpenEditionMinterUpdatableCreationFee(openEditionUpdatableFactoryParameters?.params?.creation_fee?.amount) + if (openEditionMinterDetails?.collectionDetails?.updatable) { + setMinimumOpenEditionMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount) + setMintTokenFromOpenEditionFactory( + tokensList.find( + (token) => token.denom === openEditionUpdatableFactoryParameters?.params?.min_mint_price?.denom, + ), + ) + } + } + }, [ + openEditionMinterDetails?.mintingDetails?.selectedMintToken, + openEditionMinterDetails?.collectionDetails?.updatable, + wallet.client, + ]) + const checkwalletBalance = async () => { const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => { if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) { @@ -1161,25 +1225,25 @@ const CollectionCreationPage: NextPage = () => { const syncCollections = useCallback(async () => { const collectionAddress = - minterType === 'openEdition' ? openEditionMinterDetails?.sg721ContractAddress : sg721ContractAddress + minterType === 'openEdition' ? openEditionMinterCreatorData?.sg721ContractAddress : sg721ContractAddress if (collectionAddress && SYNC_COLLECTIONS_API_URL) { await axios.get(`${SYNC_COLLECTIONS_API_URL}/${collectionAddress}`).catch((error) => { console.error('Sync collections: ', error) }) } - }, [minterType, openEditionMinterDetails?.sg721ContractAddress, sg721ContractAddress]) + }, [minterType, openEditionMinterCreatorData?.sg721ContractAddress, sg721ContractAddress]) useEffect(() => { if ( vendingMinterContractAddress !== null || - openEditionMinterDetails?.openEditionMinterContractAddress || + openEditionMinterCreatorData?.openEditionMinterContractAddress || isMintingComplete ) { scrollRef.current?.scrollIntoView({ behavior: 'smooth' }) } if ( (minterType === 'vending' && vendingMinterContractAddress !== null) || - (minterType === 'openEdition' && openEditionMinterDetails?.openEditionMinterContractAddress) || + (minterType === 'openEdition' && openEditionMinterCreatorData?.openEditionMinterContractAddress) || (minterType === 'base' && vendingMinterContractAddress !== null && isMintingComplete) ) { void syncCollections() @@ -1192,7 +1256,7 @@ const CollectionCreationPage: NextPage = () => { } }, [ vendingMinterContractAddress, - openEditionMinterDetails?.openEditionMinterContractAddress, + openEditionMinterCreatorData?.openEditionMinterContractAddress, isMintingComplete, minterType, syncCollections, @@ -1210,9 +1274,13 @@ const CollectionCreationPage: NextPage = () => { }, [minterType, baseMinterDetails?.baseMinterAcquisitionMethod, uploadDetails?.uploadMethod]) useEffect(() => { - void fetchFactoryParameters() + void fetchInitialFactoryParameters() }, [wallet.client]) + useEffect(() => { + void fetchOpenEditionFactoryParameters() + }, [fetchOpenEditionFactoryParameters]) + return (
{
@@ -1253,10 +1321,10 @@ const CollectionCreationPage: NextPage = () => { className="text-stargaze hover:underline" external href={`/contracts/openEditionMinter/query/?contractAddress=${ - openEditionMinterDetails?.openEditionMinterContractAddress as string + openEditionMinterCreatorData?.openEditionMinterContractAddress as string }`} > - {openEditionMinterDetails?.openEditionMinterContractAddress as string} + {openEditionMinterCreatorData?.openEditionMinterContractAddress as string}
SG721 Contract Address:{' '} @@ -1264,10 +1332,10 @@ const CollectionCreationPage: NextPage = () => { className="text-stargaze hover:underline" external href={`/contracts/sg721/query/?contractAddress=${ - openEditionMinterDetails?.sg721ContractAddress as string + openEditionMinterCreatorData?.sg721ContractAddress as string }`} > - {openEditionMinterDetails?.sg721ContractAddress as string} + {openEditionMinterCreatorData?.sg721ContractAddress as string}
Transaction Hash: {' '} @@ -1275,18 +1343,18 @@ const CollectionCreationPage: NextPage = () => { - {openEditionMinterDetails?.transactionHash} + {openEditionMinterCreatorData?.transactionHash} - {openEditionMinterDetails?.transactionHash} + {openEditionMinterCreatorData?.transactionHash}
@@ -1295,7 +1363,7 @@ const CollectionCreationPage: NextPage = () => { className="text-white" external href={`${STARGAZE_URL}/launchpad/${ - openEditionMinterDetails?.openEditionMinterContractAddress as string + openEditionMinterCreatorData?.openEditionMinterContractAddress as string }`} > View on Launchpad @@ -1563,8 +1631,10 @@ const CollectionCreationPage: NextPage = () => { From 1bfd1113bbeadb584193c0913133a217f8d4573f Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 31 Jul 2023 16:49:35 +0300 Subject: [PATCH 07/24] 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) From 4f473b6bf818809d9a4986b2240010c10c9927c7 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 31 Jul 2023 17:24:04 +0300 Subject: [PATCH 08/24] Display the right denom in minimum mint price not met error --- components/openEdition/OpenEditionMinterCreator.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/openEdition/OpenEditionMinterCreator.tsx b/components/openEdition/OpenEditionMinterCreator.tsx index 15af184..0db516e 100644 --- a/components/openEdition/OpenEditionMinterCreator.tsx +++ b/components/openEdition/OpenEditionMinterCreator.tsx @@ -284,10 +284,16 @@ export const OpenEditionMinterCreator = ({ if (collectionDetails?.updatable) { if (Number(mintingDetails.unitPrice) < Number(minimumUpdatableMintPrice)) throw new Error( - `Invalid mint price: The minimum mint price is ${Number(minimumUpdatableMintPrice) / 1000000} STARS`, + `Invalid mint price: The minimum mint price is ${Number(minimumUpdatableMintPrice) / 1000000} ${ + mintTokenFromFactory?.displayName + }`, ) } else if (Number(mintingDetails.unitPrice) < Number(minimumMintPrice)) - throw new Error(`Invalid mint price: The minimum mint price is ${Number(minimumMintPrice) / 1000000} STARS`) + throw new Error( + `Invalid mint price: The minimum mint price is ${Number(minimumMintPrice) / 1000000} ${ + mintTokenFromFactory?.displayName + }`, + ) if (!mintingDetails.perAddressLimit || mintingDetails.perAddressLimit < 1 || mintingDetails.perAddressLimit > 50) throw new Error('Invalid limit for tokens per address') if (mintingDetails.startTime === '') throw new Error('Start time is required') From ce477c8b768702dc21b56dc1551e695331ededb6 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Tue, 1 Aug 2023 11:14:22 +0300 Subject: [PATCH 09/24] Include vending minters in the minter list --- .env.example | 4 ++++ config/minter.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++++ env.d.ts | 4 ++++ utils/constants.ts | 6 +++++ 4 files changed, 71 insertions(+) diff --git a/.env.example b/.env.example index 29d3ca6..538335d 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,10 @@ NEXT_PUBLIC_BASE_MINTER_CODE_ID=2598 NEXT_PUBLIC_VENDING_FACTORY_ADDRESS="stars18h7ugh8eaug7wr0w4yjw0ls5s937z35pnkg935ucsek2y9xl3gaqqk4jtx" NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS="stars1h65nms9gwg4vdktyqj84tu50gwlm34e0eczl5w2ezllxuzfxy9esa9qlt0" NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q" +NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_BASE_FACTORY_ADDRESS="stars1a45hcxty3spnmm2f0papl8v4dk5ew29s4syhn4efte8u5haex99qlkrtnx" NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS="stars100xegx2syry4tclkmejjwxk4nfqahvcqhm9qxut5wxuzhj5d9qfsh5nmym" NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" diff --git a/config/minter.ts b/config/minter.ts index d191f14..b7d359f 100644 --- a/config/minter.ts +++ b/config/minter.ts @@ -7,6 +7,12 @@ import { OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS, OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS, OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, + VENDING_FACTORY_ADDRESS, + VENDING_FACTORY_UPDATABLE_ADDRESS, + VENDING_IBC_ATOM_FACTORY_ADDRESS, + VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS, + VENDING_IBC_USDC_FACTORY_ADDRESS, + VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS, } from 'utils/constants' import type { TokenInfo } from './token' @@ -85,3 +91,54 @@ export const openEditionMinterList = [ openEditionIbcUsdcMinter, openEditionUpdatableIbcUsdcMinter, ] + +export const vendingStarsMinter: MinterInfo = { + id: 'vending-stars-minter', + factoryAddress: VENDING_FACTORY_ADDRESS, + supportedToken: stars, + updatable: false, +} + +export const vendingUpdatableStarsMinter: MinterInfo = { + id: 'vending-updatable-stars-minter', + factoryAddress: VENDING_FACTORY_UPDATABLE_ADDRESS, + supportedToken: stars, + updatable: true, +} + +export const vendingIbcAtomMinter: MinterInfo = { + id: 'vending-ibc-atom-minter', + factoryAddress: VENDING_IBC_ATOM_FACTORY_ADDRESS, + supportedToken: ibcAtom, + updatable: false, +} + +export const vendingUpdatableIbcAtomMinter: MinterInfo = { + id: 'vending-updatable-ibc-atom-minter', + factoryAddress: VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS, + supportedToken: ibcAtom, + updatable: true, +} + +export const vendingIbcUsdcMinter: MinterInfo = { + id: 'vending-ibc-usdc-minter', + factoryAddress: VENDING_IBC_USDC_FACTORY_ADDRESS, + supportedToken: ibcUsdc, + updatable: false, +} + +export const vendingUpdatableIbcUsdcMinter: MinterInfo = { + id: 'vending-updatable-ibc-usdc-minter', + factoryAddress: VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS, + supportedToken: ibcUsdc, + updatable: true, +} + +export const vendingMinterList = [ + vendingStarsMinter, + vendingUpdatableStarsMinter, + vendingIbcAtomMinter, + vendingUpdatableIbcAtomMinter, + vendingIbcUsdcMinter, + vendingUpdatableIbcUsdcMinter, +] diff --git a/env.d.ts b/env.d.ts index 72e2935..1325002 100644 --- a/env.d.ts +++ b/env.d.ts @@ -23,6 +23,10 @@ declare namespace NodeJS { readonly NEXT_PUBLIC_VENDING_MINTER_CODE_ID: string readonly NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string diff --git a/utils/constants.ts b/utils/constants.ts index 2f0e607..01b8a8a 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -12,6 +12,12 @@ export const VENDING_MINTER_FLEX_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VEND export const VENDING_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_ADDRESS export const VENDING_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS export const VENDING_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS +export const VENDING_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS +export const VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS = + process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS +export const VENDING_IBC_USDC_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS +export const VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS = + process.env.NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS export const BASE_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS export const OPEN_EDITION_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS From 3621a7363e3f2ea4bb95d1c26856a8b01077f3cd Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Tue, 1 Aug 2023 11:26:24 +0300 Subject: [PATCH 10/24] Add mint denom selection for standard collections --- .../collections/creation/MintingDetails.tsx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index 6ca136e..e6555f1 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -4,6 +4,9 @@ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' import { InputDateTime } from 'components/InputDateTime' +import { vendingMinterList } from 'config/minter' +import type { TokenInfo } from 'config/token' +import { stars, tokensList } from 'config/token' import React, { useEffect, useState } from 'react' import { resolveAddress } from 'utils/resolveAddress' @@ -24,12 +27,14 @@ export interface MintingDetailsDataProps { perAddressLimit: number startTime: string paymentAddress?: string + selectedMintToken?: TokenInfo } export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimumMintPrice }: MintingDetailsProps) => { const wallet = useWallet() const [timestamp, setTimestamp] = useState() + const [selectedMintToken, setSelectedMintToken] = useState(stars) const numberOfTokensState = useNumberInputState({ id: 'numberoftokens', @@ -85,6 +90,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum perAddressLimit: perAddressLimitState.value, startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '', paymentAddress: paymentAddressState.value.trim(), + selectedMintToken, } onChange(data) // eslint-disable-next-line react-hooks/exhaustive-deps @@ -95,6 +101,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum perAddressLimitState.value, timestamp, paymentAddressState.value, + selectedMintToken, ]) return ( @@ -106,7 +113,22 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum isRequired value={uploadMethod === 'new' ? numberOfTokens : numberOfTokensState.value} /> - +
+ + +
+ setTimestamp(date)} value={timestamp} /> From 180eb914b3025a904d521bd9ef73a9cae3109b5b Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 2 Aug 2023 22:56:41 +0300 Subject: [PATCH 11/24] Fetch vending factory parameters wrt selected mint denom --- pages/collections/create.tsx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 42573f7..d03115e 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -33,7 +33,7 @@ import { Conditional } from 'components/Conditional' import { LoadingModal } from 'components/LoadingModal' import type { OpenEditionMinterCreatorDataProps } from 'components/openEdition/OpenEditionMinterCreator' import { OpenEditionMinterCreator } from 'components/openEdition/OpenEditionMinterCreator' -import { openEditionMinterList } from 'config/minter' +import { flexibleVendingMinterList, openEditionMinterList, vendingMinterList } from 'config/minter' import type { TokenInfo } from 'config/token' import { useContracts } from 'contexts/contracts' import { addLogItem } from 'contexts/log' @@ -129,6 +129,7 @@ const CollectionCreationPage: NextPage = () => { const [minimumFlexMintPrice, setMinimumFlexMintPrice] = useState('0') const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState(stars) + const [mintTokenFromVendingFactory, setMintTokenFromVendingFactory] = useState(stars) const [uploading, setUploading] = useState(false) const [isMintingComplete, setIsMintingComplete] = useState(false) @@ -540,7 +541,7 @@ const CollectionCreationPage: NextPage = () => { payment_address: mintingDetails?.paymentAddress ? mintingDetails.paymentAddress : undefined, mint_price: { amount: mintingDetails?.unitPrice, - denom: 'ustars', + denom: (mintTokenFromVendingFactory?.denom as string) || 'ustars', }, per_address_limit: mintingDetails?.perAddressLimit, whitelist, @@ -1185,6 +1186,34 @@ const CollectionCreationPage: NextPage = () => { wallet.client, ]) + const fetchVendingFactoryParameters = useCallback(async () => { + const client = wallet.client + if (!client) return + const vendingFactoryForSelectedDenom = vendingMinterList + .concat(flexibleVendingMinterList) + .find( + (minter) => + minter.supportedToken === mintingDetails?.selectedMintToken && + minter.updatable === collectionDetails?.updatable && + minter.flexible === (whitelistDetails?.whitelistType === 'flex'), + )?.factoryAddress + if (vendingFactoryForSelectedDenom) { + const vendingFactoryParameters = await client + .queryContractSmart(vendingFactoryForSelectedDenom, { params: {} }) + .catch((error) => { + toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) + addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) + }) + setVendingMinterCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) + if (!collectionDetails?.updatable) { + setMinimumMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount) + setMintTokenFromVendingFactory( + tokensList.find((token) => token.denom === vendingFactoryParameters?.params?.min_mint_price?.denom), + ) + } + } + }, [collectionDetails?.updatable, mintingDetails?.selectedMintToken, tokensList, whitelistDetails?.whitelistType]) + const checkwalletBalance = async () => { const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => { if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) { From 15427072e4acfa7e83716aa06c431637540b08bf Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 6 Aug 2023 16:53:02 +0300 Subject: [PATCH 12/24] Add flexible factories to the minter list --- .env.example | 4 +++ config/minter.ts | 70 ++++++++++++++++++++++++++++++++++++++++++++++ env.d.ts | 9 ++++-- utils/constants.ts | 7 +++++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 538335d..45ed4b3 100644 --- a/.env.example +++ b/.env.example @@ -15,6 +15,10 @@ NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" +NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" NEXT_PUBLIC_BASE_FACTORY_ADDRESS="stars1a45hcxty3spnmm2f0papl8v4dk5ew29s4syhn4efte8u5haex99qlkrtnx" NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS="stars100xegx2syry4tclkmejjwxk4nfqahvcqhm9qxut5wxuzhj5d9qfsh5nmym" NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e" diff --git a/config/minter.ts b/config/minter.ts index b7d359f..02ebc5b 100644 --- a/config/minter.ts +++ b/config/minter.ts @@ -8,11 +8,17 @@ import { OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS, OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS, VENDING_FACTORY_ADDRESS, + VENDING_FACTORY_FLEX_ADDRESS, VENDING_FACTORY_UPDATABLE_ADDRESS, + VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS, VENDING_IBC_ATOM_FACTORY_ADDRESS, + VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS, VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS, + VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS, VENDING_IBC_USDC_FACTORY_ADDRESS, + VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS, VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS, + VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS, } from 'utils/constants' import type { TokenInfo } from './token' @@ -23,6 +29,7 @@ export interface MinterInfo { factoryAddress: string supportedToken: TokenInfo updatable?: boolean + flexible?: boolean } export const openEditionStarsMinter: MinterInfo = { @@ -97,6 +104,7 @@ export const vendingStarsMinter: MinterInfo = { factoryAddress: VENDING_FACTORY_ADDRESS, supportedToken: stars, updatable: false, + flexible: false, } export const vendingUpdatableStarsMinter: MinterInfo = { @@ -104,6 +112,7 @@ export const vendingUpdatableStarsMinter: MinterInfo = { factoryAddress: VENDING_FACTORY_UPDATABLE_ADDRESS, supportedToken: stars, updatable: true, + flexible: false, } export const vendingIbcAtomMinter: MinterInfo = { @@ -111,6 +120,7 @@ export const vendingIbcAtomMinter: MinterInfo = { factoryAddress: VENDING_IBC_ATOM_FACTORY_ADDRESS, supportedToken: ibcAtom, updatable: false, + flexible: false, } export const vendingUpdatableIbcAtomMinter: MinterInfo = { @@ -118,6 +128,7 @@ export const vendingUpdatableIbcAtomMinter: MinterInfo = { factoryAddress: VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS, supportedToken: ibcAtom, updatable: true, + flexible: false, } export const vendingIbcUsdcMinter: MinterInfo = { @@ -125,6 +136,7 @@ export const vendingIbcUsdcMinter: MinterInfo = { factoryAddress: VENDING_IBC_USDC_FACTORY_ADDRESS, supportedToken: ibcUsdc, updatable: false, + flexible: false, } export const vendingUpdatableIbcUsdcMinter: MinterInfo = { @@ -132,6 +144,7 @@ export const vendingUpdatableIbcUsdcMinter: MinterInfo = { factoryAddress: VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS, supportedToken: ibcUsdc, updatable: true, + flexible: false, } export const vendingMinterList = [ @@ -142,3 +155,60 @@ export const vendingMinterList = [ vendingIbcUsdcMinter, vendingUpdatableIbcUsdcMinter, ] + +export const flexibleVendingStarsMinter: MinterInfo = { + id: 'flexible-vending-stars-minter', + factoryAddress: VENDING_FACTORY_FLEX_ADDRESS, + supportedToken: stars, + updatable: false, + flexible: true, +} + +export const flexibleVendingUpdatableStarsMinter: MinterInfo = { + id: 'flexible-vending-updatable-stars-minter', + factoryAddress: VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS, + supportedToken: stars, + updatable: true, + flexible: true, +} + +export const flexibleVendingIbcAtomMinter: MinterInfo = { + id: 'flexible-vending-ibc-atom-minter', + factoryAddress: VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS, + supportedToken: ibcAtom, + updatable: false, + flexible: true, +} + +export const flexibleVendingUpdatableIbcAtomMinter: MinterInfo = { + id: 'flexible-vending-updatable-ibc-atom-minter', + factoryAddress: VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS, + supportedToken: ibcAtom, + updatable: true, + flexible: true, +} + +export const flexibleVendingIbcUsdcMinter: MinterInfo = { + id: 'flexible-vending-ibc-usdc-minter', + factoryAddress: VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS, + supportedToken: ibcUsdc, + updatable: false, + flexible: true, +} + +export const flexibleVendingUpdatableIbcUsdcMinter: MinterInfo = { + id: 'flexible-vending-updatable-ibc-usdc-minter', + factoryAddress: VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS, + supportedToken: ibcUsdc, + updatable: true, + flexible: true, +} + +export const flexibleVendingMinterList = [ + flexibleVendingStarsMinter, + flexibleVendingUpdatableStarsMinter, + flexibleVendingIbcAtomMinter, + flexibleVendingUpdatableIbcAtomMinter, + flexibleVendingIbcUsdcMinter, + flexibleVendingUpdatableIbcUsdcMinter, +] diff --git a/env.d.ts b/env.d.ts index 1325002..d41c8e5 100644 --- a/env.d.ts +++ b/env.d.ts @@ -23,10 +23,17 @@ declare namespace NodeJS { readonly NEXT_PUBLIC_VENDING_MINTER_CODE_ID: string readonly NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID: string readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS: string readonly NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS: string + readonly NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string @@ -36,8 +43,6 @@ declare namespace NodeJS { readonly NEXT_PUBLIC_OPEN_EDITION_IBC_FRENZ_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRENZ_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID: string - readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS: string - readonly NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS: string readonly NEXT_PUBLIC_BASE_FACTORY_ADDRESS: string readonly NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS: string readonly NEXT_PUBLIC_SG721_NAME_ADDRESS: string diff --git a/utils/constants.ts b/utils/constants.ts index 01b8a8a..8b919ed 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -12,12 +12,19 @@ export const VENDING_MINTER_FLEX_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VEND export const VENDING_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_ADDRESS export const VENDING_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS export const VENDING_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS +export const VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS export const VENDING_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS export const VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS export const VENDING_IBC_USDC_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS export const VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS +export const VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS +export const VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS = + process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS +export const VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS +export const VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS = + process.env.NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS export const BASE_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS export const OPEN_EDITION_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS From ade9410a91764ec618c85d5ba934bdf1abdef3ab Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 6 Aug 2023 17:24:51 +0300 Subject: [PATCH 13/24] Fetch and display factory denom for minimum mint price --- components/collections/creation/MintingDetails.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index e6555f1..22f802f 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -19,6 +19,7 @@ interface MintingDetailsProps { numberOfTokens: number | undefined uploadMethod: UploadMethod minimumMintPrice: number + mintingTokenFromFactory?: TokenInfo } export interface MintingDetailsDataProps { @@ -30,7 +31,13 @@ export interface MintingDetailsDataProps { selectedMintToken?: TokenInfo } -export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimumMintPrice }: MintingDetailsProps) => { +export const MintingDetails = ({ + onChange, + numberOfTokens, + uploadMethod, + minimumMintPrice, + mintingTokenFromFactory, +}: MintingDetailsProps) => { const wallet = useWallet() const [timestamp, setTimestamp] = useState() @@ -48,7 +55,9 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum id: 'unitPrice', name: 'unitPrice', title: 'Unit Price', - subtitle: `Price of each token (min. ${minimumMintPrice} STARS)`, + subtitle: `Price of each token (min. ${minimumMintPrice} ${ + mintingTokenFromFactory ? mintingTokenFromFactory.displayName : 'STARS' + })`, placeholder: '50', }) From 8aaff3823877825f18ffc1c99e021abf5597e4ca Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 6 Aug 2023 18:44:22 +0300 Subject: [PATCH 14/24] Instantiate vending minter wrt selected denom --- contracts/vendingFactory/contract.ts | 14 +---- pages/collections/create.tsx | 90 ++++++++++++++++++---------- 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/contracts/vendingFactory/contract.ts b/contracts/vendingFactory/contract.ts index 30f59d0..af41418 100644 --- a/contracts/vendingFactory/contract.ts +++ b/contracts/vendingFactory/contract.ts @@ -1,11 +1,8 @@ /* eslint-disable eslint-comments/disable-enable-pair */ -/* eslint-disable no-nested-ternary */ + import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' import type { Coin } from '@cosmjs/proto-signing' import type { logs } from '@cosmjs/stargate' -import { VENDING_FACTORY_ADDRESS, VENDING_FACTORY_FLEX_ADDRESS } from 'utils/constants' - -import { VENDING_FACTORY_UPDATABLE_ADDRESS } from '../../utils/constants' export interface CreateVendingMinterResponse { readonly vendingMinterAddress: string @@ -63,14 +60,7 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string): updatable?: boolean, flex?: boolean, ): Promise => { - const result = await client.execute( - senderAddress, - flex ? VENDING_FACTORY_FLEX_ADDRESS : updatable ? VENDING_FACTORY_UPDATABLE_ADDRESS : VENDING_FACTORY_ADDRESS, - msg, - 'auto', - '', - funds, - ) + const result = await client.execute(senderAddress, contractAddress, msg, 'auto', '', funds) return { vendingMinterAddress: result.logs[0].events[5].attributes[0].value, diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index d03115e..c29bd28 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -90,16 +90,6 @@ const CollectionCreationPage: NextPage = () => { const scrollRef = useRef(null) const sidetabRef = useRef(null) - const vendingFactoryMessages = useMemo( - () => vendingFactoryContract?.use(VENDING_FACTORY_ADDRESS), - [vendingFactoryContract, wallet.address], - ) - - const baseFactoryMessages = useMemo( - () => baseFactoryContract?.use(BASE_FACTORY_ADDRESS), - [baseFactoryContract, wallet.address], - ) - const [uploadDetails, setUploadDetails] = useState(null) const [collectionDetails, setCollectionDetails] = useState(null) const [baseMinterDetails, setBaseMinterDetails] = useState(null) @@ -130,6 +120,17 @@ const CollectionCreationPage: NextPage = () => { const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState(stars) const [mintTokenFromVendingFactory, setMintTokenFromVendingFactory] = useState(stars) + const [vendingFactoryAddress, setVendingFactoryAddress] = useState(VENDING_FACTORY_ADDRESS) + + const vendingFactoryMessages = useMemo( + () => vendingFactoryContract?.use(vendingFactoryAddress as string), + [vendingFactoryContract, wallet.address], + ) + + const baseFactoryMessages = useMemo( + () => baseFactoryContract?.use(BASE_FACTORY_ADDRESS), + [baseFactoryContract, wallet.address], + ) const [uploading, setUploading] = useState(false) const [isMintingComplete, setIsMintingComplete] = useState(false) @@ -547,11 +548,7 @@ const CollectionCreationPage: NextPage = () => { whitelist, }, collection_params: { - code_id: collectionDetails?.updatable - ? whitelistDetails?.whitelistType === 'flex' - ? SG721_CODE_ID - : SG721_UPDATABLE_CODE_ID - : SG721_CODE_ID, + code_id: collectionDetails?.updatable ? SG721_CODE_ID : SG721_UPDATABLE_CODE_ID, name: collectionDetails?.name, symbol: collectionDetails?.symbol, info: { @@ -572,12 +569,7 @@ const CollectionCreationPage: NextPage = () => { } const payload: VendingFactoryDispatchExecuteArgs = { - contract: - whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex' - ? VENDING_FACTORY_FLEX_ADDRESS - : collectionDetails?.updatable - ? VENDING_FACTORY_UPDATABLE_ADDRESS - : VENDING_FACTORY_ADDRESS, + contract: vendingFactoryAddress as string, messages: vendingFactoryMessages, txSigner: wallet.address, msg, @@ -912,14 +904,24 @@ const CollectionCreationPage: NextPage = () => { if (mintingDetails.unitPrice === '') throw new Error('Public mint price is required') if (whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex') { if (Number(mintingDetails.unitPrice) < Number(minimumFlexMintPrice)) - throw new Error(`Invalid unit price: The minimum unit price is ${Number(minimumFlexMintPrice) / 1000000} STARS`) + throw new Error( + `Invalid unit price: The minimum unit price is ${Number(minimumFlexMintPrice) / 1000000} ${ + mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS' + }`, + ) } else if (collectionDetails?.updatable) { if (Number(mintingDetails.unitPrice) < Number(minimumUpdatableMintPrice)) throw new Error( - `Invalid unit price: The minimum unit price is ${Number(minimumUpdatableMintPrice) / 1000000} STARS`, + `Invalid unit price: The minimum unit price is ${Number(minimumUpdatableMintPrice) / 1000000} ${ + mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS' + }`, ) } else if (Number(mintingDetails.unitPrice) < Number(minimumMintPrice)) - throw new Error(`Invalid unit price: The minimum unit price is ${Number(minimumMintPrice) / 1000000} STARS`) + throw new Error( + `Invalid unit price: The minimum unit price is ${Number(minimumMintPrice) / 1000000} ${ + mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS' + }`, + ) if ( !mintingDetails.perAddressLimit || mintingDetails.perAddressLimit < 1 || @@ -1128,7 +1130,7 @@ const CollectionCreationPage: NextPage = () => { addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) }) setOpenEditionMinterUpdatableCreationFee(openEditionUpdatableFactoryParameters?.params?.creation_fee?.amount) - setMinimumOpenEditionMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount) + setMinimumOpenEditionUpdatableMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount) } } @@ -1187,8 +1189,10 @@ const CollectionCreationPage: NextPage = () => { ]) const fetchVendingFactoryParameters = useCallback(async () => { + console.log('Here') const client = wallet.client if (!client) return + console.log('Selected Token: ', mintingDetails?.selectedMintToken) const vendingFactoryForSelectedDenom = vendingMinterList .concat(flexibleVendingMinterList) .find( @@ -1197,22 +1201,38 @@ const CollectionCreationPage: NextPage = () => { minter.updatable === collectionDetails?.updatable && minter.flexible === (whitelistDetails?.whitelistType === 'flex'), )?.factoryAddress + console.log(vendingFactoryForSelectedDenom) if (vendingFactoryForSelectedDenom) { + setVendingFactoryAddress(vendingFactoryForSelectedDenom) const vendingFactoryParameters = await client .queryContractSmart(vendingFactoryForSelectedDenom, { params: {} }) .catch((error) => { toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) }) - setVendingMinterCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) - if (!collectionDetails?.updatable) { + + if (whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex') { + setVendingMinterFlexCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) + setMinimumFlexMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount) + } else if (collectionDetails?.updatable) { + setVendingMinterUpdatableCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) + setMinimumUpdatableMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount) + } else { + setVendingMinterCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) setMinimumMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount) - setMintTokenFromVendingFactory( - tokensList.find((token) => token.denom === vendingFactoryParameters?.params?.min_mint_price?.denom), - ) } + + setMintTokenFromVendingFactory( + tokensList.find((token) => token.denom === vendingFactoryParameters?.params?.min_mint_price?.denom), + ) } - }, [collectionDetails?.updatable, mintingDetails?.selectedMintToken, tokensList, whitelistDetails?.whitelistType]) + }, [ + collectionDetails?.updatable, + mintingDetails?.selectedMintToken, + wallet.client, + whitelistDetails?.whitelistState, + whitelistDetails?.whitelistType, + ]) const checkwalletBalance = async () => { const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => { @@ -1309,6 +1329,10 @@ const CollectionCreationPage: NextPage = () => { void fetchOpenEditionFactoryParameters() }, [fetchOpenEditionFactoryParameters]) + useEffect(() => { + void fetchVendingFactoryParameters() + }, [fetchVendingFactoryParameters]) + return (
{ Date: Sun, 6 Aug 2023 21:09:43 +0300 Subject: [PATCH 15/24] Update whitelist mint price denom wrt selected denom --- .../collections/creation/MintingDetails.tsx | 2 +- .../collections/creation/WhitelistDetails.tsx | 8 ++++++-- pages/collections/create.tsx | 15 +++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index 22f802f..8246327 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -125,7 +125,7 @@ export const MintingDetails = ({