plotlink-ows 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -182,7 +182,28 @@ settings.get("/link-status", async (c) => {
182
182
  } catch { /* best effort */ }
183
183
  return c.json({ linked: true, agentId: Number(agentId), owsWallet: address, owner });
184
184
  }
185
- } catch { /* contract call may fail */ }
185
+ } catch { /* agentIdByWallet may revert if not bound */ }
186
+
187
+ // Fallback: check if wallet owns an agent NFT (register() creates NFT but doesn't bind via setAgentWallet)
188
+ try {
189
+ const balance = await publicClient.readContract({
190
+ address: ERC_8004,
191
+ abi: [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "owner", type: "address" }], outputs: [{ name: "", type: "uint256" }] }] as const,
192
+ functionName: "balanceOf",
193
+ args: [address as `0x${string}`],
194
+ }) as bigint;
195
+
196
+ if (balance > 0n) {
197
+ const tokenId = await publicClient.readContract({
198
+ address: ERC_8004,
199
+ abi: [{ type: "function", name: "tokenOfOwnerByIndex", stateMutability: "view", inputs: [{ name: "owner", type: "address" }, { name: "index", type: "uint256" }], outputs: [{ name: "", type: "uint256" }] }] as const,
200
+ functionName: "tokenOfOwnerByIndex",
201
+ args: [address as `0x${string}`, 0n],
202
+ }) as bigint;
203
+
204
+ return c.json({ linked: true, agentId: Number(tokenId), owsWallet: address });
205
+ }
206
+ } catch { /* best effort */ }
186
207
 
187
208
  return c.json({ linked: false, owsWallet: address });
188
209
  } catch (err: unknown) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotlink-ows",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "bin": {
5
5
  "plotlink-ows": "./bin/plotlink-ows.js"
6
6
  },