This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ProjectOpenSea/dan/2023/09/add-dynamic-met…
…adata-test Dan/2023/09/add dynamic metadata test
- Loading branch information
Showing
6 changed files
with
354 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
interface DeleteTraitInterface { | ||
function deleteTrait(bytes32 traitKey, uint256 tokenId) external; | ||
} | ||
|
||
/** | ||
* @title DeleteTraitScript | ||
* @notice This script deletes a trait for a given traitKey and tokenId. Note | ||
* That this is not permissible if the trait is required to have a | ||
* value. Check the current tokenURI response for token 1 by running | ||
* `cast call --rpc-url $GOERLI_RPC_URL | ||
* <the_address_of_the_target_contract> "tokenURI(uint256)(string)" 1`. | ||
* It should return the base64 encoded json for the NFT. Then run | ||
* `forge script script/DeleteTrait.s.sol --tc DeleteTraitScript | ||
* --sender <the_deployer_address> --fork-url $GOERLI_RPC_URL -vvvv` to | ||
* simulate the tx. To run it for real, change it to `forge script | ||
* script/DeleteTrait.s.sol --tc DeleteTraitScript --private-key | ||
* $MY_ACTUAL_PK_BE_CAREFUL --fork-url $GOERLI_RPC_URL --broadcast`. | ||
*/ | ||
contract DeleteTraitScript is Script { | ||
DeleteTraitInterface targetContract; | ||
|
||
function setUp() public { | ||
// Add the address of the target contract to the script here. | ||
targetContract = DeleteTraitInterface(address(0)); | ||
} | ||
|
||
function run() public { | ||
// Call the function to delete the trait on token ID 1. | ||
vm.startBroadcast(); | ||
|
||
targetContract.deleteTrait(bytes32("test.scriptTest"), 1); | ||
} | ||
} |
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,38 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
interface MintInterface { | ||
function mint(address to) external; | ||
} | ||
|
||
/** | ||
* @title MintScript | ||
* @notice This script mints a token. Simulate running it by entering `forge | ||
* script script/Mint.s.sol --tc MintScript --sender | ||
* <the_caller_address> --fork-url $GOERLI_RPC_URL -vvvv` in the | ||
* terminal. To run it for real, change it to `forge script | ||
* script/Mint.s.sol --tc MintScript --private-key | ||
* $MY_ACTUAL_PK_BE_CAREFUL --fork-url $GOERLI_RPC_URL --broadcast`. | ||
* | ||
*/ | ||
contract MintScript is Script { | ||
MintInterface targetContract; | ||
|
||
function setUp() public { | ||
// Replace the address of the target NFT contract here. | ||
targetContract = MintInterface(address(0)); | ||
} | ||
|
||
function run() public { | ||
// Call the function to mint a token. Note that the mint function on the | ||
// Dockmaster contract can only be called by an address with two leading | ||
// zeros in its address. | ||
vm.broadcast(); | ||
|
||
// Replace the address below with the address that should recieve the | ||
// token. | ||
targetContract.mint(address(0)); | ||
} | ||
} |
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,34 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
interface SetTraitInterface { | ||
function setTrait(bytes32 traitKey, uint256 tokenId, bytes32 trait) | ||
external; | ||
} | ||
|
||
/** | ||
* @title SetTraitScript | ||
* @notice This script sets a trait on a Dynamic Traits contract. Check the | ||
* current tokenURI response for token 1 by running `cast call --rpc-url | ||
* $GOERLI_RPC_URL <the_address_of_the_target_contract> | ||
* "tokenURI(uint256)(string)" 1`. It should return the base64 encoded | ||
* json for the NFT. Then run `forge script script/SetTrait.s.sol --tc | ||
* SetTraitScript --sender <the_deployer_address> --fork-url | ||
* $GOERLI_RPC_URL -vvvv` to simulate the tx. | ||
*/ | ||
contract SetTraitScript is Script { | ||
SetTraitInterface targetContract; | ||
|
||
function setUp() public { | ||
// Replace the address of the target NFT contract here. | ||
targetContract = SetTraitInterface(address(0)); | ||
} | ||
|
||
function run() public { | ||
// Call the function to set the trait on token ID 1. | ||
vm.broadcast(); | ||
targetContract.setTrait(bytes32("test.scriptTest"), 1, "First Value"); | ||
} | ||
} |
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,63 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Script.sol"; | ||
import { | ||
AllowedEditor, | ||
DisplayType, | ||
Editors, | ||
FullTraitValue, | ||
TraitLabel, | ||
EditorsLib | ||
} from "shipyard-core/dynamic-traits/lib/TraitLabelLib.sol"; | ||
|
||
interface SetTraitLabelInterface { | ||
function setTraitLabel(bytes32 traitKey, TraitLabel memory _traitLabel) | ||
external; | ||
} | ||
|
||
/** | ||
* @title SetTraitLabelScript | ||
* @notice This script sets a trait label on a DynamicTraits contract. Simulate | ||
* running it by entering `forge script script/SetTraitLabel.s.sol --tc | ||
* SetTraitLabelScript --sender <the_deployer_address> --fork-url | ||
* $GOERLI_RPC_URL -vvvv` in your terminal. To run it for real, | ||
* change it to `forge script script/SetTraitLabel.s.sol --tc | ||
* SetTraitLabelScript --private-key $MY_ACTUAL_PK_BE_CAREFUL --fork-url | ||
* $GOERLI_RPC_URL --broadcast`. | ||
*/ | ||
contract SetTraitLabelScript is Script { | ||
SetTraitLabelInterface targetContract; | ||
|
||
function setUp() public { | ||
// Replace the address of the target contract here. | ||
targetContract = SetTraitLabelInterface(address(0)); | ||
} | ||
|
||
function run() public { | ||
// Build the trait label. | ||
string[] memory acceptableValues = new string[](2); | ||
acceptableValues[0] = "First Value"; | ||
acceptableValues[1] = "Second Value"; | ||
|
||
AllowedEditor[] memory allowedEditorRoles = new AllowedEditor[](2); | ||
allowedEditorRoles[0] = AllowedEditor.Self; | ||
allowedEditorRoles[1] = AllowedEditor.TokenOwner; | ||
|
||
Editors editors = EditorsLib.aggregate(allowedEditorRoles); | ||
|
||
TraitLabel memory label = TraitLabel({ | ||
fullTraitKey: "Script test trait", | ||
traitLabel: "Script test trait", | ||
acceptableValues: acceptableValues, | ||
fullTraitValues: new FullTraitValue[](0), | ||
displayType: DisplayType.String, | ||
editors: editors, | ||
required: false | ||
}); | ||
|
||
// Call the function to add the new label. | ||
vm.broadcast(); | ||
targetContract.setTraitLabel(bytes32("test.scriptTest"), label); | ||
} | ||
} |
Oops, something went wrong.