diff --git a/apps/web/pages/api/auth/[...nextauth].ts b/apps/web/pages/api/auth/[...nextauth].ts index 64e9962e..aac6417e 100644 --- a/apps/web/pages/api/auth/[...nextauth].ts +++ b/apps/web/pages/api/auth/[...nextauth].ts @@ -55,7 +55,7 @@ export function getAuthOptions(req: IncomingMessage): NextAuthOptions { id: siwe.address, } } catch (_e) { - console.log(_e) + console.error(_e) return null } }, diff --git a/apps/web/pages/api/v0/course/index.ts b/apps/web/pages/api/v0/course/index.ts index d603b5cb..6a45fc71 100644 --- a/apps/web/pages/api/v0/course/index.ts +++ b/apps/web/pages/api/v0/course/index.ts @@ -47,7 +47,7 @@ const handleGetRequest = async ( .status(200) .json({ status: ApiResponseStatus.success, data: { course: course } }) } catch (error) { - console.log(error) + console.error(error) return res.status(500).json({ status: ApiResponseStatus.error, message: @@ -86,35 +86,47 @@ const handlePostRequest = async ( const karmaAccessControlAddress = karmaAccessControlCreatedLogDecoded.args.karmaAccessControl - const [symbol, baseURI, baseMagisterKarma, baseDiscipulusKarma] = - await Promise.all([ - client.readContract({ - address: courseContractAddress, - abi: CredentialsBurnableAbi, - functionName: 'symbol', - }), - client.readContract({ - address: courseContractAddress, - abi: CredentialsBurnableAbi, - functionName: 'baseURI', - }), - client.readContract({ - address: karmaAccessControlAddress, - abi: KarmaAccessControlAbiUint64, - functionName: 'BASE_MAGISTER_KARMA', - }), - client.readContract({ - address: karmaAccessControlAddress, - abi: KarmaAccessControlAbiUint64, - functionName: 'BASE_DISCIPULUS_KARMA', - }), - ]) + const [ + symbol, + baseURI, + contractURI, + baseMagisterKarma, + baseDiscipulusKarma, + ] = await Promise.all([ + client.readContract({ + address: courseContractAddress, + abi: CredentialsBurnableAbi, + functionName: 'symbol', + }), + client.readContract({ + address: courseContractAddress, + abi: CredentialsBurnableAbi, + functionName: 'baseURI', + }), + client.readContract({ + address: courseContractAddress, + abi: CredentialsBurnableAbi, + functionName: 'contractURI', + }), + client.readContract({ + address: karmaAccessControlAddress, + abi: KarmaAccessControlAbiUint64, + functionName: 'BASE_MAGISTER_KARMA', + }), + client.readContract({ + address: karmaAccessControlAddress, + abi: KarmaAccessControlAbiUint64, + functionName: 'BASE_DISCIPULUS_KARMA', + }), + ]) const timestamp = ( await client.getBlock({ blockNumber: txReceipt.blockNumber }) ).timestamp - const metadataResponse = await fetch(baseURI) + const metadataURL = baseURI + contractURI + + const metadataResponse = await fetch(metadataURL) if (!metadataResponse.ok) { return res.status(500).json({ @@ -149,7 +161,7 @@ const handlePostRequest = async ( image_url: jsonMetadata.image, website_url: jsonMetadata.website, symbol: symbol, - ipfs_metadata: baseURI, + ipfs_metadata: metadataURL, timestamp: Number(timestamp), chain_id: Number(chainId), karma_access_control_address: sanitizeAddress( diff --git a/apps/web/pages/api/v0/course/metadata.ts b/apps/web/pages/api/v0/course/metadata.ts index ee24752c..87448cfb 100644 --- a/apps/web/pages/api/v0/course/metadata.ts +++ b/apps/web/pages/api/v0/course/metadata.ts @@ -58,7 +58,7 @@ const handlePostRequest = async ( data: { metadata: ipfsCourseMetadata }, }) } catch (error: any) { - console.log(error) + console.error(error) return res.status(500).json({ status: ApiResponseStatus.error, message: diff --git a/apps/web/pages/api/v0/user/course/credential.ts b/apps/web/pages/api/v0/user/course/credential.ts index cf4b9be9..bdc7bc0d 100644 --- a/apps/web/pages/api/v0/user/course/credential.ts +++ b/apps/web/pages/api/v0/user/course/credential.ts @@ -125,7 +125,7 @@ const handleDeleteRequest = async ( data: { userCredential: deletedCredential }, }) } catch (error: any) { - console.log(error) + console.error(error) return res.status(500).json({ status: ApiResponseStatus.error, message: diff --git a/apps/web/pages/api/v0/user/course/credentials.ts b/apps/web/pages/api/v0/user/course/credentials.ts index 52439846..e5a68a36 100644 --- a/apps/web/pages/api/v0/user/course/credentials.ts +++ b/apps/web/pages/api/v0/user/course/credentials.ts @@ -129,21 +129,17 @@ const handlePostRequest = async ( })), }) - // ONLY BEFORE TOKEN_URI FIX - const tempFixTokenURIResponse = multicallTokenURIResponses.map( - (tokenURI) => { + tokenURIs = multicallTokenURIResponses + .map((tokenURI) => { return { result: tokenURI.result ? tokenURI.result.split('/').slice(-1)[0] : undefined, } - }, - ) - /////////// - - tokenURIs = tempFixTokenURIResponse.map((response) => { - return response.result ? response.result : '' - }) + }) + .map((response) => { + return response.result ? response.result : '' + }) } else { const tokenURIResponse = await Promise.all( credentialsIssuedLogsDecoded.map((log) => { @@ -156,15 +152,13 @@ const handlePostRequest = async ( }), ) - // ONLY BEFORE TOKEN_URI FIX - const tempFixTokenURIResponse = tokenURIResponse.map((tokenURI) => { - return tokenURI.split('/').slice(-1)[0] - }) - /////////// - - tokenURIs = tempFixTokenURIResponse.map((response) => { - return response ? response : '' - }) + tokenURIs = tokenURIResponse + .map((tokenURI) => { + return tokenURI.split('/').slice(-1)[0] + }) + .map((response) => { + return response ? response : '' + }) } const createCredentialsData = credentialsIssuedLogsDecoded.map( diff --git a/packages/abi/src/CredentialsBurnableAbi.ts b/packages/abi/src/CredentialsBurnableAbi.ts index 627afaef..4f176cc2 100644 --- a/packages/abi/src/CredentialsBurnableAbi.ts +++ b/packages/abi/src/CredentialsBurnableAbi.ts @@ -21,6 +21,11 @@ export const CredentialsBurnableAbi = [ name: '_bUri', type: 'string', }, + { + internalType: 'string', + name: '_contractURI', + type: 'string', + }, ], stateMutability: 'nonpayable', type: 'constructor', @@ -340,6 +345,19 @@ export const CredentialsBurnableAbi = [ stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'burnMagister', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [], name: 'contractURI', diff --git a/packages/abi/src/CredentialsFactoryAbi.ts b/packages/abi/src/CredentialsFactoryAbi.ts index 4927db83..3a1eb136 100644 --- a/packages/abi/src/CredentialsFactoryAbi.ts +++ b/packages/abi/src/CredentialsFactoryAbi.ts @@ -35,6 +35,11 @@ export const CredentialsFactoryAbi = [ name: '_bUri', type: 'string', }, + { + internalType: 'string', + name: '_contractURI', + type: 'string', + }, { internalType: 'uint64', name: '_baseMagisterKarma', diff --git a/packages/chains/src/index.ts b/packages/chains/src/index.ts index f5a34595..0c174fbf 100644 --- a/packages/chains/src/index.ts +++ b/packages/chains/src/index.ts @@ -48,7 +48,7 @@ export type ChainSnapshotWebsite = export const FactoryContractAddress = { [ChainId.ETHEREUM]: '', - [ChainId.SEPOLIA]: '0xb6c59c1538d362d9495f1564629ae2b59f0532af', + [ChainId.SEPOLIA]: '0xf39ff550e518c9044e6235e3708141fc28dbd4bb', [ChainId.FOUNDRY]: process.env.NEXT_PUBLIC_FOUNDRY_FACTORY_CONTRACT_ADDRESS, } as const diff --git a/packages/ui/src/Layouts/Footer/Footer.tsx b/packages/ui/src/Layouts/Footer/Footer.tsx index 50732716..4ce39498 100644 --- a/packages/ui/src/Layouts/Footer/Footer.tsx +++ b/packages/ui/src/Layouts/Footer/Footer.tsx @@ -3,7 +3,6 @@ import { chakra, Container, Stack, - Text, useColorModeValue, VisuallyHidden, } from '@chakra-ui/react' @@ -51,15 +50,9 @@ export const Footer = () => { py={4} direction={{ base: 'column', md: 'row' }} spacing={4} - justify={{ base: 'center', md: 'space-between' }} + justify={{ base: 'center', md: 'flex-end' }} align={{ base: 'center', md: 'center' }} > - - Version:{' '} - - {''} - - diff --git a/packages/wagmi/src/hooks/web3/useBurnCredential.ts b/packages/wagmi/src/hooks/web3/useBurnCredential.ts index 129cd991..070f52d2 100644 --- a/packages/wagmi/src/hooks/web3/useBurnCredential.ts +++ b/packages/wagmi/src/hooks/web3/useBurnCredential.ts @@ -35,7 +35,7 @@ export function useBurnCredential({ const { writeAsync: burn } = useContractWrite({ abi: CredentialsBurnableAbi, address: courseAddress, - functionName: 'burn', + functionName: credentialType === 'MAGISTER' ? 'burnMagister' : 'burn', }) const { removeModerator } = useEditSnapshotSpace(courseAddress, chain?.id) diff --git a/packages/wagmi/src/hooks/web3/useCreateCourse.ts b/packages/wagmi/src/hooks/web3/useCreateCourse.ts index 751123a7..102c9e28 100644 --- a/packages/wagmi/src/hooks/web3/useCreateCourse.ts +++ b/packages/wagmi/src/hooks/web3/useCreateCourse.ts @@ -143,7 +143,8 @@ export function useCreateCourse({ args: [ name, 'DAEC', - uploadMetadataResponseJson.data.metadata.url, + `${process.env.NEXT_PUBLIC_IPFS_GATEWAY_URL}/`, + uploadMetadataResponseJson.data.metadata.hash, BigInt(magisterBaseKarma), BigInt(discipulusBaseKarma), ], diff --git a/packages/wagmi/src/hooks/web3/useTransferCredentials.ts b/packages/wagmi/src/hooks/web3/useTransferCredentials.ts index a91f17e6..cba45a38 100644 --- a/packages/wagmi/src/hooks/web3/useTransferCredentials.ts +++ b/packages/wagmi/src/hooks/web3/useTransferCredentials.ts @@ -102,7 +102,6 @@ export function useTransferCredentials({ state.setSigning() - const tokenURI = `${process.env.NEXT_PUBLIC_IPFS_GATEWAY_URL}/${credentialIPFSCid}` if (mint === undefined) { throw new Error( 'The data provided is incorrect. Please ensure that you have entered the correct information.', @@ -110,7 +109,7 @@ export function useTransferCredentials({ } const writeResult = await mint({ - args: [userData.address, tokenURI, 2], + args: [userData.address, credentialIPFSCid, 2], }) await fetch('/api/v0/transactions', { @@ -197,7 +196,6 @@ export function useTransferCredentials({ try { state.setValidating() - const tokenURI = `${process.env.NEXT_PUBLIC_IPFS_GATEWAY_URL}/${credentialIPFSCid}` if (credentialType === 'OTHER') { let accessList: { address: Address; hasAccess: boolean }[] @@ -298,7 +296,7 @@ export function useTransferCredentials({ const writeResult = await multiMint({ args: [ addressToMint, - Array(addressToMint.length).fill(tokenURI), + Array(addressToMint.length).fill(credentialIPFSCid), Array(addressToMint.length).fill(2), ], })