Skip to content

Commit

Permalink
fix: silence warnings and fix _transfer in CompliantERC20
Browse files Browse the repository at this point in the history
  • Loading branch information
jatZama committed Feb 27, 2024
1 parent 76a1001 commit d85ca56
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 76 deletions.
144 changes: 72 additions & 72 deletions examples/GasEstimation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,279 +6,279 @@ import "../lib/TFHE.sol";
contract GasEstimation {
function empty() public {}

function randEuint8() public {
euint8 random = TFHE.randEuint8();
function randEuint8() public view {
TFHE.randEuint8();
}

function randEuint16() public {
euint16 random = TFHE.randEuint16();
function randEuint16() public view {
TFHE.randEuint16();
}

function randEuint32() public {
euint32 random = TFHE.randEuint32();
function randEuint32() public view {
TFHE.randEuint32();
}

function add8() public {
function add8() public pure {
TFHE.asEuint8(1) + TFHE.asEuint8(2);
}

function sub8() public {
function sub8() public pure {
TFHE.asEuint8(2) - TFHE.asEuint8(1);
}

function mul8() public {
function mul8() public pure {
TFHE.asEuint8(2) * TFHE.asEuint8(10);
}

function div8() public {
function div8() public pure {
TFHE.div(TFHE.asEuint8(2), 2);
}

function rem8() public {
function rem8() public pure {
TFHE.rem(TFHE.asEuint8(2), 2);
}

function shr8() public {
function shr8() public pure {
TFHE.shr(TFHE.asEuint8(2), 1);
}

function shl8() public {
function shl8() public pure {
TFHE.shr(TFHE.asEuint8(2), 1);
}

function add16() public {
function add16() public pure {
TFHE.asEuint16(1) + TFHE.asEuint16(2);
}

function sub16() public {
function sub16() public pure {
TFHE.asEuint16(2) - TFHE.asEuint16(1);
}

function mul16() public {
function mul16() public pure {
TFHE.asEuint16(2) * TFHE.asEuint16(10);
}

function div16() public {
function div16() public pure {
TFHE.div(TFHE.asEuint16(2), 2);
}

function rem16() public {
function rem16() public pure {
TFHE.rem(TFHE.asEuint16(2), 2);
}

function shr16() public {
function shr16() public pure {
TFHE.shr(TFHE.asEuint16(2), 1);
}

function shl16() public {
function shl16() public pure {
TFHE.shr(TFHE.asEuint16(2), 1);
}

function add32() public {
function add32() public pure {
TFHE.asEuint32(1) + TFHE.asEuint32(2);
}

function sub32() public {
function sub32() public pure {
TFHE.asEuint32(2) - TFHE.asEuint32(1);
}

function mul32() public {
function mul32() public pure {
TFHE.asEuint32(2) * TFHE.asEuint32(10);
}

function div32() public {
function div32() public pure {
TFHE.div(TFHE.asEuint32(2), 2);
}

function rem32() public {
function rem32() public pure {
TFHE.rem(TFHE.asEuint32(2), 2);
}

function shr32() public {
function shr32() public pure {
TFHE.shr(TFHE.asEuint32(2), 1);
}

function shl32() public {
function shl32() public pure {
TFHE.shr(TFHE.asEuint32(2), 1);
}

function or8() public {
function or8() public pure {
TFHE.or(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function or16() public {
function or16() public pure {
TFHE.or(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function or32() public {
function or32() public pure {
TFHE.or(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function and8() public {
function and8() public pure {
TFHE.and(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function and16() public {
function and16() public pure {
TFHE.and(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function and32() public {
function and32() public pure {
TFHE.and(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function xor8() public {
function xor8() public pure {
TFHE.xor(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function xor16() public {
function xor16() public pure {
TFHE.xor(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function xor32() public {
function xor32() public pure {
TFHE.xor(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function eq8() public {
function eq8() public pure {
TFHE.eq(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function eq16() public {
function eq16() public pure {
TFHE.eq(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function eq32() public {
function eq32() public pure {
TFHE.eq(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function ne8() public {
function ne8() public pure {
TFHE.ne(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function ne16() public {
function ne16() public pure {
TFHE.ne(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function ne32() public {
function ne32() public pure {
TFHE.ne(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function le8() public {
function le8() public pure {
TFHE.le(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function le16() public {
function le16() public pure {
TFHE.le(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function le32() public {
function le32() public pure {
TFHE.le(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function lt8() public {
function lt8() public pure {
TFHE.lt(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function lt16() public {
function lt16() public pure {
TFHE.lt(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function lt32() public {
function lt32() public pure {
TFHE.lt(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function gt8() public {
function gt8() public pure {
TFHE.gt(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function gt16() public {
function gt16() public pure {
TFHE.gt(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function gt32() public {
function gt32() public pure {
TFHE.gt(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function ge8() public {
function ge8() public pure {
TFHE.ge(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function ge16() public {
function ge16() public pure {
TFHE.ge(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function ge32() public {
function ge32() public pure {
TFHE.ge(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function min8() public {
function min8() public pure {
TFHE.min(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function min16() public {
function min16() public pure {
TFHE.min(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function min32() public {
function min32() public pure {
TFHE.min(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function max8() public {
function max8() public pure {
TFHE.max(TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function max16() public {
function max16() public pure {
TFHE.max(TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function max32() public {
function max32() public pure {
TFHE.max(TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function not8() public {
function not8() public pure {
TFHE.not(TFHE.asEuint8(2));
}

function not16() public {
function not16() public pure {
TFHE.not(TFHE.asEuint16(2));
}

function not32() public {
function not32() public pure {
TFHE.not(TFHE.asEuint32(2));
}

function neg8() public {
function neg8() public pure {
TFHE.neg(TFHE.asEuint8(2));
}

function neg16() public {
function neg16() public pure {
TFHE.neg(TFHE.asEuint16(2));
}

function neg32() public {
function neg32() public pure {
TFHE.neg(TFHE.asEuint32(2));
}

function cmux8() public {
function cmux8() public pure {
TFHE.cmux(TFHE.asEbool(true), TFHE.asEuint8(2), TFHE.asEuint8(1));
}

function cmux16() public {
function cmux16() public pure {
TFHE.cmux(TFHE.asEbool(true), TFHE.asEuint16(2), TFHE.asEuint16(1));
}

function cmux32() public {
function cmux32() public pure {
TFHE.cmux(TFHE.asEbool(true), TFHE.asEuint32(2), TFHE.asEuint32(1));
}

function decrypt8() public {
function decrypt8() public view {
TFHE.decrypt(TFHE.asEuint8(2));
}

function decrypt16() public {
function decrypt16() public view {
TFHE.decrypt(TFHE.asEuint16(2));
}

function decrypt32() public {
function decrypt32() public view {
TFHE.decrypt(TFHE.asEuint32(2));
}
}
2 changes: 1 addition & 1 deletion examples/Governor/Timelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract Timelock {
delay = delay_;
}

fallback() external payable {}
receive() external payable {}

function setDelay(uint delay_) public {
require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock.");
Expand Down
6 changes: 3 additions & 3 deletions examples/Identity/CompliantERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ contract CompliantERC20 is EncryptedERC20 {

// Transfers an encrypted amount.
function _transfer(address from, address to, euint64 _amount, ebool isTransferable) internal override {
// Condition 1: hasEnoughFunds
ebool enoughFund = TFHE.le(_amount, balances[from]);
euint64 amount = TFHE.cmux(enoughFund, _amount, TFHE.asEuint64(0));
// Condition 1: hasEnoughFunds and hasEnoughAllowance (classical ERC20)
euint64 amount = TFHE.cmux(isTransferable, _amount, TFHE.asEuint64(0));

amount = rulesContract.transfer(from, to, amount);

balances[to] = balances[to] + amount;
balances[from] = balances[from] - amount;
emit Transfer(from, to);
}
}

0 comments on commit d85ca56

Please sign in to comment.