Skip to content

[PLA-1839] fix token owners#206

Merged
zlayine merged 2 commits intomasterfrom
bugfix/PLA-1839/token-owners-fix
Mar 4, 2026
Merged

[PLA-1839] fix token owners#206
zlayine merged 2 commits intomasterfrom
bugfix/PLA-1839/token-owners-fix

Conversation

@zlayine
Copy link
Copy Markdown
Contributor

@zlayine zlayine commented Mar 2, 2026

No description provided.

@zlayine zlayine requested a review from pawell67 March 2, 2026 11:44
@zlayine zlayine self-assigned this Mar 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Data Mismatch

recipient is initialized with publicKeyToAddress(props.item?.owners?.[0] ?? ''), but other parts of this PR (e.g., DTOTokenFactory) appear to already convert owners into addresses. Double-conversion (address passed into publicKeyToAddress) can yield an invalid recipient. Verify whether owners contains public keys or already-normalized addresses across all call sites and keep the representation consistent.

const isLoading = ref(false);
const collectionId = ref(props.item?.collectionId);
const recipient = ref(publicKeyToAddress(props.item?.owners?.[0] ?? ''));
const amount = ref();
Possible Runtime Error

owners is built via token.accounts.edges.map(...) without guarding for missing/undefined accounts or edges. If the API can return accounts as null/empty (or edges omitted), this will throw at runtime. Consider defaulting to an empty array or using optional chaining with a fallback.

owners: token.accounts.edges.map((edge: any) =>
    publicKeyToAddress(edge.node.wallet.account.publicKey)
),
Display/Sort Edge Cases

Supply rendering uses loose equality and doesn’t handle undefined supply cleanly (token.supply == '-1' ? '0' : token.supply), which can render undefined. Also, sorting by owner now uses the first element of owners; confirm that sorting behavior is intentional when multiple owners exist and that sortTable/column keys align with the updated UI.

    class="px-3 py-4 text-sm text-light-content dark:text-dark-content max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap truncate"
>
    <div class="flex flex-row gap-1 truncate">
        <span v-for="owner in token.owners" :key="owner">
            {{ addressShortHex(owner) }}
        </span>
    </div>
</td>
<td
    class="whitespace-nowrap px-3 py-4 text-sm text-light-content dark:text-dark-content"
>
    {{ token.attributeCount }}
</td>
<td
    class="whitespace-nowrap px-3 py-4 text-sm text-light-content dark:text-dark-content"
>
    {{ token.supply == '-1' ? '0' : token.supply }}
</td>

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent crash on missing edges

token.accounts/token.accounts.edges being null/undefined will cause a runtime crash
on .map(). Default to an empty array (and optionally filter falsy values) to keep
token building resilient to partial API responses.

resources/js/factory/token.ts [12-14]

-owners: token.accounts.edges.map((edge: any) =>
-    publicKeyToAddress(edge.node.wallet.account.publicKey)
-),
+owners: (token.accounts?.edges ?? [])
+    .map((edge: any) => publicKeyToAddress(edge.node.wallet.account.publicKey))
+    .filter(Boolean),
Suggestion importance[1-10]: 7

__

Why: token.accounts.edges.map(...) will throw if token.accounts or edges is null/undefined, so defaulting to [] improves runtime resilience to partial API responses. The change is localized to DTOTokenFactory.buildToken and preserves behavior when data is present.

Medium
Guard address conversion on empty input

Avoid calling publicKeyToAddress with an empty string when no owners are present, as
that can throw or produce an invalid address. Initialize recipient conditionally so
it stays empty until a valid public key exists.

resources/js/components/slideovers/token/MintTokenSlideover.vue [123]

-const recipient = ref(publicKeyToAddress(props.item?.owners?.[0] ?? ''));
+const firstOwnerPublicKey = props.item?.owners?.[0];
+const recipient = ref(firstOwnerPublicKey ? publicKeyToAddress(firstOwnerPublicKey) : '');
Suggestion importance[1-10]: 6

__

Why: Calling publicKeyToAddress with '' (when props.item?.owners?.[0] is missing) can produce an invalid value or throw depending on implementation. The proposed conditional initialization keeps recipient safely empty until a real public key is available.

Low
Normalize and strictly compare supply

Using loose equality and mixing string/number semantics for supply can lead to
incorrect display and sorting. Normalize supply to a number and use strict
comparison so -1 is handled consistently across UI and sorting.

resources/js/components/pages/Tokens.vue [171]

-{{ token.supply == '-1' ? '0' : token.supply }}
+{{ Number(token.supply ?? -1) === -1 ? 0 : Number(token.supply) }}
Suggestion importance[1-10]: 5

__

Why: Replacing loose equality on token.supply with numeric normalization and strict comparison avoids edge cases from string/number mixing (especially with the sentinel -1). This is a minor correctness/readability improvement since sorting already parses supply numerically elsewhere.

Low

@zlayine zlayine merged commit 45c4fae into master Mar 4, 2026
4 checks passed
@zlayine zlayine deleted the bugfix/PLA-1839/token-owners-fix branch March 4, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants