@parity/product-sdk 0.22.0 → 0.23.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.
Files changed (40) hide show
  1. package/dist/chunk-BRZNHTLQ.js +89 -0
  2. package/dist/chunk-BRZNHTLQ.js.map +1 -0
  3. package/dist/{chunk-6BI66XUJ.js → chunk-DHRCWMY5.js} +9 -10
  4. package/dist/chunk-DHRCWMY5.js.map +1 -0
  5. package/dist/core/index.d.ts +2 -2
  6. package/dist/core/index.js +2 -2
  7. package/dist/dotns-bswWAmR2.d.ts +136 -0
  8. package/dist/identity/index.d.ts +502 -45
  9. package/dist/identity/index.js +800 -32
  10. package/dist/identity/index.js.map +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +2 -2
  13. package/dist/react/index.d.ts +2 -2
  14. package/dist/react/index.js +2 -2
  15. package/dist/testing/index.d.ts +2 -2
  16. package/dist/{types-DTgyMIi0.d.ts → types-B5Zx4RNq.d.ts} +1 -1
  17. package/package.json +10 -10
  18. package/src/core/createApp.ts +10 -8
  19. package/src/identity/dotns-abis.test.ts +43 -0
  20. package/src/identity/dotns-abis.ts +309 -0
  21. package/src/identity/dotns-addresses.test.ts +536 -0
  22. package/src/identity/dotns-addresses.ts +320 -0
  23. package/src/identity/dotns-errors.ts +36 -0
  24. package/src/identity/dotns-namehash.test.ts +155 -0
  25. package/src/identity/dotns-namehash.ts +149 -0
  26. package/src/identity/dotns-owner.test.ts +92 -0
  27. package/src/identity/dotns-registry.test.ts +1309 -0
  28. package/src/identity/dotns-registry.ts +868 -0
  29. package/src/identity/dotns.test.ts +128 -0
  30. package/src/identity/dotns.ts +91 -78
  31. package/src/identity/index.test.ts +43 -0
  32. package/src/identity/index.ts +40 -10
  33. package/src/identity/types.ts +29 -25
  34. package/src/individuality/contract.test.ts +272 -2
  35. package/dist/chunk-6BI66XUJ.js.map +0 -1
  36. package/dist/chunk-BIKT6X54.js +0 -70
  37. package/dist/chunk-BIKT6X54.js.map +0 -1
  38. package/dist/dotns-DIaptENj.d.ts +0 -167
  39. package/src/identity/product-account.test.ts +0 -129
  40. package/src/identity/product-account.ts +0 -115
@@ -1,63 +1,520 @@
1
- import { C as ContextAliasInfo } from '../dotns-DIaptENj.js';
2
- export { D as DotNsRecord, O as OnChainIdentity, P as PeopleUsernameChain, a as PeopleUsernameQueryApi, V as VerificationResult, b as accountIdHexToBytes, i as isDotNsAvailable, c as isValidDotNsName, n as normalizeDotNsName, r as resolveDotNs, d as resolvePeopleUsernameOwner, e as reverseDotNs } from '../dotns-DIaptENj.js';
3
- import 'polkadot-api';
1
+ export { P as PeopleUsernameChain, a as PeopleUsernameQueryApi, b as accountIdHexToBytes, c as accountIdToHex, i as isResolvableDotNsName, d as isValidDotNsName, n as normalizeDotNsName, r as resolvePeopleUsernameOwner } from '../dotns-bswWAmR2.js';
2
+ import { Result } from '@parity/result';
3
+ import { ContractRuntime, BatchableCall } from '@parity/product-sdk-contracts';
4
+ import { SS58String } from 'polkadot-api';
5
+ import { SdkError } from '@parity/product-sdk-errors';
4
6
 
