@bloxchain/contracts 1.0.0-alpha.6 → 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +8 -9
  3. package/abi/BaseStateMachine.abi.json +773 -822
  4. package/abi/EngineBlox.abi.json +562 -552
  5. package/abi/GuardController.abi.json +1597 -1609
  6. package/abi/GuardControllerDefinitions.abi.json +257 -120
  7. package/abi/IDefinition.abi.json +57 -47
  8. package/abi/RuntimeRBAC.abi.json +841 -842
  9. package/abi/RuntimeRBACDefinitions.abi.json +265 -99
  10. package/abi/SecureOwnable.abi.json +1365 -1349
  11. package/abi/SecureOwnableDefinitions.abi.json +174 -164
  12. package/components/README.md +8 -0
  13. package/core/AUDIT.md +45 -0
  14. package/core/access/RuntimeRBAC.sol +130 -61
  15. package/core/access/interface/IRuntimeRBAC.sol +3 -3
  16. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +67 -3
  17. package/core/base/BaseStateMachine.sol +971 -967
  18. package/core/base/interface/IBaseStateMachine.sol +153 -160
  19. package/core/execution/GuardController.sol +89 -75
  20. package/core/execution/interface/IGuardController.sol +146 -160
  21. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +180 -24
  22. package/core/lib/EngineBlox.sol +577 -327
  23. package/core/lib/interfaces/IDefinition.sol +49 -49
  24. package/core/lib/interfaces/IEventForwarder.sol +4 -2
  25. package/core/lib/utils/SharedValidation.sol +534 -487
  26. package/core/pattern/Account.sol +84 -65
  27. package/core/security/SecureOwnable.sol +446 -390
  28. package/core/security/interface/ISecureOwnable.sol +105 -105
  29. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +49 -17
  30. package/package.json +11 -7
  31. package/standards/README.md +12 -0
  32. package/{core/research → standards/behavior}/ICopyable.sol +3 -11
  33. package/standards/hooks/IOnActionHook.sol +21 -0
  34. package/abi/AccountBlox.abi.json +0 -3916
  35. package/abi/BareBlox.abi.json +0 -1378
  36. package/abi/RoleBlox.abi.json +0 -2983
  37. package/abi/SecureBlox.abi.json +0 -2753
  38. package/abi/SimpleRWA20.abi.json +0 -4032
  39. package/abi/SimpleRWA20Definitions.abi.json +0 -191
  40. package/abi/SimpleVault.abi.json +0 -3407
  41. package/abi/SimpleVaultDefinitions.abi.json +0 -269
  42. package/core/research/BloxchainWallet.sol +0 -292
  43. package/core/research/FactoryBlox/FactoryBlox.sol +0 -346
  44. package/core/research/FactoryBlox/FactoryBloxDefinitions.sol +0 -143
  45. package/core/research/erc1155-blox/ERC1155Blox.sol +0 -169
  46. package/core/research/erc1155-blox/lib/definitions/ERC1155BloxDefinitions.sol +0 -203
  47. package/core/research/erc20-blox/ERC20Blox.sol +0 -167
  48. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  49. package/core/research/erc721-blox/ERC721Blox.sol +0 -131
  50. package/core/research/erc721-blox/lib/definitions/ERC721BloxDefinitions.sol +0 -172
  51. package/core/research/lending-blox/.gitkeep +0 -1
  52. package/core/research/p2p-blox/P2PBlox.sol +0 -266
  53. package/core/research/p2p-blox/README.md +0 -85
  54. package/core/research/p2p-blox/lib/definitions/P2PBloxDefinitions.sol +0 -19
