-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
3a47e49
commit 499d32a
Showing
13 changed files
with
94 additions
and
70 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
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 @@ | ||
export type NftPostPayModalConfig = { | ||
ctaText: string | undefined | ||
ctaLink: string | undefined | ||
content: string | undefined | ||
} |
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
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
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,25 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { CV_V3 } from 'constants/cv' | ||
import { JUICEBOX_MONEY_PROJECT_METADATA_DOMAIN } from 'constants/metadataDomain' | ||
import { readNetwork } from 'constants/networks' | ||
import { readProvider } from 'constants/readProvider' | ||
import { V2V3ContractName } from 'packages/v2v3/models/contracts' | ||
import { loadV2V3Contract } from 'packages/v2v3/utils/loadV2V3Contract' | ||
|
||
export const V2V3GetMetadataCidFromContract = async (projectId: number) => { | ||
const JBProjects = await loadV2V3Contract( | ||
V2V3ContractName.JBProjects, | ||
readNetwork.name, | ||
readProvider, | ||
CV_V3, // Note: v2 and v3 use the same JBProjects, so the CV doesn't matter. | ||
) | ||
if (!JBProjects) { | ||
throw new Error(`contract not found ${V2V3ContractName.JBProjects}`) | ||
} | ||
const metadataCid = (await JBProjects.metadataContentOf( | ||
projectId, | ||
JUICEBOX_MONEY_PROJECT_METADATA_DOMAIN, | ||
)) as string | ||
|
||
return metadataCid | ||
} |
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,42 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { getPublicClient } from '@wagmi/core' | ||
import { | ||
readJbDirectoryControllerOf, | ||
getProjectMetadata as sdkGetProjectMetadata, | ||
} from 'juice-sdk-core' | ||
import { chainNameMap } from 'packages/v4/utils/networks' | ||
import { wagmiConfig } from 'packages/v4/wagmiConfig' | ||
import { PublicClient } from 'viem' | ||
|
||
export const getV4ProjectMetadata = async ( | ||
projectId: string | number, | ||
chain?: string | undefined, | ||
) => { | ||
if (typeof projectId === 'string') { | ||
projectId = Number(projectId) | ||
} | ||
if (isNaN(projectId)) return undefined | ||
|
||
if (!chain) throw new Error('Chain is required for V4 projects') | ||
return await V4GetMetadataCidFromContract(projectId, chain) | ||
} | ||
|
||
const V4GetMetadataCidFromContract = async ( | ||
projectId: number, | ||
chainName: string, | ||
) => { | ||
const chainId = chainNameMap[chainName] | ||
const jbControllerAddress = await readJbDirectoryControllerOf(wagmiConfig, { | ||
chainId, | ||
args: [BigInt(projectId)], | ||
}) | ||
const client = getPublicClient(wagmiConfig, { | ||
chainId, | ||
}) as PublicClient | ||
const metadata = await sdkGetProjectMetadata(client, { | ||
jbControllerAddress, | ||
projectId: BigInt(projectId), | ||
}) | ||
|
||
return metadata | ||
} |