@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
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@bloxchain/contracts.svg)](https://www.npmjs.com/package/@bloxchain/contracts)
4
4
  [![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-blue.svg)](https://opensource.org/licenses/MPL-2.0)
5
- [![Solidity](https://img.shields.io/badge/Solidity-0.8.33-blue.svg)](https://soliditylang.org/)
5
+ [![Solidity](https://img.shields.io/badge/Solidity-0.8.34-blue.svg)](https://soliditylang.org/)
6
6
 
7
7
  Bloxchain Protocol smart contracts – state abstraction and core components for building on the Bloxchain Protocol.
8
8
 
@@ -12,7 +12,7 @@ Bloxchain Protocol smart contracts – state abstraction and core components for
12
12
  ## Requirements
13
13
 
14
14
  - **Node.js**: >= 18.0.0 (for tooling; Solidity has no runtime dependency)
15
- - **Solidity**: 0.8.x (0.8.33 recommended)
15
+ - **Solidity**: 0.8.x (0.8.34 recommended)
16
16
  - **Compilers**: Foundry, Hardhat, or Truffle
17
17
 
18
18
  ## Installation
@@ -23,18 +23,18 @@ npm install @bloxchain/contracts
23
23
 
24
24
  ## Usage
25
25
 
26
- Import contracts in your Solidity files. Paths are relative to the package root (`core/`, `utils/`, `interfaces/`):
26
+ Import contracts in your Solidity files. All contracts live under `@bloxchain/contracts/core/`:
27
27
 
28
28
  ```solidity
29
29
  import "@bloxchain/contracts/core/base/BaseStateMachine.sol";
30
30
  import "@bloxchain/contracts/core/security/SecureOwnable.sol";
31
31
  import "@bloxchain/contracts/core/access/RuntimeRBAC.sol";
32
32
  import "@bloxchain/contracts/core/execution/GuardController.sol";
33
- import "@bloxchain/contracts/utils/SharedValidation.sol";
34
- import "@bloxchain/contracts/interfaces/IDefinition.sol";
33
+ import "@bloxchain/contracts/core/lib/utils/SharedValidation.sol";
34
+ import "@bloxchain/contracts/core/lib/interfaces/IDefinition.sol";
35
35
  ```
36
36
 
37
- **Foundry**: No remapping needed; the package exposes `core/`, `utils/`, and `interfaces/` at root.
37
+ **Foundry**: No remapping needed; the package exposes `core/` at root (lib, base, access, execution, security live inside it).
38
38
  **Hardhat / Truffle**: Resolve `@bloxchain/contracts` from `node_modules` as usual.
39
39
 
40
40
  ## Contracts
@@ -50,7 +50,7 @@ import "@bloxchain/contracts/interfaces/IDefinition.sol";
50
50
 
51
51
  ### Templates and examples
52
52
 
53
- Templates (e.g. BareBlox, SecureBlox, AccountBlox) 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.
53
+ Templates (e.g. AccountBlox, CopyBlox) 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.
54
54
 
55
55
  ## Dependencies
56
56
 
@@ -4,22 +4,6 @@
4
4
  "name": "InvalidInitialization",
5
5
  "type": "error"
6
6
  },
7
- {
8
- "inputs": [
9
- {
10
- "internalType": "uint256",
11
- "name": "from",
12
- "type": "uint256"
13
- },
14
- {
15
- "internalType": "uint256",
16
- "name": "to",
17
- "type": "uint256"
18
- }
19
- ],
20
- "name": "InvalidRange",
21
- "type": "error"
22
- },
23
7
  {
24
8
  "inputs": [
25
9
  {
@@ -158,6 +142,25 @@
158
142
  "stateMutability": "view",
159
143
  "type": "function"
160
144
  },
145
+ {
146
+ "inputs": [
147
+ {
148
+ "internalType": "bytes4",
149
+ "name": "functionSelector",
150
+ "type": "bytes4"
151
+ }
152
+ ],
153
+ "name": "getHooks",
154
+ "outputs": [
155
+ {
156
+ "internalType": "address[]",
157
+ "name": "hooks",
158
+ "type": "address[]"
159
+ }
160
+ ],
161
+ "stateMutability": "view",
162
+ "type": "function"
163
+ },
161
164
  {
162
165
  "inputs": [
163
166
  {
@@ -1001,7 +1004,7 @@
1001
1004
  },
1002
1005
  {
1003
1006
  "internalType": "bytes32",
1004
- "name": "roleHashReturn",
1007
+ "name": "hash",
1005
1008
  "type": "bytes32"
1006
1009
  },
1007
1010
  {
@@ -1074,7 +1077,7 @@
1074
1077
  "type": "bytes32"
1075
1078
  }
1076
1079
  ],
1077
- "name": "getWalletsInRole",
1080
+ "name": "getAuthorizedWallets",
1078
1081
  "outputs": [
1079
1082
  {
1080
1083
  "internalType": "address[]",
@@ -1093,36 +1096,54 @@
1093
1096
  "type": "bytes4"
1094
1097
  }
1095
1098
  ],
1096
- "name": "functionSchemaExists",
1097
- "outputs": [
1098
- {
1099
- "internalType": "bool",
1100
- "name": "",
1101
- "type": "bool"
1102
- }
1103
- ],
1104
- "stateMutability": "view",
1105
- "type": "function"
1106
- },
1107
- {
1108
- "inputs": [
1109
- {
1110
- "internalType": "bytes4",
1111
- "name": "functionSelector",
1112
- "type": "bytes4"
1113
- },
1114
- {
1115
- "internalType": "enum EngineBlox.TxAction",
1116
- "name": "action",
1117
- "type": "uint8"
1118
- }
1119
- ],
1120
- "name": "isActionSupportedByFunction",
1099
+ "name": "getFunctionSchema",
1121
1100
  "outputs": [
1122
1101
  {
1123
- "internalType": "bool",
1102
+ "components": [
1103
+ {
1104
+ "internalType": "string",
1105
+ "name": "functionSignature",
1106
+ "type": "string"
1107
+ },
1108
+ {
1109
+ "internalType": "bytes4",
1110
+ "name": "functionSelector",
1111
+ "type": "bytes4"
1112
+ },
1113
+ {
1114
+ "internalType": "bytes32",
1115
+ "name": "operationType",
1116
+ "type": "bytes32"
1117
+ },
1118
+ {
1119
+ "internalType": "string",
1120
+ "name": "operationName",
1121
+ "type": "string"
1122
+ },
1123
+ {
1124
+ "internalType": "uint16",
1125
+ "name": "supportedActionsBitmap",
1126
+ "type": "uint16"
1127
+ },
1128
+ {
1129
+ "internalType": "bool",
1130
+ "name": "enforceHandlerRelations",
1131
+ "type": "bool"
1132
+ },
1133
+ {
1134
+ "internalType": "bool",
1135
+ "name": "isProtected",
1136
+ "type": "bool"
1137
+ },
1138
+ {
1139
+ "internalType": "bytes4[]",
1140
+ "name": "handlerForSelectors",
1141
+ "type": "bytes4[]"
1142
+ }
1143
+ ],
1144
+ "internalType": "struct EngineBlox.FunctionSchema",
1124
1145
  "name": "",
1125
- "type": "bool"
1146
+ "type": "tuple"
1126
1147
  }
1127
1148
  ],
1128
1149
  "stateMutability": "view",
@@ -1247,5 +1268,24 @@
1247
1268
  ],
1248
1269
  "stateMutability": "view",
1249
1270
  "type": "function"
1271
+ },
1272
+ {
1273
+ "inputs": [
1274
+ {
1275
+ "internalType": "bytes4",
1276
+ "name": "functionSelector",
1277
+ "type": "bytes4"
1278
+ }
1279
+ ],
1280
+ "name": "getFunctionWhitelistTargets",
1281
+ "outputs": [
1282
+ {
1283
+ "internalType": "address[]",
1284
+ "name": "",
1285
+ "type": "address[]"
1286
+ }
1287
+ ],
1288
+ "stateMutability": "view",
1289
+ "type": "function"
1250
1290
  }
1251
1291
  ]
@@ -58,22 +58,6 @@
58
58
  "name": "ConflictingMetaTxPermissions",
59
59
  "type": "error"
60
60
  },
61
- {
62
- "inputs": [
63
- {
64
- "internalType": "bytes4",
65
- "name": "functionSelector",
66
- "type": "bytes4"
67
- },
68
- {
69
- "internalType": "string",
70
- "name": "functionSignature",
71
- "type": "string"
72
- }
73
- ],
74
- "name": "ContractFunctionMustBeProtected",
75
- "type": "error"
76
- },
77
61
  {
78
62
  "inputs": [
79
63
  {
@@ -338,6 +322,17 @@
338
322
  "name": "MaxRolesExceeded",
339
323
  "type": "error"
340
324
  },
325
+ {
326
+ "inputs": [
327
+ {
328
+ "internalType": "uint256",
329
+ "name": "provided",
330
+ "type": "uint256"
331
+ }
332
+ ],
333
+ "name": "MaxWalletsZero",
334
+ "type": "error"
335
+ },
341
336
  {
342
337
  "inputs": [
343
338
  {
@@ -354,6 +349,44 @@
354
349
  "name": "MetaTxExpired",
355
350
  "type": "error"
356
351
  },
352
+ {
353
+ "inputs": [
354
+ {
355
+ "internalType": "address",
356
+ "name": "signedContract",
357
+ "type": "address"
358
+ },
359
+ {
360
+ "internalType": "address",
361
+ "name": "entryContract",
362
+ "type": "address"
363
+ }
364
+ ],
365
+ "name": "MetaTxHandlerContractMismatch",
366
+ "type": "error"
367
+ },
368
+ {
369
+ "inputs": [
370
+ {
371
+ "internalType": "uint256",
372
+ "name": "txId",
373
+ "type": "uint256"
374
+ }
375
+ ],
376
+ "name": "MetaTxPaymentMismatchStoredTx",
377
+ "type": "error"
378
+ },
379
+ {
380
+ "inputs": [
381
+ {
382
+ "internalType": "uint256",
383
+ "name": "txId",
384
+ "type": "uint256"
385
+ }
386
+ ],
387
+ "name": "MetaTxRecordMismatchStoredTx",
388
+ "type": "error"
389
+ },
357
390
  {
358
391
  "inputs": [
359
392
  {
@@ -581,12 +614,12 @@
581
614
  },
582
615
  {
583
616
  "inputs": [],
584
- "name": "MAX_BATCH_SIZE",
617
+ "name": "ATTACHED_PAYMENT_RECIPIENT_SELECTOR",
585
618
  "outputs": [
586
619
  {
587
- "internalType": "uint256",
620
+ "internalType": "bytes4",
588
621
  "name": "",
589
- "type": "uint256"
622
+ "type": "bytes4"
590
623
  }
591
624
  ],
592
625
  "stateMutability": "view",
@@ -594,12 +627,12 @@
594
627
  },
595
628
  {
596
629
  "inputs": [],
597
- "name": "MAX_FUNCTIONS",
630
+ "name": "ERC20_TRANSFER_SELECTOR",
598
631
  "outputs": [
599
632
  {
600
- "internalType": "uint256",
633
+ "internalType": "bytes4",
601
634
  "name": "",
602
- "type": "uint256"
635
+ "type": "bytes4"
603
636
  }
604
637
  ],
605
638
  "stateMutability": "view",
@@ -607,7 +640,7 @@
607
640
  },
608
641
  {
609
642
  "inputs": [],
610
- "name": "MAX_HOOKS_PER_SELECTOR",
643
+ "name": "MAX_BATCH_SIZE",
611
644
  "outputs": [
612
645
  {
613
646
  "internalType": "uint256",
@@ -620,7 +653,7 @@
620
653
  },
621
654
  {
622
655
  "inputs": [],
623
- "name": "MAX_ROLES",
656
+ "name": "MAX_FUNCTIONS",
624
657
  "outputs": [
625
658
  {
626
659
  "internalType": "uint256",
@@ -633,12 +666,12 @@
633
666
  },
634
667
  {
635
668
  "inputs": [],
636
- "name": "NATIVE_TRANSFER_OPERATION",
669
+ "name": "MAX_HOOKS_PER_SELECTOR",
637
670
  "outputs": [
638
671
  {
639
- "internalType": "bytes32",
672
+ "internalType": "uint256",
640
673
  "name": "",
641
- "type": "bytes32"
674
+ "type": "uint256"
642
675
  }
643
676
  ],
644
677
  "stateMutability": "view",
@@ -646,25 +679,12 @@
646
679
  },
647
680
  {
648
681
  "inputs": [],
649
- "name": "NATIVE_TRANSFER_SELECTOR",
682
+ "name": "MAX_RESULT_PREVIEW_BYTES",
650
683
  "outputs": [
651
684
  {
652
- "internalType": "bytes4",
653
- "name": "",
654
- "type": "bytes4"
655
- }
656
- ],
657
- "stateMutability": "view",
658
- "type": "function"
659
- },
660
- {
661
- "inputs": [],
662
- "name": "PROTOCOL_NAME_HASH",
663
- "outputs": [
664
- {
665
- "internalType": "bytes32",
685
+ "internalType": "uint256",
666
686
  "name": "",
667
- "type": "bytes32"
687
+ "type": "uint256"
668
688
  }
669
689
  ],
670
690
  "stateMutability": "view",
@@ -672,12 +692,12 @@
672
692
  },
673
693
  {
674
694
  "inputs": [],
675
- "name": "UPDATE_PAYMENT_OPERATION",
695
+ "name": "MAX_ROLES",
676
696
  "outputs": [
677
697
  {
678
- "internalType": "bytes32",
698
+ "internalType": "uint256",
679
699
  "name": "",
680
- "type": "bytes32"
700
+ "type": "uint256"
681
701
  }
682
702
  ],
683
703
  "stateMutability": "view",
@@ -685,7 +705,7 @@
685
705
  },
686
706
  {
687
707
  "inputs": [],
688
- "name": "UPDATE_PAYMENT_SELECTOR",
708
+ "name": "NATIVE_TRANSFER_SELECTOR",
689
709
  "outputs": [
690
710
  {
691
711
  "internalType": "bytes4",
@@ -698,25 +718,12 @@
698
718
  },
699
719
  {
700
720
  "inputs": [],
701
- "name": "VERSION_MAJOR",
702
- "outputs": [
703
- {
704
- "internalType": "uint8",
705
- "name": "",
706
- "type": "uint8"
707
- }
708
- ],
709
- "stateMutability": "view",
710
- "type": "function"
711
- },
712
- {
713
- "inputs": [],
714
- "name": "VERSION_MINOR",
721
+ "name": "PROTOCOL_NAME_HASH",
715
722
  "outputs": [
716
723
  {
717
- "internalType": "uint8",
724
+ "internalType": "bytes32",
718
725
  "name": "",
719
- "type": "uint8"
726
+ "type": "bytes32"
720
727
  }
721
728
  ],
722
729
  "stateMutability": "view",
@@ -724,12 +731,12 @@
724
731
  },
725
732
  {
726
733
  "inputs": [],
727
- "name": "VERSION_PATCH",
734
+ "name": "VERSION",
728
735
  "outputs": [
729
736
  {
730
- "internalType": "uint8",
737
+ "internalType": "string",
731
738
  "name": "",
732
- "type": "uint8"
739
+ "type": "string"
733
740
  }
734
741
  ],
735
742
  "stateMutability": "view",
@@ -844,29 +851,5 @@
844
851
  ],
845
852
  "stateMutability": "view",
846
853
  "type": "function"
847
- },
848
- {
849
- "inputs": [
850
- {
851
- "internalType": "address",
852
- "name": "contractAddress",
853
- "type": "address"
854
- },
855
- {
856
- "internalType": "bytes4",
857
- "name": "selector",
858
- "type": "bytes4"
859
- }
860
- ],
861
- "name": "selectorExistsInContract",
862
- "outputs": [
863
- {
864
- "internalType": "bool",
865
- "name": "",
866
- "type": "bool"
867
- }
868
- ],
869
- "stateMutability": "view",
870
- "type": "function"
871
854
  }
872
855
  ]