@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
package/core/pattern/Account.sol
CHANGED
|
@@ -1,75 +1,84 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
pragma solidity 0.8.
|
|
3
|
-
|
|
4
|
-
import "../execution/GuardController.sol";
|
|
5
|
-
import "../
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
address
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @dev
|
|
70
|
-
* @notice
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
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
|
+
}
|