This commit is contained in:
osmannyildiz 2023-12-17 08:01:10 +03:00
parent 44a57410a6
commit c2514c84bc
3 changed files with 44 additions and 28 deletions

View File

@ -24,19 +24,27 @@ contract CubLearn is Ownable {
dtlContract = DTLToken(dtlContractAddress); dtlContract = DTLToken(dtlContractAddress);
cubcertContract = NftCertificate(cubcertContractAddress); cubcertContract = NftCertificate(cubcertContractAddress);
coursePrices["1"] = 300; coursePrices["1"] = 300;
coursePrices["2"] = 500; coursePrices["2"] = 500;
coursePrices["3"] = 200; coursePrices["3"] = 200;
coursePrices["4"] = 150; coursePrices["4"] = 150;
coursePrices["5"] = 250; coursePrices["5"] = 250;
coursePrices["6"] = 250; coursePrices["6"] = 250;
coursePrices["7"] = 450; coursePrices["7"] = 450;
cashbackPercentage = 50; cashbackPercentage = 50;
} }
function amIEnrolledInCourse(string courseId) external view returns (bool) {
return enrolledCourses[courseId][msg.sender];
}
function didICompleteCourse(string courseId) external view returns (bool) {
return issuedCertificates[courseId][msg.sender];
}
function setCashbackPercentage(uint256 newValue) external onlyOwner { function setCashbackPercentage(uint256 newValue) external onlyOwner {
require(newValue <= 100, "Cashback percentage cannot be more than 100."); require(newValue <= 100, "Cashback percentage cannot be more than 100.");
cashbackPercentage = newValue; cashbackPercentage = newValue;
} }
@ -46,7 +54,7 @@ contract CubLearn is Ownable {
dtlContract.transferFrom(msg.sender, address(this), coursePrices[courseId]); dtlContract.transferFrom(msg.sender, address(this), coursePrices[courseId]);
enrolledCourses[courseId][msg.sender] = true; enrolledCourses[courseId][msg.sender] = true;
} }
function finishCourse( function finishCourse(
@ -63,9 +71,9 @@ contract CubLearn is Ownable {
// Mark the certificate as issued // Mark the certificate as issued
issuedCertificates[courseId][msg.sender] = true; issuedCertificates[courseId][msg.sender] = true;
// Cashback // Cashback
uint256 cashbackAmount = coursePrices[courseId] * cashbackPercentage / 100; uint256 cashbackAmount = coursePrices[courseId] * cashbackPercentage / 100;
dtlContract.transfer(msg.sender, cashbackAmount); dtlContract.transfer(msg.sender, cashbackAmount);
} }
function getDTLBalance() external view onlyOwner returns (uint256) { function getDTLBalance() external view onlyOwner returns (uint256) {

View File

@ -8,11 +8,19 @@ contract DTLToken is ERC20 {
_mint(initialHolder, 1000000000); _mint(initialHolder, 1000000000);
} }
function decimals() public view virtual override returns (uint8) { function decimals() public view virtual override returns (uint8) {
return 0; return 0;
} }
function approveMax(address spender) external returns (bool) { function getAllowanceOfSpender(address spender) external view returns (uint256) {
return approve(spender, totalSupply()); return allowance(msg.sender, spender);
} }
function approveMax(address spender) external returns (bool) {
return approve(spender, totalSupply());
}
function getMyBalance() external view returns (uint) {
return balanceOf(msg.sender);
}
} }

View File

@ -48,15 +48,15 @@ contract NftCertificate is ERC721 {
}); });
} }
function getCertificateInfo(uint256 tokenId) // function getCertificateInfo(uint256 tokenId)
external // external
view // view
returns ( // returns (
CertificateInfo memory certInfo // CertificateInfo memory certInfo
) // )
{ // {
return certificateInfoMapping[tokenId]; // return certificateInfoMapping[tokenId];
} // }
function _getSvg(uint256 tokenId) internal view returns (string memory) { function _getSvg(uint256 tokenId) internal view returns (string memory) {
CertificateInfo storage certInfo = certificateInfoMapping[tokenId]; CertificateInfo storage certInfo = certificateInfoMapping[tokenId];