Skip to content

Commit 5e8a64f

Browse files
committed
add LICENSE
1 parent ac0395d commit 5e8a64f

File tree

7 files changed

+2186
-1
lines changed

7 files changed

+2186
-1
lines changed

LICENSE

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Business Source License 1.1
2+
3+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4+
"Business Source License" is a trademark of MariaDB Corporation Ab.
5+
6+
-----------------------------------------------------------------------------
7+
8+
Parameters
9+
10+
Licensor: Intuition Systems, Inc.
11+
12+
Licensed Work: Intuition Protocol Contracts
13+
The Licensed Work is (c) 2024 Intuition Systems, Inc.
14+
15+
Additional Use Grant: None.
16+
17+
Change Date: The earlier of 2026-06-01 (June 1st, 2026) or a date
18+
specified at https://
19+
20+
Change License: MIT
21+
22+
-----------------------------------------------------------------------------
23+
24+
Terms
25+
26+
The Licensor hereby grants you the right to copy, modify, create derivative
27+
works, redistribute, and make non-production use of the Licensed Work. The
28+
Licensor may make an Additional Use Grant, above, permitting limited
29+
production use.
30+
31+
Effective on the Change Date, or the fourth anniversary of the first publicly
32+
available distribution of a specific version of the Licensed Work under this
33+
License, whichever comes first, the Licensor hereby grants you rights under
34+
the terms of the Change License, and the rights granted in the paragraph
35+
above terminate.
36+
37+
If your use of the Licensed Work does not comply with the requirements
38+
currently in effect as described in this License, you must purchase a
39+
commercial license from the Licensor, its affiliated entities, or authorized
40+
resellers, or you must refrain from using the Licensed Work.
41+
42+
All copies of the original and modified Licensed Work, and derivative works
43+
of the Licensed Work, are subject to this License. This License applies
44+
separately for each version of the Licensed Work and the Change Date may vary
45+
for each version of the Licensed Work released by Licensor.
46+
47+
You must conspicuously display this License on each original or modified copy
48+
of the Licensed Work. If you receive the Licensed Work in original or
49+
modified form from a third party, the terms and conditions set forth in this
50+
License apply to your use of that work.
51+
52+
Any use of the Licensed Work in violation of this License will automatically
53+
terminate your rights under this License for the current and all other
54+
versions of the Licensed Work.
55+
56+
This License does not grant you any right in any trademark or logo of
57+
Licensor or its affiliates (provided that you may use a trademark or logo of
58+
Licensor as expressly required by this License).
59+
60+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
61+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
62+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
63+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
64+
TITLE.
65+
66+
MariaDB hereby grants you permission to use this License’s text to license
67+
your works, and to refer to it using the trademark "Business Source License",
68+
as long as you comply with the Covenants of Licensor below.
69+
70+
-----------------------------------------------------------------------------
71+
72+
Covenants of Licensor
73+
74+
In consideration of the right to use this License’s text and the "Business
75+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
76+
other recipients of the licensed work to be provided by Licensor:
77+
78+
1. To specify as the Change License the GPL Version 2.0 or any later version,
79+
or a license that is compatible with GPL Version 2.0 or a later version,
80+
where "compatible" means that software provided under the Change License can
81+
be included in a program with software provided under GPL Version 2.0 or a
82+
later version. Licensor may specify additional Change Licenses without
83+
limitation.
84+
85+
2. To either: (a) specify an additional grant of rights to use that does not
86+
impose any additional restriction on the right granted in this License, as
87+
the Additional Use Grant; or (b) insert the text "None".
88+
89+
3. To specify a Change Date.
90+
91+
4. Not to modify this License in any other way.
92+
93+
-----------------------------------------------------------------------------
94+
95+
Notice
96+
97+
The Business Source License (this document, or the "License") is not an Open
98+
Source license. However, the Licensed Work will eventually be made available
99+
under an Open Source License, as stated in this License.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# Intuition Protocol
1+
# Intuition Protocol
2+
3+
The open source contracts of the Intuition protocol v1.

