Commit 7cfc48a
committed
fix(sign-transaction): render hex signer keys instead of throwing
SDK 17's revokeSponsorship signer arm returns sha256Hash and preAuthTx as
already-hex strings (convertXdrSignerKeyToObject calls uint8ArrayToHex),
while setOptions returns real Uint8Arrays. formattedBuffer asserted bytes,
so reviewing a revokeSignerSponsorship op with a hash-based signer threw
`TypeError: Expected Uint8Array, got string` from a render body and put the
ErrorBoundary screen where the sign/reject decision belongs.
formattedBuffer now accepts Uint8Array | string, passing a string through
rather than re-encoding it -- encoding it again hexes the ASCII of the hex,
which is what the old Buffer.from(<hex string>) path did. That silent
corruption is the wrong-hex display reported in #2838, so this closes it
too: the row now reads DEAD…BEEF where it used to read 6465…6566.
The types were not the problem; the casts were. RevokeSignerOpts already
declares these fields as `Uint8Array | string` -- correctly -- and it was
`signer as unknown as Signer` at the call site that discarded the string,
because setOptions' Signer type declares bare Uint8Array. Both signer
components now derive their prop type from the operation unions:
type RevokeSignerKey = Operation.RevokeSignerSponsorship["signer"]
type SetOptionsSignerKey =
NonNullable<Extract<OperationRecord, { type: "setOptions" }>["signer"]>
so the compiler tracks reality and both `as unknown as Signer` casts are
gone. Verified that dropping the cast without this change is a typecheck
error, i.e. the compiler would have caught the original bug. The `in`
checks became discriminant truthiness checks, which is how the SDK's
`?: never` unions are meant to be narrowed.
The setOptions path is fixed alongside the reported one. It returns real
bytes today so it was never broken, but it carried the identical cast on
the adjacent line and would have hidden the same defect on the next SDK
shape change.
Tests cover formattedBuffer for both input shapes (it had none) and assert
the rendered hex for decoded revokeSignerSponsorship ops, driving the real
TransactionBuilder decode path rather than a hand-built signer object.1 parent 64607e2 commit 7cfc48a
5 files changed
Lines changed: 139 additions & 22 deletions
File tree
- extension/src/popup
- components
- __tests__
- signTransaction/Operations
- KeyVal
- helpers
- __tests__
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
4 | 13 | | |
5 | 14 | | |
6 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
7 | 19 | | |
8 | 20 | | |
9 | 21 | | |
| |||
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
310 | 377 | | |
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
152 | 161 | | |
153 | 162 | | |
154 | 163 | | |
155 | | - | |
| 164 | + | |
156 | 165 | | |
157 | 166 | | |
158 | 167 | | |
| |||
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
164 | | - | |
| 173 | + | |
165 | 174 | | |
166 | 175 | | |
167 | 176 | | |
| |||
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
173 | | - | |
| 182 | + | |
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| |||
179 | 188 | | |
180 | 189 | | |
181 | 190 | | |
182 | | - | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
| |||
345 | 354 | | |
346 | 355 | | |
347 | 356 | | |
348 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
349 | 369 | | |
350 | 370 | | |
351 | | - | |
| 371 | + | |
352 | 372 | | |
353 | 373 | | |
354 | 374 | | |
| |||
357 | 377 | | |
358 | 378 | | |
359 | 379 | | |
360 | | - | |
| 380 | + | |
361 | 381 | | |
362 | 382 | | |
363 | 383 | | |
| |||
366 | 386 | | |
367 | 387 | | |
368 | 388 | | |
369 | | - | |
| 389 | + | |
370 | 390 | | |
371 | 391 | | |
372 | 392 | | |
| |||
375 | 395 | | |
376 | 396 | | |
377 | 397 | | |
378 | | - | |
| 398 | + | |
379 | 399 | | |
380 | 400 | | |
381 | 401 | | |
| |||
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
| 420 | + | |
425 | 421 | | |
426 | 422 | | |
427 | 423 | | |
| |||
819 | 815 | | |
820 | 816 | | |
821 | 817 | | |
822 | | - | |
| 818 | + | |
823 | 819 | | |
824 | 820 | | |
825 | 821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| |||
0 commit comments