mirror of
https://github.com/getwax/bls-wallet.git
synced 2026-01-09 15:48:11 -05:00
@@ -10,8 +10,6 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so
|
||||
import "./interfaces/IWallet.sol";
|
||||
import "./BLSWallet.sol";
|
||||
|
||||
import "hardhat/console.sol";
|
||||
|
||||
/**
|
||||
A non-upgradable gateway used to create BLSWallets and call them with
|
||||
verified Operations that have been respectively signed.
|
||||
@@ -52,13 +50,6 @@ contract VerificationGateway
|
||||
bytes[] results
|
||||
);
|
||||
|
||||
event WalletOperationFailed(
|
||||
bytes32 indexed walletHash,
|
||||
address indexed wallet,
|
||||
uint256 nonce,
|
||||
bytes returnData
|
||||
);
|
||||
|
||||
event PendingBLSKeySet(
|
||||
bytes32 previousHash,
|
||||
uint256[BLS_KEY_LEN] newBLSKey
|
||||
@@ -326,8 +317,8 @@ contract VerificationGateway
|
||||
Can be called with a single operation with no actions.
|
||||
*/
|
||||
function processBundle(
|
||||
IWallet.Bundle calldata bundle
|
||||
) external payable returns (
|
||||
IWallet.Bundle memory bundle
|
||||
) external returns (
|
||||
bool[] memory successes,
|
||||
bytes[][] memory results
|
||||
) {
|
||||
@@ -338,65 +329,25 @@ contract VerificationGateway
|
||||
successes = new bool[](opLength);
|
||||
results = new bytes[][](opLength);
|
||||
for (uint256 i = 0; i<opLength; i++) {
|
||||
IWallet wallet = getOrCreateWallet(bundle.senderPublicKeys[i]);
|
||||
|
||||
bytes32 publicKeyHash = keccak256(abi.encodePacked(bundle.senderPublicKeys[i]));
|
||||
address walletAddress = address(walletFromHash[publicKeyHash]);
|
||||
|
||||
// try wallet calls, catching if they throw
|
||||
try this._processWalletOperation(
|
||||
bundle.senderPublicKeys[i],
|
||||
bundle.operations[i]
|
||||
) returns (
|
||||
bool success,
|
||||
bytes[] memory resultSet
|
||||
) {
|
||||
walletAddress = address(walletFromHash[publicKeyHash]);
|
||||
|
||||
console.log(" vg: pass"); //TODO remove log event without creating errors
|
||||
|
||||
// check nonce then perform action
|
||||
if (bundle.operations[i].nonce == wallet.nonce{gas:20000}()) {
|
||||
// request wallet perform operation
|
||||
(
|
||||
bool success,
|
||||
bytes[] memory resultSet
|
||||
) = wallet.performOperation{gas:bundle.operations[i].gas}(bundle.operations[i]);
|
||||
successes[i] = success;
|
||||
results[i] = resultSet;
|
||||
emit WalletOperationProcessed(
|
||||
walletAddress,
|
||||
address(wallet),
|
||||
bundle.operations[i].nonce,
|
||||
bundle.operations[i].actions,
|
||||
successes[i],
|
||||
results[i]
|
||||
);
|
||||
address(0).staticcall(""); //TODO remove this line without creating more errors
|
||||
}
|
||||
catch (bytes memory returnData) { //TODO add tests for wallet implementations that throw
|
||||
console.log(" vg: fail");
|
||||
successes[i] = false;
|
||||
results[i] = new bytes[](1);
|
||||
results[i][0] = returnData;
|
||||
emit WalletOperationFailed(
|
||||
publicKeyHash,
|
||||
walletAddress,
|
||||
bundle.operations[i].nonce,
|
||||
returnData
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Perform wallet related functions that could throw.
|
||||
@dev Restricted to only be called by this contract, but needs to be public
|
||||
so that it can be used in a try/catch block.
|
||||
*/
|
||||
function _processWalletOperation(
|
||||
uint256[4] calldata senderPublicKey,
|
||||
IWallet.Operation calldata operation
|
||||
) public payable onlyThis returns (
|
||||
bool success,
|
||||
bytes[] memory resultSet
|
||||
)
|
||||
{
|
||||
IWallet wallet = getOrCreateWallet(senderPublicKey);
|
||||
// check nonce then perform action
|
||||
if (operation.nonce == wallet.nonce{gas:20000}()) {
|
||||
(success, resultSet) = wallet.performOperation{gas:operation.gas}(operation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,11 +462,6 @@ contract VerificationGateway
|
||||
_;
|
||||
}
|
||||
|
||||
modifier onlyThis() {
|
||||
require(msg.sender == address(this), "VG: not called from VG");
|
||||
_;
|
||||
}
|
||||
|
||||
function messagePoint(
|
||||
address walletAddress,
|
||||
IWallet.Operation memory op
|
||||
|
||||
@@ -85,7 +85,7 @@ const config: HardhatUserConfig = {
|
||||
solidity: {
|
||||
compilers: [
|
||||
{
|
||||
version: "0.8.19",
|
||||
version: "0.8.15",
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"@openzeppelin/contracts": "^4.7.3",
|
||||
"dotenv": "^16.0.3",
|
||||
"ethers": "^5.7.2",
|
||||
"hardhat": "^2.13.0"
|
||||
"hardhat": "^2.12.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"ethers": "^5.0.0"
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BigNumber, ContractReceipt } from "ethers";
|
||||
import { parseEther, solidityPack } from "ethers/lib/utils";
|
||||
import { getOperationResults } from "../clients/src";
|
||||
|
||||
describe.only("WalletActions", async function () {
|
||||
describe("WalletActions", async function () {
|
||||
if (`${process.env.DEPLOYER_DEPLOYMENT}` === "true") {
|
||||
console.log("Skipping non-deployer tests.");
|
||||
return;
|
||||
|
||||
@@ -5574,10 +5574,10 @@ hardhat-gas-reporter@^1.0.9:
|
||||
eth-gas-reporter "^0.2.25"
|
||||
sha1 "^1.1.1"
|
||||
|
||||
hardhat@^2.13.0:
|
||||
version "2.13.0"
|
||||
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.13.0.tgz#d52a0ec9b733a651687e5b1c1b0ee9a11a30f3d0"
|
||||
integrity sha512-ZlzBOLML1QGlm6JWyVAG8lVTEAoOaVm1in/RU2zoGAnYEoD1Rp4T+ZMvrLNhHaaeS9hfjJ1gJUBfiDr4cx+htQ==
|
||||
hardhat@^2.12.1:
|
||||
version "2.12.6"
|
||||
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.12.6.tgz#ea3c058bbd81850867389d10f76037cfa52a0019"
|
||||
integrity sha512-0Ent1O5DsPgvaVb5sxEgsQ3bJRt/Ex92tsoO+xjoNH2Qc4bFmhI5/CHVlFikulalxOPjNmw5XQ2vJFuVQFESAA==
|
||||
dependencies:
|
||||
"@ethersproject/abi" "^5.1.2"
|
||||
"@metamask/eth-sig-util" "^4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user