5
7
  /**
6
- * Context alias derivation (deprecated, removal in 0.23.0)
8
+ * Error on the `Err` channel of a DotNS registry read/write. Implements the
9
+ * cross-package {@link SdkError} marker so `isSdkError(e)` recognizes it.
7
10
  *
8
- * Derives a deterministic, context-bound alias from a parent account using blake2b-256.
11
+ * `reason` distinguishes the failure kind so callers can branch without string
12
+ * matching.
13
+ */
14
+ type DotNsErrorReason = "InvalidName" | "InvalidTld" | "TldMismatch" | "MissingOrigin" | "InvalidOrigin" | "NameUnavailable" | "NameReserved" | "OwnerStatusInsufficient" | "AddressDiscovery" | "AddressMismatch" | "RegistryCall" | "Decode";
15
+ declare class DotNsError extends Error implements SdkError {
16
+ readonly isSdkError: true;
17
+ readonly source = "dotns";
18
+ readonly reason: DotNsErrorReason;
19
+ constructor(reason: DotNsErrorReason, message: string, options?: ErrorOptions);
20
+ }
21
+
22
+ /**
23
+ * Where the DotNS contract addresses come from.
24
+ *
25
+ * Every entry point in `./dotns-registry.js` asks {@link resolveDotNsAddresses}
26
+ * rather than reaching for a constant, so "which address do I call?" has one
27
+ * answer and the gateway walk can plug in behind it without touching them.
28
+ */
29
+
30
+ type HexString$1 = `0x${string}`;
31
+ interface DotNsAddresses {
32
+ registry: HexString$1;
33
+ reverseResolver: HexString$1;
34
+ resolver: HexString$1;
35
+ registrarController: HexString$1;
36
+ popRules: HexString$1;
37
+ protocolRegistry: HexString$1;
38
+ }
39
+ /**
40
+ * The `DotnsProtocolRegistry.get(bytes32)` key each role answers under, from
41
+ * `DotnsConstants`. Solidity's `bytes32("name")` is the UTF-8 bytes
42
+ * right-padded with zeros, which is what these literals are.
43
+ *
44
+ * Two are not the name you would guess, and guessing wrong is silent: `get`
45
+ * answers with a live address for the contract you did not want, and it
46
+ * surfaces much later as a revert. `registrarController` is the commit-reveal
47
+ * controller, key `controller` — `registrar` is the ERC-721 holding name
48
+ * ownership. `resolver` is the forward address resolver — `contentResolver`
49
+ * holds contenthash and text records, which nothing here calls.
50
+ *
51
+ * `protocolRegistry` has no key at all, so it cannot be looked up in the
52
+ * registry it is. The walk reaches it via `popController.protocolRegistry()`.
53
+ */
54
+ declare const DOTNS_REGISTRY_KEYS: {
55
+ readonly registry: "0x7265676973747279000000000000000000000000000000000000000000000000";
56
+ readonly registrarController: "0x636f6e74726f6c6c657200000000000000000000000000000000000000000000";
57
+ readonly reverseResolver: "0x726576657273655265736f6c7665720000000000000000000000000000000000";
58
+ readonly resolver: "0x7265736f6c766572000000000000000000000000000000000000000000000000";
59
+ readonly popRules: "0x706f7052756c6573000000000000000000000000000000000000000000000000";
60
+ };
61
+ declare function resolveDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
62
+ /**
63
+ * Reads `DotnsGateway.DispatcherAddress`, the pallet storage the walk starts
64
+ * from. Structural because `ContractRuntime` does not declare it.
65
+ */
66
+ type DotNsGatewayQueryApi = {
67
+ query: {
68
+ DotnsGateway: {
69
+ DispatcherAddress: {
70
+ getValue: () => Promise<{
71
+ asHex(): string;
72
+ } | string | undefined>;
73
+ };
74
+ };
75
+ };
76
+ };
77
+ /**
78
+ * Locate the live deployment from chain state, trusting nothing pinned here.
9
79
  *
10
- * The output is a hash, not a key, so no signing key exists for the addresses
11
- * returned here. See the notes on each function for what to use instead.
80
+ * Pallet -> `dispatcher.TARGET()` -> `popController.protocolRegistry()` ->
81
+ * `get(key)` per role. The first three are sequential because each answer is
82
+ * the next call's address; the role reads are not, so they go together.
12
83
  *
13
- * NOTE: this is NOT the canonical sr25519 product-account derivation used by
14
- * mobile, desktop, and dotli hosts. For that, use
15
- * `@parity/product-sdk-keys::deriveProductAccountPublicKey`.
84
+ * A failed or zero read is always an error: falling back to the pinned table
85
+ * would recreate the situation this exists to detect, and hide it better.
16
86
  */
87
+ declare function discoverDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
88
+ /**
89
+ * Walk the gateway and report every role whose live address differs from the
90
+ * one this client would call. Meant for startup: it fails loudly once, rather
91
+ * than making every later read pay for the check.
92
+ */
93
+ declare function verifyDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
17
94
 
