@bloxchain/contracts 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (42) hide show
  1. package/README.md +7 -7
  2. package/abi/BaseStateMachine.abi.json +85 -45
  3. package/abi/EngineBlox.abi.json +73 -90
  4. package/abi/GuardController.abi.json +252 -806
  5. package/abi/{SimpleVaultDefinitions.abi.json → GuardControllerDefinitions.abi.json} +170 -28
  6. package/abi/IDefinition.abi.json +5 -0
  7. package/abi/RuntimeRBAC.abi.json +155 -218
  8. package/abi/RuntimeRBACDefinitions.abi.json +179 -0
  9. package/abi/SecureOwnable.abi.json +524 -1621
  10. package/abi/SecureOwnableDefinitions.abi.json +5 -0
  11. package/components/README.md +8 -0
  12. package/core/access/RuntimeRBAC.sol +255 -270
  13. package/core/access/interface/IRuntimeRBAC.sol +55 -84
  14. package/core/access/lib/definitions/RuntimeRBACDefinitions.sol +93 -2
  15. package/core/base/BaseStateMachine.sol +193 -107
  16. package/core/base/interface/IBaseStateMachine.sol +153 -153
  17. package/core/execution/GuardController.sol +155 -131
  18. package/core/execution/interface/IGuardController.sol +146 -120
  19. package/core/execution/lib/definitions/GuardControllerDefinitions.sol +193 -43
  20. package/core/lib/EngineBlox.sol +2683 -2322
  21. package/{interfaces → core/lib/interfaces}/IDefinition.sol +49 -49
  22. package/{interfaces → core/lib/interfaces}/IEventForwarder.sol +33 -33
  23. package/{utils → core/lib/utils}/SharedValidation.sol +61 -8
  24. package/core/pattern/Account.sol +84 -0
  25. package/core/security/SecureOwnable.sol +456 -412
  26. package/core/security/interface/ISecureOwnable.sol +105 -104
  27. package/core/security/lib/definitions/SecureOwnableDefinitions.sol +22 -6
  28. package/package.json +5 -5
  29. package/standards/README.md +12 -0
  30. package/standards/behavior/ICopyable.sol +34 -0
  31. package/standards/hooks/IOnActionHook.sol +21 -0
  32. package/abi/AccountBlox.abi.json +0 -5799
  33. package/abi/BareBlox.abi.json +0 -1284
  34. package/abi/RoleBlox.abi.json +0 -4209
  35. package/abi/SecureBlox.abi.json +0 -3828
  36. package/abi/SimpleRWA20.abi.json +0 -5288
  37. package/abi/SimpleRWA20Definitions.abi.json +0 -191
  38. package/abi/SimpleVault.abi.json +0 -4951
  39. package/core/research/BloxchainWallet.sol +0 -306
  40. package/core/research/erc20-blox/ERC20Blox.sol +0 -140
  41. package/core/research/erc20-blox/lib/definitions/ERC20BloxDefinitions.sol +0 -185
  42. package/interfaces/IOnActionHook.sol +0 -79
@@ -42,36 +42,57 @@
42
42
  "name": "CannotModifyProtected",
43
43
  "type": "error"
44
44
  },
45
+ {
46
+ "inputs": [
47
+ {
48
+ "internalType": "bytes4",
49
+ "name": "functionSelector",
50
+ "type": "bytes4"
51
+ }
52
+ ],
53
+ "name": "ContractFunctionMustBeProtected",
54
+ "type": "error"
55
+ },
45
56
  {
46
57
  "inputs": [],
47
58
  "name": "InvalidInitialization",
48
59
  "type": "error"
49
60
  },
61
+ {
62
+ "inputs": [],
63
+ "name": "InvalidPayment",
64
+ "type": "error"
65
+ },
50
66
  {
51
67
  "inputs": [
52
68
  {
53
- "internalType": "uint256",
54
- "name": "from",
55
- "type": "uint256"
69
+ "internalType": "address",
70
+ "name": "signedContract",
71
+ "type": "address"
56
72
  },
57
73
  {
58
- "internalType": "uint256",
59
- "name": "to",
60
- "type": "uint256"
74
+ "internalType": "address",
75
+ "name": "entryContract",
76
+ "type": "address"
61
77
  }
62
78
  ],
63
- "name": "InvalidRange",
79
+ "name": "MetaTxHandlerContractMismatch",
64
80
  "type": "error"
65
81
  },
