Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrainPass Nft Contract #4

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4e773ae
BrainPass Nft Contract Added
OleanjiKingCode May 22, 2023
c4aec5a
addedexpalainable comments to functions
OleanjiKingCode May 22, 2023
c2f67f9
refined the vars in the brainpass contract
OleanjiKingCode May 22, 2023
bc3a1cc
adds brainpass deployer script
Emmanueldmlr May 22, 2023
51cd490
started testing
OleanjiKingCode May 22, 2023
1c6e3fe
updated test file and improved contract
OleanjiKingCode May 23, 2023
d88b6e8
changes noticed fix, getAllPassType Func,
OleanjiKingCode May 23, 2023
4482b93
labelling functions
OleanjiKingCode May 23, 2023
2959b63
updated contract and arranged the functions, used reverts instead of …
OleanjiKingCode May 24, 2023
a3e0bd7
changed all require func to if..revert
OleanjiKingCode May 24, 2023
9e52d56
readme doc
OleanjiKingCode May 24, 2023
ff9f7db
validate pass duration func
OleanjiKingCode May 24, 2023
347c98c
test for the new contract update
OleanjiKingCode May 24, 2023
a74cb88
Update README.md
OleanjiKingCode May 24, 2023
ae58340
test for the new contract update
OleanjiKingCode May 24, 2023
566e6a9
Merge branch 'BrainPass' of https://github.com/EveripediaNetwork/ep-c…
OleanjiKingCode May 24, 2023
ef3731a
IncresePassTime Func Refined
OleanjiKingCode May 24, 2023
5ef8ca1
changes variable names
Emmanueldmlr May 25, 2023
9a9bc99
removed for loop
OleanjiKingCode May 25, 2023
77d4183
renmoved a mapping
OleanjiKingCode May 25, 2023
0301aa2
removes unused script
Emmanueldmlr May 25, 2023
7444fee
changes function name
Emmanueldmlr May 25, 2023
3bbca93
corrected the test script
OleanjiKingCode May 25, 2023
f7c7a5d
removing unused error and added maxSupplyReached test
OleanjiKingCode May 25, 2023
888dc99
little fix in maxtokenminted per pass
OleanjiKingCode May 27, 2023
6696764
describing functions well
OleanjiKingCode May 28, 2023
b21b030
Update README.md
OleanjiKingCode May 28, 2023
639d9a0
more tests and pause Func
OleanjiKingCode May 28, 2023
8379083
Updated readme file, allows different url for differnt pass type, mor…
OleanjiKingCode May 29, 2023
92444b8
removed unsed contrac import,toggle pass type status
OleanjiKingCode May 29, 2023
d9b5bda
validating users to know if they do an activity that requires their pass
OleanjiKingCode May 29, 2023
9ed21bc
configureMintlimit test and pause contract testing
OleanjiKingCode May 30, 2023
f0dc368
seperated the withdraw func
OleanjiKingCode May 30, 2023
86eb11d
updated README.md
OleanjiKingCode May 30, 2023
cef37c7
updated readme file and contract with test
OleanjiKingCode May 31, 2023
b8fffdf
removed the id logic for passtypes
OleanjiKingCode May 31, 2023
9a230bf
added more tests for the validator
OleanjiKingCode May 31, 2023
3e6c1f6
updated the contract
OleanjiKingCode May 31, 2023
a4065fc
little changes
OleanjiKingCode Jun 1, 2023
49a3661
checking for validity of the timestamp entered
OleanjiKingCode Jun 5, 2023
2fe00bd
little fixes in the contract
OleanjiKingCode Jun 9, 2023
721b931
improved test from edited contract
OleanjiKingCode Jun 9, 2023
3f9a1eb
improved test from edited contract
OleanjiKingCode Jun 9, 2023
f717fe8
using erc721pausable
OleanjiKingCode Jun 9, 2023
717d7a0
using erc721pausable tests
OleanjiKingCode Jun 9, 2023
6260675
improving the brainPassValidator
OleanjiKingCode Jun 10, 2023
fc932ed
improved the READMe file
OleanjiKingCode Jun 11, 2023
8669373
removed unused code and improved tests
OleanjiKingCode Jun 13, 2023
fa5b0fb
removed discount
OleanjiKingCode Jun 13, 2023
b7f9781
reworked the event
OleanjiKingCode Jun 14, 2023
bb03b8e
added data to event
OleanjiKingCode Jun 14, 2023
f63d3fa
improved the contract, tests, deployment scripts
OleanjiKingCode Jun 14, 2023
7095eb3
fixed failed assertion
OleanjiKingCode Jun 14, 2023
903fdfc
deployer script
OleanjiKingCode Jun 15, 2023
b2283b2
updated the tests
OleanjiKingCode Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,83 @@ Deploy and verify a contract
source .env

# To deploy and verify our contract
forge script script/WikiNoValidator.s.sol:WikiNoValidator --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv --gas-price 60 --legacy
forge script script/BrainPassDeployer.s.sol:BrainPassDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv --gas-price 60 --legacy

