Commit 059c83d
fix(signing): label contract args from the spec's parameter list (#1011)
* fix(signing): label contract args from the spec's parameter list
Argument names came from the JSON-Schema `required` array, which is not
the parameter list -- `Spec.jsonSchema()` omits `Option<T>` params from
it. A non-trailing optional shifted every later label onto the wrong
value, and an all-optional function emitted no `required` at all, so
indexing it threw and took down the signing view.
Names now come from `properties.args.properties`, the complete ordered
list. On an arity mismatch or integer-like keys the derivation returns
null and rows render unlabelled rather than mislabelled.
list. On an arity mismatch or integer-like keys the derivation returns
null and rows render unlabelled rather than mislabelled.
Also adds a note qualifying spec-derived names as the contract's own
claim, drops late spec responses so they can't label a different
invocation, and skips the lookup for auth entries entirely --
`require_auth_for_args` can substitute an arbitrary same-arity list, so
the length check doesn't protect them (stellar/freighter#2196).
* docs(soroban): correct the contract-spec docstring's parameter list
The `getContractSpecs` docstring still told the reader to take parameter
names from `properties.args.required` -- the exact mistake this branch
fixes -- and its two examples verified only because neither sample
function has an `Option<T>` parameter.
Prose and both examples now point at `properties.args.properties` and
say why `required` is not the parameter list.
* refactor(soroban): type the contract spec instead of casting into it
`getContractFnArgNames` took `Record<string, any>` and cast its way back
to the one declared leaf type, and `checkContractSupportsMuxed` carried a
second, inline copy of the same shape. Declaring the intermediate levels
lets the optional chain resolve on its own, so both casts go away and one
named type describes the response. Narrowing `getContractSpecs` to match
drops the last `any` in that region, and the eslint-disable with it.
Also corrects the `getContractSpecs` docstring, which still pointed at
`properties.args.required` -- the mistake this branch fixes. Its two
examples verified only because neither sample function has an `Option<T>`
parameter.
* fix(signing): drop the unreachable auth-entry spec note
The note was rendered under `showHeader && argNames?.length`, but every
call site that shows the heading is one where names are never resolved --
auth entries suppress the lookup, the rest pass no contract id -- and the
one site with names owns its heading and renders the note itself. The
branch could not fire, leaving its `authorizations.contractSpecNote` key
dead in `en` and `pt`.
Removes the branch, the `translationKey` prop that existed only to serve
it, and both locale entries.
* test(signing): pin the auth-entry spec-label suppression
Suppressing spec-derived labels on auth entries is the one behaviour this
branch changes rather than ports, and nothing asserted it -- dropping
`isAuthEntry` from either call site, or the guard from the hook, would
have regressed silently.
Covers both call sites: the spec mock resolves names that would label the
rows, and each test asserts it is never called and the rows stay bare.
Verified by mutation -- all three removals fail these tests.
* fix(signing): re-raise the spec lookup's loading flag on a refetch
The effect drops the resolved parameter names on every run, but the
loading flag was only ever lowered. A second run left
(isLoading: false, argNames: null), which reads as "the lookup finished
and produced nothing" -- unlabelled rows and no spec note, with no
spinner while the refetch was in flight. Raise the flag alongside the
clear so the two stay in step.
Not reachable from the signing screen today: every effect dep is fixed
for the screen's lifetime, and networkDetails is a module-level
constant, so this disarms the trap rather than fixing a live bug.
The clear itself stays unconditional -- a name resolved for one
invocation must never outlive it -- and the second test pins that, so
a failed refetch settles on unlabelled rows instead of stale names.
* Update contract spec note translation key
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* fix(signing): key the contract-spec lookup to its invocation
The lookup dropped its names inside a passive effect, so a changed
invocation committed one render carrying the previous one's argNames
with isLoading already false -- new values wearing old parameter names.
Store the result under the key it was fetched for and compare that key
during render, which closes the window and collapses two useStates into
one.
That window was unreachable only because SignTransactionOperationDetails
latched its operations into a ref, a workaround for
useSignTransactionDetails re-parsing the XDR every render. Memoize the
parse and drop the latch, so the sheet also follows a changed
transaction instead of pinning the first one.
Also move contractSpecNote to the operations namespace its only caller
reads, which was rendering the raw key to users.
* fix(signing): drop resolved arg names for an unresolved invocation
`isAuthEntry` gated the spec fetch but not the read of its result, and it
is not part of the invocation key. A hook instance that resolved names and
then flipped to an auth entry at the same contract, function and arity kept
returning them -- spec labels on args that need not be the function's
declared parameters. No call site can reach that today; every one passes a
constant. Gating the read on `shouldResolve` states the invariant instead of
relying on that.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent ea66f5a commit 059c83d
15 files changed
Lines changed: 1044 additions & 121 deletions
File tree
- __tests__
- components/screens
- SignTransactionDetails/components
- WalletKit
- helpers
- src
- components/screens
- SignTransactionDetails
- components
- hooks
- WalletKit
- helpers
- i18n/locales
- en
- pt
- services
Lines changed: 204 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
Lines changed: 166 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
529 | 536 | | |
530 | 537 | | |
531 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
0 commit comments