18
95
  /**
19
- * Derive a context-bound alias from a parent account.
96
+ * A network's DotNS top-level domain: the suffix names are spelled with, and
97
+ * the node every one of its names hashes onto.
20
98
  *
21
- * The alias is deterministically derived using:
22
- * aliasPublicKey = blake2b256(parentPublicKey || context)
99
+ * The two must agree — `node` is `namehash(0, labelhash(label))` of `suffix`'s
100
+ * label — so build one with {@link dotNsTld} rather than by hand, and check an
101
+ * externally supplied pair with {@link isConsistentDotNsTld}. A `.paseo` suffix
102
+ * carrying the `.dot` node is exactly the defect this type exists to prevent.
103
+ */
104
+ interface DotNsTld {
105
+ /** Suffix including the leading dot, as `protocolRegistry.tld()` returns it. */
106
+ suffix: string;
107
+ /** Namehash of the TLD label, as `protocolRegistry.tldNode()` returns it. */
108
+ node: `0x${string}`;
109
+ }
110
+ /** The `.dot` TLD node. Mirrors the `DotnsConstants.DOT_NODE` the contracts removed in `b4096968`. */
111
+ declare const DOT_NODE = "0x3fce7d1364a893e213bc4212792b517ffc88f5b13b86c8ef9c8d390c3a1370ce";
112
+ /**
113
+ * Build a {@link DotNsTld} from a TLD suffix, deriving the node the same way the
114
+ * contract does.
23
115
  *
24
- * @deprecated Returns addresses that no key can spend. The alias public key is a
25
- * blake2b-256 hash rather than a derived key, so no secret corresponds to the
26
- * SS58 address or to the H160: both can receive value and neither can ever
27
- * send it. Removal: `@parity/product-sdk` 0.23.0. Replace by intent:
116
+ * Mirrors `DotnsProtocolRegistry.initialize`, which sets
117
+ * `_tldNode = namehashUnder(bytes32(0), labelhash(tldLabel))`. Because the node
118
+ * is a pure function of the label, a client only ever needs the suffix — reading
119
+ * `tldNode()` is a cross-check, never the source.
28
120
  *
29
- * - An account that holds or spends value:
30
- * `SignerManager.getProductAccount(dotNsIdentifier, index)` from
31
- * `@parity/product-sdk-signer`. Host-backed and actually signable.
32
- * - The address offline, with no host: `deriveProductAccountPublicKey` from
33
- * `@parity/product-sdk-keys`, the canonical sr25519 soft derivation.
34
- * - An unlinkable per-context alias: select a registered ring-VRF key, then call
35
- * `SignerManager.getProductAccountAlias(keyHandle, context, location)` or
36
- * `createRingVRFProof(keyHandle, context, location, message)`.
37
- * - A context-scoped identifier, never used as an account: `blake2b256` from
38
- * `@parity/product-sdk/crypto`. Same bytes, without address packaging that
39
- * invites the mistake.
121
+ * Accepts `".paseo"` or `"paseo"`: `tld()` returns the dotted form while
122
+ * `initialize` and the deploy pipeline speak the bare label.
123
+ */
124
+ declare function dotNsTld(suffix: string): DotNsTld;
125
+ /**
126
+ * Whether a {@link DotNsTld} could have come from a real deployment.
127
+ *
128
+ * Three ways a pair fails, all of which produce silently wrong nodes rather
129
+ * than errors if they reach {@link namehash}:
130
+ *
131
+ * - the node is not the derivation of the suffix (a caller mixing `.paseo`
132
+ * with `DOT_NODE`);
133
+ * - the suffix is empty, or the node is zero — what a pre-`b4096968` registry
134
+ * proxy reports after an upgrade with no reinitializer, since `_tld` and
135
+ * `_tldNode` are then still at their defaults and *both getters succeed*;
136
+ * - the suffix is not a single label, which `initialize` rejects outright.
40
137
  *
41
- * @param parentAddress - Parent account SS58 address
42
- * @param context - Context string for derivation (e.g. an app id or scope label)
43
- * @param ss58Prefix - SS58 prefix (default: 42)
44
- * @returns Context alias info
138
+ * Returns a boolean rather than a `Result` to keep this module free of the
139
+ * error type; callers with an error channel (`resolveTld`) map `false` to an
140
+ * `err` carrying the offending value.
45
141
  */
