This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ether, balance } = require('@openzeppelin/test-helpers'); | |
const { accounts, contract } = require('@openzeppelin/test-environment'); | |
const SideEntranceLenderPool = contract.fromArtifact('SideEntranceLenderPool'); | |
const SideEntranceAttacker = contract.fromArtifact('SideEntranceAttacker'); | |
const { expect } = require('chai'); | |
describe('[Challenge] Side entrance', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ether, balance } = require('@openzeppelin/test-helpers'); | |
const { accounts, contract, web3 } = require('@openzeppelin/test-environment'); | |
const LenderPool = contract.fromArtifact('NaiveReceiverLenderPool'); | |
const FlashLoanReceiver = contract.fromArtifact('FlashLoanReceiver'); | |
const myAttackContract = contract.fromArtifact('AttackContract'); | |
const { expect } = require('chai'); | |
describe('[Challenge] Naive receiver', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract UnstoppableLender is ReentrancyGuard { | |
using SafeMath for uint256; | |
IERC20 public damnValuableToken; | |
uint256 public poolBalance; | |
constructor(address tokenAddress) public { | |
require(tokenAddress != address(0), "Token address cannot be zero"); | |
damnValuableToken = IERC20(tokenAddress); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ether, expectRevert } = require('@openzeppelin/test-helpers'); | |
const { accounts, contract } = require('@openzeppelin/test-environment'); | |
const DamnValuableToken = contract.fromArtifact('DamnValuableToken'); | |
const UnstoppableLender = contract.fromArtifact('UnstoppableLender'); | |
const ReceiverContract = contract.fromArtifact('ReceiverUnstoppable'); | |
const { expect } = require('chai'); | |
describe('[Challenge] Unstoppable', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.2; | |
import "../../introspection/IERC165.sol"; | |
interface IERC721 is IERC165 { | |
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DONATING FUNDS TO PATIENTS | |
function donateAmount(address _pid) public payable{ | |
require((msg.sender).balance >= msg.value); | |
patientList[_pid].donatedAmount = msg.value; | |
donorList[msg.sender] = msg.value; | |
donorCount++; | |
donationHistoryList[donorCount] = donationHistory(_pid, msg.sender,now,msg.value,patientList[_pid].name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Withdrawing Funds from Patient | |
function withdrawInsurance(address _pid, uint256 _amountRequired) public{ | |
// Checkpoints Before execution | |
require(doctorList[msg.sender]); | |
require(patientList[_pid].doctorAddress == msg.sender); | |
require(patientList[_pid].insuranceAmount >= _amountRequired); | |
// If all Conditions are satisfied, Funds are transferred to the assigned doctor | |
address payable recepientDoctor = msg.sender; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add a New DOCTOR | |
function setDoctor(address _docAddress,string memory _name, string memory _spec) public onlyOwner{ | |
require(!doctorList[_docAddress]); | |
doctorList[_docAddress] = true; | |
doctorDetailList[_docAddress].docAdress = _docAddress; | |
doctorDetailList[_docAddress].docName = _name; | |
doctorDetailList[_docAddress].docSpecialization = _spec; | |
doctorCount++; | |
docAddressList[doctorCount] = _docAddress; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Function to add a New Patient | |
function setPatientData(string memory _name, string memory _disease,string memory _ipfsHash) public payable onlyOwner{ | |
//GENERATING a UNIQUE ID for Patient | |
address pid = address(bytes20(keccak256(abi.encodePacked(msg.sender,now)))); | |
patientList[pid] = Patient(now,0,0,_name,_disease,' ',_ipfsHash,0x0000000000000000000000000000000000000000,pid,true,false); | |
// Adding Insurance Amount | |
patientList[pid].insuranceAmount = msg.value; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapping( address => bool) public doctorList; | |
mapping(address => uint256) public donorList; | |
mapping(uint => address) public pidList; | |
mapping(address => Patient) public patientList; | |
mapping(address => Doctor) public doctorDetailList; | |
mapping(uint => donationHistory) public donationHistoryList; | |
mapping(uint => withdrawHistory) public withdrawHistoryList; |