Skip to content

Commit

Permalink
Script to deploy and fund genesis drops with allowlists
Browse files Browse the repository at this point in the history
  • Loading branch information
lykhonis committed Oct 19, 2023
1 parent f9d39ca commit 692e895
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CONTRACT_LSP8_OFFERS_ADDRESS=0xaebcc2c80abacb7e4d928d4c0a52c7bbeba4c4be
CONTRACT_LSP8_AUCTIONS_ADDRESS=0x39456bcd4d450e55f851f97c30df828a4e1f6c66
CONTRACT_LSP8_MARKETPLACE_ADDRESS=0xe9f0feab3d50ccbe40d99f669fe1e89172908cdf

CONTRACT_GENESIS_DIGITAL_ASSET_ADDRESS=0x233e7fd9d58bd4a4b7be0fe51f1005152d5d76fc
CONTRACT_GENESIS_DIGITAL_ASSET_ADDRESS=0x30e7100533d4cdc74ed20acee79f8406d7df8932

CONTRACT_PAGE_NAME_ADDRESS=0x48e37a167a3ee426389dc6e1dc2d440e86c3737f

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
| mainnet | Points | |
| mainnet | Royalties | |
| testnet | PageName | 0x48e37a167a3ee426389dc6e1dc2d440e86c3737f |
| testnet | GenesisDigitalAsset | 0x87fb68f9b6392502903cc9a1a0fd82dfd8445f4c |
| testnet | GenesisDigitalAsset | 0x30e7100533d4cdc74ed20acee79f8406d7df8932 |
| testnet | CollectorDigitalAsset | 0x1744807c38865bda3812a66884754421f65624dd |
| testnet | Participant | 0x5a485297a1b909032a6b7000354f3322047028ee |
| testnet | LSP7Listings | 0x44cd7d06ceb509370b75e426ea3c12824a665e36 |
Expand Down
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src = "src"
out = "out"
libs = ["lib"]
extra_output_files = ["metadata"]
fs_permissions = [{ access = "read", path = "./scripts/" }]

# solidity compiler
solc = "0.8.17"
Expand Down
1 change: 1 addition & 0 deletions scripts/assets/lsp7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/genesis-drop.json
63 changes: 61 additions & 2 deletions scripts/assets/lsp7/GenesisDigitalAsset.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,76 @@ pragma solidity 0.8.17;

import "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {Merkle} from "murky/Merkle.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {GenesisDigitalAsset} from "../../../src/assets/lsp7/GenesisDigitalAsset.sol";
import {DigitalAssetDrop} from "../../../src/assets/lsp7/DigitalAssetDrop.sol";

contract Deploy is Script {
function run() external {
address admin = vm.envAddress("ADMIN_ADDRESS");
address owner = vm.envAddress("OWNER_ADDRESS");
address beneficiary = vm.envAddress("BENEFICIARY_ADDRESS");

vm.broadcast(admin);
GenesisDigitalAsset asset = new GenesisDigitalAsset("Universal Page Genesis", "UPG", owner, beneficiary);
GenesisDigitalAsset asset = new GenesisDigitalAsset("Universal Page Genesis", "UPG", owner, owner);
console.log(string.concat("GenesisDigitalAsset: ", Strings.toHexString(address(asset))));
}
}

contract Drop is Script {
struct Claim {
uint256 amount;
address profile;
}

struct Data {
Claim[] claims;
}

function run() external {
address owner = vm.envAddress("OWNER_ADDRESS");
GenesisDigitalAsset genesisAsset =
GenesisDigitalAsset(payable(vm.envAddress("CONTRACT_GENESIS_DIGITAL_ASSET_ADDRESS")));

uint256 fundAmount = 0;

// build merkle tree
string memory json = vm.readFile(string.concat(vm.projectRoot(), "/scripts/assets/lsp7/genesis-drop.json"));
Data memory jsonData = abi.decode(vm.parseJson(json), (Data));

console.log("Allowlist claims:", jsonData.claims.length);
bytes32[] memory data = new bytes32[](jsonData.claims.length);
for (uint256 i = 0; i < jsonData.claims.length; i++) {
Claim memory claim = jsonData.claims[i];
console.log("-", i, claim.profile, claim.amount);
data[i] = keccak256(abi.encodePacked(uint256(i), claim.profile, claim.amount));
fundAmount += claim.amount;
}

Merkle merkle = new Merkle();
bytes32 root = merkle.getRoot(data);

// deploy drop
vm.broadcast(owner);
DigitalAssetDrop drop = new DigitalAssetDrop(genesisAsset, root, owner);
console.log(string.concat("DigitalAssetDrop: ", Strings.toHexString(address(drop))));

// fund drop
console.log("Fund drop:", fundAmount);
vm.broadcast(owner);
genesisAsset.reserve(fundAmount);

// dispose drop and remaining assets
// {
// vm.broadcast(owner);
// drop.dispose(owner);

// uint256 balance = genesisAsset.balanceOf(owner);
// if (balance > 0) {
// console.log("Dispose remaining assets:", balance);
// vm.broadcast(owner);
// genesisAsset.release(balance);
// }
// }
}
}
11 changes: 10 additions & 1 deletion tools/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ help() {
echo -e "\t-t --target: Target network to deploy to"
echo -e "\t-b --broadcast: Broadcast transactions to a network"
echo -e "\t-l --libraries: Deploys libraries only"
echo -e "\t-n --name: Name of script contract or 'Deploy' if not specified"
echo -e "\t-h --help: Prints this message"
exit 1
}
Expand All @@ -24,6 +25,10 @@ while [ -n "$1" ]; do
[[ ! "$2" =~ ^- ]] && SCRIPT=$2
shift 2
;;
-n | --name)
[[ ! "$2" =~ ^- ]] && SCRIPT_NAME=$2
shift 2
;;
-t | --target)
[[ ! "$2" =~ ^- ]] && TARGET=$2
shift 2
Expand Down Expand Up @@ -57,6 +62,10 @@ if [ -n "${SCRIPT}" ] && [ -n "${LIBRARIES}" ]; then
help
fi

if [ -z "${SCRIPT_NAME}" ]; then
SCRIPT_NAME="Deploy"
fi

case "${TARGET}" in
local | testnet | mainnet) ;;
*)
Expand Down Expand Up @@ -120,6 +129,6 @@ else
ARGS+=" --libraries src/common/Royalties.sol:Royalties:${LIBRARY_ROYALTIES_ADDRESS}"
fi

forge script "${PROJECT_DIR}/scripts/${SCRIPT}:Deploy" ${ARGS}
forge script "${PROJECT_DIR}/scripts/${SCRIPT}:${SCRIPT_NAME}" ${ARGS}

fi

0 comments on commit 692e895

Please sign in to comment.