src/AtomWallet.sol

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.21;
3+
4+
import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol";
5+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6+
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
7+
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
8+
import {BaseAccount, UserOperation} from "account-abstraction/contracts/core/BaseAccount.sol";
9+
import {IEntryPoint} from "account-abstraction/contracts/interfaces/IEntryPoint.sol";
10+
import {Errors} from "./libraries/Errors.sol";
11+
12+
/**
13+
* @title AtomWallet
14+
* @notice This contract is an abstract account associated with a corresponding atom.
15+
*/
16+
contract AtomWallet is Initializable, BaseAccount, OwnableUpgradeable {
17+
using ECDSA for bytes32;
18+
19+
/// @notice The storage slot for the AtomWallet contract ownable storage
20+
/// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
21+
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
22+
23+
/// @notice The EthMultiVault contract address
24+
IEthMultiVault public ethMultiVault;
25+
26+
/// @notice The flag to indicate if the wallet's ownership has been claimed by the user
27+
bool public isClaimed;
28+
29+
/// @notice The entry point contract address
30+
IEntryPoint private _entryPoint;
31+
32+
// solhint-disable-next-line no-empty-blocks
33+
receive() external payable {}
34+
35+
/**
36+
* @notice Initialize the AtomWallet contract
37+
* @param anEntryPoint the entry point contract address
38+
* @param anOwner the owner of the contract (`walletConfig.atomWarden` is the initial owner of all atom wallets)
39+
* @param _ethMultiVault the EthMultiVault contract address
40+
*/
41+
function init(IEntryPoint anEntryPoint, address anOwner, IEthMultiVault _ethMultiVault) external initializer {
42+
__Ownable_init(anOwner);
43+
_entryPoint = anEntryPoint;
44+
ethMultiVault = _ethMultiVault;
45+
}
46+
47+
/// @notice Get the entry point contract address
48+
/// @return the entry point contract address
49+
function entryPoint() public view virtual override returns (IEntryPoint) {
50+
return _entryPoint;
51+
}
52+
53+
/**
54+
* @notice Execute a transaction (called directly from owner, or by entryPoint)
55+
* @param dest the target address
56+
* @param value the value to send
57+
* @param func the function call data
58+
*/
59+
function execute(address dest, uint256 value, bytes calldata func) external onlyOwnerOrEntryPoint {
60+
_call(dest, value, func);
61+
}
62+
63+
/**
64+
* @notice Execute a sequence (batch) of transactions
65+
* @param dest the target addresses array
66+
* @param func the function call data array
67+
*/
68+
function executeBatch(address[] calldata dest, bytes[] calldata func) external onlyOwnerOrEntryPoint {
69+
if (dest.length != func.length) {
70+
revert Errors.AtomWallet_WrongArrayLengths();
71+
}
72+
73+
for (uint256 i = 0; i < dest.length; i++) {
74+
_call(dest[i], 0, func[i]);
75+
}
76+
}
77+
78+
/// implement template method of BaseAccount
79+
/**
80+
* @notice Validate the signature of the user operation
81+
* @param userOp the user operation
82+
* @param userOpHash the hash of the user operation
83+
* @return validationData the validation data (0 if successful)
84+
*/
85+
function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
86+
internal
87+
virtual
88+
override
89+
returns (uint256 validationData)
90+
{
91+
bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", userOpHash));
92+
93+
(address recovered,,) = ECDSA.tryRecover(hash, userOp.signature);
94+
95+
if (recovered != owner()) {
96+
return SIG_VALIDATION_FAILED;
97+
}
98+
99+
return 0;
100+
}
101+
102+
/**
103+
* @notice An internal method that calls a target address with value and data
104+
* @param target the target address
105+
* @param value the value to send
106+
* @param data the function call data
107+
*/
108+
function _call(address target, uint256 value, bytes memory data) internal {
109+
(bool success, bytes memory result) = target.call{value: value}(data);
110+
if (!success) {
111+
assembly {
112+
revert(add(result, 32), mload(result))
113+
}
114+
}
115+
}
116+
117+
/// @notice Returns the deposit of the account in the entry point contract
118+
function getDeposit() public view returns (uint256) {
119+
return entryPoint().balanceOf(address(this));
120+
}
121+
122+
/// @notice Add deposit to the account in the entry point contract
123+
function addDeposit() public payable {
124+
entryPoint().depositTo{value: msg.value}(address(this));
125+
}
126+
127+
/**
128+
* @notice Withdraws value from the account's deposit
129+
* @param withdrawAddress target to send to
130+
* @param amount to withdraw
131+
*/
132+
function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public {
133+
if (!(msg.sender == owner() || msg.sender == address(this))) {
134+
revert Errors.AtomWallet_OnlyOwner();
135+
}
136+
entryPoint().withdrawTo(withdrawAddress, amount);
137+
}
138+
139+
/// @notice Transfer ownership of the wallet to a new owner. Ifn the wallet's ownership
140+
/// is being transferred to the user, the wallet is considered claimed. Once claimed,
141+
/// wallet is considered owned by the user and the action cannot be undone.
142+
/// @param newOwner the new owner of the wallet
143+
function transferOwnership(address newOwner) public override onlyOwner {
144+
if (newOwner == address(0)) {
145+
revert OwnableInvalidOwner(address(0));
146+
}
147+
148+
if (!isClaimed && newOwner != ethMultiVault.getAtomWarden()) {
149+
isClaimed = true;
150+
}
151+
152+
_transferOwnership(newOwner);
153+
}
154+
155+
/// @notice Returns the owner of the wallet. If the wallet has been claimed, the owner
156+
/// is the user. Otherwise, the owner is the atomWarden.
157+
function owner() public view override returns (address) {
158+
OwnableStorage storage $ = _getAtomWalletOwnableStorage();
159+
return isClaimed ? $._owner : ethMultiVault.getAtomWarden();
160+
}
161+
162+
/// @dev Get the storage slot for the AtomWallet contract ownable storage
163+
function _getAtomWalletOwnableStorage() private pure returns (OwnableStorage storage $) {
164+
assembly {
165+
$.slot := OwnableStorageLocation
166+
}
167+
}
168+
169+
/// @dev Modifier to allow only the owner or entry point to call a function
170+
modifier onlyOwnerOrEntryPoint() {
171+
if (!(msg.sender == address(entryPoint()) || msg.sender == owner())) {
172+
revert Errors.AtomWallet_OnlyOwnerOrEntryPoint();
173+
}
174+
_;
175+
}
176+
}

0 commit comments

Comments
 (0)