@libid/contracts 0.13.1 → 0.15.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 (72) hide show
  1. package/README.md +53 -32
  2. package/dist/abis/handleEscrow.d.ts +632 -0
  3. package/dist/abis/handleEscrow.d.ts.map +1 -0
  4. package/dist/abis/handleEscrow.js +815 -0
  5. package/dist/abis/handleEscrow.js.map +1 -0
  6. package/dist/abis/handleResolver.d.ts +1 -1
  7. package/dist/abis/handleResolver.js +1 -1
  8. package/dist/abis/handleResolver.js.map +1 -1
  9. package/dist/abis/{identityNames.d.ts → identityRegistry.d.ts} +251 -105
  10. package/dist/abis/{identityNames.d.ts.map → identityRegistry.d.ts.map} +1 -1
  11. package/dist/abis/{identityNames.js → identityRegistry.js} +312 -118
  12. package/dist/abis/identityRegistry.js.map +1 -0
  13. package/dist/abis/index.d.ts +2 -1
  14. package/dist/abis/index.d.ts.map +1 -1
  15. package/dist/abis/index.js +2 -1
  16. package/dist/abis/index.js.map +1 -1
  17. package/dist/calls/handleEscrow.d.ts +15 -0
  18. package/dist/calls/handleEscrow.d.ts.map +1 -0
  19. package/dist/calls/handleEscrow.js +49 -0
  20. package/dist/calls/handleEscrow.js.map +1 -0
  21. package/dist/calls/identityRegistry.d.ts +16 -0
  22. package/dist/calls/identityRegistry.d.ts.map +1 -0
  23. package/dist/calls/identityRegistry.js +55 -0
  24. package/dist/calls/identityRegistry.js.map +1 -0
  25. package/dist/calls/index.d.ts +2 -1
  26. package/dist/calls/index.d.ts.map +1 -1
  27. package/dist/calls/index.js +2 -1
  28. package/dist/calls/index.js.map +1 -1
  29. package/dist/ceremony/profiles.d.ts +34 -2
  30. package/dist/ceremony/profiles.d.ts.map +1 -1
  31. package/dist/ceremony/profiles.js +52 -2
  32. package/dist/ceremony/profiles.js.map +1 -1
  33. package/dist/identity/handle.d.ts +1 -1
  34. package/dist/identity/handle.d.ts.map +1 -1
  35. package/dist/identity/handle.js +12 -9
  36. package/dist/identity/handle.js.map +1 -1
  37. package/dist/identity/handleVectors.d.ts +3 -6
  38. package/dist/identity/handleVectors.d.ts.map +1 -1
  39. package/dist/identity/handleVectors.js +3 -13
  40. package/dist/identity/handleVectors.js.map +1 -1
  41. package/dist/identity/index.d.ts +1 -0
  42. package/dist/identity/index.d.ts.map +1 -1
  43. package/dist/identity/index.js +2 -1
  44. package/dist/identity/index.js.map +1 -1
  45. package/dist/identity/node.d.ts +5 -0
  46. package/dist/identity/node.d.ts.map +1 -0
  47. package/dist/identity/node.js +19 -0
  48. package/dist/identity/node.js.map +1 -0
  49. package/dist/identity/resolve.d.ts +19 -9
  50. package/dist/identity/resolve.d.ts.map +1 -1
  51. package/dist/identity/resolve.js +76 -47
  52. package/dist/identity/resolve.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/abis/handleEscrow.ts +817 -0
  55. package/src/abis/handleResolver.ts +1 -1
  56. package/src/abis/{identityNames.ts → identityRegistry.ts} +311 -117
  57. package/src/abis/index.ts +2 -1
  58. package/src/calls/handleEscrow.ts +78 -0
  59. package/src/calls/identityRegistry.ts +91 -0
  60. package/src/calls/index.ts +2 -1
  61. package/src/ceremony/profiles.ts +55 -2
  62. package/src/identity/handle.ts +14 -8
  63. package/src/identity/handleVectors.ts +3 -14
  64. package/src/identity/index.ts +2 -1
  65. package/src/identity/node.ts +28 -0
  66. package/src/identity/resolve.ts +127 -69
  67. package/dist/abis/identityNames.js.map +0 -1
  68. package/dist/calls/identityNames.d.ts +0 -16
  69. package/dist/calls/identityNames.d.ts.map +0 -1
  70. package/dist/calls/identityNames.js +0 -55
  71. package/dist/calls/identityNames.js.map +0 -1
  72. package/src/calls/identityNames.ts +0 -88
