@5ive-tech/cli 1.0.18 → 1.0.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5ive-tech/cli",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "High-performance CLI for Five VM development with WebAssembly integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@5ive-tech/sdk": "^1.1.5",
71
+ "@5ive-tech/sdk": "^1.1.7",
72
72
  "@iarna/toml": "^2.2.5",
73
73
  "@solana/web3.js": "^1.90.0",
74
74
  "bs58": "^5.0.0",
@@ -98,4 +98,4 @@
98
98
  "ts-jest": "^29.1.2",
99
99
  "typescript": "^5.9.2"
100
100
  }
101
- }
101
+ }
@@ -42,6 +42,7 @@ These rules are non-negotiable and prevent the most common compilation failures:
42
42
  5. **`pubkey(0)` and `0` are valid** for zero-initializing pubkey fields (disabling authorities).
43
43
  6. **`string<N>` is production-safe** — use freely in accounts and function parameters.
44
44
  7. **All comparison operators work in `require()`** — `==`, `!=`, `<`, `<=`, `>`, `>=`, `!`.
45
+ 8. **Local variables are immutable by default** — use `let x = value;` for immutable bindings. **Use `let mut x = value;` if the variable will be reassigned** (e.g., in conditional branches). Attempting to reassign an immutable local causes a compiler error.
45
46
 
46
47
  ## 4) DSL Feature Inventory (Deep)
47
48
 
@@ -145,6 +146,9 @@ Observed and parser-supported:
145
146
  1. `let` declarations (with `mut` and optional type annotation)
146
147
  - Type inference works: `let is_owner = source.owner == authority.key;` infers `bool`
147
148
  - Use `let` without explicit annotation for boolean and scalar expressions
149
+ - **Immutability by default**: `let x = value;` creates an immutable binding; reassignment will fail
150
+ - **For reassignable variables, use `let mut`**: `let mut x: u64 = 0; ... x = new_value;`
151
+ - Example: `let mut shares: u64 = 0; if (condition) { shares = computed_value; }`
148
152
  2. Assignment:
149
153
  - direct: `x = y`
150
154
  - compound: `+=`, `-=`, `*=`, `/=`, `<<=`, `>>=`, `&=`, `|=`, `^=`
@@ -708,10 +712,10 @@ pub perform_action(
708
712
  ) {
709
713
  require(local_state.authority == user.key);
710
714
  require(amount > 0);
711
-
715
+
712
716
  // CPI to external program
713
717
  ExternalProgram.process(external_account, user, amount);
714
-
718
+
715
719
  // Update local state after CPI
716
720
  local_state.last_amount = amount;
717
721
  local_state.call_count = local_state.call_count + 1;
@@ -820,7 +824,9 @@ Follow this procedure to produce correct 5IVE contracts on first compilation, re
820
824
  | Zero-amount guard | `require(amount > 0);` |
821
825
  | Revoke authority | `state.authority = 0;` |
822
826
  | Status transition | `state.status = 1;` |
823
- | Local variable | `let x = expr;` |
827
+ | Local variable (immutable) | `let x = expr;` |
828
+ | Local variable (mutable) | `let mut x = expr;` (required for reassignment) |
829
+ | Reassign local variable | `let mut x: u64 = 0; ... x = new_value;` |
824
830
  | Return value | `pub fn(...) -> u64 { return state.value; }` |
825
831
  | Fixed string field | `name: string<32>;` |
826
832
  | Zero-init pubkey | `state.delegate = 0;` or `state.delegate = pubkey(0);` |
@@ -1064,10 +1070,10 @@ pub call_external(
1064
1070
  ) {
1065
1071
  require(controller.authority == authority.key);
1066
1072
  require(value > 0);
1067
-
1073
+
1068
1074
  // CPI to external program
1069
1075
  ExternalProgram.update_value(external_state, authority, value);
1070
-
1076
+
1071
1077
  // Update local state
1072
1078
  controller.counter = controller.counter + 1;
1073
1079
  controller.last_value = value;
@@ -1080,10 +1086,10 @@ pub call_anchor(
1080
1086
  amount: u64
1081
1087
  ) {
1082
1088
  require(controller.authority == user.key);
1083
-
1089
+
1084
1090
  // CPI to Anchor program
1085
1091
  AnchorProgram.process(anchor_config, user, amount);
1086
-
1092
+
1087
1093
  controller.counter = controller.counter + 1;
1088
1094
  }
1089
1095
  ```