66
82
  {
67
83
  "inputs": [
68
84
  {
69
- "internalType": "uint256",
70
- "name": "provided",
71
- "type": "uint256"
85
+ "internalType": "bytes4",
86
+ "name": "signedSelector",
87
+ "type": "bytes4"
88
+ },
89
+ {
90
+ "internalType": "bytes4",
91
+ "name": "entrySelector",
92
+ "type": "bytes4"
72
93
  }
73
94
  ],
74
- "name": "MaxWalletsZero",
95
+ "name": "MetaTxHandlerSelectorMismatch",
75
96
  "type": "error"
76
97
  },
77
98
  {
@@ -261,25 +282,6 @@
261
282
  "stateMutability": "view",
262
283
  "type": "function"
263
284
  },
264
- {
265
- "inputs": [
266
- {
267
- "internalType": "bytes4",
268
- "name": "functionSelector",
269
- "type": "bytes4"
270
- }
271
- ],
272
- "name": "functionSchemaExists",
273
- "outputs": [
274
- {
275
- "internalType": "bool",
276
- "name": "",
277
- "type": "bool"
278
- }
279
- ],
280
- "stateMutability": "view",
281
- "type": "function"
282
- },
283
285
  {
284
286
  "inputs": [
285
287
  {
@@ -808,6 +810,25 @@
808
810
  "stateMutability": "view",
809
811
  "type": "function"
810
812
  },
813
+ {
814
+ "inputs": [
815
+ {
816
+ "internalType": "bytes32",
817
+ "name": "roleHash",
818
+ "type": "bytes32"
819
+ }
820
+ ],
821
+ "name": "getAuthorizedWallets",
822
+ "outputs": [
823
+ {
824
+ "internalType": "address[]",
825
+ "name": "",
826
+ "type": "address[]"
827
+ }
828
+ ],
829
+ "stateMutability": "view",
830
+ "type": "function"
831
+ },
811
832
  {
812
833
  "inputs": [],
813
834
  "name": "getBroadcasters",
@@ -821,6 +842,105 @@
821
842
  "stateMutability": "view",
822
843
  "type": "function"
823
844
  },
845
+ {
846
+ "inputs": [
847
+ {
848
+ "internalType": "bytes4",
849
+ "name": "functionSelector",
850
+ "type": "bytes4"
851
+ }
852
+ ],
853
+ "name": "getFunctionSchema",
854
+ "outputs": [
855
+ {
856
+ "components": [
857
+ {
858
+ "internalType": "string",
859
+ "name": "functionSignature",
860
+ "type": "string"
861
+ },
862
+ {
863
+ "internalType": "bytes4",
864
+ "name": "functionSelector",
865
+ "type": "bytes4"
866
+ },
867
+ {
868
+ "internalType": "bytes32",
869
+ "name": "operationType",
870
+ "type": "bytes32"
871
+ },
872
+ {
873
+ "internalType": "string",
874
+ "name": "operationName",
875
+ "type": "string"
876
+ },
877
+ {
878
+ "internalType": "uint16",
879
+ "name": "supportedActionsBitmap",
880
+ "type": "uint16"
881
+ },
882
+ {
883
+ "internalType": "bool",
884
+ "name": "enforceHandlerRelations",
885
+ "type": "bool"
886
+ },
887
+ {
888
+ "internalType": "bool",
889
+ "name": "isProtected",
890
+ "type": "bool"
891
+ },
892
+ {
893
+ "internalType": "bytes4[]",
894
+ "name": "handlerForSelectors",
895
+ "type": "bytes4[]"
896
+ }
897
+ ],
898
+ "internalType": "struct EngineBlox.FunctionSchema",
899
+ "name": "",
900
+ "type": "tuple"
901
+ }
902
+ ],
903
+ "stateMutability": "view",
904
+ "type": "function"
905
+ },
906
+ {
907
+ "inputs": [
908
+ {
909
+ "internalType": "bytes4",
910
+ "name": "functionSelector",
911
+ "type": "bytes4"
912
+ }
913
+ ],
914
+ "name": "getFunctionWhitelistTargets",
915
+ "outputs": [
916
+ {
917
+ "internalType": "address[]",
918
+ "name": "",
919
+ "type": "address[]"
920
+ }
921
+ ],
922
+ "stateMutability": "view",
923
+ "type": "function"
924
+ },
925
+ {
926
+ "inputs": [
927
+ {
928
+ "internalType": "bytes4",
929
+ "name": "functionSelector",
930
+ "type": "bytes4"
931
+ }
932
+ ],
933
+ "name": "getHooks",
934
+ "outputs": [
935
+ {
936
+ "internalType": "address[]",
937
+ "name": "hooks",
938
+ "type": "address[]"
939
+ }
940
+ ],
941
+ "stateMutability": "view",
942
+ "type": "function"
943
+ },
824
944
  {
825
945
  "inputs": [],
826
946
  "name": "getPendingTransactions",
@@ -864,7 +984,7 @@
864
984
  },
865
985
  {
866
986
  "internalType": "bytes32",
867
- "name": "roleHashReturn",
987
+ "name": "hash",
868
988
  "type": "bytes32"
869
989
  },
870
990
  {
@@ -1211,25 +1331,6 @@
1211
1331
  "stateMutability": "view",
1212
1332
  "type": "function"
1213
1333
  },
1214
- {
1215
- "inputs": [
1216
- {
1217
- "internalType": "bytes32",
1218
- "name": "roleHash",
1219
- "type": "bytes32"
1220
- }
1221
- ],
1222
- "name": "getWalletsInRole",
1223
- "outputs": [
1224
- {
1225
- "internalType": "address[]",
1226
- "name": "",
1227
- "type": "address[]"
1228
- }
1229
- ],
1230
- "stateMutability": "view",
1231
- "type": "function"
1232
- },
1233
1334
  {
1234
1335
  "inputs": [
1235
1336
  {
@@ -1267,30 +1368,6 @@
1267
1368
  "stateMutability": "view",
1268
1369
  "type": "function"
1269
1370
  },
1270
- {
1271
- "inputs": [
1272
- {
1273
- "internalType": "bytes4",
1274
- "name": "functionSelector",
1275
- "type": "bytes4"
1276
- },
1277
- {
1278
- "internalType": "enum EngineBlox.TxAction",
1279
- "name": "action",
1280
- "type": "uint8"
1281
- }
1282
- ],
1283
- "name": "isActionSupportedByFunction",
1284
- "outputs": [
1285
- {
1286
- "internalType": "bool",
1287
- "name": "",
1288
- "type": "bool"
1289
- }
1290
- ],
1291
- "stateMutability": "view",
1292
- "type": "function"
1293
- },
1294
1371
  {
1295
1372
  "inputs": [],
1296
1373
  "name": "owner",
@@ -1532,105 +1609,9 @@
1532
1609
  "name": "roleConfigBatchRequestAndApprove",
1533
1610
  "outputs": [
1534
1611
  {
1535
- "components": [
1536
- {
1537
- "internalType": "uint256",
1538
- "name": "txId",
1539
- "type": "uint256"
1540
- },
1541
- {
1542
- "internalType": "uint256",
1543
- "name": "releaseTime",
1544
- "type": "uint256"
1545
- },
1546
- {
1547
- "internalType": "enum EngineBlox.TxStatus",
1548
- "name": "status",
1549
- "type": "uint8"
1550
- },
1551
- {
1552
- "components": [
1553
- {
1554
- "internalType": "address",
1555
- "name": "requester",
1556
- "type": "address"
1557
- },
1558
- {
1559
- "internalType": "address",
1560
- "name": "target",
1561
- "type": "address"
1562
- },
1563
- {
1564
- "internalType": "uint256",
1565
- "name": "value",
1566
- "type": "uint256"
1567
- },
1568
- {
1569
- "internalType": "uint256",
1570
- "name": "gasLimit",
1571
- "type": "uint256"
1572
- },
1573
- {
1574
- "internalType": "bytes32",
1575
- "name": "operationType",
1576
- "type": "bytes32"
1577
- },
1578
- {
1579
- "internalType": "bytes4",
1580
- "name": "executionSelector",
1581
- "type": "bytes4"
1582
- },
1583
- {
1584
- "internalType": "bytes",
1585
- "name": "executionParams",
1586
- "type": "bytes"
1587
- }
1588
- ],
1589
- "internalType": "struct EngineBlox.TxParams",
1590
- "name": "params",
1591
- "type": "tuple"
1592
- },
1593
- {
1594
- "internalType": "bytes32",
1595
- "name": "message",
1596
- "type": "bytes32"
1597
- },
1598
- {
1599
- "internalType": "bytes",
1600
- "name": "result",
1601
- "type": "bytes"
1602
- },
1603
- {
1604
- "components": [
1605
- {
1606
- "internalType": "address",
1607
- "name": "recipient",
1608
- "type": "address"
1609
- },
1610
- {
1611
- "internalType": "uint256",
1612
- "name": "nativeTokenAmount",
1613
- "type": "uint256"
1614
- },
1615
- {
1616
- "internalType": "address",
1617
- "name": "erc20TokenAddress",
1618
- "type": "address"
1619
- },
1620
- {
1621
- "internalType": "uint256",
1622
- "name": "erc20TokenAmount",
1623
- "type": "uint256"
1624
- }
1625
- ],
1626
- "internalType": "struct EngineBlox.PaymentDetails",
1627
- "name": "payment",
1628
- "type": "tuple"
1629
- }
1630
- ],
1631
- "internalType": "struct EngineBlox.TxRecord",
1612
+ "internalType": "uint256",
1632
1613
  "name": "",
1633
- "type": "tuple"
1614
+ "type": "uint256"
1634
1615
  }
1635
1616
  ],
1636
1617
  "stateMutability": "nonpayable",
@@ -1641,7 +1622,7 @@
1641
1622
  {
1642
1623
  "components": [
1643
1624
  {
1644
- "internalType": "enum RuntimeRBAC.RoleConfigActionType",
1625
+ "internalType": "enum IRuntimeRBAC.RoleConfigActionType",
1645
1626
  "name": "actionType",
1646
1627
  "type": "uint8"
1647
1628
  },
@@ -1651,7 +1632,7 @@
1651
1632
  "type": "bytes"
1652
1633
  }
1653
1634
  ],
1654
- "internalType": "struct RuntimeRBAC.RoleConfigAction[]",
1635
+ "internalType": "struct IRuntimeRBAC.RoleConfigAction[]",
1655
1636
  "name": "actions",
1656
1637
  "type": "tuple[]"
1657
1638
  }
@@ -1660,49 +1641,5 @@
1660
1641
  "outputs": [],
1661
1642
  "stateMutability": "nonpayable",
1662
1643
  "type": "function"
1663
- },
1664
- {
1665
- "inputs": [
1666
- {
1667
- "internalType": "bytes4",
1668
- "name": "functionSelector",
1669
- "type": "bytes4"
1670
- }
1671
- ],
1672
- "name": "getFunctionSchema",
1673
- "outputs": [
1674
- {
1675
- "internalType": "string",
1676
- "name": "functionSignature",
1677
- "type": "string"
1678
- },
1679
- {
1680
- "internalType": "bytes4",
1681
- "name": "functionSelectorReturn",
1682
- "type": "bytes4"
1683
- },
1684
- {
1685
- "internalType": "bytes32",
1686
- "name": "operationType",
1687
- "type": "bytes32"
1688
- },
1689
- {
1690
- "internalType": "string",
1691
- "name": "operationName",
1692
- "type": "string"
1693
- },
1694
- {
1695
- "internalType": "enum EngineBlox.TxAction[]",
1696
- "name": "supportedActions",
1697
- "type": "uint8[]"
1698
- },
1699
- {
1700
- "internalType": "bool",
1701
- "name": "isProtected",
1702
- "type": "bool"
1703
- }
1704
- ],
1705
- "stateMutability": "view",
1706
- "type": "function"
1707
1644
  }
1708
1645
  ]
@@ -69,6 +69,11 @@
69
69
  "name": "supportedActionsBitmap",
70
70
  "type": "uint16"
71
71
  },
72
+ {
73
+ "internalType": "bool",
74
+ "name": "enforceHandlerRelations",
75
+ "type": "bool"
76
+ },
72
77
  {
73
78
  "internalType": "bool",
74
79
  "name": "isProtected",
@@ -130,6 +135,180 @@
130
135
  "stateMutability": "pure",
131
136
  "type": "function"
132
137
  },
138
+ {
139
+ "inputs": [],
140
+ "name": "getRoleConfigActionSpecs",
141
+ "outputs": [
142
+ {
143
+ "internalType": "string[]",
144
+ "name": "actionNames",
145
+ "type": "string[]"
146
+ },
147
+ {
148
+ "internalType": "string[]",
149
+ "name": "formats",
150
+ "type": "string[]"
151
+ }
152
+ ],
153
+ "stateMutability": "pure",
154
+ "type": "function"
155
+ },
156
+ {
157
+ "inputs": [
158
+ {
159
+ "internalType": "string",
160
+ "name": "roleName",
161
+ "type": "string"
162
+ },
163
+ {
164
+ "internalType": "uint256",
165
+ "name": "maxWallets",
166
+ "type": "uint256"
167
+ }
168
+ ],
169
+ "name": "encodeCreateRole",
170
+ "outputs": [
171
+ {
172
+ "internalType": "bytes",
173
+ "name": "",
174
+ "type": "bytes"
175
+ }
176
+ ],
177
+ "stateMutability": "pure",
178
+ "type": "function"
179
+ },
180
+ {
181
+ "inputs": [
182
+ {
183
+ "internalType": "bytes32",
184
+ "name": "roleHash",
185
+ "type": "bytes32"
186
+ }
187
+ ],
188
+ "name": "encodeRemoveRole",
189
+ "outputs": [
190
+ {
191
+ "internalType": "bytes",
192
+ "name": "",
193
+ "type": "bytes"
194
+ }
195
+ ],
196
+ "stateMutability": "pure",
197
+ "type": "function"
198
+ },
199
+ {
200
+ "inputs": [
201
+ {
202
+ "internalType": "bytes32",
203
+ "name": "roleHash",
204
+ "type": "bytes32"
205
+ },
206
+ {
207
+ "internalType": "address",
208
+ "name": "wallet",
209
+ "type": "address"
210
+ }
211
+ ],
212
+ "name": "encodeAddWallet",
213
+ "outputs": [
214
+ {
215
+ "internalType": "bytes",
216
+ "name": "",
217
+ "type": "bytes"
218
+ }
219
+ ],
220
+ "stateMutability": "pure",
221
+ "type": "function"
222
+ },
223
+ {
224
+ "inputs": [
225
+ {
226
+ "internalType": "bytes32",
227
+ "name": "roleHash",
228
+ "type": "bytes32"
229
+ },
230
+ {
231
+ "internalType": "address",
232
+ "name": "wallet",
233
+ "type": "address"
234
+ }
235
+ ],
236
+ "name": "encodeRevokeWallet",
237
+ "outputs": [
238
+ {
239
+ "internalType": "bytes",
240
+ "name": "",
241
+ "type": "bytes"
242
+ }
243
+ ],
244
+ "stateMutability": "pure",
245
+ "type": "function"
246
+ },
247
+ {
248
+ "inputs": [
249
+ {
250
+ "internalType": "bytes32",
251
+ "name": "roleHash",
252
+ "type": "bytes32"
253
+ },
254
+ {
255
+ "components": [
256
+ {
257
+ "internalType": "bytes4",
258
+ "name": "functionSelector",
259
+ "type": "bytes4"
260
+ },
261
+ {
262
+ "internalType": "uint16",
263
+ "name": "grantedActionsBitmap",
264
+ "type": "uint16"
265
+ },
266
+ {
267
+ "internalType": "bytes4[]",
268
+ "name": "handlerForSelectors",
269
+ "type": "bytes4[]"
270
+ }
271
+ ],
272
+ "internalType": "struct EngineBlox.FunctionPermission",
273
+ "name": "functionPermission",
274
+ "type": "tuple"
275
+ }
276
+ ],
277
+ "name": "encodeAddFunctionToRole",
278
+ "outputs": [
279
+ {
280
+ "internalType": "bytes",
281
+ "name": "",
282
+ "type": "bytes"
283
+ }
284
+ ],
285
+ "stateMutability": "pure",
286
+ "type": "function"
287
+ },
288
+ {
289
+ "inputs": [
290
+ {
291
+ "internalType": "bytes32",
292
+ "name": "roleHash",
293
+ "type": "bytes32"
294
+ },
295
+ {
296
+ "internalType": "bytes4",
297
+ "name": "functionSelector",
298
+ "type": "bytes4"
299
+ }
300
+ ],
301
+ "name": "encodeRemoveFunctionFromRole",
302
+ "outputs": [
303
+ {
304
+ "internalType": "bytes",
305
+ "name": "",
306
+ "type": "bytes"
307
+ }
308
+ ],
309
+ "stateMutability": "pure",
310
+ "type": "function"
311
+ },
133
312
  {
134
313
  "inputs": [
135
314
  {