46
- declare function deriveContextAlias(parentAddress: string, context: string, ss58Prefix?: number): ContextAliasInfo;
142
+ declare function isConsistentDotNsTld(tld: DotNsTld): boolean;
143
+ /** The `.dot` TLD, for a deployment that uses it. Not a default: pass it explicitly. */
144
+ declare const DOT_TLD: DotNsTld;
47
145
  /**
48
- * Verify that a context alias was derived from a parent account.
146
+ * Drop `suffix` from the end of `name`, leaving the labels beneath it.
147
+ *
148
+ * Strips by the suffix's own length, which is the whole point: the same logic
149
+ * written as `slice(0, -4)` turns `alice.paseo` into `alice.pa`, and every
150
+ * lookup for that name then asks about a subname nobody registered. A name that
151
+ * does not carry the suffix is returned unchanged, so a foreign suffix stays
152
+ * visible to whatever validates next.
153
+ *
154
+ * Lives here rather than in `./dotns.js` so the one copy is reachable from this
155
+ * module without pulling its heavier imports in.
156
+ */
157
+ declare function stripSuffix(name: string, suffix: string): string;
158
+ /**
159
+ * Compute the DotNS node hash for a name like `"alice.paseo"` or
160
+ * `"bob.alice.paseo"`, rooted at `tld`.
161
+ *
162
+ * The trailing suffix is the TLD (folded into `tld.node`); remaining labels are
163
+ * hashed most-significant-last, so `bob.alice.paseo` layers `bob` on top of
164
+ * `alice` on top of the TLD. Input is used as-is — normalize with
165
+ * `normalizeDotNsName` first if needed.
166
+ *
167
+ * `tld` is required rather than defaulted, because a default that is correct on
168
+ * one deployment is the defect this module was fixed for. It is also not
169
+ * validated here: a name whose suffix belongs to another deployment hashes to a
170
+ * node under `tld` instead of being refused, since this function returns a hash
171
+ * and has nowhere to report a complaint. The entry points in
172
+ * `./dotns-registry.js` do that check, where there is an error channel.
173
+ *
174
+ * @returns the 32-byte node as a `0x`-prefixed hex string.
175
+ */
176
+ declare function namehash(name: string, tld: DotNsTld): `0x${string}`;
177
+
178
+ /**
179
+ * Identity module types
180
+ */
181
+ /** DotNS name resolution result */
182
+ interface DotNsRecord {
183
+ /**
184
+ * H160 the name resolves to, `0x` and 20 bytes. Not SS58: DotNS is a set of
185
+ * Revive contracts and both address fields come back as EVM addresses.
186
+ * Convert with `h160ToSs58` from `@parity/product-sdk-address` if a
187
+ * Substrate-shaped address is needed.
188
+ *
189
+ * Absent when the name is registered but has no forward record yet, the
190
+ * state of every name just after registration. An unregistered name is
191
+ * `null` from `resolveDotNs`, not a record.
192
+ */
193
+ address?: `0x${string}`;
194
+ /**
195
+ * Name that was resolved, normalized: lowercased, and carrying the
196
+ * deployment's own TLD suffix — `.paseo` on Paseo Asset Hub Next V2, `.dot`
197
+ * on Previewnet. A bare label passed in comes back suffixed.
198
+ *
199
+ * Note for a **lite-person** registrant: the registry stores their label
200
+ * flattened, so `alice.42` is registered as `alice42` and this field reads
201
+ * `alice42.paseo`. Pass the flattened spelling when resolving; the dotted
202
+ * one derives a different node and finds nothing.
203
+ */
204
+ name: string;
205
+ /** H160 of the node's owner. Not SS58, same as {@link DotNsRecord.address}. */
206
+ owner: `0x${string}`;
207
+ /**
208
+ * Expiration timestamp, if the deployment has one.
209
+ *
210
+ * Always absent today: the Paseo Asset Hub registrar exposes no expiry
211
+ * getter, so nothing populates this.
212
+ */
213
+ expiresAt?: number;
214
+ }
215
+ /** Identity verification result */
216
+ interface VerificationResult {
217
+ /** Whether identity is verified */
218
+ verified: boolean;
219
+ /** Verification method used */
220
+ method: "on-chain" | "judgement" | "social";
221
+ /** Verification details */
222
+ details?: Record<string, unknown>;
223
+ }
224
+ /** On-chain identity info */
225
+ interface OnChainIdentity {
226
+ /** Display name */
227
+ display?: string;
228
+ /** Legal name */
229
+ legal?: string;
230
+ /** Web URL */
231
+ web?: string;
232
+ /** Email */
233
+ email?: string;
234
+ /** Twitter handle */
235
+ twitter?: string;
236
+ /** Riot/Matrix handle */
237
+ riot?: string;
238
+ /** Additional fields */
239
+ additional: Array<[string, string]>;
240
+ }
241
+
242
+ /**
243
+ * DotNS registry reads and writes.
244
+ *
245
+ * DotNS is an ENS-style system on Asset Hub: a `DotnsRegistry` maps a node
246
+ * (namehash) to a resolver + owner, a `DotnsResolver` maps a node to an
247
+ * address, and a `DotnsReverseResolver` maps an account back to its name. All
248
+ * are Revive contracts, reached via `@parity/product-sdk-contracts`'
249
+ * `createContract(...).<method>.query(...)`. Contract source:
250
+ * https://github.com/paritytech/dotns
251
+ *
252
+ * **Names are rooted at the network's TLD, which is per deployment.** It is
253
+ * fixed when `DotnsProtocolRegistry.initialize` runs, has no setter, and is
254
+ * published as `tld()`. `.paseo` on Paseo Asset Hub Next V2, `.test` on
255
+ * Previewnet, and operators can choose others. Every entry point that hashes a
256
+ * name therefore asks the chain first, through {@link resolveTld}, and callers
257
+ * can supply `opts.tld` to skip the read. Hashing under the wrong root returns a
258
+ * node the chain never wrote to, so the failure looks exactly like an
259
+ * unregistered name — which is why nothing here assumes a root.
260
+ *
261
+ * **A node's resolver pointer is not necessarily a forward resolver.** The
262
+ * deployment has several — forward, reverse, content, PoP — and only the forward
263
+ * one answers `addressOf`. `resolveDotNs` therefore calls it only when the
264
+ * pointer *is* the forward resolver, and reports every other pointer as
265
+ * "registered, no forward record". The content resolver is the common case for a
266
+ * product name.
267
+ *
268
+ * A rule this module holds to throughout: **a failed read must never become a
269
+ * plausible value.** The one deliberate exception is documented on
270
+ * {@link resolveTld}, where a missing getter identifies a deployment whose TLD
271
+ * could only have been `.dot`.
272
+ *
273
+ * Reads (`resolveDotNs` / `reverseDotNs` / `isDotNsAvailable`) query chain.
274
+ * Writes return prepared calls the caller submits with their own signer:
275
+ * `setDotNsRecord` (the resolver pointer, when it needs moving, plus the
276
+ * record) and `prepareDotNsRegistration` (the commit call plus a thunk for the
277
+ * register call, which cannot be built until the commitment is on chain).
278
+ *
279
+ * Note: this deployment has no name-expiry concept (the registrar exposes no
280
+ * expiry getter), so `DotNsRecord.expiresAt` is always omitted.
281
+ */
282
+
283
+ type HexString = `0x${string}`;
284
+ /** Shared inputs for a DotNS registry call. */
285
+ interface DotNsClientOptions {
286
+ /** A contract runtime for the chain hosting DotNS (Asset Hub). */
287
+ runtime: ContractRuntime;
288
+ /**
289
+ * SS58 account that will submit the prepared calls.
290
+ *
291
+ * Required by the write helpers, which dry-run against it: `setAddress` and
292
+ * `setResolver` are owner-gated, so a dry-run from anyone else reverts.
293
+ * Optional for reads, which fall back to the pallet-revive query account.
294
+ *
295
+ * Must be SS58, not the account's H160. pallet-revive derives `msg.sender`
296
+ * from it; convert with `h160ToSs58` from `@parity/product-sdk-address`.
297
+ */
298
+ origin?: SS58String;
299
+ /** `DotnsRegistry` address. Defaults to the deployed set, which is the same on every network. */
300
+ registryAddress?: HexString;
301
+ /** `DotnsReverseResolver` address. Defaults to the deployed set. */
302
+ reverseResolverAddress?: HexString;
303
+ /** `DotnsResolver` address (writes: setDotNsRecord). Defaults to Paseo AH. */
304
+ resolverAddress?: HexString;
305
+ /** `DotnsRegistrarController` address (registration). Defaults to Paseo AH. */
306
+ registrarControllerAddress?: HexString;
307
+ /** `PopRules` address (registration price). Defaults to Paseo AH. */
308
+ popRulesAddress?: HexString;
309
+ /**
310
+ * `DotnsProtocolRegistry` address, the contract holding this network's TLD.
311
+ * Defaults to Paseo AH — and the address is the same on every network, since
312
+ * the whole set is CREATE3-deterministic.
313
+ */
314
+ protocolRegistryAddress?: HexString;
315
+ /**
316
+ * Where the addresses come from. `"pinned"` (the default) uses the
317
+ * {@link DOTNS_ADDRESSES} table; `"discovered"` walks the gateway on the
318
+ * chain `runtime` points at, so nothing is trusted from this bundle.
319
+ *
320
+ * Pinned is the default because the table is currently correct and a walk
321
+ * costs four round trips on the first call. Discovery is the honest choice
322
+ * once a deployment has moved, and its trust root is
323
+ * `DotnsGateway.DispatcherAddress` — a governance-set value on the chain the
324
+ * caller already trusts for every name read. Per-field address overrides win
325
+ * over either source.
326
+ *
327
+ * Discovery also selects the address `setDotNsRecord` and
328
+ * `prepareDotNsRegistration` build calls against, so it decides where a
329
+ * signed transaction goes, not only where a read comes from. A pinned
330
+ * address constrains that destination even against a hostile RPC; a
331
+ * discovered one does not. Use {@link verifyDotNsAddresses} at startup if
332
+ * that matters.
333
+ */
334
+ addressSource?: "pinned" | "discovered";
335
+ /**
336
+ * Typed API for the chain hosting the `DotnsGateway` pallet, needed only by
337
+ * `"discovered"`.
338
+ *
339
+ * Optional because `runtime.api` is usually the same chain and is used when
340
+ * it carries the pallet. `ContractRuntime` does not declare that storage, so
341
+ * it is probed rather than assumed; on a chain without the pallet, discovery
342
+ * fails with `AddressDiscovery` instead of throwing.
343
+ */
344
+ gatewayApi?: DotNsGatewayQueryApi;
345
+ /**
346
+ * The deployment's TLD, when you already know it.
347
+ *
348
+ * Omit it and the client reads `protocolRegistry.tld()` once per runtime and
349
+ * caches it, which is the correct default: the TLD is per network and only
350
+ * the chain knows which one is in play. Supply it to skip the read for
351
+ * offline or test use, or to pin a deployment deliberately. Build it with
352
+ * `dotNsTld(".paseo")` rather than by hand — a suffix paired with the wrong
353
+ * node is rejected, because that pairing is the defect this option could
354
+ * otherwise reintroduce.
355
+ */
356
+ tld?: DotNsTld;
357
+ }
358
+ /** Arguments for {@link prepareDotNsRegistration}. */
359
+ interface RegisterDotNsArgs {
360
+ /** The name to register, e.g. `"alice.paseo"` — or the bare label `"alice"`. */
361
+ name: string;
362
+ /**
363
+ * The account that will own the registered name: an H160, `0x` and 20
364
+ * bytes. Not SS58 — DotNS is a set of Revive contracts, and the registrar
365
+ * takes the owner as an ABI `address`. Convert with `ss58ToH160` from
366
+ * `@parity/product-sdk-address` if you hold a Substrate-shaped address.
367
+ *
368
+ * Typed `string` rather than `` `0x${string}` `` so callers need no cast,
369
+ * which means the compiler will not catch an SS58 address here: it reaches
370
+ * the contract and reverts on chain.
371
+ */
372
+ owner: string;
373
+ /** Reserved-name registration (default `false`). */
374
+ reserved?: boolean;
375
+ }
376
+ /** Arguments for {@link setDotNsRecord}. */
377
+ interface SetRecordArgs {
378
+ /** The name whose resolver record is being set. */
379
+ name: string;
380
+ /**
381
+ * The address the name should resolve to: an H160, `0x` and 20 bytes. It is
382
+ * written straight into `resolver.setAddress` as an ABI `address`, so SS58
383
+ * is not accepted — convert with `ss58ToH160` from
384
+ * `@parity/product-sdk-address` first. Unenforced by the type, as with
385
+ * {@link RegisterDotNsArgs.owner}.
386
+ */
387
+ address: string;
388
+ }
389
+ /**
390
+ * Resolve a DotNS name. `expiresAt` is omitted (no on-chain expiry here).
391
+ *
392
+ * Three outcomes, because the registry's resolver pointer is configuration, not
393
+ * proof of existence:
394
+ *
395
+ * - `ok(null)` — unregistered (`registry.owner` is zero).
396
+ * - `ok({ name, owner })` — registered, no forward record yet.
397
+ * - `ok({ name, owner, address })` — resolves.
398
+ */
399
+ declare function resolveDotNs(name: string, opts: DotNsClientOptions): Promise<Result<DotNsRecord | null, DotNsError>>;
400
+ /**
401
+ * Reverse-resolve an account to its primary DotNS name.
402
+ *
403
+ * Single call: `reverseResolver.nameOf(account)`. `ok(null)` when no primary
404
+ * name is set (empty string on-chain).
405
+ */
406
+ declare function reverseDotNs(address: string, opts: DotNsClientOptions): Promise<Result<string | null, DotNsError>>;
407
+ /**
408
+ * Whether a DotNS name is available to claim.
409
+ *
410
+ * Two reads, because "not minted" and "claimable" are different questions:
411
+ *
412
+ * - `registrarController.available(label)`, the predicate `register` enforces
413
+ * through `_requireAvailableLabel`. Deliberately not inferred from
414
+ * resolution: a registered name has no forward record until its owner sets
415
+ * one, so that would report owned names as free.
416
+ * - `PopRules.classifyName(label)`, which is pure and owner-independent.
417
+ * Labels of 5 base characters or fewer are reserved for governance and can
418
+ * never be claimed, though the registrar still reports them as unminted.
419
+ *
420
+ * `ok(true)` means the name can be registered by someone. It does not mean the
421
+ * caller can register it: labels of 6 to 8 characters additionally require a
422
+ * personhood tier, which depends on the owner and is checked by
423
+ * {@link prepareDotNsRegistration}.
424
+ *
425
+ * Validated first because both reads revert on labels we already reject.
426
+ */
427
+ declare function isDotNsAvailable(name: string, opts: DotNsClientOptions): Promise<Result<boolean, DotNsError>>;
428
+ /**
429
+ * Prepare the calls binding a name to an address. Submit them in order with the
430
+ * owner's signer via `batchSubmitAndWatch`; both are owner-gated.
431
+ *
432
+ * Returns two calls when the node still points at the reverse resolver (the
433
+ * post-registration default): `registry.setResolver` first, or the record
434
+ * written by `setAddress` is real but unreadable. One call once it is pointed.
435
+ */
436
+ declare function setDotNsRecord(args: SetRecordArgs, opts: DotNsClientOptions): Promise<Result<BatchableCall[], DotNsError>>;
437
+ /** The prepared pieces of a DotNS registration. */
438
+ interface DotNsRegistration {
439
+ /** The random secret bound into both commit and register. */
440
+ secret: HexString;
441
+ /** The commitment hash (also encoded inside `commitCall`). */
442
+ commitment: HexString;
443
+ /** Submit first, with the owner's signer. */
444
+ commitCall: BatchableCall;
445
+ /** Seconds to wait after `commit` before `register` is accepted. */
446
+ minCommitmentAge: bigint;
447
+ /** Seconds after which the commitment expires and `register` is rejected. */
448
+ maxCommitmentAge: bigint;
449
+ /** Quote at prepare time, for display. The submitted value is re-read below. */
450
+ price: bigint;
451
+ /**
452
+ * Build the register call, once `minCommitmentAge` has elapsed.
453
+ *
454
+ * Deferred rather than returned up front: `register` consumes the
455
+ * commitment, so dry-running it before `commitCall` lands reverts with
456
+ * `CommitmentNotFound` and no call could be built at all. Deferring also
457
+ * prices and sizes it against the state it will actually execute in.
458
+ */
459
+ prepareRegisterCall: () => Promise<Result<BatchableCall, DotNsError>>;
460
+ }
461
+ /**
462
+ * Prepare a DotNS registration: the commit call, the shared secret, the timing
463
+ * window, and a thunk that builds the register call afterwards.
464
+ *
465
+ * 1. submit `commitCall`
466
+ * 2. wait `minCommitmentAge`, and register before `maxCommitmentAge`
467
+ * 3. `await prepareRegisterCall()`, then submit what it returns
468
+ *
469
+ * Eligibility is checked here, before the caller pays for the commit: a
470
+ * governance-reserved label, or an owner below the tier the label requires,
471
+ * fails now rather than on the second transaction.
472
+ */
473
+ declare function prepareDotNsRegistration(args: RegisterDotNsArgs, opts: DotNsClientOptions): Promise<Result<DotNsRegistration, DotNsError>>;
474
+
475
+ /**
476
+ * Minimal ABIs for the DotNS contracts: the read and write methods this module
477
+ * calls, and nothing else. Sourced from `paritytech/dotns` (`contracts/registry`,
478
+ * `contracts/resolvers`, `contracts/registrars`, `contracts/pop`).
479
+ */
480
+
481
+ /** `IPopRules.PopStatus`. Ordering is meaningful: a user meets a tier when `userStatus >= status`. */
482
+ declare const POP_STATUS: {
483
+ readonly NoStatus: 0;
484
+ readonly PopLite: 1;
485
+ readonly PopFull: 2;
486
+ readonly Reserved: 3;
487
+ };
488
+ /**
489
+ * The deployed DotNS addresses. The same on every network.
490
+ *
491
+ * Not a per-network table, despite what the old name (`PASEO_ASSETHUB_DOTNS`)
492
+ * implied: every DotNS network is deployed through the same CREATE3 factory, so
493
+ * the addresses are identical everywhere and **only the TLD differs**, `.paseo`
494
+ * on Paseo Asset Hub Next V2 and `.test` on Previewnet. Verified on both:
495
+ * `protocolRegistry.get(...)` returns the same registry on each, and all six
496
+ * addresses hold contracts on both. `paritytech/dotns` `DEPLOYMENTS.md` states the mechanism, and
497
+ * `preview-net-v1` confirms it from the deploy side: the TLD is passed only as
498
+ * registry init calldata, so it moves no address.
499
+ *
500
+ * So extending this module to another network means resolving its TLD, which
501
+ * `resolveTld` already does — not adding a second address table.
49
502
  *
50
- * @deprecated Recomputes {@link deriveContextAlias} from two public values and
51
- * compares the result, so it confirms a derivation relationship and nothing
52
- * more. No secret enters the operation at any point, which means there is
53
- * nothing here to authenticate: a passing result does not show that anyone
54
- * controls either account. Removal: `@parity/product-sdk` 0.23.0.
503
+ * Five answer `DotnsProtocolRegistry.get(bytes32)` under the keys in
504
+ * `DOTNS_REGISTRY_KEYS`, two of which differ from the field name used here.
505
+ * `protocolRegistry` has no key and comes from the gateway walk. All six have a
506
+ * `Revive.AccountInfoOf` entry.
55
507
  *
56
- * @param aliasAddress - Context alias SS58 address
57
- * @param parentAddress - Claimed parent address
58
- * @param context - Context string used for derivation
59
- * @returns True if derivation is valid
508
+ * Pinned, not resolved at runtime: re-verify after a redeploy, or have the
509
+ * client do it with `verifyDotNsAddresses`.
60
510
  */