@@ -1,7 +1,7 @@
1
1
  /// The wallet-agnostic identity system, TypeScript half.
2
2
  ///
3
3
  /// Handle normalization mirrors the on-chain normalizer byte for byte, and the
4
- /// resolvers wrap the `IdentityNames` view calls. Everything on-chain-shaped
4
+ /// resolvers wrap the `IdentityRegistry` view calls. Everything on-chain-shaped
5
5
  /// comes from the generated ABIs in `../abis`, so this layer and the contracts
6
6
  /// cannot drift apart silently.
7
7
  ///
@@ -9,5 +9,6 @@
9
9
  /// hand-written builder here until every write function got one.
10
10
  export * from './handle.js';
11
11
  export * from './handleVectors.js';
12
+ export * from './node.js';
12
13
  export * from './resolve.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,GAAG;AACH,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,gCAAgC;AAChC,GAAG;AACH,+EAA+E;AAC/E,iEAAiE;AAEjE,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,GAAG;AACH,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,gCAAgC;AAChC,GAAG;AACH,+EAA+E;AAC/E,iEAAiE;AAEjE,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { type Hex } from 'viem';
2
+ import { type Rules } from './handle.js';
3
+ export declare function handleHash(raw: string, rules: Rules): Hex;
4
+ export declare function handleNode(platformId: Hex, hash: Hex): Hex;
5
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/identity/node.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,GAAG,EAAoB,MAAM,MAAM,CAAA;AAEtE,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAMnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG,CAEzD;AAKD,wBAAgB,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,CAO1D"}
@@ -0,0 +1,19 @@
1
+ /// Handle hashes and nodes, mirroring `IdentityRegistry.handleHashOf` and
2
+ /// `handleNodeOfHash`, computed locally so the handle text never reaches an
3
+ /// RPC. `HandleEscrow.deposit` takes the hash; `handleBinding` and the
4
+ /// escrow's reads take the node.
5
+ import { encodeAbiParameters, keccak256, toHex } from 'viem';
6
+ import { normalize } from './handle.js';
7
+ const HANDLE_NODE_V1 = keccak256(toHex('libid.identity.handle-node.v1'));
8
+ /// `keccak256` of `raw` normalized under `rules` (from `rulesOf`, or
9
+ /// `rulesFor` offline). Throws `HandleError` for text the rules refuse.
10
+ export function handleHash(raw, rules) {
11
+ return keccak256(toHex(normalize(raw, rules)));
12
+ }
13
+ /// The node a handle hash sits on, on the platform `platformId` names
14
+ /// (`platformId(PLATFORM_X_KEY)`), as `IdentityRegistry.handleNodeOfHash` derives
15
+ /// it.
16
+ export function handleNode(platformId, hash) {
17
+ return keccak256(encodeAbiParameters([{ type: 'bytes32' }, { type: 'bytes32' }, { type: 'bytes32' }], [HANDLE_NODE_V1, platformId, hash]));
18
+ }
19
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/identity/node.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE;AACvE,iCAAiC;AAEjC,OAAO,EAAE,mBAAmB,EAAY,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAc,MAAM,aAAa,CAAA;AAEnD,MAAM,cAAc,GAAQ,SAAS,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAA;AAE7E,qEAAqE;AACrE,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,KAAY;IAClD,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC;AAED,sEAAsE;AACtE,kFAAkF;AAClF,OAAO;AACP,MAAM,UAAU,UAAU,CAAC,UAAe,EAAE,IAAS;IACnD,OAAO,SAAS,CACd,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,CAAC,CACnC,CACF,CAAA;AACH,CAAC"}
@@ -1,16 +1,26 @@
1
1
  import { type Address, type PublicClient } from 'viem';
