-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b544963
commit e624551
Showing
93 changed files
with
23,125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useCustomGallerySBT = (masa, customGallerySBT): any[] => { | ||
const [contracts, setContracts] = useState<any[]>(); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if (customGallerySBT && customGallerySBT.length) { | ||
const contracts: any[] = []; | ||
for (const sbt of customGallerySBT) { | ||
const sbtContract = await masa?.sbt.connect(sbt.address); | ||
contracts.push({ ...sbtContract, ...sbt }); | ||
} | ||
setContracts(contracts); | ||
} | ||
})(); | ||
}, [customGallerySBT, masa]); | ||
|
||
return contracts ?? []; | ||
}; | ||
|
||
export const useCustomSBT = (masa, customContracts) => { | ||
const [hidratatedSBTs, setHidratatedSBTs] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const contracts = customContracts; | ||
const hidratatedContracts: any[] = []; | ||
for (const contract of contracts) { | ||
const tokens: any[] = await contract.list(); | ||
const hidratatedTokens: any[] = []; | ||
if (contract.getMetadata) { | ||
for (const token of tokens) { | ||
try { | ||
const metadata = await contract.getMetadata(token); | ||
hidratatedTokens.push({ metadata, ...token }); | ||
} catch (e) { | ||
console.log('METADTA ERROR', e); | ||
} | ||
} | ||
} | ||
|
||
hidratatedContracts.push({ ...contract, tokens: hidratatedTokens }); | ||
} | ||
setHidratatedSBTs(hidratatedContracts); | ||
})(); | ||
}, [masa]); | ||
|
||
return hidratatedSBTs; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { useCustomSBT, useCustomGallerySBT } from './custom-sbts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type * as masaContractsIdentity from "./masa-contracts-identity"; | ||
export type { masaContractsIdentity }; |
Oops, something went wrong.