// SPDX-License-Identifier: MITpragmasolidity ^0.8;interfaceIMetadataProvider{
/// @notice Whether or not the metadata provider supports registrars that can/// set metadata for other instances./// @dev See `MetadataRegistry` for more information on the registrar role.functionsupportsRegistrars() externalviewreturns (bool);
/// @notice Get the metadata for a Party instance./// @param instance The address of the instance./// @param tokenId The ID of the token to get the metadata for./// @return metadata The encoded metadata.functiongetMetadata(address instance,
uint256 tokenId
) externalviewreturns (bytesmemory metadata);
}
Contract Source Code
File 3 of 7: Implementation.sol
// SPDX-License-Identifier: GPL-3.0pragmasolidity 0.8.20;// Base contract for all contracts intended to be delegatecalled into.abstractcontractImplementation{
errorOnlyDelegateCallError();
errorOnlyConstructorError();
addresspublicimmutable IMPL;
constructor() {
IMPL =address(this);
}
// Reverts if the current function context is not inside of a delegatecall.modifieronlyDelegateCall() virtual{
if (address(this) == IMPL) {
revert OnlyDelegateCallError();
}
_;
}
// Reverts if the current function context is not inside of a constructor.modifieronlyConstructor() {
if (address(this).code.length!=0) {
revert OnlyConstructorError();
}
_;
}
}
Contract Source Code
File 4 of 7: LibGlobals.sol
// SPDX-License-Identifier: GPL-3.0pragmasolidity 0.8.20;// Valid keys in `IGlobals`. Append-only.libraryLibGlobals{
// The Globals commented out below were depreciated in 1.2; factories// can now choose the implementation address to deploy and no longer// deploy the latest implementation. They will no longer be updated// in future releases.//// See https://github.com/PartyDAO/party-migrations for// implementation addresses by release.uint256internalconstant GLOBAL_PARTY_IMPL =1;
uint256internalconstant GLOBAL_PROPOSAL_ENGINE_IMPL =2;
uint256internalconstant GLOBAL_PARTY_FACTORY =3;
uint256internalconstant GLOBAL_GOVERNANCE_NFT_RENDER_IMPL =4;
uint256internalconstant GLOBAL_CF_NFT_RENDER_IMPL =5;
uint256internalconstant GLOBAL_OS_ZORA_AUCTION_TIMEOUT =6;
uint256internalconstant GLOBAL_OS_ZORA_AUCTION_DURATION =7;
// uint256 internal constant GLOBAL_AUCTION_CF_IMPL = 8;// uint256 internal constant GLOBAL_BUY_CF_IMPL = 9;// uint256 internal constant GLOBAL_COLLECTION_BUY_CF_IMPL = 10;uint256internalconstant GLOBAL_DAO_WALLET =11;
uint256internalconstant GLOBAL_TOKEN_DISTRIBUTOR =12;
uint256internalconstant GLOBAL_OPENSEA_CONDUIT_KEY =13;
uint256internalconstant GLOBAL_OPENSEA_ZONE =14;
uint256internalconstant GLOBAL_PROPOSAL_MAX_CANCEL_DURATION =15;
uint256internalconstant GLOBAL_ZORA_MIN_AUCTION_DURATION =16;
uint256internalconstant GLOBAL_ZORA_MAX_AUCTION_DURATION =17;
uint256internalconstant GLOBAL_ZORA_MAX_AUCTION_TIMEOUT =18;
uint256internalconstant GLOBAL_OS_MIN_ORDER_DURATION =19;
uint256internalconstant GLOBAL_OS_MAX_ORDER_DURATION =20;
uint256internalconstant GLOBAL_DISABLE_PARTY_ACTIONS =21;
uint256internalconstant GLOBAL_RENDERER_STORAGE =22;
uint256internalconstant GLOBAL_PROPOSAL_MIN_CANCEL_DURATION =23;
// uint256 internal constant GLOBAL_ROLLING_AUCTION_CF_IMPL = 24;// uint256 internal constant GLOBAL_COLLECTION_BATCH_BUY_CF_IMPL = 25;uint256internalconstant GLOBAL_METADATA_REGISTRY =26;
// uint256 internal constant GLOBAL_CROWDFUND_FACTORY = 27;// uint256 internal constant GLOBAL_INITIAL_ETH_CF_IMPL = 28;// uint256 internal constant GLOBAL_RERAISE_ETH_CF_IMPL = 29;uint256internalconstant GLOBAL_SEAPORT =30;
uint256internalconstant GLOBAL_CONDUIT_CONTROLLER =31;
}
Contract Source Code
File 5 of 7: LibRawResult.sol
// SPDX-License-Identifier: GPL-3.0pragmasolidity 0.8.20;libraryLibRawResult{
// Revert with the data in `b`.functionrawRevert(bytesmemory b) internalpure{
assembly {
revert(add(b, 32), mload(b))
}
}
// Return with the data in `b`.functionrawReturn(bytesmemory b) internalpure{
assembly {
return(add(b, 32), mload(b))
}
}
}
Contract Source Code
File 6 of 7: MetadataRegistry.sol
// SPDX-License-Identifier: GPL-3.0pragmasolidity 0.8.20;import { IGlobals } from"../globals/IGlobals.sol";
import { LibGlobals } from"../globals/LibGlobals.sol";
import { IMetadataProvider } from"./IMetadataProvider.sol";
import { Multicall } from"../utils/Multicall.sol";
/// @notice A registry of custom metadata providers for Party Cards.contractMetadataRegistryisMulticall{
eventProviderSet(addressindexed instance, IMetadataProvider indexed provider);
eventRegistrarSet(addressindexed registrar, addressindexed instance, bool canSetData);
errorNotAuthorized(address caller, address instance);
// The `Globals` contract storing global configuration values. This contract// is immutable and it’s address will never change.
IGlobals privateimmutable _GLOBALS;
/// @notice Get the metadata provider for a Party instance.mapping(address instance => IMetadataProvider provider) public getProvider;
/// @notice Whether or not an address is a registar that can set the/// provider and metadata for another instance. If registrar is set/// true for `address(1)`, the address is a universal registar and/// can set data for any instance./// @dev Registrars' ability to set metadata for another instance must also be/// supported by the metadata provider used by that instance, indicated by/// `IMetadataProvider.supportsRegistrars()`.mapping(address registrar =>mapping(address instance =>bool canSetData)) private _isRegistrar;
/// @param globals The address of the `Globals` contract./// @param registrars The addresses of the initial universal registrars.constructor(IGlobals globals, address[] memory registrars) {
_GLOBALS = globals;
// Set the initial universal registrars.for (uint256 i =0; i < registrars.length; i++) {
_isRegistrar[registrars[i]][address(1)] =true;
}
}
/// @notice Set the metadata provider for a Party instance./// @param instance The address of the instance./// @param provider The address of the metadata provider.functionsetProvider(address instance, IMetadataProvider provider) external{
// Check if the caller is authorized to set the provider for the instance.if (!isRegistrar(msg.sender, instance)) revert NotAuthorized(msg.sender, instance);
getProvider[instance] = provider;
emit ProviderSet(instance, provider);
}
/// @notice Set whether or not an address can set metadata for a Party instance./// @param registrar The address of the possible registrar./// @param instance The address of the instance the registrar can set/// metadata for./// @param canSetData Whether or not the address can set data for the instance.functionsetRegistrar(address registrar, address instance, bool canSetData) external{
if (
msg.sender!= instance &&msg.sender!= _GLOBALS.getAddress(LibGlobals.GLOBAL_DAO_WALLET)
) {
revert NotAuthorized(msg.sender, instance);
}
_isRegistrar[registrar][instance] = canSetData;
emit RegistrarSet(registrar, instance, canSetData);
}
/// @notice Get whether or not an address can set metadata for a Party instance./// @param registrar The address of the possible registrar./// @param instance The address of the instance the registrar can set/// metadata for./// @return canSetData Whether or not the address can set data for the instance.functionisRegistrar(address registrar, address instance) publicviewreturns (bool) {
return
registrar == instance ||
_isRegistrar[registrar][address(1)] ||
_isRegistrar[registrar][instance];
}
/// @notice Get the metadata for a Party instance./// @param instance The address of the instance./// @param tokenId The ID of the token to get the metadata for./// @return metadata The encoded metadata.functiongetMetadata(address instance, uint256 tokenId) externalviewreturns (bytesmemory) {
IMetadataProvider provider = getProvider[instance];
returnaddress(provider) !=address(0) ? provider.getMetadata(instance, tokenId) : bytes("");
}
}
Contract Source Code
File 7 of 7: Multicall.sol
// SPDX-License-Identifier: GPL-3.0pragmasolidity 0.8.20;import"../utils/LibRawResult.sol";
abstractcontractMulticall{
usingLibRawResultforbytes;
/// @notice Perform multiple delegatecalls on ourselves.functionmulticall(bytes[] calldata multicallData) external{
for (uint256 i; i < multicallData.length; ++i) {
(bool s, bytesmemory r) =address(this).delegatecall(multicallData[i]);
if (!s) {
r.rawRevert();
}
}
}
}