plotlink-ows 1.0.15 → 1.0.16
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.
- package/app/routes/settings.ts +14 -9
- package/package.json +1 -1
package/app/routes/settings.ts
CHANGED
|
@@ -194,16 +194,21 @@ settings.get("/link-status", async (c) => {
|
|
|
194
194
|
}) as bigint;
|
|
195
195
|
|
|
196
196
|
if (balance > 0n) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
197
|
+
// Try to get token ID (ERC-721 Enumerable — may not be supported)
|
|
198
|
+
let agentId: number | undefined;
|
|
199
|
+
try {
|
|
200
|
+
const tokenId = await publicClient.readContract({
|
|
201
|
+
address: ERC_8004,
|
|
202
|
+
abi: [{ type: "function", name: "tokenOfOwnerByIndex", stateMutability: "view", inputs: [{ name: "owner", type: "address" }, { name: "index", type: "uint256" }], outputs: [{ name: "", type: "uint256" }] }] as const,
|
|
203
|
+
functionName: "tokenOfOwnerByIndex",
|
|
204
|
+
args: [address as `0x${string}`, 0n],
|
|
205
|
+
}) as bigint;
|
|
206
|
+
agentId = Number(tokenId);
|
|
207
|
+
} catch { /* ERC-721 Enumerable not supported — agent ID unknown */ }
|
|
208
|
+
|
|
209
|
+
return c.json({ linked: true, agentId, owsWallet: address });
|
|
205
210
|
}
|
|
206
|
-
} catch { /*
|
|
211
|
+
} catch { /* balanceOf failed */ }
|
|
207
212
|
|
|
208
213
|
return c.json({ linked: false, owsWallet: address });
|
|
209
214
|
} catch (err: unknown) {
|