@hoodag/sdk 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/hood.js +14 -2
  2. package/package.json +5 -2
package/hood.js CHANGED
@@ -6,7 +6,17 @@
6
6
  * 2) viem helpers (if you already use viem) — at the bottom
7
7
  *
8
8
  * All calls hit ONE contract (the HoodUniversalResolver), so integration is a single read.
9
+ * Inputs are normalized with ENSIP-15 (the exact standard ENS uses) so names resolve identically
10
+ * everywhere and confusable/invalid names are rejected.
9
11
  */
12
+ import { ens_normalize } from '@adraffy/ens-normalize';
13
+
14
+ // Canonicalize a full .hood name (case-fold, emoji allowlist, confusables rejected). Throws if invalid.
15
+ const norm = (name) => {
16
+ let s = String(name).trim();
17
+ if (!/\.hood$/i.test(s)) s += '.hood';
18
+ return ens_normalize(s);
19
+ };
10
20
 
11
21
  export const HOOD = {
12
22
  chainId: 4663,
@@ -54,7 +64,8 @@ async function ethCall(to, data, rpcUrl = HOOD.rpcUrl) {
54
64
 
55
65
  /** resolveHood("robin.hood") -> "0x..." (or null if unset) */
56
66
  export async function resolveHood(name, rpcUrl = HOOD.rpcUrl) {
57
- const { len, padded } = encStringArg(name);
67
+ let fq; try { fq = norm(name); } catch { return null; } // invalid/confusable name → unresolvable
68
+ const { len, padded } = encStringArg(fq);
58
69
  const data = keccakSelector('resolve(string)') +
59
70
  '0000000000000000000000000000000000000000000000000000000000000020' + len + padded;
60
71
  const out = await ethCall(HOOD.contracts.universalResolver, data, rpcUrl);
@@ -77,7 +88,8 @@ export async function reverseHood(address, rpcUrl = HOOD.rpcUrl) {
77
88
 
78
89
  /** resolveTextHood("robin.hood", "com.twitter") -> "..." */
79
90
  export async function resolveTextHood(name, key, rpcUrl = HOOD.rpcUrl) {
80
- const n = encStringArg(name), k = encStringArg(key);
91
+ let fq; try { fq = norm(name); } catch { return null; } // invalid/confusable name → unresolvable
92
+ const n = encStringArg(fq), k = encStringArg(key);
81
93
  // two dynamic args: head = [off1=0x40, off2], then arg1, then arg2
82
94
  const head = '0000000000000000000000000000000000000000000000000000000000000040';
83
95
  const arg1 = n.len + n.padded;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hoodag/sdk",
3
- "version": "0.1.0",
4
- "description": "Resolve .hood names on Robinhood Chain (ENS-standard) — one call, zero dependencies, optional viem helpers.",
3
+ "version": "0.1.1",
4
+ "description": "Resolve .hood names on Robinhood Chain (ENS-standard) — one call, ENSIP-15 name normalization, optional viem helpers.",
5
5
  "type": "module",
6
6
  "main": "./hood.js",
7
7
  "module": "./hood.js",
@@ -25,6 +25,9 @@
25
25
  ],
26
26
  "homepage": "https://hood.ag",
27
27
  "license": "MIT",
28
+ "dependencies": {
29
+ "@adraffy/ens-normalize": "^1.11.1"
30
+ },
28
31
  "publishConfig": {
29
32
  "access": "public"
30
33
  }