Skip to content

Commit

Permalink
feat: add default configs for Gateway and FHEVM
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Nov 15, 2024
1 parent c5e6f87 commit 5d84f04
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
90 changes: 90 additions & 0 deletions config/DefaultFHEVMConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import {FHEVMConfig, TFHE} from "../lib/TFHE.sol";

/**
* @dev Address of the ACL contract from Zama for mock purposes.
*/
address constant ACL_MOCK = 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2;

/**
* @dev Address of the TFHEExecutor contract from Zama for mock purposes.
*/
address constant TFHEEXECUTOR_MOCK = 0x596E6682c72946AF006B27C131793F2b62527A4b;

/**
* @dev Address of the FHEPayment contract from Zama for mock purposes.
*/
address constant FHEPAYMENT_MOCK = 0x6d5A11aC509C707c00bc3A0a113ACcC26c532547;

/**
* @dev Address of the KMSVerifier contract from Zama for mock purposes.
*/
address constant KMSVERIFIER_MOCK = 0x208De73316E44722e16f6dDFF40881A3e4F86104;

/**
* @title ZamaConfig.
* @notice This library returns the TFHE config for different networks
* with the contract addresses for
* (1) ACL, (2) TFHEExecutor, (3) FHEPayment, (4) KMSVerifier,
* which are deployed & maintained by Zama.
*/
library ZamaFHEVMConfig {
function getMockConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
return
FHEVMConfig.FHEVMConfigStruct({
ACLAddress: ACL_MOCK,
TFHEExecutorAddress: TFHEEXECUTOR_MOCK,
FHEPaymentAddress: FHEPAYMENT_MOCK,
KMSVerifierAddress: KMSVERIFIER_MOCK
});
}

function getSepoliaConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
/// TODO
}

function getMainnetConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
/// TODO
}
}

/**
* @title MockZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use these contracts on the mock
* environment provided by Zama.
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions provided by these providers.
*/
contract MockZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getMockConfig());
}
}

/**
* @title SepoliaZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use the FHEVM contracts provided by Zama
* on the Sepolia network.
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions provided by these providers.
*/
contract SepoliaZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getSepoliaConfig());
}
}

/**
* @title MainnetZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use the FHEVM contracts provided by Zama
* on the Mainnet network.
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions provided by these providers.
*/
contract MainnetZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getMainnetConfig());
}
}
24 changes: 24 additions & 0 deletions config/DefaultGatewayConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import {Gateway} from "../gateway/lib/Gateway.sol";

/**
* @dev Address of the Gateway contract from Zama for mock purposes.
*/
address constant GATEWAY_MOCK = 0x096b4679d45fB675d4e2c1E4565009Cec99A12B1;

/**
* @title MockZamaGatewayConfig.
* @notice This config contains the mock Gateway config with the address for the Gateway
* contract deployed & maintained by Zama.
* @dev This contract can be inherited by a contract wishing to use the Gateway service
* provided by Zama.
* Other providers may offer other Gateways deployed at different addresses.
* If you wish to use them, you should rely on the instructions provided by these providers.
*/
contract MockZamaGatewayConfig {
constructor() {
Gateway.setGateway(GATEWAY_MOCK);
}
}

0 comments on commit 5d84f04

Please sign in to comment.