Skip to content
Open
Changes from 1 commit
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
32 changes: 15 additions & 17 deletions src/BrainPass/BrainPass.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
setBaseURI(_baseTokenURI);
}

function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override(ERC721, ERC721Pausable) {
super._beforeTokenTransfer(from, to, amount);
}

/// -----------------------------------------------------------------------
/// External functions
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -190,22 +182,19 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
if (addressToNFTPass[msg.sender].tokenId != 0)
revert AlreadyMintedAPass();
PassType storage passType = passTypes[passId];

if (passType.isPaused) revert PassTypeIsPaused();
if (passType.lastMintedId >= passType.maxTokens)
revert PassMaxSupplyReached();
if (!validatePassDuration(startTimestamp, endTimestamp))
revert DurationNotInTimeFrame();

uint256 price = calculatePrice(passId, startTimestamp, endTimestamp);

bool success = IERC20(iqToken).transferFrom(
msg.sender,
address(this),
price
);
if (!success) revert MintingPaymentFailed();

uint256 tokenId = tokenIdTracker.current();
passType.lastMintedId += 1;
UserPassItem memory purchase = UserPassItem(
Expand All @@ -215,14 +204,14 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
endTimestamp
);
addressToNFTPass[msg.sender] = purchase;

tokenIdTracker.increment();
_safeMint(msg.sender, tokenId);

emit BrainPassBought(
msg.sender,
tokenId,
price,
passId,
tokenId,
startTimestamp,
endTimestamp
);
Expand All @@ -248,7 +237,6 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
} else {
newStartTime = pass.endTimestamp;
}

if (!validatePassDuration(newStartTime, newEndTime))
revert DurationNotInTimeFrame();

Expand All @@ -259,7 +247,6 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
price
);
if (!success) revert IncreseTimePaymentFailed();

UserPassItem memory purchase = UserPassItem(
pass.tokenId,
pass.passId,
Expand All @@ -268,9 +255,9 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
);

addressToNFTPass[msg.sender] = purchase;

emit TimeIncreased(
msg.sender,
price,
tokenId,
pass.startTimestamp,
pass.endTimestamp
Expand Down Expand Up @@ -311,7 +298,8 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
uint256 endTimestamp
) internal view returns (uint256) {
PassType memory passType = passTypes[passId];
uint256 subscriptionPeriodInDays = (endTimestamp - startTimestamp) /1 days;
uint256 subscriptionPeriodInDays = (endTimestamp - startTimestamp) /
1 days;
// Calculate the total price
uint256 totalPrice = subscriptionPeriodInDays * passType.pricePerDay;
return totalPrice;
Expand All @@ -333,6 +321,14 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {
durationInDays <= MINT_UPPER_LIMIT;
}

function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override(ERC721, ERC721Pausable) {
super._beforeTokenTransfer(from, to, amount);
Comment thread
OleanjiKingCode marked this conversation as resolved.
}

/// -----------------------------------------------------------------------
/// Public
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -384,6 +380,7 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {

event BrainPassBought(
address indexed _owner,
uint256 amount,
Comment thread
OleanjiKingCode marked this conversation as resolved.
Outdated
uint256 _passId,
uint256 _tokenId,
uint256 _startTimestamp,
Expand All @@ -392,6 +389,7 @@ contract BrainPassCollectibles is ERC721, ERC721Pausable, Ownable {

event TimeIncreased(
address indexed _owner,
uint256 amount,
uint256 _tokenId,
uint256 _startTimestamp,
uint256 _newEndTimestamp
Expand Down