Skip to content

Commit

Permalink
chore: update script
Browse files Browse the repository at this point in the history
  • Loading branch information
Doge-is-Dope committed Nov 16, 2024
1 parent a8d6f58 commit 4e69aad
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 62 deletions.
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
## Drip
# Drip Protocol

A decentralized challenge and profile management system built on Ethereum.

## Overview

Drip Protocol is a smart contract system that enables users to create and manage challenges, maintain profiles, and handle token vaults. The protocol consists of several key components:

- Challenge: Manages individual challenges
- ChallengeManager: Orchestrates challenge creation and management
- DripProfile: Handles user profiles and their associated data
- DripVault: Manages token deposits and withdrawals

## Contract Addresses

Challenge: 0xaDcaAe61b8983940FB2c8098BDe112e507A0e1f0
ChallengeManager: 0xB3084eF0Dc7440e32A6cD64e2E5072FBCd9AEEeE
DripProfile: 0x0E69Ba1FF53c36D0fbb4fccC0e9B732D58593B2f

### Testnet (Goerli)

- Challenge: [Contract Address]
- ChallengeManager: [Contract Address]
- DripProfile: [Contract Address]
- DripVault: [Contract Address]

## Architecture

The protocol consists of four main contracts:

1. **Challenge.sol**: Core contract for challenge creation and management

- Handles challenge parameters
- Manages challenge states
- Processes challenge completion

2. **ChallengeManager.sol**: Orchestration layer for challenges

- Creates new challenges
- Manages challenge lifecycle
- Handles challenge verification

3. **DripProfile.sol**: User profile management

- Stores user information
- Tracks challenge participation
- Manages user achievements

4. **DripVault.sol**: Token management
- Handles token deposits
- Processes withdrawals
- Manages challenge stakes

## Libraries

### TimeLib

Utility library for time-based calculations and validations used throughout the protocol.

### Types

Contains core data structures and custom types used across the protocol.

## Security

This protocol has been designed with security in mind. However, it has not been audited yet. Use at your own risk.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
62 changes: 1 addition & 61 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ import {BaseDeploy} from "./BaseDeploy.s.sol";

contract Deploy is BaseDeploy {
using TimeLib for uint256;
// Constants

// Constants
uint256 private constant DURATION = 5 days;
address private constant MOCK_TOKEN = 0x235c36243BD73d65B530a469658FeF591daA2f45; // Vault: underlying token

// Accounts
address private constant CLE = 0x8D0B05b837FB0e28e78b8939dDaD8CE7B91b678D;
address private constant SHA = 0xE033dfbeE8CB2DaE2F4FB13acb5d493f1fDEA318;

// Private Keys
uint256 internal immutable ShanePrivateKey = vm.envUint("PRIVATE_KEY_SHA");

// Contract Instances
Challenge challenge;
ChallengeManager challengeManager;
Expand All @@ -36,10 +29,6 @@ contract Deploy is BaseDeploy {

function run() public {
_deployContracts();

// DEMO ONLY
_initializeEpochs();
_createProfiles();
}

function _deployContracts() private broadcast(deployerPrivateKey) {
Expand All @@ -65,53 +54,4 @@ contract Deploy is BaseDeploy {
bytes32 salt = _calculateSalt(fileName);
return Create2.deploy(0, salt, creationBytecode);
}

function _initializeEpochs() private broadcast(deployerPrivateKey) {
uint256 currentTimestamp = block.timestamp;
_createEpoch(0, currentTimestamp - 5 days, "ETHGlobal Bangkok Demo");
_createEpoch(1, currentTimestamp - 3 days, "TOEFL 7000 words");
console.log("Epochs initialized");
}

/// @notice DEMO only - Helper function to create an epoch
function _createEpoch(uint256 id, uint256 startTimestamp, string memory description) private {
DripVault vault = new DripVault(MOCK_TOKEN, address(challengeManager));
Types.Epoch memory epoch = Types.Epoch({
id: id,
startTimestamp: startTimestamp,
endTimestamp: startTimestamp + DURATION,
durationInDays: DURATION.convertSecondsToDays(),
vault: address(vault),
asset: MOCK_TOKEN,
description: description,
participantCount: 0,
totalDeposits: 0
});
challengeManager.setEpoch(id, epoch);
}

/// @notice DEMO only - Helper function to create profiles
function _createProfiles() private {
_createProfile("@clement", vm.envUint("PRIVATE_KEY"));
_createProfile("@shane", vm.envUint("PRIVATE_KEY_SHA"));
}

function _createProfile(string memory handle, uint256 pk) private broadcast(pk) {
address account = vm.addr(pk);
uint32[] memory avatar = _createAvatar(pk);
uint256 profileId = profile.createProfile(account, handle, avatar);
Types.Profile memory createdProfile = profile.getProfileById(profileId);
profiles[account] = createdProfile;
console.log(handle, "profile with ID:", profileId);
}

function _createAvatar(uint256 seed) private pure returns (uint32[] memory avatar) {
avatar = new uint32[](5);
for (uint32 i; i < 5;) {
avatar[i] = uint32((uint256(keccak256(abi.encodePacked(seed, i)))) + 3);
unchecked {
i++;
}
}
}
}

0 comments on commit 4e69aad

Please sign in to comment.