@hoodfi/sdk 0.0.0-stage → 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.
- package/README.md +103 -2
- package/dist/abi.d.ts +106 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +34 -0
- package/dist/abi.js.map +1 -0
- package/dist/client.d.ts +145 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +304 -0
- package/dist/client.js.map +1 -0
- package/dist/coins.d.ts +34 -0
- package/dist/coins.d.ts.map +1 -0
- package/dist/coins.js +53 -0
- package/dist/coins.js.map +1 -0
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +38 -0
- package/dist/constants.js.map +1 -0
- package/dist/contenthash.d.ts +96 -0
- package/dist/contenthash.d.ts.map +1 -0
- package/dist/contenthash.js +385 -0
- package/dist/contenthash.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/labels.d.ts +45 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +83 -0
- package/dist/labels.js.map +1 -0
- package/dist/xrp.d.ts +24 -0
- package/dist/xrp.d.ts.map +1 -0
- package/dist/xrp.js +43 -0
- package/dist/xrp.js.map +1 -0
- package/package.json +41 -4
- package/src/abi.ts +35 -0
- package/src/client.ts +481 -0
- package/src/coins.ts +76 -0
- package/src/constants.ts +41 -0
- package/src/contenthash.ts +408 -0
- package/src/index.ts +30 -0
- package/src/labels.ts +91 -0
- package/src/xrp.ts +44 -0
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hoodfi/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Resolve, reverse-look-up and register `*.hoodfi.eth` names on Robinhood Chain (chain id 4663).
|
|
4
|
+
|
|
5
|
+
HoodFi names are lifetime ENS subnames, minted as ERC-721s on Robinhood Chain. There are no renewals and there is no token. They also resolve on Ethereum through ENS (CCIP-Read), so any ENS-aware wallet already reads them. This SDK is for apps that want the details: one multicall per lookup, typed results, and errors that tell an outage apart from a "no".
|
|
6
|
+
|
|
7
|
+
Keyless: it reads public RPCs and builds unsigned transactions. You sign with your own wallet.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @hoodfi/sdk viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createHoodfiClient } from '@hoodfi/sdk'
|
|
17
|
+
|
|
18
|
+
const hoodfi = createHoodfiClient()
|
|
19
|
+
|
|
20
|
+
// Forward: everything a name holds
|
|
21
|
+
const profile = await hoodfi.resolve('gm') // or 'gm.hoodfi.eth'
|
|
22
|
+
profile?.owner
|
|
23
|
+
profile?.addresses.robinhood // also: ethereum, bitcoin, solana, xrp
|
|
24
|
+
profile?.records.avatar
|
|
25
|
+
|
|
26
|
+
// Paying a name: the record for THAT chain, or an error
|
|
27
|
+
const { address, warnings, caveat } = await hoodfi.getSendAddress('gm', 'robinhood')
|
|
28
|
+
|
|
29
|
+
// Reverse: which name to show for a wallet
|
|
30
|
+
const { primary, names } = await hoodfi.lookupAddress('0x…')
|
|
31
|
+
|
|
32
|
+
// Is it free, and what does it cost?
|
|
33
|
+
const check = await hoodfi.checkName('alice')
|
|
34
|
+
check.available, check.price.usdg // 3_000_000n = $3 (USDG, 6 decimals)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Registering
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { createWalletClient, custom } from 'viem'
|
|
41
|
+
import { createHoodfiClient, robinhoodChain } from '@hoodfi/sdk'
|
|
42
|
+
|
|
43
|
+
const hoodfi = createHoodfiClient()
|
|
44
|
+
const wallet = createWalletClient({ chain: robinhoodChain, transport: custom(window.ethereum) })
|
|
45
|
+
const [account] = await wallet.getAddresses()
|
|
46
|
+
|
|
47
|
+
const { steps } = await hoodfi.buildRegistration({ name: 'alice', account, payWith: 'eth' })
|
|
48
|
+
for (const step of steps) {
|
|
49
|
+
const hash = await wallet.sendTransaction({ account, to: step.to, data: step.data, value: step.value })
|
|
50
|
+
const receipt = await hoodfi.publicClient.waitForTransactionReceipt({ hash })
|
|
51
|
+
if (receipt.status !== 'success') throw new Error(`${step.description} reverted`)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- **The name goes to whoever sends the transaction.** The registrar mints to `msg.sender` and takes no recipient, so to give a name to someone else, mint it and then transfer it.
|
|
56
|
+
- `payWith: 'usdg'` adds an `approve` step first when the allowance is short.
|
|
57
|
+
- ETH payments send the quoted price plus a buffer (`overpayBps`, default 100 = 1%) so the transaction still goes through if the registrar owner reprices between quote and send. The registrar refunds the excess to the sender in the same transaction.
|
|
58
|
+
- Prices: $3 for 4+ characters, $5 / $10 / $15 for 3 / 2 / 1 characters in USDG. The ETH price is a fixed amount per tier that the registrar owner sets, not an oracle price, so in dollars it drifts with ETH. `checkName` returns both as currently set.
|
|
59
|
+
|
|
60
|
+
## Errors
|
|
61
|
+
|
|
62
|
+
Every failure is a `HoodfiError` with a `code`:
|
|
63
|
+
|
|
64
|
+
| code | meaning |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `INVALID_NAME` | Not a valid hoodfi name (or address). Nothing was read. |
|
|
67
|
+
| `NOT_REGISTERED` | `getSendAddress` on a name nobody holds. (`resolve` returns `null` instead.) |
|
|
68
|
+
| `NO_RECORD` | The name has no address for that chain. **Don't fall back to another chain's record.** |
|
|
69
|
+
| `UNAVAILABLE` | `buildRegistration` on a taken, reserved or paused name. |
|
|
70
|
+
| `UNREADABLE` | The RPC or API didn't answer. **This tells you nothing about the name.** Retry it, and never show it as "not registered" or "no names". |
|
|
71
|
+
|
|
72
|
+
## Things that bite
|
|
73
|
+
|
|
74
|
+
- **`gm.eth` is not `gm.hoodfi.eth`.** `resolve` and `getSendAddress` reject any `.eth` name outside `hoodfi.eth` rather than quietly reading the hoodfi name with the same label, which could belong to someone else entirely.
|
|
75
|
+
- **Robinhood Chain and Ethereum are separate records.** They normally hold the same address. `getSendAddress('x', 'robinhood')` never borrows the Ethereum record (or vice versa). A Safe or other contract wallet exists only on the chains it was deployed to, and funds sent to its address on another chain can be stuck.
|
|
76
|
+
- **Records don't follow the token.** After a name is sold, its address records still point at the seller until the new owner updates them. `lookupAddress` only names a wallet `primary` when the name resolves back to that wallet.
|
|
77
|
+
- **Solana addresses have no checksum**, and a classic XRP address carries no destination tag. `getSendAddress` returns a `caveat` for these; show it to the user.
|
|
78
|
+
- The Robinhood Chain coinType is `2147488311n`. In JavaScript, `0x80000000 | 4663` evaluates to a negative number, which silently reads nothing.
|
|
79
|
+
|
|
80
|
+
## Options
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
createHoodfiClient({
|
|
84
|
+
rpcUrls: ['https://your-robinhood-rpc'], // tried before the public RPCs; recommended on servers
|
|
85
|
+
publicClient, // or bring your own viem client (chain 4663)
|
|
86
|
+
apiUrl: 'https://ccip.hoodfi-mcp.com', // reverse-lookup API
|
|
87
|
+
fetch, // custom fetch
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The public RPC rate-limits by IP. Servers doing volume should pass their own endpoint.
|
|
92
|
+
|
|
93
|
+
## Also exported
|
|
94
|
+
|
|
95
|
+
`checkLabel`, `checkHoodfiName`, `normalizeLabel`, `tierOf`, `fullName`, `decodeContenthash`, `CHAINS`, `CONTRACTS`, `robinhoodChain`, the coin-type constants, and the minimal `registrarAbi` / `registryAbi`.
|
|
96
|
+
|
|
97
|
+
## Related
|
|
98
|
+
|
|
99
|
+
- Integration guide: [docs/INTEGRATING.md](https://github.com/RWA-ID/hoodfi-eth/blob/main/docs/INTEGRATING.md)
|
|
100
|
+
- Drop-in mint widget: [`@hoodfi/widget`](https://www.npmjs.com/package/@hoodfi/widget)
|
|
101
|
+
- MCP server for AI agents: `https://hoodfi-mcp.com/mcp`
|
|
102
|
+
- Contracts and owners: [contracts/README.md](https://github.com/RWA-ID/hoodfi-eth/blob/main/contracts/README.md)
|
|
103
|
+
|
|
104
|
+
MIT
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Only the parts of each ABI this SDK actually calls. */
|
|
2
|
+
export declare const registrarAbi: readonly [{
|
|
3
|
+
readonly type: "function";
|
|
4
|
+
readonly name: "register";
|
|
5
|
+
readonly stateMutability: "payable";
|
|
6
|
+
readonly inputs: readonly [{
|
|
7
|
+
readonly name: "label";
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
}];
|
|
10
|
+
readonly outputs: readonly [];
|
|
11
|
+
}, {
|
|
12
|
+
readonly type: "function";
|
|
13
|
+
readonly name: "registerWithUsdc";
|
|
14
|
+
readonly stateMutability: "nonpayable";
|
|
15
|
+
readonly inputs: readonly [{
|
|
16
|
+
readonly name: "label";
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
}];
|
|
19
|
+
readonly outputs: readonly [];
|
|
20
|
+
}, {
|
|
21
|
+
readonly type: "function";
|
|
22
|
+
readonly name: "status";
|
|
23
|
+
readonly stateMutability: "view";
|
|
24
|
+
readonly inputs: readonly [{
|
|
25
|
+
readonly name: "label";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
}];
|
|
28
|
+
readonly outputs: readonly [{
|
|
29
|
+
readonly type: "uint8";
|
|
30
|
+
}];
|
|
31
|
+
}, {
|
|
32
|
+
readonly type: "function";
|
|
33
|
+
readonly name: "priceOf";
|
|
34
|
+
readonly stateMutability: "view";
|
|
35
|
+
readonly inputs: readonly [{
|
|
36
|
+
readonly name: "label";
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
}];
|
|
39
|
+
readonly outputs: readonly [{
|
|
40
|
+
readonly name: "weiPrice";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "usdcPrice";
|
|
44
|
+
readonly type: "uint256";
|
|
45
|
+
}];
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: "function";
|
|
48
|
+
readonly name: "paused";
|
|
49
|
+
readonly stateMutability: "view";
|
|
50
|
+
readonly inputs: readonly [];
|
|
51
|
+
readonly outputs: readonly [{
|
|
52
|
+
readonly type: "bool";
|
|
53
|
+
}];
|
|
54
|
+
}];
|
|
55
|
+
export declare const registryAbi: readonly [{
|
|
56
|
+
readonly type: "function";
|
|
57
|
+
readonly name: "ownerOf";
|
|
58
|
+
readonly stateMutability: "view";
|
|
59
|
+
readonly inputs: readonly [{
|
|
60
|
+
readonly name: "tokenId";
|
|
61
|
+
readonly type: "uint256";
|
|
62
|
+
}];
|
|
63
|
+
readonly outputs: readonly [{
|
|
64
|
+
readonly type: "address";
|
|
65
|
+
}];
|
|
66
|
+
}, {
|
|
67
|
+
readonly type: "function";
|
|
68
|
+
readonly name: "addr";
|
|
69
|
+
readonly stateMutability: "view";
|
|
70
|
+
readonly inputs: readonly [{
|
|
71
|
+
readonly name: "node";
|
|
72
|
+
readonly type: "bytes32";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "coinType";
|
|
75
|
+
readonly type: "uint256";
|
|
76
|
+
}];
|
|
77
|
+
readonly outputs: readonly [{
|
|
78
|
+
readonly type: "bytes";
|
|
79
|
+
}];
|
|
80
|
+
}, {
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly name: "text";
|
|
83
|
+
readonly stateMutability: "view";
|
|
84
|
+
readonly inputs: readonly [{
|
|
85
|
+
readonly name: "node";
|
|
86
|
+
readonly type: "bytes32";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "key";
|
|
89
|
+
readonly type: "string";
|
|
90
|
+
}];
|
|
91
|
+
readonly outputs: readonly [{
|
|
92
|
+
readonly type: "string";
|
|
93
|
+
}];
|
|
94
|
+
}, {
|
|
95
|
+
readonly type: "function";
|
|
96
|
+
readonly name: "contenthash";
|
|
97
|
+
readonly stateMutability: "view";
|
|
98
|
+
readonly inputs: readonly [{
|
|
99
|
+
readonly name: "node";
|
|
100
|
+
readonly type: "bytes32";
|
|
101
|
+
}];
|
|
102
|
+
readonly outputs: readonly [{
|
|
103
|
+
readonly type: "bytes";
|
|
104
|
+
}];
|
|
105
|
+
}];
|
|
106
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaf,CAAA;AAEV,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBd,CAAA"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Only the parts of each ABI this SDK actually calls. */
|
|
2
|
+
export const registrarAbi = [
|
|
3
|
+
{ type: 'function', name: 'register', stateMutability: 'payable', inputs: [{ name: 'label', type: 'string' }], outputs: [] },
|
|
4
|
+
{ type: 'function', name: 'registerWithUsdc', stateMutability: 'nonpayable', inputs: [{ name: 'label', type: 'string' }], outputs: [] },
|
|
5
|
+
// 0 = available, 1 = taken, 2 = locked, 3 = invalid, 4 = blocked.
|
|
6
|
+
{ type: 'function', name: 'status', stateMutability: 'view', inputs: [{ name: 'label', type: 'string' }], outputs: [{ type: 'uint8' }] },
|
|
7
|
+
{
|
|
8
|
+
type: 'function',
|
|
9
|
+
name: 'priceOf',
|
|
10
|
+
stateMutability: 'view',
|
|
11
|
+
inputs: [{ name: 'label', type: 'string' }],
|
|
12
|
+
outputs: [{ name: 'weiPrice', type: 'uint256' }, { name: 'usdcPrice', type: 'uint256' }],
|
|
13
|
+
},
|
|
14
|
+
{ type: 'function', name: 'paused', stateMutability: 'view', inputs: [], outputs: [{ type: 'bool' }] },
|
|
15
|
+
];
|
|
16
|
+
export const registryAbi = [
|
|
17
|
+
{ type: 'function', name: 'ownerOf', stateMutability: 'view', inputs: [{ name: 'tokenId', type: 'uint256' }], outputs: [{ type: 'address' }] },
|
|
18
|
+
{
|
|
19
|
+
type: 'function',
|
|
20
|
+
name: 'addr',
|
|
21
|
+
stateMutability: 'view',
|
|
22
|
+
inputs: [{ name: 'node', type: 'bytes32' }, { name: 'coinType', type: 'uint256' }],
|
|
23
|
+
outputs: [{ type: 'bytes' }],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'function',
|
|
27
|
+
name: 'text',
|
|
28
|
+
stateMutability: 'view',
|
|
29
|
+
inputs: [{ name: 'node', type: 'bytes32' }, { name: 'key', type: 'string' }],
|
|
30
|
+
outputs: [{ type: 'string' }],
|
|
31
|
+
},
|
|
32
|
+
{ type: 'function', name: 'contenthash', stateMutability: 'view', inputs: [{ name: 'node', type: 'bytes32' }], outputs: [{ type: 'bytes' }] },
|
|
33
|
+
];
|
|
34
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC5H,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACv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AO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC7B;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5E,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KAC9B;IACD,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE;CACrI,CAAA"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
import { type SendChain } from './coins.js';
|
|
3
|
+
import { ROBINHOOD_CHAIN_ID } from './constants.js';
|
|
4
|
+
import { type ContentHash } from './contenthash.js';
|
|
5
|
+
import { type NameStatus } from './labels.js';
|
|
6
|
+
export type HoodfiErrorCode =
|
|
7
|
+
/** The input isn't a valid hoodfi.eth name. Nothing was read. */
|
|
8
|
+
'INVALID_NAME'
|
|
9
|
+
/** The name exists, or can't be minted right now. `checkName` explains why. */
|
|
10
|
+
| 'UNAVAILABLE'
|
|
11
|
+
/** The name has never been minted. */
|
|
12
|
+
| 'NOT_REGISTERED'
|
|
13
|
+
/** The name has no record for the chain asked about. Do NOT fall back to another one. */
|
|
14
|
+
| 'NO_RECORD'
|
|
15
|
+
/**
|
|
16
|
+
* The chain or API didn't answer. This says nothing about the name: never show it as
|
|
17
|
+
* "not registered" or "no names". Retry.
|
|
18
|
+
*/
|
|
19
|
+
| 'UNREADABLE';
|
|
20
|
+
export declare class HoodfiError extends Error {
|
|
21
|
+
readonly code: HoodfiErrorCode;
|
|
22
|
+
constructor(code: HoodfiErrorCode, message: string, options?: {
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export interface HoodfiClientOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Robinhood Chain RPC URLs, tried in order before the public defaults. The public RPC
|
|
29
|
+
* throttles per IP; a server doing volume should pass its own endpoint here.
|
|
30
|
+
*/
|
|
31
|
+
rpcUrls?: string[];
|
|
32
|
+
/** Bring your own viem client instead. It must be connected to chain 4663. */
|
|
33
|
+
publicClient?: PublicClient;
|
|
34
|
+
/** HoodFi gateway base URL, for reverse lookups. */
|
|
35
|
+
apiUrl?: string;
|
|
36
|
+
/** Override `fetch` (tests, proxies). */
|
|
37
|
+
fetch?: typeof fetch;
|
|
38
|
+
}
|
|
39
|
+
export interface NameCheck {
|
|
40
|
+
name: string;
|
|
41
|
+
label: string;
|
|
42
|
+
length: number;
|
|
43
|
+
/** 0-3 for 1, 2, 3 and 4+ characters. */
|
|
44
|
+
tier: 0 | 1 | 2 | 3;
|
|
45
|
+
status: NameStatus;
|
|
46
|
+
/** True only when status is available AND minting isn't paused. */
|
|
47
|
+
available: boolean;
|
|
48
|
+
paused: boolean;
|
|
49
|
+
/** Why it can't be registered, in a sentence you can show. Undefined when available. */
|
|
50
|
+
reason?: string;
|
|
51
|
+
price: {
|
|
52
|
+
/**
|
|
53
|
+
* ETH price in wei: a fixed per-tier amount the registrar owner sets, not an oracle
|
|
54
|
+
* price, so its dollar value moves with ETH. Read fresh on every call.
|
|
55
|
+
*/
|
|
56
|
+
wei: bigint;
|
|
57
|
+
/** USDG price, 6 decimals. */
|
|
58
|
+
usdg: bigint;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface NameProfile {
|
|
62
|
+
name: string;
|
|
63
|
+
node: Hex;
|
|
64
|
+
owner: Address;
|
|
65
|
+
/**
|
|
66
|
+
* Robinhood Chain and Ethereum are separate records. They normally hold the same
|
|
67
|
+
* address, but reported apart so a name where they differ is visible.
|
|
68
|
+
*/
|
|
69
|
+
addresses: Record<SendChain, string | null>;
|
|
70
|
+
/** Text records that are set: avatar, description, url, com.twitter, com.github, email. */
|
|
71
|
+
records: Partial<Record<TextKey, string>>;
|
|
72
|
+
/** The name's website, or null when it has none (or one in a namespace not decoded here). */
|
|
73
|
+
website: (ContentHash & {
|
|
74
|
+
url: string;
|
|
75
|
+
gateway: string;
|
|
76
|
+
}) | null;
|
|
77
|
+
explorer: string;
|
|
78
|
+
}
|
|
79
|
+
export interface SendAddress {
|
|
80
|
+
name: string;
|
|
81
|
+
chain: SendChain;
|
|
82
|
+
address: string;
|
|
83
|
+
/** E.g. the Robinhood and Ethereum records disagree. Show these to the sender. */
|
|
84
|
+
warnings: string[];
|
|
85
|
+
/** What a well-formed record can't prove (Solana has no checksum, XRP r-addresses no tag). */
|
|
86
|
+
caveat: string | null;
|
|
87
|
+
}
|
|
88
|
+
export interface OwnedName {
|
|
89
|
+
name: string;
|
|
90
|
+
node: Hex;
|
|
91
|
+
/** The name's ETH address record, or null when unset. */
|
|
92
|
+
addr: Address | null;
|
|
93
|
+
/** True when the name's record points back at this address. Only these may be shown as "this wallet is X". */
|
|
94
|
+
resolves: boolean;
|
|
95
|
+
avatar: string | null;
|
|
96
|
+
}
|
|
97
|
+
export interface AddressLookup {
|
|
98
|
+
address: Address;
|
|
99
|
+
/** The name to display for this address: it resolves back to it. Null when none does. */
|
|
100
|
+
primary: string | null;
|
|
101
|
+
/** "ens": the holder set it as their ENS primary. "inferred": shortest name that resolves back. */
|
|
102
|
+
primarySource: 'ens' | 'inferred' | null;
|
|
103
|
+
/** Every hoodfi name this address holds now, resolving ones first. */
|
|
104
|
+
names: OwnedName[];
|
|
105
|
+
}
|
|
106
|
+
export interface TxStep {
|
|
107
|
+
description: string;
|
|
108
|
+
to: Address;
|
|
109
|
+
data: Hex;
|
|
110
|
+
value: bigint;
|
|
111
|
+
chainId: typeof ROBINHOOD_CHAIN_ID;
|
|
112
|
+
}
|
|
113
|
+
export interface Registration {
|
|
114
|
+
name: string;
|
|
115
|
+
label: string;
|
|
116
|
+
payWith: 'eth' | 'usdg';
|
|
117
|
+
/** The price at quote time. ETH steps send `price.wei` plus the overpay buffer. */
|
|
118
|
+
price: {
|
|
119
|
+
wei: bigint;
|
|
120
|
+
usdg: bigint;
|
|
121
|
+
};
|
|
122
|
+
/** Send in order; wait for each receipt (and check its status) before the next. */
|
|
123
|
+
steps: TxStep[];
|
|
124
|
+
/** E.g. the account can't afford it yet. The steps still build. */
|
|
125
|
+
warnings: string[];
|
|
126
|
+
}
|
|
127
|
+
declare const TEXT_KEYS: readonly ["avatar", "description", "url", "com.twitter", "com.github", "email"];
|
|
128
|
+
export type TextKey = (typeof TEXT_KEYS)[number];
|
|
129
|
+
export interface HoodfiClient {
|
|
130
|
+
checkName(name: string): Promise<NameCheck>;
|
|
131
|
+
resolve(name: string): Promise<NameProfile | null>;
|
|
132
|
+
getSendAddress(name: string, chain: SendChain): Promise<SendAddress>;
|
|
133
|
+
lookupAddress(address: string): Promise<AddressLookup>;
|
|
134
|
+
buildRegistration(args: {
|
|
135
|
+
name: string;
|
|
136
|
+
account: string;
|
|
137
|
+
payWith?: 'eth' | 'usdg';
|
|
138
|
+
overpayBps?: number;
|
|
139
|
+
}): Promise<Registration>;
|
|
140
|
+
/** The viem client in use, e.g. for `waitForTransactionReceipt`. */
|
|
141
|
+
publicClient: PublicClient;
|
|
142
|
+
}
|
|
143
|
+
export declare function createHoodfiClient(options?: HoodfiClientOptions): HoodfiClient;
|
|
144
|
+
export {};
|
|
145
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ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