Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Nov 6, 2023
1 parent c4cfd2b commit ac89c60
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
20 changes: 10 additions & 10 deletions contracts/modules/SoundMetadataV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { LibString } from "solady/utils/LibString.sol";
import { OwnableRoles } from "solady/auth/OwnableRoles.sol";
import { ISoundEditionV2 } from "@core/interfaces/ISoundEditionV2.sol";
import { ArweaveURILib } from "@core/utils/ArweaveURILib.sol";
import { ISoundMetadata } from "@modules/interfaces/ISoundMetadata.sol";
import { ISoundMetadataV1_1 } from "@modules/interfaces/ISoundMetadataV1_1.sol";
import { LibMulticaller } from "multicaller/LibMulticaller.sol";
import { LibOps } from "@core/utils/LibOps.sol";

contract SoundMetadata is ISoundMetadata {
contract SoundMetadataV1_1 is ISoundMetadataV1_1 {
using ArweaveURILib for ArweaveURILib.URI;
// =============================================================
// STRUCTS
Expand Down Expand Up @@ -55,23 +55,23 @@ contract SoundMetadata is ISoundMetadata {
// =============================================================

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function setNumberedUpTo(address edition, uint32 tokenId) external onlyEditionOwnerOrAdmin(edition) {
_configs[edition].numberedUpTo = tokenId;
emit NumberUpToSet(edition, tokenId);
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function setUseTierTokenIdIndex(address edition, bool value) external onlyEditionOwnerOrAdmin(edition) {
_configs[edition].useTierTokenIdIndex = value ? 1 : 2;
emit UseTierTokenIdIndexSet(edition, value);
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function setBaseURI(
address edition,
Expand All @@ -87,29 +87,29 @@ contract SoundMetadata is ISoundMetadata {
// =============================================================

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function numberedUpTo(address edition) public view returns (uint32) {
uint32 n = _configs[edition].numberedUpTo;
return n == 0 ? DEFAULT_NUMBER_UP_TO : n;
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function useTierTokenIdIndex(address edition) public view returns (bool) {
return _configs[edition].useTierTokenIdIndex != 2;
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function baseURI(address edition, uint8 tier) public view returns (string memory) {
return _baseURI[LibOps.packId(edition, tier)].load();
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function tokenURI(uint256 tokenId) external view returns (string memory) {
uint8 tier = ISoundEditionV2(msg.sender).tokenTier(tokenId);
Expand All @@ -135,7 +135,7 @@ contract SoundMetadata is ISoundMetadata {
}

/**
* @inheritdoc ISoundMetadata
* @inheritdoc ISoundMetadataV1_1
*/
function goldenEggTokenId(address edition, uint8 tier) public view returns (uint256 tokenId) {
return ISoundEditionV2(edition).mintRandomnessOneOfOne(tier);
Expand Down
22 changes: 11 additions & 11 deletions contracts/modules/SoundOnChainMetadataV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { JSONParserLib } from "solady/utils/JSONParserLib.sol";
import { DynamicBufferLib } from "solady/utils/DynamicBufferLib.sol";
import { OwnableRoles } from "solady/auth/OwnableRoles.sol";
import { ISoundEditionV2 } from "@core/interfaces/ISoundEditionV2.sol";
import { ISoundOnChainMetadata } from "@modules/interfaces/ISoundOnChainMetadata.sol";
import { ISoundOnChainMetadataV1_1 } from "@modules/interfaces/ISoundOnChainMetadataV1_1.sol";
import { SoundOnChainMetadataLib as M } from "@modules/utils/SoundOnChainMetadataLib.sol";
import { LibMulticaller } from "multicaller/LibMulticaller.sol";
import { LibOps } from "@core/utils/LibOps.sol";

contract SoundOnChainMetadata is ISoundOnChainMetadata {
contract SoundOnChainMetadataV1_1 is ISoundOnChainMetadataV1_1 {
using JSONParserLib for JSONParserLib.Item;
using DynamicBufferLib for DynamicBufferLib.DynamicBuffer;

Expand Down Expand Up @@ -51,7 +51,7 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
// =============================================================

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function createTemplate(string memory templateJSON) public returns (string memory templateId) {
templateId = predictTemplateId(templateJSON);
Expand All @@ -62,15 +62,15 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function setValues(address edition, string memory valuesJSON) public onlyEditionOwnerOrAdmin(edition) {
_values[edition] = Store(SSTORE2.write(bytes(valuesJSON)), false);
emit ValuesSet(edition, false);
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function setValuesCompressed(address edition, bytes memory compressed) public onlyEditionOwnerOrAdmin(edition) {
_values[edition] = Store(SSTORE2.write(bytes(compressed)), true);
Expand All @@ -82,14 +82,14 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
// =============================================================

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function predictTemplateId(string memory templateJSON) public pure returns (string memory) {
return Base64.encode(abi.encodePacked(bytes9(keccak256(bytes(templateJSON)))));
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function getTemplate(string memory templateId) public view returns (string memory) {
address ss2 = _templates[keccak256(bytes(templateId))].value;
Expand All @@ -98,7 +98,7 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function getValues(address edition) public view returns (string memory) {
Store memory s = _values[edition];
Expand All @@ -109,7 +109,7 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function rawTokenJSON(
address edition,
Expand All @@ -124,7 +124,7 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function tokenURI(uint256 tokenId) external view returns (string memory) {
DynamicBufferLib.DynamicBuffer memory buffer;
Expand All @@ -139,7 +139,7 @@ contract SoundOnChainMetadata is ISoundOnChainMetadata {
}

/**
* @inheritdoc ISoundOnChainMetadata
* @inheritdoc ISoundOnChainMetadataV1_1
*/
function goldenEggTokenId(address edition, uint8 tier) public view returns (uint256) {
return ISoundEditionV2(edition).mintRandomnessOneOfOne(tier);
Expand Down
4 changes: 2 additions & 2 deletions contracts/modules/interfaces/ISoundMetadataV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { IMetadataModule } from "@core/interfaces/IMetadataModule.sol";
import { ISoundEditionV2 } from "@core/interfaces/ISoundEditionV2.sol";

/**
* @title ISoundMetadata
* @title ISoundMetadataV1_1
* @notice The interface for the Sound Golden Egg metadata module with open edition compatibility.
*/
interface ISoundMetadata is IMetadataModule {
interface ISoundMetadataV1_1 is IMetadataModule {
// =============================================================
// EVENTS
// =============================================================
Expand Down
4 changes: 2 additions & 2 deletions contracts/modules/interfaces/ISoundOnChainMetadataV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { IMetadataModule } from "@core/interfaces/IMetadataModule.sol";
import { ISoundEditionV2 } from "@core/interfaces/ISoundEditionV2.sol";

/**
* @title ISoundOnChainMetadata
* @title ISoundOnChainMetadataV1_1
* @notice Sound metadata module with on-chain JSON.
*/
interface ISoundOnChainMetadata is IMetadataModule {
interface ISoundOnChainMetadataV1_1 is IMetadataModule {
// =============================================================
// EVENTS
// =============================================================
Expand Down

0 comments on commit ac89c60

Please sign in to comment.