Skip to content

Commit 0843c10

Browse files
authored
Merge pull request #47 from skalenetwork/bite-solidity
Start using bite-solidity library
2 parents db793ac + 3faaf7d commit 0843c10

17 files changed

Lines changed: 61 additions & 830 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ node_modules
3636

3737
# Hardhat Ignition default folder for deployments against a local node
3838
ignition/deployments/chain-31337
39+
40+
# imported contracts
41+
contracts/hardhat-dependency-compiler

.solhintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
contracts/hardhat-dependency-compiler

contracts/ConfidentialToken.sol

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ import { ERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/ERC2
2929
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
3030
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
3131
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
32+
import { BITE, PublicKey } from "@skalenetwork/bite-solidity/BITE.sol";
3233

3334
import { EIP3009 } from "./eip3009/EIP3009.sol";
3435

3536
import { ZeroAddress } from "./errors.sol";
36-
import { IBiteSupplicant } from "./interfaces/bite/IBiteSupplicant.sol";
37-
import { IConfidentialToken } from "./interfaces/IConfidentialToken.sol";
38-
import { Precompiled } from "./Precompiled.sol";
39-
import { PublicKey } from "./types.sol";
37+
import { IBiteSupplicant, IConfidentialToken } from "./interfaces/IConfidentialToken.sol";
4038

4139

4240
/// @title ConfidentialToken
@@ -54,10 +52,10 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
5452
uint256 public callbackFee = 1_000 gwei;
5553

5654
/// @notice Address of the EncryptECIES precompiled contract
57-
address public encryptECIESAddress = address(0x1C);
55+
address public encryptECIESAddress = BITE.ENCRYPT_ECIES_ADDRESS;
5856

5957
/// @notice Address of the EncryptTE precompiled contract
60-
address public encryptTEAddress = address(0x1D);
58+
address public encryptTEAddress = BITE.ENCRYPT_TE_ADDRESS;
6159

6260
/// @notice Mapping of holder addresses to their viewers' addresses
6361
mapping(address holder => address viewerAddress) public viewerAddresses;
@@ -66,7 +64,7 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
6664
mapping(address accountAddress => PublicKey publicKey) public publicKeys;
6765

6866
/// @notice Address of the submitCTX precompiled contract
69-
address public submitCTXAddress = address(0x1B);
67+
address public submitCTXAddress = BITE.SUBMIT_CTX_ADDRESS;
7068

7169
/// @notice Version of the contract
7270
/// @dev Is used to get proper ABI
@@ -385,7 +383,7 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
385383
}
386384
uint256 valueIndex = encryptedArgumentsLength;
387385
++encryptedArgumentsLength;
388-
bytes memory encryptedValue = Precompiled.encryptTE(encryptTEAddress, abi.encodePacked(value));
386+
bytes memory encryptedValue = BITE.encryptTE(encryptTEAddress, abi.encodePacked(value));
389387

390388
bytes[] memory encryptedArguments = new bytes[](encryptedArgumentsLength);
391389
if (from != address(0)) {
@@ -399,7 +397,7 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
399397
bytes[] memory plaintextArguments = new bytes[](1);
400398
plaintextArguments[0] = abi.encode(from, to);
401399

402-
address payable callback = Precompiled.submitCTX(
400+
address payable callback = BITE.submitCTX(
403401
submitCTXAddress,
404402
callbackFee / tx.gasprice,
405403
encryptedArguments,
@@ -414,10 +412,10 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
414412
// Private functions
415413

416414
function _setBalance(address holder, uint256 balance) private {
417-
_thresholdBalances[holder] = Precompiled.encryptTE(encryptTEAddress, abi.encodePacked(balance));
415+
_thresholdBalances[holder] = BITE.encryptTE(encryptTEAddress, abi.encodePacked(balance));
418416
if (_viewerIsRegistered(holder)) {
419417
PublicKey memory viewerPublicKey = _getViewKey(holder);
420-
_userBalances[holder] = Precompiled.encryptECIES(
418+
_userBalances[holder] = BITE.encryptECIES(
421419
encryptECIESAddress,
422420
abi.encodePacked(balance),
423421
viewerPublicKey
@@ -428,7 +426,7 @@ contract ConfidentialToken is EIP3009, ERC20Permit, AccessManaged, IConfidential
428426
function _getEncryptedBalance(address holder) private view returns (bytes memory encryptedBalance) {
429427
encryptedBalance = _thresholdBalances[holder];
430428
if (encryptedBalance.length == 0) {
431-
encryptedBalance = Precompiled.encryptTE(
429+
encryptedBalance = BITE.encryptTE(
432430
encryptTEAddress,
433431
abi.encodePacked(uint256(0))
434432
);

contracts/Precompiled.sol

Lines changed: 0 additions & 184 deletions
This file was deleted.

contracts/interfaces/IConfidentialToken.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
pragma solidity ^0.8.24;
2525

26-
import { PublicKey } from "../types.sol";
27-
import { IBiteSupplicant } from "./bite/IBiteSupplicant.sol";
26+
import { PublicKey } from "@skalenetwork/bite-solidity/BITE.sol";
27+
import { IBiteSupplicant } from "@skalenetwork/bite-solidity/interfaces/IBiteSupplicant.sol";
2828

2929

3030
/// @title IConfidentialToken

contracts/interfaces/bite/IBiteSupplicant.sol

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)