@totems/evm 1.0.8 → 1.0.11
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 +66 -0
- package/artifacts/IMarket.json +1011 -0
- package/artifacts/ITotems.json +1477 -0
- package/artifacts/ModMarket.json +1060 -0
- package/artifacts/ProxyMod.json +334 -0
- package/artifacts/Totems.json +1503 -0
- package/bin/validate.js +143 -0
- package/mods/TotemsLibrary.sol +18 -0
- package/package.json +12 -2
- package/test/helpers.d.ts +28 -2
- package/test/helpers.ts +102 -21
- package/validator/index.js +534 -0
package/README.md
CHANGED
|
@@ -25,4 +25,70 @@ forge install nsjames/totems-evm
|
|
|
25
25
|
contracts/ - Core contracts (Totems, ModMarket, etc.)
|
|
26
26
|
constants/ - Network addresses
|
|
27
27
|
test/ - Test helpers (TypeScript)
|
|
28
|
+
validator/ - Mod validation tool
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Mod Validator
|
|
32
|
+
|
|
33
|
+
Validates that mod contracts follow the setup pattern correctly.
|
|
34
|
+
|
|
35
|
+
### CLI Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Validate a single contract
|
|
39
|
+
npx @totems/evm validate ./contracts/MyMod.sol
|
|
40
|
+
|
|
41
|
+
# Validate all contracts in a directory
|
|
42
|
+
npx @totems/evm validate ./contracts/
|
|
43
|
+
|
|
44
|
+
# Strict mode - treat warnings as errors (for CI)
|
|
45
|
+
npx @totems/evm validate ./contracts/ --strict
|
|
46
|
+
|
|
47
|
+
# Output as JSON
|
|
48
|
+
npx @totems/evm validate ./contracts/ --json
|
|
49
|
+
|
|
50
|
+
# Generate required actions for market publish
|
|
51
|
+
npx @totems/evm validate ./contracts/MyMod.sol --actions
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### What It Checks
|
|
55
|
+
|
|
56
|
+
1. **`isSetupFor` Analysis** - Does your mod need setup? If `isSetupFor` depends on state variables, setup is required.
|
|
57
|
+
|
|
58
|
+
2. **Setup Functions** - Finds functions that modify state used by `isSetupFor`.
|
|
59
|
+
|
|
60
|
+
3. **Validator Functions** - Each setup function should have a corresponding validator:
|
|
61
|
+
- `setAcceptedToken()` → `canSetAcceptedToken()`
|
|
62
|
+
- `configure()` → `canConfigure()`
|
|
63
|
+
- `setup()` → `canSetup()`
|
|
64
|
+
|
|
65
|
+
4. **Access Control** - Setup functions should have access control (e.g., `onlyCreator`).
|
|
66
|
+
|
|
67
|
+
### Example Output
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
────────────────────────────────────────────────────────────
|
|
71
|
+
Contract: MinerMod
|
|
72
|
+
File: ./contracts/Miner.sol
|
|
73
|
+
|
|
74
|
+
isSetupFor: Depends on state
|
|
75
|
+
└─ Variables: totemsPerMine
|
|
76
|
+
|
|
77
|
+
Setup Functions:
|
|
78
|
+
┌─────────────────────────┬─────────────────────────┬─────────────┐
|
|
79
|
+
│ Function │ Validator │ Access │
|
|
80
|
+
├─────────────────────────┼─────────────────────────┼─────────────┤
|
|
81
|
+
│ setup │ canSetup() ✓ │ onlyCreator │
|
|
82
|
+
└─────────────────────────┴─────────────────────────┴─────────────┘
|
|
83
|
+
|
|
84
|
+
Result: PASS ✓
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Programmatic Usage
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { validateContract, formatResults } from '@totems/evm/validator';
|
|
91
|
+
|
|
92
|
+
const results = validateContract('./contracts/MyMod.sol');
|
|
93
|
+
console.log(formatResults(results));
|
|
28
94
|
```
|