This commit is contained in:
parent
44a57410a6
commit
c2514c84bc
|
|
@ -24,19 +24,27 @@ contract CubLearn is Ownable {
|
|||
dtlContract = DTLToken(dtlContractAddress);
|
||||
cubcertContract = NftCertificate(cubcertContractAddress);
|
||||
|
||||
coursePrices["1"] = 300;
|
||||
coursePrices["2"] = 500;
|
||||
coursePrices["3"] = 200;
|
||||
coursePrices["4"] = 150;
|
||||
coursePrices["5"] = 250;
|
||||
coursePrices["6"] = 250;
|
||||
coursePrices["7"] = 450;
|
||||
coursePrices["1"] = 300;
|
||||
coursePrices["2"] = 500;
|
||||
coursePrices["3"] = 200;
|
||||
coursePrices["4"] = 150;
|
||||
coursePrices["5"] = 250;
|
||||
coursePrices["6"] = 250;
|
||||
coursePrices["7"] = 450;
|
||||
|
||||
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 {
|
||||
require(newValue <= 100, "Cashback percentage cannot be more than 100.");
|
||||
require(newValue <= 100, "Cashback percentage cannot be more than 100.");
|
||||
|
||||
cashbackPercentage = newValue;
|
||||
}
|
||||
|
|
@ -46,7 +54,7 @@ contract CubLearn is Ownable {
|
|||
|
||||
dtlContract.transferFrom(msg.sender, address(this), coursePrices[courseId]);
|
||||
|
||||
enrolledCourses[courseId][msg.sender] = true;
|
||||
enrolledCourses[courseId][msg.sender] = true;
|
||||
}
|
||||
|
||||
function finishCourse(
|
||||
|
|
@ -63,9 +71,9 @@ contract CubLearn is Ownable {
|
|||
// Mark the certificate as issued
|
||||
issuedCertificates[courseId][msg.sender] = true;
|
||||
|
||||
// Cashback
|
||||
uint256 cashbackAmount = coursePrices[courseId] * cashbackPercentage / 100;
|
||||
dtlContract.transfer(msg.sender, cashbackAmount);
|
||||
// Cashback
|
||||
uint256 cashbackAmount = coursePrices[courseId] * cashbackPercentage / 100;
|
||||
dtlContract.transfer(msg.sender, cashbackAmount);
|
||||
}
|
||||
|
||||
function getDTLBalance() external view onlyOwner returns (uint256) {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,19 @@ contract DTLToken is ERC20 {
|
|||
_mint(initialHolder, 1000000000);
|
||||
}
|
||||
|
||||
function decimals() public view virtual override returns (uint8) {
|
||||
return 0;
|
||||
}
|
||||
function decimals() public view virtual override returns (uint8) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function approveMax(address spender) external returns (bool) {
|
||||
return approve(spender, totalSupply());
|
||||
}
|
||||
function getAllowanceOfSpender(address spender) external view returns (uint256) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,15 +48,15 @@ contract NftCertificate is ERC721 {
|
|||
});
|
||||
}
|
||||
|
||||
function getCertificateInfo(uint256 tokenId)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
CertificateInfo memory certInfo
|
||||
)
|
||||
{
|
||||
return certificateInfoMapping[tokenId];
|
||||
}
|
||||
// function getCertificateInfo(uint256 tokenId)
|
||||
// external
|
||||
// view
|
||||
// returns (
|
||||
// CertificateInfo memory certInfo
|
||||
// )
|
||||
// {
|
||||
// return certificateInfoMapping[tokenId];
|
||||
// }
|
||||
|
||||
function _getSvg(uint256 tokenId) internal view returns (string memory) {
|
||||
CertificateInfo storage certInfo = certificateInfoMapping[tokenId];
|
||||
|
|
|
|||
Loading…
Reference in New Issue