Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
dd378a1
created interfaces for Account recovery feature
Oct 16, 2023
37e2c9d
guardian interface and contract
Oct 17, 2023
1b09442
added test suite for Guardian.sol
Oct 20, 2023
3f4e74c
Merge branch 'thirdweb-dev:main' into account-social-recovery
alfheimrShiven Oct 20, 2023
a3cc320
AccountGuardian contract
Oct 20, 2023
f22fb72
added test suite for AccountGuardian contract
Oct 21, 2023
d3e6fe0
dependency injection for social recovery feature
Oct 21, 2023
3dba350
account lock req creation, signature validation and acceptance check
Oct 24, 2023
2ee0e32
Chainlink automation for lock request evaluation and lock account fea…
Oct 26, 2023
c642267
refactored deploy script for smart account util contracts
Oct 27, 2023
c476031
Deploy script for util contracts and its test
Oct 28, 2023
d7bd5d6
added link to feature doc in Readme
Oct 28, 2023
5bd148f
Merge pull request #1 from alfheimrShiven/account-social-recovery
alfheimrShiven Oct 30, 2023
14dfa8f
fixing..
Oct 30, 2023
8395b06
brought back DeployGuardian as DeploySmartAccountUtilContracts script…
Oct 30, 2023
b106090
Merge pull request #2 from alfheimrShiven/account-social-recovery
alfheimrShiven Oct 30, 2023
8001b8b
moved account util contract deployments to Account.sol, commented out…
Nov 1, 2023
c72f748
switched AccountLock to single instance deployment (as per the system…
Nov 2, 2023
a8ca25f
Merge pull request #3 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 2, 2023
19f18e3
restoring to util contract deployments to createAccount()
Nov 4, 2023
0ddb444
Changed the approach of calling Account.sol from AccountLock.sol
Nov 8, 2023
9c15308
added modifier to restrict an Account's lock status change by Account…
Nov 8, 2023
493001e
Merge pull request #4 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 8, 2023
f6b4843
made AccountGuardianTest compatible with deployment of AccountGuardia…
Nov 8, 2023
53b9588
replaced DeployGuardian script with DeploySmartAccountUtilContracts s…
Nov 10, 2023
38e568d
Merge pull request #5 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 10, 2023
3f763ed
sending AccountLock address while initilizing Account clones for acco…
Nov 14, 2023
665f243
Merge pull request #6 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 14, 2023
bb6c8ba
AccountLock tests: createLockRequest() unit tests
Nov 14, 2023
dc9a859
[Buggy] ECDSA.recover(hash, signature) throwing error
Nov 16, 2023
5a7d6aa
Merge pull request #7 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 16, 2023
a6f7e33
foundry error
codypharm Nov 17, 2023
82c9281
depencies added but errors persist
codypharm Nov 17, 2023
598de03
error comntinues
codypharm Nov 17, 2023
3be95eb
build error persists
codypharm Nov 17, 2023
896717d
updated chainlink remappings
Nov 17, 2023
b15ce17
ECDSA.recover(...) bug fixed, made lockRequest hash EIP 191 compatibl…
Nov 17, 2023
fe87435
Merge pull request #8 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 17, 2023
819a0a7
unlock request feature, refactored concensys evaluation to both lock/…
Nov 18, 2023
a764396
Merge pull request #9 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 18, 2023
4ae52bb
added unit tests for account unlock feature
Nov 18, 2023
a50e537
Merge pull request #10 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 19, 2023
0aee37b
Makefile
Nov 21, 2023
ad2a9b1
Merge pull request #11 from alfheimrShiven/account-social-recovery
alfheimrShiven Nov 22, 2023
cb6691e
cross chain transaction now includes estimated amount deposit
codypharm Nov 28, 2023
11c2173
slippage calvualtion added
codypharm Nov 29, 2023
1687b2f
bugs fixed
codypharm Nov 30, 2023
0bc9b51
stopped at this stage
codypharm Dec 4, 2023
20e1477
added IAccountRecovery
Dec 5, 2023
ecab36c
native payment intiation done
codypharm Dec 5, 2023
c3c5a31
link transfer initiator done
codypharm Dec 5, 2023
e822483
Account Recovery interface
Dec 5, 2023
42322c5
stock with userOp
codypharm Dec 5, 2023
0f95847
external signing implemented
codypharm Dec 5, 2023
37c3a36
recovery request guardian signature collection & concensus evaluation
Dec 7, 2023
78bb350
used isValidSignature but review is needed
codypharm Dec 7, 2023
7ceeb42
comments added and code made more dynamic
codypharm Dec 7, 2023
0bf4596
private key restoration
Dec 8, 2023
fc7af00
now using just one estimate function
codypharm Dec 9, 2023
4d4a248
proceed now has _
codypharm Dec 9, 2023
5c6ada8
Merge pull request #13 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 9, 2023
aaee738
Merge branch 'main' into cross-chain-transactions
codypharm Dec 9, 2023
b81a628
cross chain contracts deployed with accessible address
codypharm Dec 10, 2023
921b5c8
merge added
codypharm Dec 10, 2023
706d43e
getter added for account lock
codypharm Dec 10, 2023
c48ef73
Merge pull request #12 from alfheimrShiven/cross-chain-transactions
codypharm Dec 10, 2023
b818a8b
cross chain script sample added
codypharm Dec 10, 2023
faed719
Merge pull request #14 from alfheimrShiven/cross-chain-script
codypharm Dec 10, 2023
67ab98b
interface changes
Dec 10, 2023
e838c6d
Updated contract deploy script, fixed backward compatibility issues d…
Dec 10, 2023
318e840
Code optimized
codypharm Dec 10, 2023
7ec5c55
restructured functions
codypharm Dec 10, 2023
c036372
link address also added to constructot
codypharm Dec 10, 2023
3ad8a0b
master deployment updated
codypharm Dec 11, 2023
648be6c
one step skipped
codypharm Dec 11, 2023
e426334
last trial
codypharm Dec 11, 2023
21c1db4
Merge pull request #16 from alfheimrShiven/Fix-compilation
alfheimrShiven Dec 11, 2023
13454b1
Merge pull request #15 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 11, 2023
9994ac3
Update README.md
alfheimrShiven Dec 11, 2023
ddf5634
building cancelling
codypharm Dec 16, 2023
4e07d7c
resolved conflicts with main
Dec 18, 2023
4d11bd3
added AccountRecovery to deploy script
Dec 19, 2023
d968a8b
commented out both CCIP contracts [build still failing]
Dec 19, 2023
b17bd89
[FIX]: Fixed the stack too deep error by removing the _router, _link …
Dec 19, 2023
4b0133d
updating owner of smart account
Dec 22, 2023
89d12a4
Email verification to generate recovery request
Dec 24, 2023
669d16f
uncommented the CCIP contracts
Dec 24, 2023
15718b2
moved the deployment of CCIP contracts from BaseAccountFactory to non…
Dec 24, 2023
6a28d89
Merge pull request #17 from alfheimrShiven/revert/debugging
alfheimrShiven Dec 24, 2023
6413321
merged with main
Dec 24, 2023
14cc533
Merge pull request #18 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 24, 2023
a91ba30
updated account util deploy script and test
Dec 25, 2023
e12640a
Moved smart account creation to deploy script, updated deployment scr…
Dec 27, 2023
ab94b18
Merge pull request #19 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 27, 2023
17ed4de
generateRecoveryReq(..) tests
Dec 31, 2023
b9b472e
collectGuardianSignaturesOnRecoveryRequest(..) unit tests
Dec 31, 2023
b5490d4
refactored AccountRecovery unit tests
Dec 31, 2023
6abbb81
Consensus evaluation tests
Dec 31, 2023
f694b4f
Merge pull request #20 from alfheimrShiven/account-social-recovery
alfheimrShiven Dec 31, 2023
abbeeff
fixed Account::updateAdmin() function signature and call from Account…
Jan 3, 2024
6454a6c
Merge pull request #21 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 3, 2024
625340b
removed _generateSalt dependency on account admin, as it can get upda…
Jan 4, 2024
b0d399a
finished AccountRecovery unit tests. Coverage: 92%
Jan 4, 2024
af976db
Merge pull request #22 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 4, 2024
faf0a62
reduced params for commitEmailVerificationHash()
Jan 5, 2024
41099ca
Merge pull request #23 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 5, 2024
047eac0
updated Readme: Problem statement, Architecture
Jan 6, 2024
548776e
Merge pull request #24 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 6, 2024
d4162c5
updated Readme: Benefits of smart wallets
Jan 8, 2024
d54fdb5
Readme touchups
Jan 8, 2024
8b9536a
Merge pull request #25 from alfheimrShiven/account-social-recovery
alfheimrShiven Jan 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions contracts/prebuilts/account/dynamic/DynamicAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ contract DynamicAccount is AccountCore, BaseRouter {
Constructor and Initializer
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, Extension[] memory _defaultExtensions)
AccountCore(_entrypoint, msg.sender)
BaseRouter(_defaultExtensions)
{
constructor(
IEntryPoint _entrypoint,
Extension[] memory _defaultExtensions
) AccountCore(_entrypoint, msg.sender) BaseRouter(_defaultExtensions) {
_disableInitializers();
}

/// @notice Initializes the smart contract wallet.
function initialize(address _defaultAdmin, bytes calldata) public override initializer {
function initialize(address _defaultAdmin, bytes calldata, address _accountLock) public override initializer {
__BaseRouter_init();
AccountCoreStorage.data().firstAdmin = _defaultAdmin;
_setAdmin(_defaultAdmin, true);
Expand Down
15 changes: 6 additions & 9 deletions contracts/prebuilts/account/dynamic/DynamicAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, IExtension.Extension[] memory _defaultExtensions)
BaseAccountFactory(payable(address(new DynamicAccount(_entrypoint, _defaultExtensions))), address(_entrypoint))
{
constructor(
IEntryPoint _entrypoint,
IExtension.Extension[] memory _defaultExtensions
) BaseAccountFactory(payable(address(new DynamicAccount(_entrypoint, _defaultExtensions))), address(_entrypoint)) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

Expand All @@ -37,12 +38,8 @@ contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
//////////////////////////////////////////////////////////////*/

/// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
function _initializeAccount(
address _account,
address _admin,
bytes calldata _data
) internal override {
DynamicAccount(payable(_account)).initialize(_admin, _data);
function _initializeAccount(address _account, address _admin, bytes calldata _data) internal override {
DynamicAccount(payable(_account)).initialize(_admin, _data, address(accountLock));
}

/// @dev Returns whether contract metadata can be set in the given execution context.
Expand Down
13 changes: 6 additions & 7 deletions contracts/prebuilts/account/managed/ManagedAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ contract ManagedAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, Extension[] memory _defaultExtensions)
constructor(
IEntryPoint _entrypoint,
Extension[] memory _defaultExtensions
)
BaseRouter(_defaultExtensions)
BaseAccountFactory(payable(address(new ManagedAccount(_entrypoint, address(this)))), address(_entrypoint))
{
Expand All @@ -43,12 +46,8 @@ contract ManagedAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
//////////////////////////////////////////////////////////////*/

/// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
function _initializeAccount(
address _account,
address _admin,
bytes calldata _data
) internal override {
ManagedAccount(payable(_account)).initialize(_admin, _data);
function _initializeAccount(address _account, address _admin, bytes calldata _data) internal override {
ManagedAccount(payable(_account)).initialize(_admin, _data, address(accountLock));
}

/// @dev Returns whether all relevant permission and other checks are met before any upgrade.
Expand Down
12 changes: 6 additions & 6 deletions contracts/prebuilts/account/non-upgradeable/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "../../../eip/ERC1271.sol";
import "../utils/Helpers.sol";
import "../../../external-deps/openzeppelin/utils/cryptography/ECDSA.sol";
import "../utils/BaseAccountFactory.sol";

import "forge-std/console.sol";
import { Guardian } from "../utils/Guardian.sol";
import { AccountLock } from "../utils/AccountLock.sol";

Expand All @@ -37,17 +37,15 @@ contract Account is AccountCore, ContractMetadata, ERC1271, ERC721Holder, ERC115
using EnumerableSet for EnumerableSet.AddressSet;
bool public paused;
Guardian guardian;
address accountLock;

error NotAuthorizedToLock(address locker);
error NotAuthorizedToLock(address locker, address accountLock);

/*///////////////////////////////////////////////////////////////
Constructor, Initializer, Modifiers
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, address _factory, address _accountLock) AccountCore(_entrypoint, _factory) {
constructor(IEntryPoint _entrypoint, address _factory) AccountCore(_entrypoint, _factory) {
paused = false;
accountLock = _accountLock;
}

/// @notice Checks whether the caller is the EntryPoint contract or the admin.
Expand All @@ -58,8 +56,9 @@ contract Account is AccountCore, ContractMetadata, ERC1271, ERC721Holder, ERC115

/// @notice The account can be paused only by the AccountLock contract
modifier onlyAccountLock(address locker) {
console.log("AccountLock address in Account.sol", accountLock);
if (locker != accountLock) {
revert NotAuthorizedToLock(locker);
revert NotAuthorizedToLock(locker, accountLock);
}
_;
}
Expand Down Expand Up @@ -139,6 +138,7 @@ contract Account is AccountCore, ContractMetadata, ERC1271, ERC721Holder, ERC115

function setPaused(bool pauseStatus) external onlyAccountLock(msg.sender) {
paused = pauseStatus;
AccountLock(accountLock).addLockAccountToList(address(this));
}

/*///////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import "../interface/IEntrypoint.sol";
import { Account } from "./Account.sol";
import { Guardian } from "../utils/Guardian.sol";

import "forge-std/console.sol";

// $$\ $$\ $$\ $$\ $$\
// $$ | $$ | \__| $$ | $$ |
// $$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\
Expand All @@ -33,7 +35,7 @@ contract AccountFactory is BaseAccountFactory, ContractMetadata, PermissionsEnum

constructor(
IEntryPoint _entrypoint
) BaseAccountFactory(address(new Account(_entrypoint, address(this), address(accountLock))), address(_entrypoint)) {
) BaseAccountFactory(address(new Account(_entrypoint, address(this))), address(_entrypoint)) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

Expand All @@ -43,7 +45,9 @@ contract AccountFactory is BaseAccountFactory, ContractMetadata, PermissionsEnum

/// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
function _initializeAccount(address _account, address _admin, bytes calldata _data) internal override {
Account(payable(_account)).initialize(_admin, _data);
console.log("AccountLock address in AccountFactory used to initialize account clone", address(accountLock));

Account(payable(_account)).initialize(_admin, _data, address(accountLock));
}

/// @dev Returns whether contract metadata can be set in the given execution context.
Expand Down
7 changes: 4 additions & 3 deletions contracts/prebuilts/account/utils/AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { AccountExtension } from "./AccountExtension.sol";
import "../../../external-deps/openzeppelin/utils/cryptography/ECDSA.sol";

import "../interface/IAccountCore.sol";
import { AccountLock } from "./AccountLock.sol";

// $$\ $$\ $$\ $$\ $$\
// $$ | $$ | \__| $$ | $$ |
Expand All @@ -40,6 +39,8 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
State
//////////////////////////////////////////////////////////////*/

address public accountLock;

/// @notice EIP 4337 factory for this contract.
address public immutable factory;

Expand All @@ -57,12 +58,12 @@ contract AccountCore is IAccountCore, Initializable, Multicall, BaseAccount, Acc
}

/// @notice Initializes the smart contract wallet.
function initialize(address _defaultAdmin, bytes calldata) public virtual initializer {
function initialize(address _defaultAdmin, bytes calldata, address _accountLock) public virtual initializer {
// This is passed as data in the `_registerOnFactory()` call in `AccountExtension` / `Account`.
AccountCoreStorage.data().firstAdmin = _defaultAdmin;
_setAdmin(_defaultAdmin, true);

// deployAccountGuardian(_accountClone, _accountLock);
accountLock = _accountLock;
}

/*///////////////////////////////////////////////////////////////
Expand Down
136 changes: 70 additions & 66 deletions contracts/prebuilts/account/utils/AccountLock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ struct RegistrationParams {
uint96 amount;
}

contract AccountLock is IAccountLock, AutomationCompatibleInterface {
contract AccountLock is IAccountLock {
Guardian public guardianContract;
uint8 public constant DECIMAL = 8;
int256 public constant INITIAL_LINK_PRICE = 2000e8;
int256 public constant INITIAL_GAS_PRICE = 2e8;
uint96 public constant FUND_UPKEEP_LINK_TOKEN = 5e18;
uint256 public constant LOCK_REQUEST_TIME_TO_EVALUATION = 604800; // 7 days
address[] internal _lockedAccounts;
address[] public lockedAccounts;
mapping(address => bytes32) private accountToLockRequest;
mapping(bytes32 => uint256) private lockRequestToCreationTime;
mapping(bytes32 => bool) private lockRequestEvaluationStatus;
Expand All @@ -45,30 +45,30 @@ contract AccountLock is IAccountLock, AutomationCompatibleInterface {
// (TODO: To be moved to a script file)//
//////////////////////////////////////////

MockLinkToken mockLinkToken = new MockLinkToken();
// MockLinkToken mockLinkToken = new MockLinkToken();

MockV3Aggregator linkNativePriceFeed = new MockV3Aggregator(DECIMAL, INITIAL_LINK_PRICE);
// MockV3Aggregator linkNativePriceFeed = new MockV3Aggregator(DECIMAL, INITIAL_LINK_PRICE);

MockV3Aggregator fastGasPriceFeed = new MockV3Aggregator(DECIMAL, INITIAL_LINK_PRICE);
// MockV3Aggregator fastGasPriceFeed = new MockV3Aggregator(DECIMAL, INITIAL_LINK_PRICE);

KeeperRegistryBase2_0Mock keeperRegistryBase =
new KeeperRegistryBase2_0Mock(
KeeperRegistryBase2_0Mock.Mode.DEFAULT,
address(mockLinkToken),
address(linkNativePriceFeed),
address(fastGasPriceFeed)
);
// KeeperRegistryBase2_0Mock keeperRegistryBase =
// new KeeperRegistryBase2_0Mock(
// KeeperRegistryBase2_0Mock.Mode.DEFAULT,
// address(mockLinkToken),
// address(linkNativePriceFeed),
// address(fastGasPriceFeed)
// );

KeeperRegistry2_0Mock chainlinkKeeperRegistry = new KeeperRegistry2_0Mock(keeperRegistryBase);
// KeeperRegistry2_0Mock chainlinkKeeperRegistry = new KeeperRegistry2_0Mock(keeperRegistryBase);

KeeperRegistrar2_0Mock chainlinkKeeperRegistrar =
new KeeperRegistrar2_0Mock(
address(mockLinkToken),
KeeperRegistrar2_0Mock.AutoApproveType.ENABLED_ALL,
type(uint16).max,
address(chainlinkKeeperRegistry),
FUND_UPKEEP_LINK_TOKEN
);
// KeeperRegistrar2_0Mock chainlinkKeeperRegistrar =
// new KeeperRegistrar2_0Mock(
// address(mockLinkToken),
// KeeperRegistrar2_0Mock.AutoApproveType.ENABLED_ALL,
// type(uint16).max,
// address(chainlinkKeeperRegistry),
// FUND_UPKEEP_LINK_TOKEN
// );

constructor(Guardian _guardian) {
guardianContract = _guardian;
Expand Down Expand Up @@ -111,7 +111,7 @@ contract AccountLock is IAccountLock, AutomationCompatibleInterface {

bytes memory chainlinkUpkeepCheckData = abi.encode(lockRequestHash, account);

_registerAndFundUpKeepForEvaluationUsingTimeBasedTrigger(chainlinkUpkeepCheckData);
// _registerAndFundUpKeepForEvaluationUsingTimeBasedTrigger(chainlinkUpkeepCheckData);
return lockRequestHash;
}

Expand Down Expand Up @@ -148,47 +148,51 @@ contract AccountLock is IAccountLock, AutomationCompatibleInterface {
}
}

function addLockAccountToList(address account) public {
lockedAccounts.push(account);
}

/////////////////////////////////
/////// Chainlink Automation /////
////////////////////////////////

function checkUpkeep(bytes memory checkData) public view returns (bool upkeepNeeded, bytes memory performData) {
// assembly {
// mstore(add(lockRequest, 0x20), mload(add(checkData, 0x20)))
// mstore(add(account, 0x20), mload(add(checkData, 0x40)))
// }
// function checkUpkeep(bytes memory checkData) public view returns (bool upkeepNeeded, bytes memory performData) {
// // assembly {
// // mstore(add(lockRequest, 0x20), mload(add(checkData, 0x20)))
// // mstore(add(account, 0x20), mload(add(checkData, 0x40)))
// // }

(bytes32 lockRequest, address account) = abi.decode(checkData, (bytes32, address));
// (bytes32 lockRequest, address account) = abi.decode(checkData, (bytes32, address));

if (lockRequestEvaluationStatus[lockRequest]) {
return (false, checkData);
}
// if (lockRequestEvaluationStatus[lockRequest]) {
// return (false, checkData);
// }

uint256 lockRequestTimeElapsedSinceCreation = block.timestamp - lockRequestToCreationTime[lockRequest];
// uint256 lockRequestTimeElapsedSinceCreation = block.timestamp - lockRequestToCreationTime[lockRequest];

if (lockRequestTimeElapsedSinceCreation >= LOCK_REQUEST_TIME_TO_EVALUATION) {
return (true, checkData);
} else {
return (false, checkData);
}
}
// if (lockRequestTimeElapsedSinceCreation >= LOCK_REQUEST_TIME_TO_EVALUATION) {
// return (true, checkData);
// } else {
// return (false, checkData);
// }
// }

function performUpkeep(bytes calldata performData) external {
(bool upkeepNeeded, bytes memory performData) = checkUpkeep(performData);
// function performUpkeep(bytes calldata performData) external {
// (bool upkeepNeeded, bytes memory performData) = checkUpkeep(performData);

if (upkeepNeeded) {
// retrieving the lockRequest and account address from performData
(bytes32 lockRequest, address account) = abi.decode(performData, (bytes32, address));
// if (upkeepNeeded) {
// // retrieving the lockRequest and account address from performData
// (bytes32 lockRequest, address account) = abi.decode(performData, (bytes32, address));

lockRequestEvaluation(lockRequest, account);
}
}
// lockRequestEvaluation(lockRequest, account);
// }
// }

/////////////////////////////////
/////// View Func //////////////
////////////////////////////////
function activeLockRequestExists(address account) public view returns (bool) {
if (accountToLockRequest[account].length > 0) {
if (accountToLockRequest[account] != bytes32(0)) {
return true;
} else {
return false;
Expand Down Expand Up @@ -216,8 +220,8 @@ contract AccountLock is IAccountLock, AutomationCompatibleInterface {
/////////////////////////////////

function _isLocked(address account) internal view returns (bool) {
for (uint256 a = 0; a < _lockedAccounts.length; a++) {
if (_lockedAccounts[a] == account) {
for (uint256 a = 0; a < lockedAccounts.length; a++) {
if (lockedAccounts[a] == account) {
return true;
}
}
Expand Down Expand Up @@ -247,21 +251,21 @@ contract AccountLock is IAccountLock, AutomationCompatibleInterface {
/**
* @notice Function to register & fund an upkeep that'll be responsible for evaluating the lock request responses using a time based Chainlink Automation
*/
function _registerAndFundUpKeepForEvaluationUsingTimeBasedTrigger(bytes memory chainlinkUpkeepCheckData) internal {
mockLinkToken.transferAndCall(address(chainlinkKeeperRegistrar), FUND_UPKEEP_LINK_TOKEN, "");

KeeperRegistrar2_0Mock.RegistrationParams memory registrationParams = KeeperRegistrar2_0Mock
.RegistrationParams({
name: string(abi.encodePacked("Lock Request Upkeep", chainlinkUpkeepCheckData)),
encryptedEmail: new bytes(0),
upkeepContract: address(this),
gasLimit: 500000,
adminAddress: address(0x689EcF264657302052c3dfBD631e4c20d3ED0baB),
checkData: chainlinkUpkeepCheckData,
offchainConfig: new bytes(0),
amount: 5e18
});

chainlinkKeeperRegistrar.registerUpkeep(registrationParams);
}
// function _registerAndFundUpKeepForEvaluationUsingTimeBasedTrigger(bytes memory chainlinkUpkeepCheckData) internal {
// mockLinkToken.transferAndCall(address(chainlinkKeeperRegistrar), FUND_UPKEEP_LINK_TOKEN, "");

// KeeperRegistrar2_0Mock.RegistrationParams memory registrationParams = KeeperRegistrar2_0Mock
// .RegistrationParams({
// name: string(abi.encodePacked("Lock Request Upkeep", chainlinkUpkeepCheckData)),
// encryptedEmail: new bytes(0),
// upkeepContract: address(this),
// gasLimit: 500000,
// adminAddress: address(0x689EcF264657302052c3dfBD631e4c20d3ED0baB),
// checkData: chainlinkUpkeepCheckData,
// offchainConfig: new bytes(0),
// amount: 5e18
// });

// chainlinkKeeperRegistrar.registerUpkeep(registrationParams);
// }
}
Loading