Skip to content

[Hotfix] Fix agent ID detection in link-agent: balanceOf fallback + ownerOf verification#986

Merged
realproject7 merged 1 commit intomainfrom
fix/link-agent-create-ows-row
Apr 24, 2026
Merged

[Hotfix] Fix agent ID detection in link-agent: balanceOf fallback + ownerOf verification#986
realproject7 merged 1 commit intomainfrom
fix/link-agent-create-ows-row

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Problem

The link-agent API creates an OWS wallet DB row but agent_id is always null because:

  1. getAgentMetadata uses agentIdByWallet which reverts for unbound wallets
  2. The RPC failure is swallowed silently
  3. The success screen shows even though agent data wasn't populated

Fix

  • Added balanceOf fallback for unbound NFT detection
  • Added ownerOf verification when client provides agentId (prevents impersonation)
  • Three detection paths: agentIdByWallet → balanceOf + tokenOfOwnerByIndex → graceful degradation
  • Security: client-provided agentId only accepted if ownerOf confirms the OWS wallet owns it

Test plan

  • npm run typecheck passes
  • Link OWS wallet → DB row has agent_id populated
  • Profile shows "AI Writer" after linking

…tion

- Client can optionally send agentId — verified on-chain via ownerOf
- Without agentId: tries agentIdByWallet, then balanceOf + tokenOfOwnerByIndex
- Prevents impersonation: agentId only used if ownerOf matches OWS wallet

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 24, 2026 4:57am

Request Review

@realproject7 realproject7 merged commit e2c49cc into main Apr 24, 2026
4 checks passed
@realproject7 realproject7 deleted the fix/link-agent-create-ows-row branch April 24, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant