@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,65 +1,84 @@
1
- // SPDX-License-Identifier: MPL-2.0
2
- pragma solidity 0.8.33;
3
-
4
- import "../execution/GuardController.sol";
5
- import "../access/RuntimeRBAC.sol";
6
- import "../security/SecureOwnable.sol";
7
- import "../lib/utils/SharedValidation.sol";
8
-
9
- /**
10
- * @title Account
11
- * @dev Abstract account pattern combining GuardController, RuntimeRBAC, and SecureOwnable.
12
- *
13
- * Use this as the base for account-style contracts (e.g. AccountBlox) to avoid duplicating
14
- * initialization, interface support, and receive/fallback boilerplate.
15
- *
16
- * Combines:
17
- * - GuardController: Execution workflows and time-locked transactions
18
- * - RuntimeRBAC: Runtime role creation and management
19
- * - SecureOwnable: Secure ownership transfer and management
20
- *
21
- * @custom:security-contact security@particlecs.com
22
- */
23
- abstract contract Account is GuardController, RuntimeRBAC, SecureOwnable {
24
- /**
25
- * @notice Initializer for the Account pattern (GuardController + RuntimeRBAC + SecureOwnable).
26
- * @param initialOwner The initial owner address
27
- * @param broadcaster The broadcaster address
28
- * @param recovery The recovery address
29
- * @param timeLockPeriodSec The timelock period in seconds
30
- * @param eventForwarder The event forwarder address (optional)
31
- */
32
- function initialize(
33
- address initialOwner,
34
- address broadcaster,
35
- address recovery,
36
- uint256 timeLockPeriodSec,
37
- address eventForwarder
38
- ) public virtual override(GuardController, RuntimeRBAC, SecureOwnable) onlyInitializing {
39
- GuardController.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
40
- RuntimeRBAC.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
41
- SecureOwnable.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
42
- }
43
-
44
- /**
45
- * @dev See {IERC165-supportsInterface}.
46
- */
47
- function supportsInterface(bytes4 interfaceId) public view virtual override(GuardController, RuntimeRBAC, SecureOwnable) returns (bool) {
48
- return GuardController.supportsInterface(interfaceId) || RuntimeRBAC.supportsInterface(interfaceId) || SecureOwnable.supportsInterface(interfaceId);
49
- }
50
-
51
- /**
52
- * @dev Accepts plain ETH transfers (no calldata).
53
- * @notice General-use wallet: ETH can be sent naturally; balance is credited.
54
- * @custom:security No external calls—reentrancy-safe; outgoing ETH only via GuardController execution.
55
- */
56
- receive() external payable virtual {}
57
-
58
- /**
59
- * @dev Rejects calls with unknown selector (with or without value).
60
- * @notice Only plain transfers hit receive(); all other calls revert.
61
- */
62
- fallback() external payable virtual {
63
- revert SharedValidation.NotSupported();
64
- }
65
- }
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ pragma solidity 0.8.35;
3
+
4
+ import "../execution/GuardController.sol";
5
+ import "../execution/interface/IGuardController.sol";
6
+ import "../access/RuntimeRBAC.sol";
7
+ import "../access/interface/IRuntimeRBAC.sol";
8
+ import "../security/SecureOwnable.sol";
9
+ import "../security/interface/ISecureOwnable.sol";
10
+ import "../lib/utils/SharedValidation.sol";
11
+
12
+ /**
13
+ * @title Account
14
+ * @dev Abstract account pattern combining GuardController, RuntimeRBAC, and SecureOwnable.
15
+ *
16
+ * Use this as the base for account-style contracts (e.g. AccountBlox) to avoid duplicating
17
+ * initialization, interface support, and receive/fallback boilerplate.
18
+ *
19
+ * Combines:
20
+ * - GuardController: Execution workflows and time-locked transactions
21
+ * - RuntimeRBAC: Runtime role creation and management
22
+ * - SecureOwnable: Secure ownership transfer and management
23
+ *
24
+ * @custom:security-contact security@particlecs.com
25
+ */
26
+ abstract contract Account is GuardController, RuntimeRBAC, SecureOwnable {
27
+ /**
28
+ * @dev Emitted when plain ETH is received (receive()).
29
+ * @param sender Address that sent the ETH
30
+ * @param value Amount of wei received
31
+ * @custom:security Gas-efficient so receive() stays within 2,300 gas stipend (transfer/send compatible).
32
+ */
33
+ event EthReceived(address indexed sender, uint256 value);
34
+
35
+ /**
36
+ * @notice Initializer for the Account pattern (GuardController + RuntimeRBAC + SecureOwnable).
37
+ * @param initialOwner The initial owner address
38
+ * @param broadcaster The broadcaster address
39
+ * @param recovery The recovery address
40
+ * @param timeLockPeriodSec The timelock period in seconds
41
+ * @param eventForwarder The event forwarder address (optional)
42
+ */
43
+ function initialize(
44
+ address initialOwner,
45
+ address broadcaster,
46
+ address recovery,
47
+ uint256 timeLockPeriodSec,
48
+ address eventForwarder
49
+ ) public virtual override(GuardController, RuntimeRBAC, SecureOwnable) onlyInitializing {
50
+ GuardController.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
51
+ RuntimeRBAC.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
52
+ SecureOwnable.initialize(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
53
+ }
54
+
55
+ /**
56
+ * @dev See {IERC165-supportsInterface}.
57
+ * @notice GuardController, RuntimeRBAC, and SecureOwnable each extend BaseStateMachine directly; a single
58
+ * `super` chain only walks one branch. We OR the three component interface IDs here, then delegate
59
+ * once to `super` for IBaseStateMachine / ERC165 avoids tripling BaseStateMachine+ERC165 work.
60
+ */
61
+ function supportsInterface(bytes4 interfaceId) public view virtual override(GuardController, RuntimeRBAC, SecureOwnable) returns (bool) {
62
+ return interfaceId == type(IGuardController).interfaceId
63
+ || interfaceId == type(IRuntimeRBAC).interfaceId
64
+ || interfaceId == type(ISecureOwnable).interfaceId
65
+ || super.supportsInterface(interfaceId);
66
+ }
67
+
68
+ /**
69
+ * @dev Accepts plain ETH transfers (no calldata).
70
+ * @notice General-use wallet: ETH can be sent naturally; balance is credited.
71
+ * @custom:security No external calls—reentrancy-safe; outgoing ETH only via GuardController execution. Uses simple emit to stay within 2,300 gas stipend (transfer/send compatible).
72
+ */
73
+ receive() external payable virtual {
74
+ emit EthReceived(msg.sender, msg.value);
75
+ }
76
+
77
+ /**
78
+ * @dev Rejects calls with unknown selector (with or without value).
79
+ * @notice Only plain transfers hit receive(); all other calls revert.
80
+ */
81
+ fallback() external payable virtual {
82
+ revert SharedValidation.NotSupported();
83
+ }
84
+ }