2
- export declare function platformId(domain: string): `0x${string}`;
3
- export interface NamesReader {
2
+ import type { Rules } from './handle.js';
3
+ export type PlatformKey<K extends string> = K extends `0x${string}` ? never : K;
4
+ export declare function platformId<K extends string>(platformKey: PlatformKey<K>): `0x${string}`;
5
+ export interface RegistryReader {
4
6
  client: PublicClient;
5
7
  address: Address;
6
8
  }
7
- export declare function resolveId(reader: NamesReader, platform: `0x${string}`, userId: string): Promise<Address | null>;
8
- export declare function resolveHandle(reader: NamesReader, platform: `0x${string}`, handle: string): Promise<Address | null>;
9
- export declare function reverseOf(reader: NamesReader, wallet: Address, platform: `0x${string}`): Promise<string | null>;
10
- export declare function primaryName(reader: NamesReader, wallet: Address, platform: `0x${string}`): Promise<string | null>;
11
- export interface PairResolution {
12
- wallet: Address | null;
9
+ export declare function rulesOf(reader: RegistryReader, platformId: `0x${string}`): Promise<Rules>;
10
+ export declare function resolveId(reader: RegistryReader, platformId: `0x${string}`, id: string): Promise<Address | null>;
11
+ export declare function resolveHandle(reader: RegistryReader, platformId: `0x${string}`, handle: string): Promise<Address | null>;
12
+ export declare function publishedHandleOf(reader: RegistryReader, holder: Address, platformId: `0x${string}`): Promise<string | null>;
13
+ export interface HandleAndIdResolution {
14
+ holder: Address | null;
13
15
  idAgrees: boolean;
14
16
  }
15
- export declare function resolvePair(reader: NamesReader, platform: `0x${string}`, handle: string, userId: string): Promise<PairResolution>;
17
+ export declare function resolveHandleAndId(reader: RegistryReader, platformId: `0x${string}`, handle: string, id: string): Promise<HandleAndIdResolution>;
18
+ export interface Identity {
19
+ platformId: `0x${string}`;
20
+ id: string;
21
+ handle: string;
22
+ handleCurrent: boolean;
23
+ }
24
+ export declare function identityCount(reader: RegistryReader, holder: Address): Promise<bigint>;
25
+ export declare function identitiesOf(reader: RegistryReader, holder: Address, from: bigint, limit: bigint): Promise<Identity[]>;
16
26
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/identity/resolve.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,OAAO,EAAa,KAAK,YAAY,EAAsB,MAAM,MAAM,CAAA;AAMrF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAExD;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAA;IAEpB,OAAO,EAAE,OAAO,CAAA;CACjB;AAuBD,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,KAAK,MAAM,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAGzB;AAaD,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,KAAK,MAAM,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAGzB;AAMD,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,KAAK,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAQ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,wBAAsB,aAAa,CACjC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAGzB;AAQD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,KAAK,MAAM,EAAE,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED,MAAM,WAAW,qBAAqB;IAEpC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IAMtB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAeD,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,qBAAqB,CAAC,CAQhC;AAGD,MAAM,WAAW,QAAQ;IAEvB,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;IAEzB,EAAE,EAAE,MAAM,CAAA;IAEV,MAAM,EAAE,MAAM,CAAA;IAMd,aAAa,EAAE,OAAO,CAAA;CACvB;AAGD,wBAAsB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5F;AAaD,wBAAsB,YAAY,CAChC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,QAAQ,EAAE,CAAC,CAQrB"}
@@ -1,18 +1,18 @@
1
- /// Reading names from the chain.
1
+ /// Reading identities from the chain.
2
2
  ///
3
- /// Everything here is a view call. Claiming a name needs a ceremony payload and a
4
- /// wallet; reading one needs neither, which is the point — any product can
5
- /// resolve a name without touching the ceremony that created it.
3
+ /// Everything here is a view call. Binding an identity needs a ceremony payload
4
+ /// and a wallet; reading one needs neither, which is the point — any product
5
+ /// can resolve a handle without touching the ceremony that bound it.
6
6
  ///
7
7
  /// The client and the contract address are arguments rather than imports. This
8
8
  /// package ships separately from the repository it currently lives in, so it
9
9
  /// carries no configuration of its own and reaches for nothing outside itself.
10
10
  import { keccak256, toHex, zeroAddress } from 'viem';
11
- import { identityNamesAbi } from '../abis/identityNames.js';
12
- /// A platform id is `keccak256` of its domain string. The domains are generated
11
+ import { identityRegistryAbi } from '../abis/identityRegistry.js';
12
+ /// A platform id is `keccak256` of its platform key. The keys are generated
13
13
  /// from `handles.json`, so this and the contract agree by construction.
14
- export function platformId(domain) {
15
- return keccak256(toHex(domain));
14
+ export function platformId(platformKey) {
15
+ return keccak256(toHex(platformKey));
16
16
  }
17
17
  /// One view call.
18
18
  ///
@@ -24,67 +24,96 @@ function read(reader, functionName, args) {
24
24
  return reader.client.readContract({
25
25
  authorizationList: undefined,
26
26
  address: reader.address,
27
- abi: identityNamesAbi,
27
+ abi: identityRegistryAbi,
28
28
  functionName,
29
29
  args,
30
30
  });
31
31
  }
32
- /// The wallet that proved this account id, or `null`.
33
- export async function resolveId(reader, platform, userId) {
34
- const owner = await read(reader, 'resolveId', [platform, userId]);
35
- return owner === zeroAddress ? null : owner;
32
+ /// The platform's normalization rules as configured on chain now
33
+ /// (`IdentityRegistry.rulesOf`).
34
+ export async function rulesOf(reader, platformId) {
35
+ const rules = await read(reader, 'rulesOf', [platformId]);
36
+ return {
37
+ maxLength: Number(rules.maxLength),
38
+ stripLeadingAt: rules.stripLeadingAt,
39
+ isEmail: rules.isEmail,
40
+ allowUnderscore: rules.allowUnderscore,
41
+ allowHyphen: rules.allowHyphen,
42
+ };
36
43
  }
37
- /// The wallet that last proved this handle, or `null`.
44
+ /// The holder that proved this id, or `null`.
45
+ export async function resolveId(reader, platformId, id) {
46
+ const holder = await read(reader, 'resolveId', [platformId, id]);
47
+ return holder === zeroAddress ? null : holder;
48
+ }
49
+ /// The holder that last proved this handle, or `null`.
38
50
  ///
39
51
  /// The handle is normalized on chain before it is looked up, so a caller may
40
- /// pass what a user typed — including something that is not a handle at all.
41
- /// The contract is total in the handle: a string no platform could hold answers
42
- /// the zero address, which is the same answer as a handle nobody has proved,
43
- /// and the one a search box wants.
52
+ /// pass what was typed — including something that is not a handle at all.
53
+ /// The contract is total in the handle: a string the platform's rules refuse
54
+ /// answers the zero address, which is the same answer as a handle nobody has
55
+ /// proved, and the one a search box wants.
44
56
  ///
45
57
  /// A revert propagates. `UnknownPlatform` in particular means the platform is
46
- /// not configured, and answering "unowned" would bury a deployment mistake
58
+ /// not configured, and answering "unbound" would bury a deployment mistake
47
59
  /// under a plausible result.
48
- export async function resolveHandle(reader, platform, handle) {
49
- const owner = await read(reader, 'resolveHandle', [platform, handle]);
50
- return owner === zeroAddress ? null : owner;
51
- }
52
- /// The handle a wallet published, exactly as stored.
53
- ///
54
- /// It may be stale: it says what the wallet proved once, not what the handle
55
- /// resolves to now. Use `primaryName` to display one.
56
- export async function reverseOf(reader, wallet, platform) {
57
- const name = await read(reader, 'reverseOf', [wallet, platform]);
58
- return name.length === 0 ? null : name;
60
+ export async function resolveHandle(reader, platformId, handle) {
61
+ const holder = await read(reader, 'resolveHandle', [platformId, handle]);
62
+ return holder === zeroAddress ? null : holder;
59
63
  }
60
- /// The handle to show for a wallet, or `null`.
64
+ /// The handle to show for a holder, or `null`.
61
65
  ///
62
66
  /// Forward-checked on chain: empty once the stored handle resolves somewhere
63
67
  /// else. ENS asks integrators to perform that check themselves and warns that
64
- /// skipping it displays a name its holder no longer owns; here it cannot be
65
- /// skipped, because the contract does it.
66
- export async function primaryName(reader, wallet, platform) {
67
- const name = await read(reader, 'primaryOf', [wallet, platform]);
68
- return name.length === 0 ? null : name;
68
+ /// skipping it displays an ENS primary name that no longer resolves back; here
69
+ /// it cannot be skipped, because the contract does it.
70
+ export async function publishedHandleOf(reader, holder, platformId) {
71
+ const handle = await read(reader, 'publishedHandleOf', [holder, platformId]);
72
+ return handle.length === 0 ? null : handle;
69
73
  }
70
- /// Resolve a handle and report whether an account id still agrees with it.
74
+ /// Resolve a handle and report whether an id still agrees with it.
71
75
  ///
72
- /// **Read this before signing, and do not let it block a transfer.** A name
73
- /// that will not route is not a name: sending to a handle means sending to
76
+ /// **Read this before signing, and do not let it block a transfer.** A handle
77
+ /// that will not route is not a handle: sending to a handle means sending to
74
78
  /// whoever proved it last, which is what the handle now means. What the flag is
75
- /// for is telling a user that the account they think they are paying is not the
76
- /// one that holds the name today — a decision they can only make beforehand.
79
+ /// for is telling whoever is paying that the identity they think they are
80
+ /// paying is not the one that has the handle today — a decision they can only
81
+ /// make beforehand.
77
82
  ///
78
83
  /// Both halves are needed. A handle on its own has nothing to disagree with.
79
84
  ///
80
- /// A handle the platform's rules reject resolves to `{wallet: null, idAgrees:
85
+ /// A handle the platform's rules reject resolves to `{holder: null, idAgrees:
81
86
  /// false}`, the same as one nobody has proved — see `resolveHandle`.
82
- export async function resolvePair(reader, platform, handle, userId) {
83
- const [wallet, idAgrees] = await read(reader, 'resolvePair', [
84
- platform,
87
+ export async function resolveHandleAndId(reader, platformId, handle, id) {
88
+ const [holder, idAgrees] = await read(reader, 'resolveHandleAndId', [
89
+ platformId,
85
90
  handle,
86
- userId,
91
+ id,
87
92
  ]);
88
- return { wallet: wallet === zeroAddress ? null : wallet, idAgrees };
93
+ return { holder: holder === zeroAddress ? null : holder, idAgrees };
94
+ }
95
+ /// How many identities a holder has, on every platform together.
96
+ export async function identityCount(reader, holder) {
97
+ return read(reader, 'identityCount', [holder]);
98
+ }
99
+ /// A page of a holder's identities, on every platform together:
100
+ /// the indices `[from, from + limit)` of its list, counted from zero and
101
+ /// clipped to the list. A `from` past the end answers an empty page. A reader
102
+ /// that wants one platform filters a page by `platformId`.
103
+ ///
104
+ /// Order is arbitrary and changes when an identity leaves the list, so two
105
+ /// pages read across a removal may overlap or skip. A reader that needs every
106
+ /// identity reads `identityCount` and the pages against one block.
107
+ ///
108
+ /// A list is as long as its holder made it, and a call's gas is not. A caller
109
+ /// enumerating a holder it did not choose keeps `limit` small and pages.
110
+ export async function identitiesOf(reader, holder, from, limit) {
111
+ const page = await read(reader, 'identitiesOf', [holder, from, limit]);
112
+ return page.map(({ platformId, id, handle, handleCurrent }) => ({
113
+ platformId,
114
+ id,
115
+ handle,
116
+ handleCurrent,
117
+ }));
89
118
  }
90
119
  //# sourceMappingURL=resolve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/identity/resolve.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,GAAG;AACH,kFAAkF;AAClF,2EAA2E;AAC3E,iEAAiE;AACjE,GAAG;AACH,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAE/E,OAAO,EAAgB,SAAS,EAAqB,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAErF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,gFAAgF;AAChF,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AACjC,CAAC;AAQD,kBAAkB;AAClB,GAAG;AACH,gDAAgD;AAChD,mEAAmE;AACnE,0EAA0E;AAC1E,kDAAkD;AAClD,SAAS,IAAI,CAAI,MAAmB,EAAE,YAAoB,EAAE,IAAwB;IAClF,OACE,MAAM,CAAC,MAGR,CAAC,YAAY,CAAC;QACb,iBAAiB,EAAE,SAAS;QAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,GAAG,EAAE,gBAAgB;QACrB,YAAY;QACZ,IAAI;KACL,CAAC,CAAA;AACJ,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAmB,EACnB,QAAuB,EACvB,MAAc;IAEd,MAAM,KAAK,GAAG,MAAM,IAAI,CAAU,MAAM,EAAE,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM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C9E,2DAA2D;AAC3D,GAAG;AACH,2EAA2E;AAC3E,8EAA8E;AAC9E,mEAAmE;AACnE,GAAG;AACH,8EAA8E;AAC9E,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAsB,EACtB,MAAe,EACf,IAAY,EACZ,KAAa;IAEb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAsB,MAAM,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3F,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9D,UAAU;QACV,EAAE;QACF,MAAM;QACN,aAAa;KACd,CAAC,CAAC,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@libid/contracts",
3
- "version": "0.13.1",
4
- "description": "Typed viem-ready ABIs and call builders for the libid contracts, plus the identity helper layer (handle normalization, name resolution).",
3
+ "version": "0.15.0",
4
+ "description": "Typed viem-ready ABIs and call builders for the libid contracts, plus the identity helper layer (handle normalization, handle resolution).",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "repository": {
7
7
  "type": "git",