Skip to content

Commit

Permalink
feat: update-factory-address
Browse files Browse the repository at this point in the history
  • Loading branch information
1M4nt0 committed Nov 8, 2023
1 parent 915dc7f commit 10cc4b8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 51 deletions.
62 changes: 25 additions & 37 deletions apps/web/pages/api/v0/course/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,35 @@ const handlePostRequest = async (
const karmaAccessControlAddress =
karmaAccessControlCreatedLogDecoded.args.karmaAccessControl

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 [symbol, contractURI, baseMagisterKarma, baseDiscipulusKarma] =
await Promise.all([
client.readContract({
address: courseContractAddress,
abi: CredentialsBurnableAbi,
functionName: 'symbol',
}),
client.readContract({
address: courseContractAddress,
abi: CredentialsBurnableAbi,
functionName: 'getContractURI',
}),
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 metadataURL = baseURI + contractURI

const metadataResponse = await fetch(metadataURL)
const metadataResponse = await fetch(contractURI)

if (!metadataResponse.ok) {
return res.status(500).json({
Expand Down Expand Up @@ -161,7 +149,7 @@ const handlePostRequest = async (
image_url: jsonMetadata.image,
website_url: jsonMetadata.website,
symbol: symbol,
ipfs_metadata: metadataURL,
ipfs_metadata: contractURI,
timestamp: Number(timestamp),
chain_id: Number(chainId),
karma_access_control_address: sanitizeAddress(
Expand Down
26 changes: 13 additions & 13 deletions packages/abi/src/CredentialsBurnableAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,6 @@ export const CredentialsBurnableAbi = [
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'contractURI',
outputs: [
{
internalType: 'string',
name: '',
type: 'string',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
Expand All @@ -390,6 +377,19 @@ export const CredentialsBurnableAbi = [
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getContractURI',
outputs: [
{
internalType: 'string',
name: '',
type: 'string',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/chains/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type ChainSnapshotWebsite =

export const FactoryContractAddress = {
[ChainId.ETHEREUM]: '',
[ChainId.SEPOLIA]: '0xf39ff550e518c9044e6235e3708141fc28dbd4bb',
[ChainId.SEPOLIA]: '0xa69d82aff770a00c4f800f932bbea1c8ccc9babd',
[ChainId.FOUNDRY]: process.env.NEXT_PUBLIC_FOUNDRY_FACTORY_CONTRACT_ADDRESS,
} as const

Expand Down
10 changes: 10 additions & 0 deletions packages/wagmi/src/hooks/web3/useCreateCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ export function useCreateCourse({
)
}

const metadataResponse = await fetch(
uploadMetadataResponseJson.data.metadata.url,
)

if (!metadataResponse.ok) {
throw new Error(
'There is a problem uploading your uploaded course metadata. Please try again in a few minutes.',
)
}

if (writeAsync === undefined) {
throw new Error(
'The data provided is incorrect. Please ensure that you have entered the correct information.',
Expand Down

0 comments on commit 10cc4b8

Please sign in to comment.