```

# Expalaining How BrainPassCollectibles Works

BrainPassCollectibles is a Solidity smart contract that enables the creation and management of BrainPass NFTs. It allows users to buy passes to have some Wiki privileges on IQ Wiki and provides functionalities to mint NFTs, increase pass time, and manage pass types.

## Usage

### Contract Deployment
Deploy the `BrainPassCollectibles` contract by providing the address of the IQ token contract as a constructor parameter.

## `pause()`
Pauses the contract and prevents any further actions. Can only be called by the contract owner.

## `unpause()`
Unpauses the contract and resumes normal operations. Can only be called by the contract owner.

## `configureMintLimit()`
Configures the lower and upper limits for minting NFTs.
- `lowerLimit`: Minimum duration (in days) for a subscription.
- `upperLimit`: Maximum duration (in days) for a subscription.
Only the contract owner can call this function.

## `addPassType()`
Adds a new pass type.
- `pricePerDay`: Price per day of the new pass type.
- `name`: Name of the new pass type.
- `maxTokens`: Total number of tokens in the pass.
Only the contract owner can call this function and only when the contract is not paused

## `togglePassTypeStatus()`
toggles the status of a specific pass type from paused to unpaused.
- `passId`: ID of the pass type to be deactivated.
Only the contract owner can call this function and only when the contract is not paused

## `mintNFT()`
Mints an NFT of a particular pass type.
- `passId`: ID of the pass type to mint.
- `startTimestamp`: Time when the NFT subscription starts.
- `endTimestamp`: Time when the NFT subscription ends.
Can call this function only when the contract is not paused

## `increaseEndTime()`
Increases the EndTime time of an NFT.
- `tokenId`: ID of the NFT whose time is to be increased.
- `newEndTime`: New subscription end time for the NFT.
Only when the contrasct is not paused can this function be called.

## `withdrawEther()`
Withdraws any amount of Ether held in the contract. Can only be called by the contract owner.

## `withdrawIQ()`
Withdraws any amount of IQ tokens held in the contract. Can only be called by the contract owner.

## `getUserPassDetails()`
Retrieves the details of an NFT owned by a specific user for a given pass type.
- `user`: Address of the user.

## `getAllPassType()`
Retrieves the details of all the pass types added to the contract.

## `getPassType()`
Retrieves the details of a specific pass type.
- `passId`: ID of the pass type

## Events

The contract emits the following events:

- `BrainPassBought`: Emitted when a user buys a BrainPass NFT.
- `TimeIncreased`: Emitted when the time of a BrainPass NFT is increased.
- `NewPassAdded`: Emitted when a new pass type is added.
- `PassTypeStatusToggled`: Emitted when a pass is paused or unpaused.

## PICTORAL EXPLANATION
![image](https://github.com/EveripediaNetwork/ep-contract/assets/75235148/eee4d631-28d9-4ca4-bc0e-62e5a02998a2)


1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ forge-std/=lib/forge-std/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/
prb-test/=lib/prb-test/src/
solmate/=lib/solmate/src/

25 changes: 25 additions & 0 deletions script/BrainPassDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script} from "../lib/forge-std/src/Script.sol";
import {console} from "../lib/forge-std/src/console.sol";

import {BrainPassCollectibles} from "../src/BrainPass/BrainPass.sol";

contract BrainPassDeployer is Script {
address constant owner =
address(0xE161eB85f00eC6471E0de06bA1Cfc136C053fFfe);

function run() external {
vm.startBroadcast();

console.log("Deploying Brainpass deployer....");
BrainPassCollectibles brainPass = new BrainPassCollectibles(
0x5E959c60f86D17fb7D764AB69B654227d464E820,
"http://example.com"
);
console.log("Brainpass Deployed", address(brainPass));

vm.stopBroadcast();
}
}
21 changes: 21 additions & 0 deletions script/BrainPassValidator.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script} from "../lib/forge-std/src/Script.sol";
import {console} from "../lib/forge-std/src/console.sol";

import {BrainPassValidiator} from "../src/BrainPass/BrainPassValidator.sol";

contract BrainPassValidiatorDeployer is Script {
function run() external {
vm.startBroadcast();

console.log("Deploying Brainpass Valdiator....");
BrainPassValidiator brainPassValidator = new BrainPassValidiator(
0x6e213cE219d7ef282ACCC7734040D67875828be4
);
console.log("Brainpass Deployed", address(brainPassValidator));

vm.stopBroadcast();
}
}
2 changes: 0 additions & 2 deletions script/WikiWhitelistValidator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ contract WikiWhitelistValidator is Script {
validator.whitelistEditor(address(0xF6d9467758C08d05571f1bFa0a03A2286cE1F043));
validator.whitelistEditor(address(0x2fE6aCD015384E1ee5138eF79fe1a434dA8FA12e));
validator.whitelistEditor(address(0xb029c0367CCFeEFBc6D00B4cc22fcbFd6A781F5c));

validator.whitelistEditor(address(0x9fEAB70f3c4a944B97b7565BAc4991dF5B7A69ff));
validator.whitelistEditor(address(0x14B68b85E1037d1C75726b7794e99C20554f9CC3));

validator.setOwner(owner);

vm.stopBroadcast();
Expand Down
Loading