-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added fallback on origin, AA compatibility, tests
- Loading branch information
Showing
8 changed files
with
484 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
pragma solidity ^0.8.24; | ||
|
||
import "../lib/TFHE.sol"; | ||
import "@openzeppelin/contracts/access/Ownable2Step.sol"; | ||
import "../payment/Payment.sol"; | ||
|
||
contract PaymentLimit { | ||
constructor() payable { | ||
Payment.depositForThis(msg.value); | ||
} | ||
|
||
function wayunderBlockFHEGasLimit() external { | ||
// should pass if only tx in block | ||
euint64 x = TFHE.asEuint64(2); | ||
euint64 result; | ||
for (uint256 i; i < 3; i++) { | ||
result = TFHE.mul(result, x); | ||
} | ||
} | ||
|
||
function underBlockFHEGasLimit() external { | ||
// should pass if only tx in block | ||
euint64 x = TFHE.asEuint64(2); | ||
euint64 result; | ||
for (uint256 i; i < 15; i++) { | ||
result = TFHE.mul(result, x); | ||
} | ||
} | ||
|
||
function aboveBlockFHEGasLimit() external { | ||
// should revert due to exceeding block fheGas limit | ||
euint64 x = TFHE.asEuint64(2); | ||
euint64 result; | ||
for (uint256 i; i < 16; i++) { | ||
result = TFHE.mul(result, x); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
pragma solidity ^0.8.24; | ||
|
||
import "@openzeppelin/contracts/access/Ownable2Step.sol"; | ||
|
||
contract SmartAccount is Ownable2Step { | ||
struct Transaction { | ||
address target; | ||
uint256 value; | ||
bytes data; | ||
} | ||
|
||
constructor() Ownable(msg.sender) {} | ||
|
||
function executeBatch(Transaction[] memory transactions) public payable onlyOwner { | ||
for (uint i = 0; i < transactions.length; i++) { | ||
Transaction memory transaction = transactions[i]; | ||
(bool success, ) = transaction.target.call{value: transaction.value}(transaction.data); | ||
require(success, "Transaction failed"); | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import dotenv from 'dotenv'; | ||
import fs from 'fs'; | ||
import { ethers } from 'hardhat'; | ||
|
||
export async function initializeFHEPayment() { | ||
const fhePaymentFactory = await ethers.getContractFactory('FHEPayment'); | ||
const parsedFHEPayment = dotenv.parse(fs.readFileSync('lib/.env.fhepayment')); | ||
const fhePayment = fhePaymentFactory.attach(parsedFHEPayment.FHE_PAYMENT_CONTRACT_ADDRESS); | ||
return fhePayment; | ||
} | ||
|
||
export const FHE_GASPRICE_NATIVE_RATIO = 1000n; | ||
export const MIN_FHE_GASPRICE = 10_000_000n; |
Oops, something went wrong.