Skip to content

Commit

Permalink
refactor: remove Encrypted for Confidential
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Dec 2, 2024
1 parent 99a48b2 commit 830c4b6
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 163 deletions.
10 changes: 10 additions & 0 deletions contracts/test/token/ERC20/TestConfidentialERC20Wrapped.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { ConfidentialERC20Wrapped } from "../../../token/ERC20/ConfidentialERC20Wrapped.sol";
import { MockZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";
import { MockZamaGatewayConfig } from "fhevm/config/ZamaGatewayConfig.sol";

contract TestConfidentialERC20Wrapped is MockZamaFHEVMConfig, MockZamaGatewayConfig, ConfidentialERC20Wrapped {
constructor(address erc20_) ConfidentialERC20Wrapped(erc20_) {}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { EncryptedWETH } from "../../../token/ERC20/EncryptedWETH.sol";
import { ConfidentialWETH } from "../../../token/ERC20/ConfidentialWETH.sol";
import { MockZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";
import { MockZamaGatewayConfig } from "fhevm/config/ZamaGatewayConfig.sol";

/* solhint-disable no-empty-blocks*/
contract TestEncryptedWETH is MockZamaFHEVMConfig, MockZamaGatewayConfig, EncryptedWETH {}
contract TestConfidentialWETH is MockZamaFHEVMConfig, MockZamaGatewayConfig, ConfidentialWETH {}
10 changes: 0 additions & 10 deletions contracts/test/token/ERC20/TestEncryptedERC20Wrapped.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";

import { IEncryptedERC20Wrapped } from "./IEncryptedERC20Wrapped.sol";
import { EncryptedERC20 } from "./EncryptedERC20.sol";
import { IConfidentialERC20Wrapped } from "./IConfidentialERC20Wrapped.sol";
import { ConfidentialERC20 } from "./ConfidentialERC20.sol";

/**
* @title EncryptedERC20Wrapped
* @title ConfidentialERC20Wrapped
* @notice This contract allows users to wrap/unwrap trustlessly
* ERC20 tokens to EncryptedERC20 tokens.
* ERC20 tokens to ConfidentialERC20 tokens.
* @dev This implementation does not support tokens with rebase functions or
* tokens with a fee on transfer. All ERC20 tokens must have decimals
* inferior or equal to 18 decimals but superior or equal to 6 decimals.
*/
abstract contract EncryptedERC20Wrapped is EncryptedERC20, IEncryptedERC20Wrapped, GatewayCaller {
abstract contract ConfidentialERC20Wrapped is ConfidentialERC20, IConfidentialERC20Wrapped, GatewayCaller {
using SafeERC20 for IERC20Metadata;

/// @notice ERC20 token that is wrapped.
Expand All @@ -41,7 +41,7 @@ abstract contract EncryptedERC20Wrapped is EncryptedERC20, IEncryptedERC20Wrappe
constructor(
address erc20_
)
EncryptedERC20(
ConfidentialERC20(
string(abi.encodePacked("Encrypted ", IERC20Metadata(erc20_).name())),
string(abi.encodePacked("e", IERC20Metadata(erc20_).symbol()))
)
Expand All @@ -50,7 +50,7 @@ abstract contract EncryptedERC20Wrapped is EncryptedERC20, IEncryptedERC20Wrappe
}

/**
* @notice Unwrap EncryptedERC20 tokens to standard ERC20 tokens.
* @notice Unwrap ConfidentialERC20 tokens to standard ERC20 tokens.
* @param amount Amount to unwrap.
*/
function unwrap(uint64 amount) public virtual {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { EncryptedERC20 } from "./EncryptedERC20.sol";
import { ConfidentialERC20 } from "./ConfidentialERC20.sol";

import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";

import { IEncryptedERC20Wrapped } from "./IEncryptedERC20Wrapped.sol";
import { IConfidentialERC20Wrapped } from "./IConfidentialERC20Wrapped.sol";

/**
* @title EncryptedWETH
* @title ConfidentialWETH
* @notice This contract allows users to wrap/unwrap trustlessly
* ETH (or other native tokens) to EncryptedERC20 tokens.
* ETH (or other native tokens) to ConfidentialERC20 tokens.
*/
abstract contract EncryptedWETH is EncryptedERC20, IEncryptedERC20Wrapped, GatewayCaller {
abstract contract ConfidentialWETH is ConfidentialERC20, IConfidentialERC20Wrapped, GatewayCaller {
/// @notice Returned if ETH transfer fails.
error ETHTransferFail();

Expand All @@ -28,7 +28,7 @@ abstract contract EncryptedWETH is EncryptedERC20, IEncryptedERC20Wrapped, Gatew
* @dev The name/symbol are autogenerated.
*/
constructor()
EncryptedERC20(string(abi.encodePacked("Encrypted Wrapped Ether")), string(abi.encodePacked("eWETH")))
ConfidentialERC20(string(abi.encodePacked("Encrypted Wrapped Ether")), string(abi.encodePacked("eWETH")))
{}

/**
Expand All @@ -46,7 +46,7 @@ abstract contract EncryptedWETH is EncryptedERC20, IEncryptedERC20Wrapped, Gatew
}

/**
* @notice Unwrap EncryptedERC20 tokens to ether.
* @notice Unwrap ConfidentialERC20 tokens to ether.
* @param amount Amount to unwrap.
*/
function unwrap(uint64 amount) public virtual {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity ^0.8.24;

/**
* @title IEncryptedERC20Wrapped/
* @title IConfidentialERC20Wrapped/
* @notice Interface that defines events, errors, and structs for
* contrats that wrap native asset or ERC20 tokens.
*/
interface IEncryptedERC20Wrapped {
interface IConfidentialERC20Wrapped {
/// @notice Returned if the amount is greater than 2**64.
error AmountTooHigh();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { ethers } from "hardhat";

import type { ERC20Mintable, EncryptedERC20Wrapped, TestEncryptedERC20Wrapped } from "../../types";
import type { ConfidentialERC20Wrapped, ERC20Mintable, TestConfidentialERC20Wrapped } from "../../types";
import { Signers } from "../signers";

export async function deployERC20AndEncryptedERC20WrappedFixture(
export async function deployERC20AndConfidentialERC20WrappedFixture(
signers: Signers,
name: string,
symbol: string,
decimals: number,
): Promise<[ERC20Mintable, TestEncryptedERC20Wrapped]> {
): Promise<[ERC20Mintable, TestConfidentialERC20Wrapped]> {
const contractFactoryERC20Mintable = await ethers.getContractFactory("ERC20Mintable");
const contractERC20 = await contractFactoryERC20Mintable
.connect(signers.alice)
.deploy(name, symbol, decimals, signers.alice.address);
await contractERC20.waitForDeployment();

const contractFactoryEncryptedERC20Wrapped = await ethers.getContractFactory("TestEncryptedERC20Wrapped");
const contractEncryptedERC20Wrapped = await contractFactoryEncryptedERC20Wrapped
const contractFactory = await ethers.getContractFactory("TestConfidentialERC20Wrapped");
const contractConfidentialERC20Wrapped = await contractFactory
.connect(signers.alice)
.deploy(contractERC20.getAddress());
await contractEncryptedERC20Wrapped.waitForDeployment();
await contractConfidentialERC20Wrapped.waitForDeployment();

return [contractERC20, contractEncryptedERC20Wrapped];
return [contractERC20, contractConfidentialERC20Wrapped];
}

export async function mintAndWrap(
signers: Signers,
user: string,
plainToken: ERC20Mintable,
token: EncryptedERC20Wrapped,
token: ConfidentialERC20Wrapped,
tokenAddress: string,
amount: bigint,
): Promise<void> {
Expand Down
Loading

0 comments on commit 830c4b6

Please sign in to comment.