Commit 0a5315c
refactor: make ContractKey.code non-optional
BREAKING CHANGE: ContractKey now always contains a CodeHash.
Changes:
- Remove `ContractKey::from_id()` - created incomplete keys
- Remove `From<ContractInstanceId> for ContractKey` - lost code hash
- `code_hash()` now returns `&CodeHash` instead of `Option<&CodeHash>`
- `encoded_code_hash()` now returns `String` instead of `Option<String>`
- `TryFromFbs` now errors if code hash is missing in wire format
This eliminates a class of bugs where incomplete ContractKeys (missing
code hash) were passed to operations requiring complete keys, causing
runtime failures. Now the type system enforces completeness at compile
time.
Use `ContractInstanceId` for operations that only need the instance ID
(routing, client lookups), and `ContractKey` for operations that need
the full specification (storage, execution).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>1 parent 48e3d23 commit 0a5315c
File tree
2 files changed
+26
-48
lines changed- rust/src
- client_api
- contract_interface
2 files changed
+26
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
961 | | - | |
962 | | - | |
963 | | - | |
| 961 | + | |
964 | 962 | | |
965 | 963 | | |
966 | 964 | | |
| |||
1004 | 1002 | | |
1005 | 1003 | | |
1006 | 1004 | | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
| 1005 | + | |
1010 | 1006 | | |
1011 | 1007 | | |
1012 | 1008 | | |
| |||
1058 | 1054 | | |
1059 | 1055 | | |
1060 | 1056 | | |
1061 | | - | |
| 1057 | + | |
1062 | 1058 | | |
1063 | 1059 | | |
1064 | 1060 | | |
| |||
1075 | 1071 | | |
1076 | 1072 | | |
1077 | 1073 | | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
| 1074 | + | |
1082 | 1075 | | |
1083 | 1076 | | |
1084 | 1077 | | |
| |||
1164 | 1157 | | |
1165 | 1158 | | |
1166 | 1159 | | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
| 1160 | + | |
1170 | 1161 | | |
1171 | 1162 | | |
1172 | 1163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| |||
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
115 | | - | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
| |||
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
125 | | - | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | | - | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
144 | 140 | | |
145 | 141 | | |
146 | | - | |
147 | | - | |
148 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
149 | 145 | | |
150 | 146 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
158 | 152 | | |
159 | 153 | | |
160 | 154 | | |
| |||
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
180 | | - | |
| 174 | + | |
181 | 175 | | |
182 | 176 | | |
183 | 177 | | |
| |||
203 | 197 | | |
204 | 198 | | |
205 | 199 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | 200 | | |
215 | 201 | | |
216 | 202 | | |
| |||
238 | 224 | | |
239 | 225 | | |
240 | 226 | | |
241 | | - | |
| 227 | + | |
| 228 | + | |
242 | 229 | | |
243 | 230 | | |
244 | 231 | | |
| |||
0 commit comments