From 2abbbdb1a5339ac4d053e7d976196d23c5fcb191 Mon Sep 17 00:00:00 2001 From: Norman Meier Date: Sat, 17 Feb 2024 20:13:09 +0100 Subject: [PATCH] feat: get info from collection in indexer and hook Signed-off-by: Norman Meier --- .env | 2 +- go/internal/indexerhandler/premium_feed.go | 20 ++++++++++++++++++-- networks.json | 2 +- packages/hooks/useCollectionInfo.ts | 15 --------------- packages/hooks/useNFTInfo.ts | 4 ++-- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.env b/.env index be593b2a2a..4871afd1ca 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ INDEXER_NETWORK_ID=teritori-testnet TERITORI_MINTER_CODE_IDS=10 TENDERMINT_WEBSOCKET_ENDPOINT=wss://rpc.testnet.teritori.com/websocket -TERITORI_COLLECTION_WHITELIST=tori1qv4yn5rpu8v6sdgxww65rdpftujuzdgw5xw3tffhf633qxrzuemqgxctfl,0x43cc70bf324d716782628bed38af97e4afe92f69,0x916ad9d549907ccbbaf9ba65526826bfc3a9c0c4,tori162skshe30f43kv2q2rw6we2mu3pvz43lm2zrg4hq50jdd2fjjdjsvm8mc7,tori1zxzv4j9dxarfhxhkxm5cfnv06vy6g4l80adjwaq3dxdzmh5jm8rsrkzz65,tori18etjzrma5604af50jjklk3wlkqcsxdrvmy6jzw5naw2t7kyv4rys3kpwky,tori10z8um7u47e24rv68ghd43tspeztmqy3cc283gvc3pj48zxs5ljdqn84deq,tori1afwrcs58afaka6ltynevwcvq8zhejr3ssn703c0hky5emh890vzsry5wp5 +TERITORI_COLLECTION_WHITELIST=tori1gelslcq8jg38rl69xvjmt6j560ks9fypldke5g9er06jgy5n535s048jg5,0x43cc70bf324d716782628bed38af97e4afe92f69,0x916ad9d549907ccbbaf9ba65526826bfc3a9c0c4,tori162skshe30f43kv2q2rw6we2mu3pvz43lm2zrg4hq50jdd2fjjdjsvm8mc7,tori1zxzv4j9dxarfhxhkxm5cfnv06vy6g4l80adjwaq3dxdzmh5jm8rsrkzz65,tori18etjzrma5604af50jjklk3wlkqcsxdrvmy6jzw5naw2t7kyv4rys3kpwky,tori10z8um7u47e24rv68ghd43tspeztmqy3cc283gvc3pj48zxs5ljdqn84deq,tori1afwrcs58afaka6ltynevwcvq8zhejr3ssn703c0hky5emh890vzsry5wp5 PUBLIC_TENOR_KEY=AIzaSyA8TpVfoyoBaDdLww6wJ1Xe0OVN-Hi8qPE diff --git a/go/internal/indexerhandler/premium_feed.go b/go/internal/indexerhandler/premium_feed.go index 87057d10cb..631128d4f7 100644 --- a/go/internal/indexerhandler/premium_feed.go +++ b/go/internal/indexerhandler/premium_feed.go @@ -10,6 +10,17 @@ import ( "go.uber.org/zap" ) +// TODO: handle collection config update + +type PremiumFeedInstantiateMsg struct { + AdminAddr string `json:"admin_addr"` + MintRoyalties uint16 `json:"mint_royalties"` + Name string `json:"name"` + Description string `json:"description"` + ImageURI string `json:"image_uri"` + Symbol string `json:"symbol"` +} + func (h *Handler) handleInstantiatePremiumFeedMemberships(e *Message, instantiateMsg *wasmtypes.MsgInstantiateContract) error { contractAddress, err := e.Events.First("instantiate._contract_address") if err != nil { @@ -28,6 +39,11 @@ func (h *Handler) handleInstantiatePremiumFeedMemberships(e *Message, instantiat return nil } + var instantiateData PremiumFeedInstantiateMsg + if err := json.Unmarshal(instantiateMsg.Msg, &instantiateData); err != nil { + return errors.Wrap(err, "failed to unmarshal instantiate msg") + } + blockTime, err := e.GetBlockTime() if err != nil { return errors.Wrap(err, "failed to get block time") @@ -36,8 +52,8 @@ func (h *Handler) handleInstantiatePremiumFeedMemberships(e *Message, instantiat collection := indexerdb.Collection{ ID: h.config.Network.CollectionID(contractAddress), NetworkID: h.config.Network.ID, - Name: "Premium Memberships", - ImageURI: "", + Name: instantiateData.Name, + ImageURI: instantiateData.ImageURI, MaxSupply: -1, SecondaryDuringMint: true, Time: blockTime, diff --git a/networks.json b/networks.json index 32ec49081e..8f3b24c9f1 100644 --- a/networks.json +++ b/networks.json @@ -10939,7 +10939,7 @@ "featureObjects": [ { "type": "CosmWasmPremiumFeed", - "membershipContractAddress": "tori1qv4yn5rpu8v6sdgxww65rdpftujuzdgw5xw3tffhf633qxrzuemqgxctfl", + "membershipContractAddress": "tori1gelslcq8jg38rl69xvjmt6j560ks9fypldke5g9er06jgy5n535s048jg5", "mintDenom": "utori" } ], diff --git a/packages/hooks/useCollectionInfo.ts b/packages/hooks/useCollectionInfo.ts index 7676f44839..28278a14cb 100644 --- a/packages/hooks/useCollectionInfo.ts +++ b/packages/hooks/useCollectionInfo.ts @@ -393,18 +393,3 @@ const usePremiumFeedCollectionInfo = ( return { info, notFound: false, refetch }; }; - -/* - -Premium membership cards are held by premium creator subscribers and unlock content reserved for creator communities. - -By owning a creator's premium membership card: - -- you support the creation of their content -- you have privileged access to their creations -- access to a privileged link with the creator -- you participate in the global economy of Teritori OS, which charges fees that are reinvested in the $TORI token. -- you develop the Teritori ecosystem and help finance the radical resilience of tomorrow's communities -- you benefit from potential future advantages on all Teritori OS features (whitelist, airdrops, early access on new features, alpha information, etc.). - -*/ diff --git a/packages/hooks/useNFTInfo.ts b/packages/hooks/useNFTInfo.ts index f3880a3a94..2085f03947 100644 --- a/packages/hooks/useNFTInfo.ts +++ b/packages/hooks/useNFTInfo.ts @@ -564,9 +564,9 @@ const getPremiumFeedNFTInfo = async ( isOwner, isSeller: vaultInfo.isListed && isOwner, isListed: vaultInfo.isListed, - collectionName: "Premium Memberships", + collectionName: "Premium Memberships", // FIXME: get from collection config collectionImageURL: - "ipfs://bafybeiaznarsgwk7stav6qrzjnwqw4j7eu7drm3xx4p3fokgsnrouelse4", + "ipfs://bafybeiaznarsgwk7stav6qrzjnwqw4j7eu7drm3xx4p3fokgsnrouelse4", // FIXME: get from collection config mintDenom: "", royalty: 0, networkId: network.id,