@bloxchain/contracts 1.0.0-alpha → 1.0.0-alpha.1
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/README.md +55 -18
- package/abi/BareBlox.abi.json +33 -90
- package/abi/BaseStateMachine.abi.json +33 -90
- package/abi/ControlBlox.abi.json +8 -297
- package/abi/GuardController.abi.json +20 -119
- package/abi/IDefinition.abi.json +19 -0
- package/abi/RoleBlox.abi.json +5 -263
- package/abi/RuntimeRBAC.abi.json +24 -142
- package/abi/RuntimeRBACDefinitions.abi.json +19 -0
- package/abi/SecureBlox.abi.json +49 -235
- package/abi/SecureOwnable.abi.json +49 -235
- package/abi/SecureOwnableDefinitions.abi.json +19 -0
- package/abi/SimpleRWA20.abi.json +49 -235
- package/abi/SimpleRWA20Definitions.abi.json +19 -0
- package/abi/SimpleVault.abi.json +49 -235
- package/abi/SimpleVaultDefinitions.abi.json +19 -0
- package/{contracts/core → core}/access/RuntimeRBAC.sol +8 -74
- package/{contracts/core → core}/access/interface/IRuntimeRBAC.sol +1 -13
- package/{contracts/core → core}/access/lib/definitions/RuntimeRBACDefinitions.sol +9 -0
- package/{contracts/core → core}/base/BaseStateMachine.sol +39 -26
- package/{contracts/core → core}/execution/GuardController.sol +23 -54
- package/{contracts/core → core}/execution/lib/definitions/GuardControllerDefinitions.sol +9 -0
- package/core/research/BloxchainWallet.sol +306 -0
- package/core/research/erc20-blox/ERC20Blox.sol +140 -0
- package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +185 -0
- package/{contracts/core → core}/security/SecureOwnable.sol +409 -419
- package/{contracts/core → core}/security/lib/definitions/SecureOwnableDefinitions.sol +9 -0
- package/{contracts/interfaces → interfaces}/IDefinition.sol +14 -5
- package/package.json +4 -2
- /package/{contracts/core → core}/base/interface/IBaseStateMachine.sol +0 -0
- /package/{contracts/core → core}/execution/interface/IGuardController.sol +0 -0
- /package/{contracts/core → core}/lib/EngineBlox.sol +0 -0
- /package/{contracts/core → core}/security/interface/ISecureOwnable.sol +0 -0
- /package/{contracts/interfaces → interfaces}/IEventForwarder.sol +0 -0
- /package/{contracts/interfaces → interfaces}/IOnActionHook.sol +0 -0
- /package/{contracts/utils → utils}/SharedValidation.sol +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# @bloxchain/contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@bloxchain/contracts)
|
|
4
|
+
[](https://opensource.org/licenses/MPL-2.0)
|
|
5
|
+
[](https://soliditylang.org/)
|
|
6
|
+
|
|
7
|
+
Bloxchain Protocol smart contracts – state abstraction and core components for building on the Bloxchain Protocol.
|
|
8
|
+
|
|
9
|
+
> **⚠️ EXPERIMENTAL SOFTWARE WARNING**
|
|
10
|
+
> This package contains experimental smart contract code. While the framework is feature-complete and tested, it is not yet audited for production use. Use at your own risk and do not deploy with real assets without proper security review.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
- **Node.js**: >= 18.0.0 (for tooling; Solidity has no runtime dependency)
|
|
15
|
+
- **Solidity**: 0.8.x (0.8.33 recommended)
|
|
16
|
+
- **Compilers**: Foundry, Hardhat, or Truffle
|
|
4
17
|
|
|
5
18
|
## Installation
|
|
6
19
|
|
|
@@ -10,40 +23,64 @@ npm install @bloxchain/contracts
|
|
|
10
23
|
|
|
11
24
|
## Usage
|
|
12
25
|
|
|
13
|
-
Import contracts in your Solidity files:
|
|
26
|
+
Import contracts in your Solidity files. Paths are relative to the package root (`core/`, `utils/`, `interfaces/`):
|
|
14
27
|
|
|
15
28
|
```solidity
|
|
16
29
|
import "@bloxchain/contracts/core/base/BaseStateMachine.sol";
|
|
17
30
|
import "@bloxchain/contracts/core/security/SecureOwnable.sol";
|
|
18
31
|
import "@bloxchain/contracts/core/access/RuntimeRBAC.sol";
|
|
19
32
|
import "@bloxchain/contracts/core/execution/GuardController.sol";
|
|
33
|
+
import "@bloxchain/contracts/utils/SharedValidation.sol";
|
|
34
|
+
import "@bloxchain/contracts/interfaces/IDefinition.sol";
|
|
20
35
|
```
|
|
21
36
|
|
|
37
|
+
**Foundry**: No remapping needed; the package exposes `core/`, `utils/`, and `interfaces/` at root.
|
|
38
|
+
**Hardhat / Truffle**: Resolve `@bloxchain/contracts` from `node_modules` as usual.
|
|
39
|
+
|
|
22
40
|
## Contracts
|
|
23
41
|
|
|
24
|
-
### Core
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
### Core contracts
|
|
43
|
+
|
|
44
|
+
| Contract | Description |
|
|
45
|
+
|----------|-------------|
|
|
46
|
+
| `BaseStateMachine` | Foundation state machine for all blox contracts |
|
|
47
|
+
| `SecureOwnable` | Multi-role security with time-locked operations |
|
|
48
|
+
| `RuntimeRBAC` | Dynamic role-based access control |
|
|
49
|
+
| `GuardController` | Execution workflows and time-locked transactions |
|
|
29
50
|
|
|
30
|
-
###
|
|
31
|
-
- `BareBlox` - Minimal base state machine
|
|
32
|
-
- `SecureBlox` - Basic secure ownership
|
|
33
|
-
- `RoleBlox` - Secure ownership + RBAC
|
|
34
|
-
- `ControlBlox` - Complete execution workflows
|
|
35
|
-
- `MachineBlox` - Full-featured with hooks
|
|
51
|
+
### Templates and examples
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
- `SimpleVault` - Secure asset management
|
|
39
|
-
- `SimpleRWA20` - Tokenized real-world assets
|
|
53
|
+
Templates (e.g. BareBlox, SecureBlox, ControlBlox) and example applications (SimpleVault, SimpleRWA20) live in the main repository under `contracts/examples/`. They are not included in this npm package. See the [main repo](https://github.com/PracticalParticle/Bloxchain-Protocol) for full documentation and examples.
|
|
40
54
|
|
|
41
55
|
## Dependencies
|
|
42
56
|
|
|
43
|
-
This package
|
|
57
|
+
This package declares:
|
|
58
|
+
|
|
44
59
|
- `@openzeppelin/contracts`: ^5.4.0
|
|
45
60
|
- `@openzeppelin/contracts-upgradeable`: ^5.4.0
|
|
46
61
|
|
|
62
|
+
Install them in your project if your tooling does not resolve transitive dependencies.
|
|
63
|
+
|
|
64
|
+
## Versioning and stability
|
|
65
|
+
|
|
66
|
+
This package follows [Semantic Versioning](https://semver.org/). Current versions are **alpha** (`1.0.0-alpha.x`). Pre-1.0 releases may introduce breaking changes; we recommend pinning the exact version until the protocol is audited and stable.
|
|
67
|
+
|
|
68
|
+
## Security
|
|
69
|
+
|
|
70
|
+
- **Vulnerability reporting**: Do not open public GitHub issues for security vulnerabilities. See the [Security Policy](https://github.com/PracticalParticle/Bloxchain-Protocol/blob/main/SECURITY.md) for reporting instructions (e.g. security@particlecs.com).
|
|
71
|
+
- **Audit status**: Not yet audited. Do not use with mainnet assets without an independent security review.
|
|
72
|
+
|
|
73
|
+
## Support and links
|
|
74
|
+
|
|
75
|
+
- **Documentation**: [Bloxchain Protocol README](https://github.com/PracticalParticle/Bloxchain-Protocol#readme)
|
|
76
|
+
- **Issues and feature requests**: [GitHub Issues](https://github.com/PracticalParticle/Bloxchain-Protocol/issues)
|
|
77
|
+
- **Homepage**: [bloxchain.app](https://bloxchain.app/)
|
|
78
|
+
- **Author**: [Particle Crypto Security](https://particlecs.com/)
|
|
79
|
+
|
|
80
|
+
## Repository
|
|
81
|
+
|
|
82
|
+
Part of [Bloxchain Protocol](https://github.com/PracticalParticle/Bloxchain-Protocol). For full documentation, architecture, and examples, see the main repository.
|
|
83
|
+
|
|
47
84
|
## License
|
|
48
85
|
|
|
49
|
-
MPL-2.0
|
|
86
|
+
MPL-2.0 (Mozilla Public License 2.0). See the [LICENSE](https://github.com/PracticalParticle/Bloxchain-Protocol/blob/main/LICENSE) file in the main repository.
|
package/abi/BareBlox.abi.json
CHANGED
|
@@ -58,122 +58,46 @@
|
|
|
58
58
|
"type": "error"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"anonymous": false,
|
|
62
|
-
"inputs": [
|
|
63
|
-
{
|
|
64
|
-
"indexed": false,
|
|
65
|
-
"internalType": "uint64",
|
|
66
|
-
"name": "version",
|
|
67
|
-
"type": "uint64"
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
"name": "Initialized",
|
|
71
|
-
"type": "event"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"anonymous": false,
|
|
75
61
|
"inputs": [
|
|
76
62
|
{
|
|
77
|
-
"indexed": true,
|
|
78
|
-
"internalType": "uint256",
|
|
79
|
-
"name": "txId",
|
|
80
|
-
"type": "uint256"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"indexed": true,
|
|
84
63
|
"internalType": "bytes32",
|
|
85
|
-
"name": "
|
|
64
|
+
"name": "resourceId",
|
|
86
65
|
"type": "bytes32"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"indexed": true,
|
|
90
|
-
"internalType": "address",
|
|
91
|
-
"name": "approver",
|
|
92
|
-
"type": "address"
|
|
93
66
|
}
|
|
94
67
|
],
|
|
95
|
-
"name": "
|
|
96
|
-
"type": "
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"anonymous": false,
|
|
100
|
-
"inputs": [
|
|
101
|
-
{
|
|
102
|
-
"indexed": true,
|
|
103
|
-
"internalType": "uint256",
|
|
104
|
-
"name": "txId",
|
|
105
|
-
"type": "uint256"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"indexed": true,
|
|
109
|
-
"internalType": "bytes32",
|
|
110
|
-
"name": "operationType",
|
|
111
|
-
"type": "bytes32"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"indexed": true,
|
|
115
|
-
"internalType": "address",
|
|
116
|
-
"name": "canceller",
|
|
117
|
-
"type": "address"
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"name": "TransactionCancelled",
|
|
121
|
-
"type": "event"
|
|
68
|
+
"name": "ResourceNotFound",
|
|
69
|
+
"type": "error"
|
|
122
70
|
},
|
|
123
71
|
{
|
|
124
72
|
"anonymous": false,
|
|
125
73
|
"inputs": [
|
|
126
74
|
{
|
|
127
75
|
"indexed": true,
|
|
128
|
-
"internalType": "
|
|
129
|
-
"name": "
|
|
130
|
-
"type": "
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"indexed": true,
|
|
134
|
-
"internalType": "bytes32",
|
|
135
|
-
"name": "operationType",
|
|
136
|
-
"type": "bytes32"
|
|
76
|
+
"internalType": "bytes4",
|
|
77
|
+
"name": "functionSelector",
|
|
78
|
+
"type": "bytes4"
|
|
137
79
|
},
|
|
138
80
|
{
|
|
139
81
|
"indexed": false,
|
|
140
|
-
"internalType": "
|
|
141
|
-
"name": "
|
|
142
|
-
"type": "
|
|
82
|
+
"internalType": "bytes",
|
|
83
|
+
"name": "data",
|
|
84
|
+
"type": "bytes"
|
|
143
85
|
}
|
|
144
86
|
],
|
|
145
|
-
"name": "
|
|
87
|
+
"name": "ComponentEvent",
|
|
146
88
|
"type": "event"
|
|
147
89
|
},
|
|
148
90
|
{
|
|
149
91
|
"anonymous": false,
|
|
150
92
|
"inputs": [
|
|
151
|
-
{
|
|
152
|
-
"indexed": true,
|
|
153
|
-
"internalType": "uint256",
|
|
154
|
-
"name": "txId",
|
|
155
|
-
"type": "uint256"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"indexed": true,
|
|
159
|
-
"internalType": "address",
|
|
160
|
-
"name": "requester",
|
|
161
|
-
"type": "address"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"indexed": true,
|
|
165
|
-
"internalType": "bytes32",
|
|
166
|
-
"name": "operationType",
|
|
167
|
-
"type": "bytes32"
|
|
168
|
-
},
|
|
169
93
|
{
|
|
170
94
|
"indexed": false,
|
|
171
|
-
"internalType": "
|
|
172
|
-
"name": "
|
|
173
|
-
"type": "
|
|
95
|
+
"internalType": "uint64",
|
|
96
|
+
"name": "version",
|
|
97
|
+
"type": "uint64"
|
|
174
98
|
}
|
|
175
99
|
],
|
|
176
|
-
"name": "
|
|
100
|
+
"name": "Initialized",
|
|
177
101
|
"type": "event"
|
|
178
102
|
},
|
|
179
103
|
{
|
|
@@ -1212,6 +1136,25 @@
|
|
|
1212
1136
|
"stateMutability": "view",
|
|
1213
1137
|
"type": "function"
|
|
1214
1138
|
},
|
|
1139
|
+
{
|
|
1140
|
+
"inputs": [
|
|
1141
|
+
{
|
|
1142
|
+
"internalType": "bytes32",
|
|
1143
|
+
"name": "roleHash",
|
|
1144
|
+
"type": "bytes32"
|
|
1145
|
+
}
|
|
1146
|
+
],
|
|
1147
|
+
"name": "getWalletsInRole",
|
|
1148
|
+
"outputs": [
|
|
1149
|
+
{
|
|
1150
|
+
"internalType": "address[]",
|
|
1151
|
+
"name": "",
|
|
1152
|
+
"type": "address[]"
|
|
1153
|
+
}
|
|
1154
|
+
],
|
|
1155
|
+
"stateMutability": "view",
|
|
1156
|
+
"type": "function"
|
|
1157
|
+
},
|
|
1215
1158
|
{
|
|
1216
1159
|
"inputs": [
|
|
1217
1160
|
{
|
|
@@ -58,122 +58,46 @@
|
|
|
58
58
|
"type": "error"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"anonymous": false,
|
|
62
|
-
"inputs": [
|
|
63
|
-
{
|
|
64
|
-
"indexed": false,
|
|
65
|
-
"internalType": "uint64",
|
|
66
|
-
"name": "version",
|
|
67
|
-
"type": "uint64"
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
"name": "Initialized",
|
|
71
|
-
"type": "event"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"anonymous": false,
|
|
75
61
|
"inputs": [
|
|
76
62
|
{
|
|
77
|
-
"indexed": true,
|
|
78
|
-
"internalType": "uint256",
|
|
79
|
-
"name": "txId",
|
|
80
|
-
"type": "uint256"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"indexed": true,
|
|
84
63
|
"internalType": "bytes32",
|
|
85
|
-
"name": "
|
|
64
|
+
"name": "resourceId",
|
|
86
65
|
"type": "bytes32"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"indexed": true,
|
|
90
|
-
"internalType": "address",
|
|
91
|
-
"name": "approver",
|
|
92
|
-
"type": "address"
|
|
93
66
|
}
|
|
94
67
|
],
|
|
95
|
-
"name": "
|
|
96
|
-
"type": "
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"anonymous": false,
|
|
100
|
-
"inputs": [
|
|
101
|
-
{
|
|
102
|
-
"indexed": true,
|
|
103
|
-
"internalType": "uint256",
|
|
104
|
-
"name": "txId",
|
|
105
|
-
"type": "uint256"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"indexed": true,
|
|
109
|
-
"internalType": "bytes32",
|
|
110
|
-
"name": "operationType",
|
|
111
|
-
"type": "bytes32"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"indexed": true,
|
|
115
|
-
"internalType": "address",
|
|
116
|
-
"name": "canceller",
|
|
117
|
-
"type": "address"
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"name": "TransactionCancelled",
|
|
121
|
-
"type": "event"
|
|
68
|
+
"name": "ResourceNotFound",
|
|
69
|
+
"type": "error"
|
|
122
70
|
},
|
|
123
71
|
{
|
|
124
72
|
"anonymous": false,
|
|
125
73
|
"inputs": [
|
|
126
74
|
{
|
|
127
75
|
"indexed": true,
|
|
128
|
-
"internalType": "
|
|
129
|
-
"name": "
|
|
130
|
-
"type": "
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"indexed": true,
|
|
134
|
-
"internalType": "bytes32",
|
|
135
|
-
"name": "operationType",
|
|
136
|
-
"type": "bytes32"
|
|
76
|
+
"internalType": "bytes4",
|
|
77
|
+
"name": "functionSelector",
|
|
78
|
+
"type": "bytes4"
|
|
137
79
|
},
|
|
138
80
|
{
|
|
139
81
|
"indexed": false,
|
|
140
|
-
"internalType": "
|
|
141
|
-
"name": "
|
|
142
|
-
"type": "
|
|
82
|
+
"internalType": "bytes",
|
|
83
|
+
"name": "data",
|
|
84
|
+
"type": "bytes"
|
|
143
85
|
}
|
|
144
86
|
],
|
|
145
|
-
"name": "
|
|
87
|
+
"name": "ComponentEvent",
|
|
146
88
|
"type": "event"
|
|
147
89
|
},
|
|
148
90
|
{
|
|
149
91
|
"anonymous": false,
|
|
150
92
|
"inputs": [
|
|
151
|
-
{
|
|
152
|
-
"indexed": true,
|
|
153
|
-
"internalType": "uint256",
|
|
154
|
-
"name": "txId",
|
|
155
|
-
"type": "uint256"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"indexed": true,
|
|
159
|
-
"internalType": "address",
|
|
160
|
-
"name": "requester",
|
|
161
|
-
"type": "address"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"indexed": true,
|
|
165
|
-
"internalType": "bytes32",
|
|
166
|
-
"name": "operationType",
|
|
167
|
-
"type": "bytes32"
|
|
168
|
-
},
|
|
169
93
|
{
|
|
170
94
|
"indexed": false,
|
|
171
|
-
"internalType": "
|
|
172
|
-
"name": "
|
|
173
|
-
"type": "
|
|
95
|
+
"internalType": "uint64",
|
|
96
|
+
"name": "version",
|
|
97
|
+
"type": "uint64"
|
|
174
98
|
}
|
|
175
99
|
],
|
|
176
|
-
"name": "
|
|
100
|
+
"name": "Initialized",
|
|
177
101
|
"type": "event"
|
|
178
102
|
},
|
|
179
103
|
{
|
|
@@ -1142,6 +1066,25 @@
|
|
|
1142
1066
|
"stateMutability": "view",
|
|
1143
1067
|
"type": "function"
|
|
1144
1068
|
},
|
|
1069
|
+
{
|
|
1070
|
+
"inputs": [
|
|
1071
|
+
{
|
|
1072
|
+
"internalType": "bytes32",
|
|
1073
|
+
"name": "roleHash",
|
|
1074
|
+
"type": "bytes32"
|
|
1075
|
+
}
|
|
1076
|
+
],
|
|
1077
|
+
"name": "getWalletsInRole",
|
|
1078
|
+
"outputs": [
|
|
1079
|
+
{
|
|
1080
|
+
"internalType": "address[]",
|
|
1081
|
+
"name": "",
|
|
1082
|
+
"type": "address[]"
|
|
1083
|
+
}
|
|
1084
|
+
],
|
|
1085
|
+
"stateMutability": "view",
|
|
1086
|
+
"type": "function"
|
|
1087
|
+
},
|
|
1145
1088
|
{
|
|
1146
1089
|
"inputs": [
|
|
1147
1090
|
{
|