@bloxchain/contracts 1.0.0-alpha.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +8 -9
- package/abi/BaseStateMachine.abi.json +773 -822
- package/abi/EngineBlox.abi.json +562 -552
- package/abi/GuardController.abi.json +1597 -1609
- package/abi/GuardControllerDefinitions.abi.json +235 -199
- package/abi/IDefinition.abi.json +57 -47
- package/abi/RuntimeRBAC.abi.json +841 -842
- package/abi/RuntimeRBACDefinitions.abi.json +212 -202
- package/abi/SecureOwnable.abi.json +1365 -1349
- package/abi/SecureOwnableDefinitions.abi.json +174 -164
- package/core/AUDIT.md +45 -0
- package/core/access/RuntimeRBAC.sol +130 -61
- package/core/access/interface/IRuntimeRBAC.sol +3 -3
- package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +7 -3
- package/core/base/BaseStateMachine.sol +971 -967
- package/core/base/interface/IBaseStateMachine.sol +153 -160
- package/core/execution/GuardController.sol +89 -75
- package/core/execution/interface/IGuardController.sol +146 -160
- package/core/execution/lib/definitions/GuardControllerDefinitions.sol +136 -25
- package/core/lib/EngineBlox.sol +577 -327
- package/core/lib/interfaces/IDefinition.sol +49 -49
- package/core/lib/interfaces/IEventForwarder.sol +4 -2
- package/core/lib/utils/SharedValidation.sol +534 -490
- package/core/pattern/Account.sol +84 -75
- package/core/security/SecureOwnable.sol +446 -390
- package/core/security/interface/ISecureOwnable.sol +105 -105
- package/core/security/lib/definitions/SecureOwnableDefinitions.sol +49 -17
- package/package.json +51 -49
- package/standards/behavior/ICopyable.sol +3 -11
- package/standards/hooks/IOnActionHook.sol +1 -1
- package/abi/AccountBlox.abi.json +0 -3935
- package/abi/BareBlox.abi.json +0 -1378
- package/abi/RoleBlox.abi.json +0 -2983
- package/abi/SecureBlox.abi.json +0 -2753
- package/abi/SimpleRWA20.abi.json +0 -4032
- package/abi/SimpleRWA20Definitions.abi.json +0 -191
- package/abi/SimpleVault.abi.json +0 -3407
- package/abi/SimpleVaultDefinitions.abi.json +0 -269
- package/core/research/BloxchainWallet.sol +0 -133
- package/core/research/FactoryBlox/FactoryBlox.sol +0 -343
- package/core/research/FactoryBlox/FactoryBloxDefinitions.sol +0 -143
- package/core/research/erc1155-blox/ERC1155Blox.sol +0 -169
- package/core/research/erc1155-blox/lib/definitions/ERC1155BloxDefinitions.sol +0 -203
- package/core/research/erc20-blox/ERC20Blox.sol +0 -167
- package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
- package/core/research/erc721-blox/ERC721Blox.sol +0 -131
- package/core/research/erc721-blox/lib/definitions/ERC721BloxDefinitions.sol +0 -172
- package/core/research/lending-blox/.gitkeep +0 -1
- package/core/research/p2p-blox/P2PBlox.sol +0 -266
- package/core/research/p2p-blox/README.md +0 -85
- package/core/research/p2p-blox/lib/definitions/P2PBloxDefinitions.sol +0 -19
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [],
|
|
4
|
-
"name": "APPROVE_WITHDRAWAL_DELAYED_SELECTOR",
|
|
5
|
-
"outputs": [
|
|
6
|
-
{
|
|
7
|
-
"internalType": "bytes4",
|
|
8
|
-
"name": "",
|
|
9
|
-
"type": "bytes4"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"stateMutability": "view",
|
|
13
|
-
"type": "function"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"inputs": [],
|
|
17
|
-
"name": "APPROVE_WITHDRAWAL_META_SELECTOR",
|
|
18
|
-
"outputs": [
|
|
19
|
-
{
|
|
20
|
-
"internalType": "bytes4",
|
|
21
|
-
"name": "",
|
|
22
|
-
"type": "bytes4"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"stateMutability": "view",
|
|
26
|
-
"type": "function"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"inputs": [],
|
|
30
|
-
"name": "CANCEL_WITHDRAWAL_SELECTOR",
|
|
31
|
-
"outputs": [
|
|
32
|
-
{
|
|
33
|
-
"internalType": "bytes4",
|
|
34
|
-
"name": "",
|
|
35
|
-
"type": "bytes4"
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"stateMutability": "view",
|
|
39
|
-
"type": "function"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"inputs": [],
|
|
43
|
-
"name": "GENERIC_APPROVAL",
|
|
44
|
-
"outputs": [
|
|
45
|
-
{
|
|
46
|
-
"internalType": "bytes32",
|
|
47
|
-
"name": "",
|
|
48
|
-
"type": "bytes32"
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
"stateMutability": "view",
|
|
52
|
-
"type": "function"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"inputs": [],
|
|
56
|
-
"name": "GENERIC_CANCELLATION",
|
|
57
|
-
"outputs": [
|
|
58
|
-
{
|
|
59
|
-
"internalType": "bytes32",
|
|
60
|
-
"name": "",
|
|
61
|
-
"type": "bytes32"
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"stateMutability": "view",
|
|
65
|
-
"type": "function"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"inputs": [],
|
|
69
|
-
"name": "GENERIC_META_APPROVAL",
|
|
70
|
-
"outputs": [
|
|
71
|
-
{
|
|
72
|
-
"internalType": "bytes32",
|
|
73
|
-
"name": "",
|
|
74
|
-
"type": "bytes32"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"stateMutability": "view",
|
|
78
|
-
"type": "function"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"inputs": [],
|
|
82
|
-
"name": "WITHDRAW_ETH",
|
|
83
|
-
"outputs": [
|
|
84
|
-
{
|
|
85
|
-
"internalType": "bytes32",
|
|
86
|
-
"name": "",
|
|
87
|
-
"type": "bytes32"
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
"stateMutability": "view",
|
|
91
|
-
"type": "function"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"inputs": [],
|
|
95
|
-
"name": "WITHDRAW_ETH_REQUEST_SELECTOR",
|
|
96
|
-
"outputs": [
|
|
97
|
-
{
|
|
98
|
-
"internalType": "bytes4",
|
|
99
|
-
"name": "",
|
|
100
|
-
"type": "bytes4"
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
"stateMutability": "view",
|
|
104
|
-
"type": "function"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"inputs": [],
|
|
108
|
-
"name": "WITHDRAW_ETH_SELECTOR",
|
|
109
|
-
"outputs": [
|
|
110
|
-
{
|
|
111
|
-
"internalType": "bytes4",
|
|
112
|
-
"name": "",
|
|
113
|
-
"type": "bytes4"
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
"stateMutability": "view",
|
|
117
|
-
"type": "function"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"inputs": [],
|
|
121
|
-
"name": "WITHDRAW_TOKEN",
|
|
122
|
-
"outputs": [
|
|
123
|
-
{
|
|
124
|
-
"internalType": "bytes32",
|
|
125
|
-
"name": "",
|
|
126
|
-
"type": "bytes32"
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
"stateMutability": "view",
|
|
130
|
-
"type": "function"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"inputs": [],
|
|
134
|
-
"name": "WITHDRAW_TOKEN_REQUEST_SELECTOR",
|
|
135
|
-
"outputs": [
|
|
136
|
-
{
|
|
137
|
-
"internalType": "bytes4",
|
|
138
|
-
"name": "",
|
|
139
|
-
"type": "bytes4"
|
|
140
|
-
}
|
|
141
|
-
],
|
|
142
|
-
"stateMutability": "view",
|
|
143
|
-
"type": "function"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
"inputs": [],
|
|
147
|
-
"name": "WITHDRAW_TOKEN_SELECTOR",
|
|
148
|
-
"outputs": [
|
|
149
|
-
{
|
|
150
|
-
"internalType": "bytes4",
|
|
151
|
-
"name": "",
|
|
152
|
-
"type": "bytes4"
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
"stateMutability": "view",
|
|
156
|
-
"type": "function"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"inputs": [],
|
|
160
|
-
"name": "getFunctionSchemas",
|
|
161
|
-
"outputs": [
|
|
162
|
-
{
|
|
163
|
-
"components": [
|
|
164
|
-
{
|
|
165
|
-
"internalType": "string",
|
|
166
|
-
"name": "functionSignature",
|
|
167
|
-
"type": "string"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"internalType": "bytes4",
|
|
171
|
-
"name": "functionSelector",
|
|
172
|
-
"type": "bytes4"
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"internalType": "bytes32",
|
|
176
|
-
"name": "operationType",
|
|
177
|
-
"type": "bytes32"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"internalType": "string",
|
|
181
|
-
"name": "operationName",
|
|
182
|
-
"type": "string"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
"internalType": "uint16",
|
|
186
|
-
"name": "supportedActionsBitmap",
|
|
187
|
-
"type": "uint16"
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"internalType": "bool",
|
|
191
|
-
"name": "isProtected",
|
|
192
|
-
"type": "bool"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
"internalType": "bytes4[]",
|
|
196
|
-
"name": "handlerForSelectors",
|
|
197
|
-
"type": "bytes4[]"
|
|
198
|
-
}
|
|
199
|
-
],
|
|
200
|
-
"internalType": "struct EngineBlox.FunctionSchema[]",
|
|
201
|
-
"name": "",
|
|
202
|
-
"type": "tuple[]"
|
|
203
|
-
}
|
|
204
|
-
],
|
|
205
|
-
"stateMutability": "pure",
|
|
206
|
-
"type": "function"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"inputs": [],
|
|
210
|
-
"name": "getRolePermissions",
|
|
211
|
-
"outputs": [
|
|
212
|
-
{
|
|
213
|
-
"components": [
|
|
214
|
-
{
|
|
215
|
-
"internalType": "bytes32[]",
|
|
216
|
-
"name": "roleHashes",
|
|
217
|
-
"type": "bytes32[]"
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
"components": [
|
|
221
|
-
{
|
|
222
|
-
"internalType": "bytes4",
|
|
223
|
-
"name": "functionSelector",
|
|
224
|
-
"type": "bytes4"
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"internalType": "uint16",
|
|
228
|
-
"name": "grantedActionsBitmap",
|
|
229
|
-
"type": "uint16"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"internalType": "bytes4[]",
|
|
233
|
-
"name": "handlerForSelectors",
|
|
234
|
-
"type": "bytes4[]"
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
"internalType": "struct EngineBlox.FunctionPermission[]",
|
|
238
|
-
"name": "functionPermissions",
|
|
239
|
-
"type": "tuple[]"
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
"internalType": "struct IDefinition.RolePermission",
|
|
243
|
-
"name": "",
|
|
244
|
-
"type": "tuple"
|
|
245
|
-
}
|
|
246
|
-
],
|
|
247
|
-
"stateMutability": "pure",
|
|
248
|
-
"type": "function"
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
"inputs": [
|
|
252
|
-
{
|
|
253
|
-
"internalType": "bytes4",
|
|
254
|
-
"name": "interfaceId",
|
|
255
|
-
"type": "bytes4"
|
|
256
|
-
}
|
|
257
|
-
],
|
|
258
|
-
"name": "supportsInterface",
|
|
259
|
-
"outputs": [
|
|
260
|
-
{
|
|
261
|
-
"internalType": "bool",
|
|
262
|
-
"name": "",
|
|
263
|
-
"type": "bool"
|
|
264
|
-
}
|
|
265
|
-
],
|
|
266
|
-
"stateMutability": "pure",
|
|
267
|
-
"type": "function"
|
|
268
|
-
}
|
|
269
|
-
]
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
-
// Copyright (c) 2025 Particle Crypto Security
|
|
3
|
-
pragma solidity 0.8.33;
|
|
4
|
-
|
|
5
|
-
import "../pattern/Account.sol";
|
|
6
|
-
import "../base/BaseStateMachine.sol";
|
|
7
|
-
import "../lib/utils/SharedValidation.sol";
|
|
8
|
-
import "../lib/interfaces/IDefinition.sol";
|
|
9
|
-
import "../../standards/behavior/ICopyable.sol";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @title BloxchainWallet
|
|
13
|
-
* @dev Official ParticleCS wallet controller built on Bloxchain Protocol.
|
|
14
|
-
*
|
|
15
|
-
* Extends the Account pattern (GuardController + RuntimeRBAC + SecureOwnable) with
|
|
16
|
-
* timelock bounds, optional roles/definitions init, and ICopyable for factory cloning.
|
|
17
|
-
*/
|
|
18
|
-
contract BloxchainWallet is Account, ICopyable {
|
|
19
|
-
uint256 public constant MIN_TIME_LOCK_PERIOD = 1 days;
|
|
20
|
-
uint256 public constant MAX_TIME_LOCK_PERIOD = 90 days;
|
|
21
|
-
uint256 public constant MAX_DEFINITION_CONTRACTS = 50;
|
|
22
|
-
uint256 public constant MAX_INITIAL_ROLES = 50;
|
|
23
|
-
uint256 public constant MAX_SCHEMAS_PER_DEFINITION = 100;
|
|
24
|
-
uint256 public constant MAX_PERMISSIONS_PER_DEFINITION = 200;
|
|
25
|
-
|
|
26
|
-
bool private _cloneDataSet;
|
|
27
|
-
|
|
28
|
-
struct RoleConfig {
|
|
29
|
-
string roleName;
|
|
30
|
-
uint256 maxWallets;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function initialize(
|
|
34
|
-
address initialOwner,
|
|
35
|
-
address broadcaster,
|
|
36
|
-
address recovery,
|
|
37
|
-
uint256 timeLockPeriodSec,
|
|
38
|
-
address eventForwarder
|
|
39
|
-
) public virtual override(Account) initializer {
|
|
40
|
-
_initializeBase(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function initializeWithData(
|
|
44
|
-
address initialOwner,
|
|
45
|
-
address broadcaster,
|
|
46
|
-
address recovery,
|
|
47
|
-
uint256 timeLockPeriodSec,
|
|
48
|
-
address eventForwarder,
|
|
49
|
-
bytes calldata initData
|
|
50
|
-
) external initializer {
|
|
51
|
-
_initializeBase(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
52
|
-
if (initData.length > 0) {
|
|
53
|
-
(RoleConfig[] memory roles, IDefinition[] memory definitionContracts) =
|
|
54
|
-
abi.decode(initData, (RoleConfig[], IDefinition[]));
|
|
55
|
-
_applyRolesAndDefinitions(roles, definitionContracts);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function _initializeBase(
|
|
60
|
-
address initialOwner,
|
|
61
|
-
address broadcaster,
|
|
62
|
-
address recovery,
|
|
63
|
-
uint256 timeLockPeriodSec,
|
|
64
|
-
address eventForwarder
|
|
65
|
-
) internal {
|
|
66
|
-
_validateTimeLockPeriod(timeLockPeriodSec);
|
|
67
|
-
super.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function setCloneData(bytes calldata initData) external {
|
|
71
|
-
if (!initialized()) revert SharedValidation.NotInitialized();
|
|
72
|
-
if (_cloneDataSet) revert SharedValidation.AlreadyInitialized();
|
|
73
|
-
_cloneDataSet = true;
|
|
74
|
-
(RoleConfig[] memory roles, IDefinition[] memory definitionContracts) =
|
|
75
|
-
abi.decode(initData, (RoleConfig[], IDefinition[]));
|
|
76
|
-
_applyRolesAndDefinitions(roles, definitionContracts);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function supportsInterface(bytes4 interfaceId)
|
|
80
|
-
public
|
|
81
|
-
view
|
|
82
|
-
virtual
|
|
83
|
-
override(Account)
|
|
84
|
-
returns (bool)
|
|
85
|
-
{
|
|
86
|
-
return interfaceId == type(ICopyable).interfaceId || super.supportsInterface(interfaceId);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _updateTimeLockPeriod(uint256 newTimeLockPeriodSec)
|
|
90
|
-
internal
|
|
91
|
-
virtual
|
|
92
|
-
override(BaseStateMachine)
|
|
93
|
-
{
|
|
94
|
-
_validateTimeLockPeriod(newTimeLockPeriodSec);
|
|
95
|
-
super._updateTimeLockPeriod(newTimeLockPeriodSec);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _validateTimeLockPeriod(uint256 timeLockPeriodSec) internal pure {
|
|
99
|
-
if (timeLockPeriodSec < MIN_TIME_LOCK_PERIOD || timeLockPeriodSec > MAX_TIME_LOCK_PERIOD) {
|
|
100
|
-
revert SharedValidation.InvalidTimeLockPeriod(timeLockPeriodSec);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _applyRolesAndDefinitions(
|
|
105
|
-
RoleConfig[] memory roles,
|
|
106
|
-
IDefinition[] memory definitionContracts
|
|
107
|
-
) internal {
|
|
108
|
-
if (roles.length > MAX_INITIAL_ROLES) {
|
|
109
|
-
revert SharedValidation.BatchSizeExceeded(roles.length, MAX_INITIAL_ROLES);
|
|
110
|
-
}
|
|
111
|
-
for (uint256 i = 0; i < roles.length; i++) {
|
|
112
|
-
_createRole(roles[i].roleName, roles[i].maxWallets, false);
|
|
113
|
-
}
|
|
114
|
-
if (definitionContracts.length > MAX_DEFINITION_CONTRACTS) {
|
|
115
|
-
revert SharedValidation.BatchSizeExceeded(definitionContracts.length, MAX_DEFINITION_CONTRACTS);
|
|
116
|
-
}
|
|
117
|
-
for (uint256 i = 0; i < definitionContracts.length; i++) {
|
|
118
|
-
address def = address(definitionContracts[i]);
|
|
119
|
-
if (!definitionContracts[i].supportsInterface(type(IDefinition).interfaceId)) {
|
|
120
|
-
revert SharedValidation.DefinitionNotIDefinition(def);
|
|
121
|
-
}
|
|
122
|
-
EngineBlox.FunctionSchema[] memory schemas = definitionContracts[i].getFunctionSchemas();
|
|
123
|
-
IDefinition.RolePermission memory permissions = definitionContracts[i].getRolePermissions();
|
|
124
|
-
if (schemas.length > MAX_SCHEMAS_PER_DEFINITION) {
|
|
125
|
-
revert SharedValidation.BatchSizeExceeded(schemas.length, MAX_SCHEMAS_PER_DEFINITION);
|
|
126
|
-
}
|
|
127
|
-
if (permissions.roleHashes.length > MAX_PERMISSIONS_PER_DEFINITION) {
|
|
128
|
-
revert SharedValidation.BatchSizeExceeded(permissions.roleHashes.length, MAX_PERMISSIONS_PER_DEFINITION);
|
|
129
|
-
}
|
|
130
|
-
_loadDefinitions(schemas, permissions.roleHashes, permissions.functionPermissions, false);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|