hooddomains 0.1.0

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.
@@ -0,0 +1,184 @@
1
+ import * as viem from 'viem';
2
+ import { PublicClient, WalletClient, Hex, Address } from 'viem';
3
+
4
+ declare const CHAIN_ID = 4663;
5
+ /** Robinhood Chain (Arbitrum Orbit L2). RPC is supplied by the caller. */
6
+ declare const robinhoodChain: {
7
+ blockExplorers?: {
8
+ [key: string]: {
9
+ name: string;
10
+ url: string;
11
+ apiUrl?: string | undefined;
12
+ };
13
+ default: {
14
+ name: string;
15
+ url: string;
16
+ apiUrl?: string | undefined;
17
+ };
18
+ } | undefined | undefined;
19
+ blockTime?: number | undefined | undefined;
20
+ contracts?: {
21
+ [x: string]: viem.ChainContract | {
22
+ [sourceId: number]: viem.ChainContract | undefined;
23
+ } | undefined;
24
+ ensRegistry?: viem.ChainContract | undefined;
25
+ ensUniversalResolver?: viem.ChainContract | undefined;
26
+ multicall3?: viem.ChainContract | undefined;
27
+ erc6492Verifier?: viem.ChainContract | undefined;
28
+ } | undefined;
29
+ ensTlds?: readonly string[] | undefined;
30
+ id: 4663;
31
+ name: "Robinhood Chain";
32
+ nativeCurrency: {
33
+ readonly name: "Ether";
34
+ readonly symbol: "ETH";
35
+ readonly decimals: 18;
36
+ };
37
+ experimental_preconfirmationTime?: number | undefined | undefined;
38
+ rpcUrls: {
39
+ readonly default: {
40
+ readonly http: readonly [];
41
+ };
42
+ };
43
+ sourceId?: number | undefined | undefined;
44
+ testnet?: boolean | undefined | undefined;
45
+ custom?: Record<string, unknown> | undefined;
46
+ extendSchema?: Record<string, unknown> | undefined;
47
+ fees?: viem.ChainFees<undefined> | undefined;
48
+ formatters?: undefined;
49
+ prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
50
+ client: viem.Client;
51
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
52
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
53
+ client: viem.Client;
54
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
55
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
56
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
57
+ }] | undefined;
58
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
59
+ verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
60
+ };
61
+ interface HoodContracts {
62
+ registry: `0x${string}`;
63
+ registrar: `0x${string}`;
64
+ oracle: `0x${string}`;
65
+ reverseRegistrar: `0x${string}`;
66
+ resolverImpl: `0x${string}`;
67
+ verifiableFactory: `0x${string}`;
68
+ }
69
+ /** Live Hood Domains deployment on Robinhood Chain (hood-robinhood-v2). */
70
+ declare const DEFAULT_CONTRACTS: HoodContracts;
71
+ /** Roles granted to a per-owner resolver at deploy: ADDR + TEXT (regular + admin). */
72
+ declare const RESOLVER_RECORD_ROLES: bigint;
73
+ /** Block the registry was deployed at — lower bound for TextChanged log scans. */
74
+ declare const REGISTRY_DEPLOY_BLOCK = 5785243n;
75
+ declare const SECONDS_PER_YEAR = 31536000n;
76
+ /** Common text-record keys probed in addition to keys discovered from events. */
77
+ declare const TEXT_KEYS: string[];
78
+
79
+ /**
80
+ * Hood Domains SDK — resolve, look up, and register `.hood` names on Robinhood Chain.
81
+ * Everything is on-chain; this is a thin wrapper over viem. No backend, no API keys.
82
+ *
83
+ * Website: https://www.hood.domains
84
+ * App: https://app.hood.domains
85
+ * Docs: https://app.hood.domains/docs
86
+ * X: https://x.com/hooddomains (@hooddomains)
87
+ */
88
+
89
+ interface HoodOptions {
90
+ /** RPC URL for Robinhood Chain (chainId 4663). Ignored if `publicClient` is given. */
91
+ rpcUrl?: string;
92
+ /** Bring your own read client. */
93
+ publicClient?: PublicClient;
94
+ /** Bring your own signer (with account + chain configured) for writes. */
95
+ walletClient?: WalletClient;
96
+ /** Or a private key to sign writes. */
97
+ privateKey?: Hex | string;
98
+ /** Override contract addresses. */
99
+ contracts?: Partial<HoodContracts>;
100
+ /** Lower bound for TextChanged log scans (defaults to the registry deploy block). */
101
+ deployBlock?: bigint;
102
+ }
103
+ interface NameRecords {
104
+ /** The wallet the name resolves to (its addr record), or null. */
105
+ address: Address | null;
106
+ /** Text records: key -> value (only non-empty). */
107
+ records: Record<string, string>;
108
+ /** The name's resolver, or null if none set. */
109
+ resolver: Address | null;
110
+ }
111
+ interface NameInfo {
112
+ name: string;
113
+ registered: boolean;
114
+ owner: Address | null;
115
+ expiry: Date | null;
116
+ resolver: Address | null;
117
+ tokenId: string;
118
+ }
119
+ interface RegisterResult {
120
+ name: string;
121
+ owner: Address;
122
+ years: number;
123
+ paid: {
124
+ wei: bigint;
125
+ eth: string;
126
+ };
127
+ tokenId: string;
128
+ commitTx: Hex;
129
+ registerTx: Hex;
130
+ }
131
+ /**
132
+ * Client for Hood Domains (.hood names on Robinhood Chain). Read methods need only an RPC;
133
+ * write methods need a signer (pass `privateKey` or `walletClient`).
134
+ *
135
+ * @example
136
+ * const hood = new Hood({ rpcUrl });
137
+ * await hood.resolve("alice.hood"); // -> 0x… | null
138
+ * await hood.reverse("0x…"); // -> "alice.hood" | null
139
+ */
140
+ declare class Hood {
141
+ readonly publicClient: PublicClient;
142
+ readonly walletClient?: WalletClient;
143
+ readonly contracts: HoodContracts;
144
+ readonly deployBlock: bigint;
145
+ private readonly acct?;
146
+ constructor(opts?: HoodOptions);
147
+ private signer;
148
+ private accountAddress;
149
+ private node;
150
+ private labelId;
151
+ private resolverOf;
152
+ /** Resolve a name to the wallet it points at (forward resolution). */
153
+ resolve(name: string): Promise<Address | null>;
154
+ /** Get the primary (reverse) name of a wallet. */
155
+ reverse(address: Address): Promise<string | null>;
156
+ /** Read a single text record. */
157
+ text(name: string, key: string): Promise<string | null>;
158
+ /** Read a name's address + all text records (custom keys discovered via TextChanged events). */
159
+ records(name: string): Promise<NameRecords>;
160
+ /** Whether a label is available to register. */
161
+ available(label: string): Promise<boolean>;
162
+ /** Registration price for a label over `years`. */
163
+ price(label: string, years?: number): Promise<{
164
+ wei: bigint;
165
+ eth: string;
166
+ }>;
167
+ /** Owner, expiry, resolver, and tokenId of a name. */
168
+ nameInfo(name: string): Promise<NameInfo>;
169
+ /** Register a name via commit → wait (~60s) → register. Paid in native ETH. */
170
+ register(label: string, opts?: {
171
+ years?: number;
172
+ owner?: Address;
173
+ }): Promise<RegisterResult>;
174
+ /** Set the caller's primary (reverse) name. */
175
+ setPrimary(name: string): Promise<Hex>;
176
+ /** Set the address record (deploys a per-owner resolver on first use). */
177
+ setAddr(name: string, address: Address): Promise<Hex>;
178
+ /** Set a text record (deploys a per-owner resolver on first use). */
179
+ setText(name: string, key: string, value: string): Promise<Hex>;
180
+ /** Return the name's resolver, deploying + linking a per-owner one (addr+text roles) if needed. */
181
+ ensureResolver(name: string): Promise<Address>;
182
+ }
183
+
184
+ export { CHAIN_ID, DEFAULT_CONTRACTS, Hood, type HoodContracts, type HoodOptions, type NameInfo, type NameRecords, REGISTRY_DEPLOY_BLOCK, RESOLVER_RECORD_ROLES, type RegisterResult, SECONDS_PER_YEAR, TEXT_KEYS, robinhoodChain };
@@ -0,0 +1,184 @@
1
+ import * as viem from 'viem';
2
+ import { PublicClient, WalletClient, Hex, Address } from 'viem';
3
+
4
+ declare const CHAIN_ID = 4663;
5
+ /** Robinhood Chain (Arbitrum Orbit L2). RPC is supplied by the caller. */
6
+ declare const robinhoodChain: {
7
+ blockExplorers?: {
8
+ [key: string]: {
9
+ name: string;
10
+ url: string;
11
+ apiUrl?: string | undefined;
12
+ };
13
+ default: {
14
+ name: string;
15
+ url: string;
16
+ apiUrl?: string | undefined;
17
+ };
18
+ } | undefined | undefined;
19
+ blockTime?: number | undefined | undefined;
20
+ contracts?: {
21
+ [x: string]: viem.ChainContract | {
22
+ [sourceId: number]: viem.ChainContract | undefined;
23
+ } | undefined;
24
+ ensRegistry?: viem.ChainContract | undefined;
25
+ ensUniversalResolver?: viem.ChainContract | undefined;
26
+ multicall3?: viem.ChainContract | undefined;
27
+ erc6492Verifier?: viem.ChainContract | undefined;
28
+ } | undefined;
29
+ ensTlds?: readonly string[] | undefined;
30
+ id: 4663;
31
+ name: "Robinhood Chain";
32
+ nativeCurrency: {
33
+ readonly name: "Ether";
34
+ readonly symbol: "ETH";
35
+ readonly decimals: 18;
36
+ };
37
+ experimental_preconfirmationTime?: number | undefined | undefined;
38
+ rpcUrls: {
39
+ readonly default: {
40
+ readonly http: readonly [];
41
+ };
42
+ };
43
+ sourceId?: number | undefined | undefined;
44
+ testnet?: boolean | undefined | undefined;
45
+ custom?: Record<string, unknown> | undefined;
46
+ extendSchema?: Record<string, unknown> | undefined;
47
+ fees?: viem.ChainFees<undefined> | undefined;
48
+ formatters?: undefined;
49
+ prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
50
+ client: viem.Client;
51
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
52
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
53
+ client: viem.Client;
54
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
55
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
56
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
57
+ }] | undefined;
58
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
59
+ verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
60
+ };
61
+ interface HoodContracts {
62
+ registry: `0x${string}`;
63
+ registrar: `0x${string}`;
64
+ oracle: `0x${string}`;
65
+ reverseRegistrar: `0x${string}`;
66
+ resolverImpl: `0x${string}`;
67
+ verifiableFactory: `0x${string}`;
68
+ }
69
+ /** Live Hood Domains deployment on Robinhood Chain (hood-robinhood-v2). */
70
+ declare const DEFAULT_CONTRACTS: HoodContracts;
71
+ /** Roles granted to a per-owner resolver at deploy: ADDR + TEXT (regular + admin). */
72
+ declare const RESOLVER_RECORD_ROLES: bigint;
73
+ /** Block the registry was deployed at — lower bound for TextChanged log scans. */
74
+ declare const REGISTRY_DEPLOY_BLOCK = 5785243n;
75
+ declare const SECONDS_PER_YEAR = 31536000n;
76
+ /** Common text-record keys probed in addition to keys discovered from events. */
77
+ declare const TEXT_KEYS: string[];
78
+
79
+ /**
80
+ * Hood Domains SDK — resolve, look up, and register `.hood` names on Robinhood Chain.
81
+ * Everything is on-chain; this is a thin wrapper over viem. No backend, no API keys.
82
+ *
83
+ * Website: https://www.hood.domains
84
+ * App: https://app.hood.domains
85
+ * Docs: https://app.hood.domains/docs
86
+ * X: https://x.com/hooddomains (@hooddomains)
87
+ */
88
+
89
+ interface HoodOptions {
90
+ /** RPC URL for Robinhood Chain (chainId 4663). Ignored if `publicClient` is given. */
91
+ rpcUrl?: string;
92
+ /** Bring your own read client. */
93
+ publicClient?: PublicClient;
94
+ /** Bring your own signer (with account + chain configured) for writes. */
95
+ walletClient?: WalletClient;
96
+ /** Or a private key to sign writes. */
97
+ privateKey?: Hex | string;
98
+ /** Override contract addresses. */
99
+ contracts?: Partial<HoodContracts>;
100
+ /** Lower bound for TextChanged log scans (defaults to the registry deploy block). */
101
+ deployBlock?: bigint;
102
+ }
103
+ interface NameRecords {
104
+ /** The wallet the name resolves to (its addr record), or null. */
105
+ address: Address | null;
106
+ /** Text records: key -> value (only non-empty). */
107
+ records: Record<string, string>;
108
+ /** The name's resolver, or null if none set. */
109
+ resolver: Address | null;
110
+ }
111
+ interface NameInfo {
112
+ name: string;
113
+ registered: boolean;
114
+ owner: Address | null;
115
+ expiry: Date | null;
116
+ resolver: Address | null;
117
+ tokenId: string;
118
+ }
119
+ interface RegisterResult {
120
+ name: string;
121
+ owner: Address;
122
+ years: number;
123
+ paid: {
124
+ wei: bigint;
125
+ eth: string;
126
+ };
127
+ tokenId: string;
128
+ commitTx: Hex;
129
+ registerTx: Hex;
130
+ }
131
+ /**
132
+ * Client for Hood Domains (.hood names on Robinhood Chain). Read methods need only an RPC;
133
+ * write methods need a signer (pass `privateKey` or `walletClient`).
134
+ *
135
+ * @example
136
+ * const hood = new Hood({ rpcUrl });
137
+ * await hood.resolve("alice.hood"); // -> 0x… | null
138
+ * await hood.reverse("0x…"); // -> "alice.hood" | null
139
+ */
140
+ declare class Hood {
141
+ readonly publicClient: PublicClient;
142
+ readonly walletClient?: WalletClient;
143
+ readonly contracts: HoodContracts;
144
+ readonly deployBlock: bigint;
145
+ private readonly acct?;
146
+ constructor(opts?: HoodOptions);
147
+ private signer;
148
+ private accountAddress;
149
+ private node;
150
+ private labelId;
151
+ private resolverOf;
152
+ /** Resolve a name to the wallet it points at (forward resolution). */
153
+ resolve(name: string): Promise<Address | null>;
154
+ /** Get the primary (reverse) name of a wallet. */
155
+ reverse(address: Address): Promise<string | null>;
156
+ /** Read a single text record. */
157
+ text(name: string, key: string): Promise<string | null>;
158
+ /** Read a name's address + all text records (custom keys discovered via TextChanged events). */
159
+ records(name: string): Promise<NameRecords>;
160
+ /** Whether a label is available to register. */
161
+ available(label: string): Promise<boolean>;
162
+ /** Registration price for a label over `years`. */
163
+ price(label: string, years?: number): Promise<{
164
+ wei: bigint;
165
+ eth: string;
166
+ }>;
167
+ /** Owner, expiry, resolver, and tokenId of a name. */
168
+ nameInfo(name: string): Promise<NameInfo>;
169
+ /** Register a name via commit → wait (~60s) → register. Paid in native ETH. */
170
+ register(label: string, opts?: {
171
+ years?: number;
172
+ owner?: Address;
173
+ }): Promise<RegisterResult>;
174
+ /** Set the caller's primary (reverse) name. */
175
+ setPrimary(name: string): Promise<Hex>;
176
+ /** Set the address record (deploys a per-owner resolver on first use). */
177
+ setAddr(name: string, address: Address): Promise<Hex>;
178
+ /** Set a text record (deploys a per-owner resolver on first use). */
179
+ setText(name: string, key: string, value: string): Promise<Hex>;
180
+ /** Return the name's resolver, deploying + linking a per-owner one (addr+text roles) if needed. */
181
+ ensureResolver(name: string): Promise<Address>;
182
+ }
183
+
184
+ export { CHAIN_ID, DEFAULT_CONTRACTS, Hood, type HoodContracts, type HoodOptions, type NameInfo, type NameRecords, REGISTRY_DEPLOY_BLOCK, RESOLVER_RECORD_ROLES, type RegisterResult, SECONDS_PER_YEAR, TEXT_KEYS, robinhoodChain };