61
- declare function verifyContextAlias(aliasAddress: string, parentAddress: string, context: string): boolean;
511
+ declare const DOTNS_ADDRESSES: {
512
+ readonly registry: "0xf34054fd76BbF85f216cf9908226D5f0A72E50CA";
513
+ readonly reverseResolver: "0xee3883d7eB60Ee9BCD7F3bcD8f2f05302A9Cc035";
514
+ readonly resolver: "0xbd1165E549DF96F083c0A16f61590927bC187009";
515
+ readonly registrarController: "0xBdaA01bD1bA67d709F2b1fF286Da0d854977EA30";
516
+ readonly popRules: "0x747B456bE03aec0b42bd85C51513730FBD45DA31";
517
+ readonly protocolRegistry: "0xD19e3D0C97CF501125a04A97405e3e6592fa846E";
518
+ };
62
519
 
63
- export { ContextAliasInfo, deriveContextAlias, verifyContextAlias };
520
+ export { DOTNS_ADDRESSES, DOTNS_REGISTRY_KEYS, DOT_NODE, DOT_TLD, type DotNsAddresses, type DotNsClientOptions, DotNsError, type DotNsErrorReason, type DotNsGatewayQueryApi, type DotNsRecord, type DotNsRegistration, type DotNsTld, type OnChainIdentity, POP_STATUS, type RegisterDotNsArgs, type SetRecordArgs, type VerificationResult, discoverDotNsAddresses, dotNsTld, isConsistentDotNsTld, isDotNsAvailable, namehash, prepareDotNsRegistration, resolveDotNs, resolveDotNsAddresses, reverseDotNs, setDotNsRecord, stripSuffix, verifyDotNsAddresses };