@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
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @libid/contracts
2
2
 
3
3
  Typed, viem-ready ABIs for the libid identity stack (NotaryService,
4
- CeremonyProofVerifier, GoogleJwtRoots, IdentityNames, LibidFactory, WTIA9), a
4
+ CeremonyProofVerifier, GoogleJwtRoots, IdentityRegistry, LibidFactory, WTIA9), a
5
5
  call builder for every state-changing function, and the identity helper layer:
6
- handle normalization and name resolution.
6
+ handle normalization and resolution.
7
7
 
8
8
  Both `src/abis/` and `src/calls/` are generated from the forge artifacts
9
9
  (`solidity/out`) by `scripts/codegen.mjs`, and neither is committed — CI
@@ -23,14 +23,14 @@ pnpm add @libid/contracts viem
23
23
 
24
24
  ```ts
25
25
  import { createPublicClient, http } from 'viem'
26
- import { googleJwtRootsAbi, identityNamesAbi } from '@libid/contracts/abis'
26
+ import { googleJwtRootsAbi, identityRegistryAbi } from '@libid/contracts/abis'
27
27
 
28
28
  const client = createPublicClient({ transport: http(RPC_URL) })
29
29
 
30
30
  // Fully typed: viem infers the argument and return types from the ABI.
31
- const owner = await client.readContract({
32
- address: IDENTITY_NAMES,
33
- abi: identityNamesAbi,
31
+ const holder = await client.readContract({
32
+ address: IDENTITY_REGISTRY,
33
+ abi: identityRegistryAbi,
34
34
  functionName: 'resolveHandle',
35
35
  args: [platformId, 'alice'],
36
36
  })
@@ -45,15 +45,15 @@ const [current, previous] = await client.readContract({
45
45
 
46
46
  ## Building a call
47
47
 
48
- One builder per state-changing function, namespaced by contract because names
49
- like `initialize` are on almost all of them. A builder returns the call as
50
- data — no provider, no signer — so you decide how it is submitted: directly,
51
- batched, or through a smart account's `execute`.
48
+ One builder per state-changing function, namespaced by contract because
49
+ function names like `initialize` are on almost all of them. A builder returns
50
+ the call as data — no provider, no signer — so you decide how it is submitted:
51
+ directly, batched, or through a smart wallet's `execute`.
52
52
 
53
53
  ```ts
54
54
  import { calls } from '@libid/contracts/calls'
55
55
 
56
- const call = calls.identityNames.unpublish(names, platformId)
56
+ const call = calls.identityRegistry.unpublish(IDENTITY_REGISTRY, platformId)
57
57
  // { to: `0x…`, data: `0x…` }
58
58
 
59
59
  await wallet.sendTransaction(call)
@@ -69,48 +69,57 @@ const rotate = calls.googleJwtRoots.rotate(roots, fee, attestedData, proof)
69
69
  // { to: `0x…`, value: fee, data: `0x…` }
70
70
  ```
71
71
 
72
- ## Resolving a name
72
+ ## Resolving a handle
73
73
 
74
74
  ```ts
75
75
  import {
76
+ identitiesOf,
77
+ identityCount,
76
78
  platformId,
79
+ publishedHandleOf,
77
80
  resolveHandle,
78
- resolvePair,
79
- primaryName,
80
- PLATFORM_X_DOMAIN,
81
+ resolveHandleAndId,
82
+ PLATFORM_X_KEY,
81
83
  } from '@libid/contracts/identity'
82
84
 
83
- const reader = { client, address: IDENTITY_NAMES }
84
- const x = platformId(PLATFORM_X_DOMAIN)
85
+ const reader = { client, address: IDENTITY_REGISTRY }
86
+ const x = platformId(PLATFORM_X_KEY)
85
87
 
86
- // The wallet that last proved a handle, or null. Pass what the user typed —
88
+ // The holder that last proved a handle, or null. Pass what was typed —
87
89
  // normalization happens on chain.
88
- const owner = await resolveHandle(reader, x, '@Alice')
90
+ const holder = await resolveHandle(reader, x, '@Alice')
89
91
 
90
- // Before sending funds: does the account id still agree with the handle?
91
- const { wallet, idAgrees } = await resolvePair(reader, x, 'alice', '42')
92
+ // Before sending funds: does the id still agree with the handle?
93
+ const { idAgrees } = await resolveHandleAndId(reader, x, 'alice', '42')
92
94
 
93
- // The display name for a wallet, forward-checked on chain.
94
- const name = await primaryName(reader, wallet!, x)
95
+ // The handle a holder displays, forward-checked on chain.
96
+ const handle = await publishedHandleOf(reader, holder!, x)
97
+
98
+ // Every identity the holder proved, on every platform, a page at a time.
99
+ // Order is arbitrary, and a page read across a removal may overlap or skip:
100
+ // read the count and the pages against one block when every identity matters.
101
+ const total = await identityCount(reader, holder!)
102
+ const identities = await identitiesOf(reader, holder!, 0n, 50n)
103
+ // [{ platformId: x, id: '42', handle: 'alice', handleCurrent: true }, …]
95
104
  ```
96
105
 
97
- ## Claiming a name
106
+ ## Binding an identity
98
107
 
99
- A claim is one of the generated builders: the platform, this chain's verifier
108
+ A binding is one of the generated builders: the platform, this chain's verifier
100
109
  version for it, the opaque payload the ceremony produced, and whether to
101
- publish the name. The value is what `quoteClaim` returns for the same pair.
102
- An EOA sends it directly, a smart account wraps it in its own execute:
110
+ publish the handle. The value is what `quoteBind` returns for the same pair.
111
+ An EOA sends it directly, a smart wallet wraps it in its own execute:
103
112
 
104
113
  ```ts
105
114
  import { calls } from '@libid/contracts/calls'
106
115
 
107
116
  const fee = await client.readContract({
108
- address: IDENTITY_NAMES,
109
- abi: identityNamesAbi,
110
- functionName: 'quoteClaim',
111
- args: [platformId(PLATFORM_GITHUB_DOMAIN), 1],
117
+ address: IDENTITY_REGISTRY,
118
+ abi: identityRegistryAbi,
119
+ functionName: 'quoteBind',
120
+ args: [platformId(PLATFORM_GITHUB_KEY), 1],
112
121
  })
113
- const call = calls.identityNames.claim(IDENTITY_NAMES, fee, platformId(PLATFORM_GITHUB_DOMAIN), 1, payload, true)
122
+ const call = calls.identityRegistry.bind(IDENTITY_REGISTRY, fee, platformId(PLATFORM_GITHUB_KEY), 1, payload, true)
114
123
  // call = { to, value, data } — sign and send from the address the payload names.
115
124
  ```
116
125
 
@@ -123,6 +132,18 @@ normalize(' @Alice_1 ', RULES_X) // 'alice_1'
123
132
  // Throws HandleError (with a kind matching the on-chain error) on refusal.
124
133
  ```
125
134
 
135
+ ## Deriving a handle node
136
+
137
+ Hash locally, so the handle text never reaches an RPC:
138
+
139
+ ```ts
140
+ import { handleHash, handleNode, platformId, PLATFORM_GOOGLE_KEY, rulesOf } from '@libid/contracts/identity'
141
+
142
+ const google = platformId(PLATFORM_GOOGLE_KEY)
143
+ const hash = handleHash('Alice@Gmail.com', await rulesOf(reader, google)) // HandleEscrow.deposit
144
+ const node = handleNode(google, hash) // handleBinding, escrowed, claim, refund
145
+ ```
146
+
126
147
  ## Development
127
148
 
128
149
  ```sh