@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.
- package/README.md +53 -32
- package/dist/abis/handleEscrow.d.ts +632 -0
- package/dist/abis/handleEscrow.d.ts.map +1 -0
- package/dist/abis/handleEscrow.js +815 -0
- package/dist/abis/handleEscrow.js.map +1 -0
- package/dist/abis/handleResolver.d.ts +1 -1
- package/dist/abis/handleResolver.js +1 -1
- package/dist/abis/handleResolver.js.map +1 -1
- package/dist/abis/{identityNames.d.ts → identityRegistry.d.ts} +251 -105
- package/dist/abis/{identityNames.d.ts.map → identityRegistry.d.ts.map} +1 -1
- package/dist/abis/{identityNames.js → identityRegistry.js} +312 -118
- package/dist/abis/identityRegistry.js.map +1 -0
- package/dist/abis/index.d.ts +2 -1
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +2 -1
- package/dist/abis/index.js.map +1 -1
- package/dist/calls/handleEscrow.d.ts +15 -0
- package/dist/calls/handleEscrow.d.ts.map +1 -0
- package/dist/calls/handleEscrow.js +49 -0
- package/dist/calls/handleEscrow.js.map +1 -0
- package/dist/calls/identityRegistry.d.ts +16 -0
- package/dist/calls/identityRegistry.d.ts.map +1 -0
- package/dist/calls/identityRegistry.js +55 -0
- package/dist/calls/identityRegistry.js.map +1 -0
- package/dist/calls/index.d.ts +2 -1
- package/dist/calls/index.d.ts.map +1 -1
- package/dist/calls/index.js +2 -1
- package/dist/calls/index.js.map +1 -1
- package/dist/ceremony/profiles.d.ts +34 -2
- package/dist/ceremony/profiles.d.ts.map +1 -1
- package/dist/ceremony/profiles.js +52 -2
- package/dist/ceremony/profiles.js.map +1 -1
- package/dist/identity/handle.d.ts +1 -1
- package/dist/identity/handle.d.ts.map +1 -1
- package/dist/identity/handle.js +12 -9
- package/dist/identity/handle.js.map +1 -1
- package/dist/identity/handleVectors.d.ts +3 -6
- package/dist/identity/handleVectors.d.ts.map +1 -1
- package/dist/identity/handleVectors.js +3 -13
- package/dist/identity/handleVectors.js.map +1 -1
- package/dist/identity/index.d.ts +1 -0
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +2 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/node.d.ts +5 -0
- package/dist/identity/node.d.ts.map +1 -0
- package/dist/identity/node.js +19 -0
- package/dist/identity/node.js.map +1 -0
- package/dist/identity/resolve.d.ts +19 -9
- package/dist/identity/resolve.d.ts.map +1 -1
- package/dist/identity/resolve.js +76 -47
- package/dist/identity/resolve.js.map +1 -1
- package/package.json +2 -2
- package/src/abis/handleEscrow.ts +817 -0
- package/src/abis/handleResolver.ts +1 -1
- package/src/abis/{identityNames.ts → identityRegistry.ts} +311 -117
- package/src/abis/index.ts +2 -1
- package/src/calls/handleEscrow.ts +78 -0
- package/src/calls/identityRegistry.ts +91 -0
- package/src/calls/index.ts +2 -1
- package/src/ceremony/profiles.ts +55 -2
- package/src/identity/handle.ts +14 -8
- package/src/identity/handleVectors.ts +3 -14
- package/src/identity/index.ts +2 -1
- package/src/identity/node.ts +28 -0
- package/src/identity/resolve.ts +127 -69
- package/dist/abis/identityNames.js.map +0 -1
- package/dist/calls/identityNames.d.ts +0 -16
- package/dist/calls/identityNames.d.ts.map +0 -1
- package/dist/calls/identityNames.js +0 -55
- package/dist/calls/identityNames.js.map +0 -1
- 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,
|
|
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
|
|
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,
|
|
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
|
|
32
|
-
address:
|
|
33
|
-
abi:
|
|
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
|
|
49
|
-
like `initialize` are on almost all of them. A builder returns
|
|
50
|
-
data — no provider, no signer — so you decide how it is submitted:
|
|
51
|
-
batched, or through a smart
|
|
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.
|
|
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
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
PLATFORM_X_DOMAIN,
|
|
81
|
+
resolveHandleAndId,
|
|
82
|
+
PLATFORM_X_KEY,
|
|
81
83
|
} from '@libid/contracts/identity'
|
|
82
84
|
|
|
83
|
-
const reader = { client, address:
|
|
84
|
-
const x = platformId(
|
|
85
|
+
const reader = { client, address: IDENTITY_REGISTRY }
|
|
86
|
+
const x = platformId(PLATFORM_X_KEY)
|
|
85
87
|
|
|
86
|
-
// The
|
|
88
|
+
// The holder that last proved a handle, or null. Pass what was typed —
|
|
87
89
|
// normalization happens on chain.
|
|
88
|
-
const
|
|
90
|
+
const holder = await resolveHandle(reader, x, '@Alice')
|
|
89
91
|
|
|
90
|
-
// Before sending funds: does the
|
|
91
|
-
const {
|
|
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
|
|
94
|
-
const
|
|
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
|
-
##
|
|
106
|
+
## Binding an identity
|
|
98
107
|
|
|
99
|
-
A
|
|
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
|
|
102
|
-
An EOA sends it directly, a smart
|
|
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:
|
|
109
|
-
abi:
|
|
110
|
-
functionName: '
|
|
111
|
-
args: [platformId(
|
|
117
|
+
address: IDENTITY_REGISTRY,
|
|
118
|
+
abi: identityRegistryAbi,
|
|
119
|
+
functionName: 'quoteBind',
|
|
120
|
+
args: [platformId(PLATFORM_GITHUB_KEY), 1],
|
|
112
121
|
})
|
|
113
|
-
const call = calls.
|
|
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
|