@@ -1,160 +1,146 @@
1
- // SPDX-License-Identifier: MPL-2.0
2
- pragma solidity 0.8.33;
3
-
4
- import "../../lib/EngineBlox.sol";
5
-
6
- /**
7
- * @title IGuardController
8
- * @dev Interface for GuardController contract that GuardianSafeV3 and other contracts delegate to
9
- * @notice This interface defines only GuardController-specific methods
10
- * @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, functionSchemaExists, getFunctionSchema, owner, getBroadcaster, getRecovery) should be accessed via IBaseStateMachine
11
- * @notice Functions from RuntimeRBAC (registerFunction, unregisterFunction, createNewRole, addWalletToRole, revokeWallet) should be accessed via IRuntimeRBAC
12
- * @custom:security-contact security@particlecrypto.com
13
- */
14
- interface IGuardController {
15
- /**
16
- * @dev Action types for batched Guard configuration
17
- */
18
- enum GuardConfigActionType {
19
- ADD_TARGET_TO_WHITELIST,
20
- REMOVE_TARGET_FROM_WHITELIST,
21
- REGISTER_FUNCTION,
22
- UNREGISTER_FUNCTION
23
- }
24
-
25
- /**
26
- * @dev Encodes a single Guard configuration action in a batch
27
- */
28
- struct GuardConfigAction {
29
- GuardConfigActionType actionType;
30
- bytes data;
31
- }
32
-
33
- /**
34
- * @notice Initializer to initialize GuardController
35
- * @param initialOwner The initial owner address
36
- * @param broadcaster The broadcaster address
37
- * @param recovery The recovery address
38
- * @param timeLockPeriodSec The timelock period in seconds
39
- * @param eventForwarder The event forwarder address
40
- */
41
- function initialize(
42
- address initialOwner,
43
- address broadcaster,
44
- address recovery,
45
- uint256 timeLockPeriodSec,
46
- address eventForwarder
47
- ) external;
48
-
49
- /**
50
- * @dev Requests a time-locked execution via EngineBlox workflow
51
- * @param target The address of the target contract
52
- * @param value The ETH value to send (0 for standard function calls)
53
- * @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
54
- * @param params The encoded parameters for the function (empty for simple ETH transfers)
55
- * @param gasLimit The gas limit for execution
56
- * @param operationType The operation type hash
57
- * @return txId The transaction ID for the requested operation
58
- * @notice Creates a time-locked transaction that must be approved after the timelock period
59
- * @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
60
- * @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
61
- * @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
62
- */
63
- function executeWithTimeLock(
64
- address target,
65
- uint256 value,
66
- bytes4 functionSelector,
67
- bytes memory params,
68
- uint256 gasLimit,
69
- bytes32 operationType
70
- ) external returns (uint256 txId);
71
-
72
- /**
73
- * @dev Requests a time-locked execution with payment details attached (same permissions as executeWithTimeLock)
74
- * @param target The address of the target contract
75
- * @param value The ETH value to send (0 for standard function calls)
76
- * @param functionSelector The function selector to execute (NATIVE_TRANSFER_SELECTOR for simple native token transfers)
77
- * @param params The encoded parameters for the function (empty for simple native token transfers)
78
- * @param gasLimit The gas limit for execution
79
- * @param operationType The operation type hash
80
- * @param paymentDetails The payment details to attach to the transaction
81
- * @return txId The transaction ID for the requested operation (use getTransaction(txId) for full record)
82
- * @notice Reuses EXECUTE_TIME_DELAY_REQUEST permission; approval/cancel same as executeWithTimeLock
83
- */
84
- function executeWithPayment(
85
- address target,
86
- uint256 value,
87
- bytes4 functionSelector,
88
- bytes memory params,
89
- uint256 gasLimit,
90
- bytes32 operationType,
91
- EngineBlox.PaymentDetails memory paymentDetails
92
- ) external returns (uint256 txId);
93
-
94
- /**
95
- * @dev Approves and executes a time-locked transaction
96
- * @param txId The transaction ID
97
- * @param expectedOperationType The expected operation type for validation
98
- * @return txId The transaction ID (use getTransaction(txId) for full record and result)
99
- * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
100
- */
101
- function approveTimeLockExecution(
102
- uint256 txId,
103
- bytes32 expectedOperationType
104
- ) external returns (uint256);
105
-
106
- /**
107
- * @dev Cancels a time-locked transaction
108
- * @param txId The transaction ID
109
- * @param expectedOperationType The expected operation type for validation
110
- * @return txId The transaction ID (use getTransaction(txId) for full record)
111
- * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
112
- */
113
- function cancelTimeLockExecution(
114
- uint256 txId,
115
- bytes32 expectedOperationType
116
- ) external returns (uint256);
117
-
118
- /**
119
- * @dev Approves a time-locked transaction using a meta-transaction
120
- * @param metaTx The meta-transaction containing the transaction record and signature
121
- * @param expectedOperationType The expected operation type for validation
122
- * @param requiredSelector The handler selector for validation
123
- * @return The transaction ID (use getTransaction(txId) for full record)
124
- * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
125
- */
126
- function approveTimeLockExecutionWithMetaTx(
127
- EngineBlox.MetaTransaction memory metaTx,
128
- bytes32 expectedOperationType,
129
- bytes4 requiredSelector
130
- ) external returns (uint256);
131
-
132
- /**
133
- * @dev Cancels a time-locked transaction using a meta-transaction
134
- * @param metaTx The meta-transaction containing the transaction record and signature
135
- * @param expectedOperationType The expected operation type for validation
136
- * @param requiredSelector The handler selector for validation
137
- * @return The transaction ID (use getTransaction(txId) for full record)
138
- * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
139
- */
140
- function cancelTimeLockExecutionWithMetaTx(
141
- EngineBlox.MetaTransaction memory metaTx,
142
- bytes32 expectedOperationType,
143
- bytes4 requiredSelector
144
- ) external returns (uint256);
145
-
146
- /**
147
- * @dev Requests and approves a transaction in one step using a meta-transaction
148
- * @param metaTx The meta-transaction containing the transaction record and signature
149
- * @param requiredSelector The handler selector for validation
150
- * @return The transaction ID (use getTransaction(txId) for full record)
151
- * @notice Requires STANDARD execution type
152
- * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
153
- * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
154
- */
155
- function requestAndApproveExecution(
156
- EngineBlox.MetaTransaction memory metaTx,
157
- bytes4 requiredSelector
158
- ) external returns (uint256);
159
- }
160
-
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ pragma solidity 0.8.35;
3
+
4
+ import "../../lib/EngineBlox.sol";
5
+
6
+ /**
7
+ * @title IGuardController
8
+ * @dev Interface for GuardController contract that AccountBlox and other contracts delegate to
9
+ * @notice This interface defines only GuardController-specific methods
10
+ * @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, getFunctionSchema, owner, getBroadcasters, getRecovery) should be accessed via IBaseStateMachine
11
+ * @notice Functions from RuntimeRBAC (role management: createNewRole, addWalletToRole, revokeWallet, etc.) should be accessed via IRuntimeRBAC. Function schema registration is performed via GuardController (guard config batch), not RuntimeRBAC.
12
+ * @custom:security-contact security@particlecrypto.com
13
+ */
14
+ interface IGuardController {
15
+ /**
16
+ * @dev Action types for batched Guard configuration
17
+ */
18
+ enum GuardConfigActionType {
19
+ ADD_TARGET_TO_WHITELIST,
20
+ REMOVE_TARGET_FROM_WHITELIST,
21
+ REGISTER_FUNCTION,
22
+ UNREGISTER_FUNCTION
23
+ }
24
+
25
+ /**
26
+ * @dev Encodes a single Guard configuration action in a batch
27
+ */
28
+ struct GuardConfigAction {
29
+ GuardConfigActionType actionType;
30
+ bytes data;
31
+ }
32
+
33
+ /**
34
+ * @notice Initializer to initialize GuardController
35
+ * @param initialOwner The initial owner address
36
+ * @param broadcaster The broadcaster address
37
+ * @param recovery The recovery address
38
+ * @param timeLockPeriodSec The timelock period in seconds
39
+ * @param eventForwarder The event forwarder address
40
+ */
41
+ function initialize(
42
+ address initialOwner,
43
+ address broadcaster,
44
+ address recovery,
45
+ uint256 timeLockPeriodSec,
46
+ address eventForwarder
47
+ ) external;
48
+
49
+ /**
50
+ * @dev Requests a time-locked execution via EngineBlox workflow
51
+ * @param target The address of the target contract
52
+ * @param value The ETH value to send (0 for standard function calls)
53
+ * @param functionSelector The function selector to execute (0x00000000 for simple ETH transfers)
54
+ * @param params The encoded parameters for the function (empty for simple ETH transfers)
55
+ * @param gasLimit The gas limit for execution
56
+ * @param operationType The operation type hash
57
+ * @return txId The transaction ID for the requested operation
58
+ * @notice Creates a time-locked transaction that must be approved after the timelock period
59
+ * @notice Requires EXECUTE_TIME_DELAY_REQUEST permission for the function selector
60
+ * @notice For standard function calls: value=0, functionSelector=non-zero, params=encoded data
61
+ * @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
62
+ */
63
+ function executeWithTimeLock(
64
+ address target,
65
+ uint256 value,
66
+ bytes4 functionSelector,
67
+ bytes memory params,
68
+ uint256 gasLimit,
69
+ bytes32 operationType
70
+ ) external returns (uint256 txId);
71
+
72
+ /**
73
+ * @dev Requests a time-locked execution with payment details attached (same permissions as executeWithTimeLock)
74
+ * @param target The address of the target contract
75
+ * @param value The ETH value to send (0 for standard function calls)
76
+ * @param functionSelector The function selector to execute (NATIVE_TRANSFER_SELECTOR for simple native token transfers)
77
+ * @param params The encoded parameters for the function (empty for simple native token transfers)
78
+ * @param gasLimit The gas limit for execution
79
+ * @param operationType The operation type hash
80
+ * @param paymentDetails The payment details to attach to the transaction
81
+ * @return txId The transaction ID for the requested operation (use getTransaction(txId) for full record)
82
+ * @notice Reuses EXECUTE_TIME_DELAY_REQUEST permission; approval/cancel same as executeWithTimeLock
83
+ */
84
+ function executeWithPayment(
85
+ address target,
86
+ uint256 value,
87
+ bytes4 functionSelector,
88
+ bytes memory params,
89
+ uint256 gasLimit,
90
+ bytes32 operationType,
91
+ EngineBlox.PaymentDetails memory paymentDetails
92
+ ) external returns (uint256 txId);
93
+
94
+ /**
95
+ * @dev Approves and executes a time-locked transaction
96
+ * @param txId The transaction ID
97
+ * @return txId The transaction ID (use getTransaction(txId) for full record and result)
98
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
99
+ */
100
+ function approveTimeLockExecution(
101
+ uint256 txId
102
+ ) external returns (uint256);
103
+
104
+ /**
105
+ * @dev Cancels a time-locked transaction
106
+ * @param txId The transaction ID
107
+ * @return txId The transaction ID (use getTransaction(txId) for full record)
108
+ * @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
109
+ */
110
+ function cancelTimeLockExecution(
111
+ uint256 txId
112
+ ) external returns (uint256);
113
+
114
+ /**
115
+ * @dev Approves a time-locked transaction using a meta-transaction
116
+ * @param metaTx The meta-transaction containing the transaction record and signature
117
+ * @return The transaction ID (use getTransaction(txId) for full record)
118
+ * @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
119
+ */
120
+ function approveTimeLockExecutionWithMetaTx(
121
+ EngineBlox.MetaTransaction memory metaTx
122
+ ) external returns (uint256);
123
+
124
+ /**
125
+ * @dev Cancels a time-locked transaction using a meta-transaction
126
+ * @param metaTx The meta-transaction containing the transaction record and signature
127
+ * @return The transaction ID (use getTransaction(txId) for full record)
128
+ * @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
129
+ */
130
+ function cancelTimeLockExecutionWithMetaTx(
131
+ EngineBlox.MetaTransaction memory metaTx
132
+ ) external returns (uint256);
133
+
134
+ /**
135
+ * @dev Requests and approves a transaction in one step using a meta-transaction
136
+ * @param metaTx The meta-transaction containing the transaction record and signature
137
+ * @return The transaction ID (use getTransaction(txId) for full record)
138
+ * @notice Requires STANDARD execution type
139
+ * @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
140
+ * @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
141
+ */
142
+ function requestAndApproveExecution(
143
+ EngineBlox.MetaTransaction memory metaTx
144
+ ) external returns (uint256);
145
+ }
146
+