Skip to content

Commit

Permalink
Adding network target in gallery SBTs
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Jun 9, 2023
1 parent 3c1228f commit 2e00a61
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
58 changes: 35 additions & 23 deletions src/components/masa-interface/pages/gallery/gallery.stories.tsx
Expand Up @@ -7,6 +7,7 @@ import { GalleryItem } from './galleryItem';
const customRenderWhaleSBT = {
name: 'Solid World Whale SBT',
address: '0xd843fB69473F77fF45502e1EB8733B6DD7feC98F',
network: "polygon",
getMetadata: async function (sbt: { tokenId: string; tokenUri: string }) {
const apiUrl = sbt.tokenUri.replace('.json', '');

Expand All @@ -18,44 +19,54 @@ const customRenderWhaleSBT = {
},
};

const customRenderWhaleSBTProduction = {
name: 'Solid World Whale SBT Production',
address: '0xbf060cdfc820cbdafa6313fdb0807944b99a03b7',
const DackieSBT = {
name: 'Dackies SBT',
address: '0xbA444542E493Ed497D9Ef7f2ed596244a1952Ba2',
network: "polygon",
getMetadata: async function (sbt: { tokenId: string; tokenUri: string }) {
const apiUrl = sbt.tokenUri.replace('.json', '');

return {
name: 'Solid World Whale SBT',
image: apiUrl,
name: 'Dackie quack SBT',
image: sbt.tokenUri,
description: 'Verified Discord member',
};
},
};

const customPokeSBT = {
name: 'PokeSBT',
address: '0xa0f3c1971a4d4ec4Ef3983cce75B567a9004eF1B',
const AmbassadorOGSBT = {
name: 'Masa Ambassador OG SBT',
address: '0x376f5039Df4e9E9c864185d8FaBad4f04A7E394A',
network: 'polygon',
getMetadata: async function (sbt: { tokenId: string; tokenUri: string }) {
const apiUrl = sbt.tokenUri.replace('.json', '');
const apiResponse = await fetch(apiUrl, { mode: 'cors' });
const data = await apiResponse.json();
return {
name: 'Masa Ambassador OG SBT',
image: sbt.tokenUri,
description: 'Ambassador Token',
};
},
};

const AmbassadorSBT = {
name: 'Masa Ambassador SBT',
address: '0x3F1EFED96Eb7f98F0618136133D795F5997ECEf4',
network: 'polygon',
getMetadata: async function (sbt: { tokenId: string; tokenUri: string }) {
return {
name: data.name,
image: data.image,
description: '',
name: 'Masa Ambassador SBT',
image: sbt.tokenUri,
description: 'Ambassador Token',
};
},
};

const DackieSBT = {
name: 'Dackies SBT',
address: '0xbA444542E493Ed497D9Ef7f2ed596244a1952Ba2',
const GoodDollarSBT = {
name: 'Good Dollar SBT',
address: '0x3F1EFED96Eb7f98F0618136133D795F5997ECEf4',
network: 'celo',
getMetadata: async function (sbt: { tokenId: string; tokenUri: string }) {
return {
name: 'Dackie quack SBT',
name: 'Good Dollar SBT',
image: sbt.tokenUri,
description: 'Verified Discord member',
description: 'Good Dollar Token',
};
},
};
Expand All @@ -71,9 +82,10 @@ const meta: Meta = {
company={'Masa'}
customGallerySBT={[
DackieSBT,
customRenderWhaleSBTProduction,
customPokeSBT,
customRenderWhaleSBT,
GoodDollarSBT,
AmbassadorSBT,
AmbassadorOGSBT,
]}
>
<div className="masa-modal">
Expand Down
1 change: 1 addition & 0 deletions src/components/masa-interface/pages/gallery/gallery.tsx
Expand Up @@ -33,6 +33,7 @@ export interface Tabs {
export interface CustomGallerySBT {
name: string;
address: string;
network: string;
getMetadata: (item: { tokenId; tokenUri }) => Promise<{
image: string;
name: string;
Expand Down
7 changes: 6 additions & 1 deletion src/provider/modules/custom-sbts/custom-sbts.ts
Expand Up @@ -43,6 +43,11 @@ const fetchContracts = async (masa, customGallerySBT) => {
if (customGallerySBT && customGallerySBT.length > 0) {
const newContracts: any[] = [];
for (const sbt of customGallerySBT) {
if (sbt.networks) {
if (sbt.network !== masa.config.networkName) {
continue;
}
}
try {
const sbtContract = await masa?.sbt.connect(sbt.address);

Expand Down Expand Up @@ -171,7 +176,7 @@ export const useCustomSBTsQuery = ({
async () => queryClient.invalidateQueries(['custom-sbt']),
[]
);

return {
customSBTs,
status,
Expand Down

0 comments on commit 2e00a61

Please sign in to comment.