@libid/contracts 0.13.0 → 0.14.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 +25 -5
- 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/identityNames.d.ts +199 -35
- package/dist/abis/identityNames.d.ts.map +1 -1
- package/dist/abis/identityNames.js +255 -37
- package/dist/abis/identityNames.js.map +1 -1
- package/dist/abis/index.d.ts +1 -0
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +1 -0
- 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/identityNames.d.ts +1 -1
- package/dist/calls/identityNames.d.ts.map +1 -1
- package/dist/calls/identityNames.js +2 -2
- package/dist/calls/identityNames.js.map +1 -1
- package/dist/calls/index.d.ts +1 -0
- package/dist/calls/index.d.ts.map +1 -1
- package/dist/calls/index.js +1 -0
- package/dist/calls/index.js.map +1 -1
- package/dist/identity/handle.d.ts.map +1 -1
- package/dist/identity/handle.js +3 -1
- package/dist/identity/handle.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 +1 -0
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/node.d.ts +6 -0
- package/dist/identity/node.d.ts.map +1 -0
- package/dist/identity/node.js +18 -0
- package/dist/identity/node.js.map +1 -0
- package/dist/identity/resolve.d.ts +12 -1
- package/dist/identity/resolve.d.ts.map +1 -1
- package/dist/identity/resolve.js +37 -1
- package/dist/identity/resolve.js.map +1 -1
- package/package.json +1 -1
- package/src/abis/handleEscrow.ts +817 -0
- package/src/abis/identityNames.ts +255 -37
- package/src/abis/index.ts +1 -0
- package/src/calls/handleEscrow.ts +78 -0
- package/src/calls/identityNames.ts +2 -2
- package/src/calls/index.ts +1 -0
- package/src/identity/handle.ts +3 -1
- package/src/identity/index.ts +1 -0
- package/src/identity/node.ts +27 -0
- package/src/identity/resolve.ts +71 -2
|
@@ -44,55 +44,96 @@ export const identityNamesAbi = [
|
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"type": "function",
|
|
47
|
-
"name": "
|
|
47
|
+
"name": "acceptsBindings",
|
|
48
48
|
"inputs": [
|
|
49
49
|
{
|
|
50
|
-
"name": "
|
|
50
|
+
"name": "platformId",
|
|
51
51
|
"type": "bytes32",
|
|
52
52
|
"internalType": "bytes32"
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
55
|
"outputs": [
|
|
56
56
|
{
|
|
57
|
-
"name": "
|
|
58
|
-
"type": "
|
|
59
|
-
"internalType": "
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"name": "observedAt",
|
|
63
|
-
"type": "uint64",
|
|
64
|
-
"internalType": "uint64"
|
|
57
|
+
"name": "",
|
|
58
|
+
"type": "bool",
|
|
59
|
+
"internalType": "bool"
|
|
65
60
|
}
|
|
66
61
|
],
|
|
67
62
|
"stateMutability": "view"
|
|
68
63
|
},
|
|
69
64
|
{
|
|
70
65
|
"type": "function",
|
|
71
|
-
"name": "
|
|
66
|
+
"name": "accountCount",
|
|
72
67
|
"inputs": [
|
|
73
68
|
{
|
|
74
|
-
"name": "
|
|
75
|
-
"type": "
|
|
76
|
-
"internalType": "
|
|
69
|
+
"name": "wallet",
|
|
70
|
+
"type": "address",
|
|
71
|
+
"internalType": "address"
|
|
77
72
|
}
|
|
78
73
|
],
|
|
79
74
|
"outputs": [
|
|
80
75
|
{
|
|
81
|
-
"name": "
|
|
76
|
+
"name": "",
|
|
77
|
+
"type": "uint256",
|
|
78
|
+
"internalType": "uint256"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"stateMutability": "view"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"type": "function",
|
|
85
|
+
"name": "accountsOf",
|
|
86
|
+
"inputs": [
|
|
87
|
+
{
|
|
88
|
+
"name": "wallet",
|
|
82
89
|
"type": "address",
|
|
83
90
|
"internalType": "address"
|
|
84
91
|
},
|
|
85
92
|
{
|
|
86
|
-
"name": "
|
|
87
|
-
"type": "
|
|
88
|
-
"internalType": "
|
|
93
|
+
"name": "from",
|
|
94
|
+
"type": "uint256",
|
|
95
|
+
"internalType": "uint256"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "limit",
|
|
99
|
+
"type": "uint256",
|
|
100
|
+
"internalType": "uint256"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"outputs": [
|
|
104
|
+
{
|
|
105
|
+
"name": "out",
|
|
106
|
+
"type": "tuple[]",
|
|
107
|
+
"internalType": "struct IdentityNames.Account[]",
|
|
108
|
+
"components": [
|
|
109
|
+
{
|
|
110
|
+
"name": "platformId",
|
|
111
|
+
"type": "bytes32",
|
|
112
|
+
"internalType": "bytes32"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "userId",
|
|
116
|
+
"type": "string",
|
|
117
|
+
"internalType": "string"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "handle",
|
|
121
|
+
"type": "string",
|
|
122
|
+
"internalType": "string"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "handleCurrent",
|
|
126
|
+
"type": "bool",
|
|
127
|
+
"internalType": "bool"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
89
130
|
}
|
|
90
131
|
],
|
|
91
132
|
"stateMutability": "view"
|
|
92
133
|
},
|
|
93
134
|
{
|
|
94
135
|
"type": "function",
|
|
95
|
-
"name": "
|
|
136
|
+
"name": "bind",
|
|
96
137
|
"inputs": [
|
|
97
138
|
{
|
|
98
139
|
"name": "platformId",
|
|
@@ -118,6 +159,54 @@ export const identityNamesAbi = [
|
|
|
118
159
|
"outputs": [],
|
|
119
160
|
"stateMutability": "payable"
|
|
120
161
|
},
|
|
162
|
+
{
|
|
163
|
+
"type": "function",
|
|
164
|
+
"name": "byHandle",
|
|
165
|
+
"inputs": [
|
|
166
|
+
{
|
|
167
|
+
"name": "handleNode",
|
|
168
|
+
"type": "bytes32",
|
|
169
|
+
"internalType": "bytes32"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"outputs": [
|
|
173
|
+
{
|
|
174
|
+
"name": "owner",
|
|
175
|
+
"type": "address",
|
|
176
|
+
"internalType": "address"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "observedAt",
|
|
180
|
+
"type": "uint64",
|
|
181
|
+
"internalType": "uint64"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"stateMutability": "view"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"type": "function",
|
|
188
|
+
"name": "byId",
|
|
189
|
+
"inputs": [
|
|
190
|
+
{
|
|
191
|
+
"name": "idNode",
|
|
192
|
+
"type": "bytes32",
|
|
193
|
+
"internalType": "bytes32"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"outputs": [
|
|
197
|
+
{
|
|
198
|
+
"name": "owner",
|
|
199
|
+
"type": "address",
|
|
200
|
+
"internalType": "address"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "observedAt",
|
|
204
|
+
"type": "uint64",
|
|
205
|
+
"internalType": "uint64"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"stateMutability": "view"
|
|
209
|
+
},
|
|
121
210
|
{
|
|
122
211
|
"type": "function",
|
|
123
212
|
"name": "digestSpent",
|
|
@@ -137,6 +226,30 @@ export const identityNamesAbi = [
|
|
|
137
226
|
],
|
|
138
227
|
"stateMutability": "view"
|
|
139
228
|
},
|
|
229
|
+
{
|
|
230
|
+
"type": "function",
|
|
231
|
+
"name": "handleHashOf",
|
|
232
|
+
"inputs": [
|
|
233
|
+
{
|
|
234
|
+
"name": "platformId",
|
|
235
|
+
"type": "bytes32",
|
|
236
|
+
"internalType": "bytes32"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"name": "handle",
|
|
240
|
+
"type": "string",
|
|
241
|
+
"internalType": "string"
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
"outputs": [
|
|
245
|
+
{
|
|
246
|
+
"name": "handleHash",
|
|
247
|
+
"type": "bytes32",
|
|
248
|
+
"internalType": "bytes32"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"stateMutability": "view"
|
|
252
|
+
},
|
|
140
253
|
{
|
|
141
254
|
"type": "function",
|
|
142
255
|
"name": "initialize",
|
|
@@ -150,6 +263,54 @@ export const identityNamesAbi = [
|
|
|
150
263
|
"outputs": [],
|
|
151
264
|
"stateMutability": "nonpayable"
|
|
152
265
|
},
|
|
266
|
+
{
|
|
267
|
+
"type": "function",
|
|
268
|
+
"name": "nodeOf",
|
|
269
|
+
"inputs": [
|
|
270
|
+
{
|
|
271
|
+
"name": "platformId",
|
|
272
|
+
"type": "bytes32",
|
|
273
|
+
"internalType": "bytes32"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "handle",
|
|
277
|
+
"type": "string",
|
|
278
|
+
"internalType": "string"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"outputs": [
|
|
282
|
+
{
|
|
283
|
+
"name": "",
|
|
284
|
+
"type": "bytes32",
|
|
285
|
+
"internalType": "bytes32"
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
"stateMutability": "view"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"type": "function",
|
|
292
|
+
"name": "nodeOfHash",
|
|
293
|
+
"inputs": [
|
|
294
|
+
{
|
|
295
|
+
"name": "platformId",
|
|
296
|
+
"type": "bytes32",
|
|
297
|
+
"internalType": "bytes32"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "handleHash",
|
|
301
|
+
"type": "bytes32",
|
|
302
|
+
"internalType": "bytes32"
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
"outputs": [
|
|
306
|
+
{
|
|
307
|
+
"name": "",
|
|
308
|
+
"type": "bytes32",
|
|
309
|
+
"internalType": "bytes32"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
"stateMutability": "pure"
|
|
313
|
+
},
|
|
153
314
|
{
|
|
154
315
|
"type": "function",
|
|
155
316
|
"name": "owner",
|
|
@@ -228,7 +389,7 @@ export const identityNamesAbi = [
|
|
|
228
389
|
},
|
|
229
390
|
{
|
|
230
391
|
"type": "function",
|
|
231
|
-
"name": "
|
|
392
|
+
"name": "quoteBind",
|
|
232
393
|
"inputs": [
|
|
233
394
|
{
|
|
234
395
|
"name": "platformId",
|
|
@@ -363,6 +524,52 @@ export const identityNamesAbi = [
|
|
|
363
524
|
],
|
|
364
525
|
"stateMutability": "view"
|
|
365
526
|
},
|
|
527
|
+
{
|
|
528
|
+
"type": "function",
|
|
529
|
+
"name": "rulesOf",
|
|
530
|
+
"inputs": [
|
|
531
|
+
{
|
|
532
|
+
"name": "platformId",
|
|
533
|
+
"type": "bytes32",
|
|
534
|
+
"internalType": "bytes32"
|
|
535
|
+
}
|
|
536
|
+
],
|
|
537
|
+
"outputs": [
|
|
538
|
+
{
|
|
539
|
+
"name": "",
|
|
540
|
+
"type": "tuple",
|
|
541
|
+
"internalType": "struct HandleNormalizer.Rules",
|
|
542
|
+
"components": [
|
|
543
|
+
{
|
|
544
|
+
"name": "maxLength",
|
|
545
|
+
"type": "uint16",
|
|
546
|
+
"internalType": "uint16"
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"name": "stripLeadingAt",
|
|
550
|
+
"type": "bool",
|
|
551
|
+
"internalType": "bool"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"name": "isEmail",
|
|
555
|
+
"type": "bool",
|
|
556
|
+
"internalType": "bool"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"name": "allowUnderscore",
|
|
560
|
+
"type": "bool",
|
|
561
|
+
"internalType": "bool"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"name": "allowHyphen",
|
|
565
|
+
"type": "bool",
|
|
566
|
+
"internalType": "bool"
|
|
567
|
+
}
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
"stateMutability": "view"
|
|
572
|
+
},
|
|
366
573
|
{
|
|
367
574
|
"type": "function",
|
|
368
575
|
"name": "setPlatform",
|
|
@@ -467,7 +674,7 @@ export const identityNamesAbi = [
|
|
|
467
674
|
},
|
|
468
675
|
{
|
|
469
676
|
"type": "event",
|
|
470
|
-
"name": "
|
|
677
|
+
"name": "BindFeePaid",
|
|
471
678
|
"inputs": [
|
|
472
679
|
{
|
|
473
680
|
"name": "authorizationDigest",
|
|
@@ -476,29 +683,23 @@ export const identityNamesAbi = [
|
|
|
476
683
|
"internalType": "bytes32"
|
|
477
684
|
},
|
|
478
685
|
{
|
|
479
|
-
"name": "
|
|
686
|
+
"name": "receiver",
|
|
480
687
|
"type": "address",
|
|
481
688
|
"indexed": true,
|
|
482
689
|
"internalType": "address"
|
|
483
690
|
},
|
|
484
691
|
{
|
|
485
|
-
"name": "
|
|
486
|
-
"type": "
|
|
487
|
-
"indexed": true,
|
|
488
|
-
"internalType": "bytes32"
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
"name": "clientIdentifier",
|
|
492
|
-
"type": "bytes",
|
|
692
|
+
"name": "amount",
|
|
693
|
+
"type": "uint256",
|
|
493
694
|
"indexed": false,
|
|
494
|
-
"internalType": "
|
|
695
|
+
"internalType": "uint256"
|
|
495
696
|
}
|
|
496
697
|
],
|
|
497
698
|
"anonymous": false
|
|
498
699
|
},
|
|
499
700
|
{
|
|
500
701
|
"type": "event",
|
|
501
|
-
"name": "
|
|
702
|
+
"name": "CeremonyBound",
|
|
502
703
|
"inputs": [
|
|
503
704
|
{
|
|
504
705
|
"name": "authorizationDigest",
|
|
@@ -507,16 +708,22 @@ export const identityNamesAbi = [
|
|
|
507
708
|
"internalType": "bytes32"
|
|
508
709
|
},
|
|
509
710
|
{
|
|
510
|
-
"name": "
|
|
711
|
+
"name": "owner",
|
|
511
712
|
"type": "address",
|
|
512
713
|
"indexed": true,
|
|
513
714
|
"internalType": "address"
|
|
514
715
|
},
|
|
515
716
|
{
|
|
516
|
-
"name": "
|
|
517
|
-
"type": "
|
|
717
|
+
"name": "platformId",
|
|
718
|
+
"type": "bytes32",
|
|
719
|
+
"indexed": true,
|
|
720
|
+
"internalType": "bytes32"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"name": "clientIdentifier",
|
|
724
|
+
"type": "bytes",
|
|
518
725
|
"indexed": false,
|
|
519
|
-
"internalType": "
|
|
726
|
+
"internalType": "bytes"
|
|
520
727
|
}
|
|
521
728
|
],
|
|
522
729
|
"anonymous": false
|
|
@@ -941,7 +1148,18 @@ export const identityNamesAbi = [
|
|
|
941
1148
|
},
|
|
942
1149
|
{
|
|
943
1150
|
"type": "error",
|
|
944
|
-
"name": "
|
|
1151
|
+
"name": "UnusableHandle",
|
|
1152
|
+
"inputs": [
|
|
1153
|
+
{
|
|
1154
|
+
"name": "problem",
|
|
1155
|
+
"type": "uint8",
|
|
1156
|
+
"internalType": "enum HandleNormalizer.Problem"
|
|
1157
|
+
}
|
|
1158
|
+
]
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
"type": "error",
|
|
1162
|
+
"name": "WrongBindValue",
|
|
945
1163
|
"inputs": [
|
|
946
1164
|
{
|
|
947
1165
|
"name": "required",
|
package/src/abis/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Source artifact: solidity/out/*
|
|
3
3
|
export { identityNamesAbi } from './identityNames.js'
|
|
4
4
|
export { handleResolverAbi } from './handleResolver.js'
|
|
5
|
+
export { handleEscrowAbi } from './handleEscrow.js'
|
|
5
6
|
export { notaryServiceAbi } from './notaryService.js'
|
|
6
7
|
export { ceremonyProofVerifierAbi } from './ceremonyProofVerifier.js'
|
|
7
8
|
export { googleJwtRootsAbi } from './googleJwtRoots.js'
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Generated by ts/packages/contracts/scripts/codegen.mjs. Do not edit.
|
|
2
|
+
// Source artifact: solidity/out/HandleEscrow.sol/HandleEscrow.json
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type Address,
|
|
6
|
+
type ContractFunctionArgs,
|
|
7
|
+
type ContractFunctionName,
|
|
8
|
+
encodeFunctionData,
|
|
9
|
+
} from 'viem'
|
|
10
|
+
|
|
11
|
+
import type { Call } from '../call.js'
|
|
12
|
+
import { handleEscrowAbi } from '../abis/handleEscrow.js'
|
|
13
|
+
|
|
14
|
+
type Mutability = 'nonpayable' | 'payable'
|
|
15
|
+
type HandleEscrowFn = ContractFunctionName<typeof handleEscrowAbi, Mutability>
|
|
16
|
+
type HandleEscrowArgs<F extends HandleEscrowFn> = ContractFunctionArgs<
|
|
17
|
+
typeof handleEscrowAbi,
|
|
18
|
+
Mutability,
|
|
19
|
+
F
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
export function acceptOwnership(to: Address, ...args: HandleEscrowArgs<'acceptOwnership'>): Call {
|
|
23
|
+
return {
|
|
24
|
+
to,
|
|
25
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'acceptOwnership', args }),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function claim(to: Address, ...args: HandleEscrowArgs<'claim'>): Call {
|
|
30
|
+
return {
|
|
31
|
+
to,
|
|
32
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'claim', args }),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function deposit(to: Address, value: bigint, ...args: HandleEscrowArgs<'deposit'>): Call {
|
|
37
|
+
return {
|
|
38
|
+
to,
|
|
39
|
+
value,
|
|
40
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'deposit', args }),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function initialize(to: Address, ...args: HandleEscrowArgs<'initialize'>): Call {
|
|
45
|
+
return {
|
|
46
|
+
to,
|
|
47
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'initialize', args }),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function refund(to: Address, ...args: HandleEscrowArgs<'refund'>): Call {
|
|
52
|
+
return {
|
|
53
|
+
to,
|
|
54
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'refund', args }),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function transferOwnership(
|
|
59
|
+
to: Address,
|
|
60
|
+
...args: HandleEscrowArgs<'transferOwnership'>
|
|
61
|
+
): Call {
|
|
62
|
+
return {
|
|
63
|
+
to,
|
|
64
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'transferOwnership', args }),
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function upgradeToAndCall(
|
|
69
|
+
to: Address,
|
|
70
|
+
value: bigint,
|
|
71
|
+
...args: HandleEscrowArgs<'upgradeToAndCall'>
|
|
72
|
+
): Call {
|
|
73
|
+
return {
|
|
74
|
+
to,
|
|
75
|
+
value,
|
|
76
|
+
data: encodeFunctionData({ abi: handleEscrowAbi, functionName: 'upgradeToAndCall', args }),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -26,11 +26,11 @@ export function acceptOwnership(to: Address, ...args: IdentityNamesArgs<'acceptO
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function
|
|
29
|
+
export function bind(to: Address, value: bigint, ...args: IdentityNamesArgs<'bind'>): Call {
|
|
30
30
|
return {
|
|
31
31
|
to,
|
|
32
32
|
value,
|
|
33
|
-
data: encodeFunctionData({ abi: identityNamesAbi, functionName: '
|
|
33
|
+
data: encodeFunctionData({ abi: identityNamesAbi, functionName: 'bind', args }),
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
package/src/calls/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Source artifact: solidity/out/*
|
|
3
3
|
export * as identityNames from './identityNames.js'
|
|
4
4
|
export * as handleResolver from './handleResolver.js'
|
|
5
|
+
export * as handleEscrow from './handleEscrow.js'
|
|
5
6
|
export * as notaryService from './notaryService.js'
|
|
6
7
|
export * as ceremonyProofVerifier from './ceremonyProofVerifier.js'
|
|
7
8
|
export * as googleJwtRoots from './googleJwtRoots.js'
|
package/src/identity/handle.ts
CHANGED
|
@@ -87,7 +87,9 @@ export const RULES_GOOGLE: Rules = {
|
|
|
87
87
|
allowHyphen: ALLOW_HYPHEN_GOOGLE,
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/// The rules for a platform key from the
|
|
90
|
+
/// The rules for a platform key from the generated table: what the contracts
|
|
91
|
+
/// were released with. The chain's owner can change a platform's rules, so a
|
|
92
|
+
/// hash for a deposit should use `rulesOnChain`.
|
|
91
93
|
export function rulesFor(platform: string): Rules | null {
|
|
92
94
|
if (platform === 'x') return RULES_X
|
|
93
95
|
if (platform === 'github') return RULES_GITHUB
|
package/src/identity/index.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// Handle hashes and nodes, mirroring `IdentityNames.handleHashOf` and
|
|
2
|
+
/// `nodeOfHash`, computed locally so the handle text never reaches an RPC.
|
|
3
|
+
/// `HandleEscrow.deposit` takes the hash; `byHandle` and the escrow's reads
|
|
4
|
+
/// take the node.
|
|
5
|
+
|
|
6
|
+
import { encodeAbiParameters, type Hex, keccak256, toHex } from 'viem'
|
|
7
|
+
|
|
8
|
+
import { normalize, type Rules } from './handle.js'
|
|
9
|
+
import { type PlatformDomain, platformId } from './resolve.js'
|
|
10
|
+
|
|
11
|
+
const HANDLE_NODE_V1: Hex = keccak256(toHex('libid.identity.handle-node.v1'))
|
|
12
|
+
|
|
13
|
+
/// `keccak256` of `raw` normalized under `rules` (from `rulesOnChain`, or
|
|
14
|
+
/// `rulesFor` offline). Throws `HandleError` for text the rules refuse.
|
|
15
|
+
export function handleHash(raw: string, rules: Rules): Hex {
|
|
16
|
+
return keccak256(toHex(normalize(raw, rules)))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// The node a handle hash keys to on a platform, named by its domain (`'x'`).
|
|
20
|
+
export function handleNode<D extends string>(domain: PlatformDomain<D>, hash: Hex): Hex {
|
|
21
|
+
return keccak256(
|
|
22
|
+
encodeAbiParameters(
|
|
23
|
+
[{ type: 'bytes32' }, { type: 'bytes32' }, { type: 'bytes32' }],
|
|
24
|
+
[HANDLE_NODE_V1, platformId(domain), hash],
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
}
|
package/src/identity/resolve.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// Reading names from the chain.
|
|
2
2
|
///
|
|
3
|
-
/// Everything here is a view call.
|
|
3
|
+
/// Everything here is a view call. Binding a name needs a ceremony payload and a
|
|
4
4
|
/// wallet; reading one needs neither, which is the point — any product can
|
|
5
5
|
/// resolve a name without touching the ceremony that created it.
|
|
6
6
|
///
|
|
@@ -11,10 +11,16 @@
|
|
|
11
11
|
import { type Address, keccak256, type PublicClient, toHex, zeroAddress } from 'viem'
|
|
12
12
|
|
|
13
13
|
import { identityNamesAbi } from '../abis/identityNames.js'
|
|
14
|
+
import type { Rules } from './handle.js'
|
|
15
|
+
|
|
16
|
+
/// A platform's domain (`'x'`, `'github'`, ...), refusing at compile time a
|
|
17
|
+
/// value typed as hex: an id passed where a domain belongs would be hashed
|
|
18
|
+
/// again into a platform nothing binds.
|
|
19
|
+
export type PlatformDomain<D extends string> = D extends `0x${string}` ? never : D
|
|
14
20
|
|
|
15
21
|
/// A platform id is `keccak256` of its domain string. The domains are generated
|
|
16
22
|
/// from `handles.json`, so this and the contract agree by construction.
|
|
17
|
-
export function platformId(domain:
|
|
23
|
+
export function platformId<D extends string>(domain: PlatformDomain<D>): `0x${string}` {
|
|
18
24
|
return keccak256(toHex(domain))
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -44,6 +50,22 @@ function read<T>(reader: NamesReader, functionName: string, args: readonly unkno
|
|
|
44
50
|
})
|
|
45
51
|
}
|
|
46
52
|
|
|
53
|
+
/// The platform's normalization rules as configured on chain now
|
|
54
|
+
/// (`IdentityNames.rulesOf`); only the platform id is sent.
|
|
55
|
+
export async function rulesOnChain<D extends string>(
|
|
56
|
+
reader: NamesReader,
|
|
57
|
+
domain: PlatformDomain<D>,
|
|
58
|
+
): Promise<Rules> {
|
|
59
|
+
const rules = await read<Rules>(reader, 'rulesOf', [platformId(domain)])
|
|
60
|
+
return {
|
|
61
|
+
maxLength: Number(rules.maxLength),
|
|
62
|
+
stripLeadingAt: rules.stripLeadingAt,
|
|
63
|
+
isEmail: rules.isEmail,
|
|
64
|
+
allowUnderscore: rules.allowUnderscore,
|
|
65
|
+
allowHyphen: rules.allowHyphen,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
47
69
|
/// The wallet that proved this account id, or `null`.
|
|
48
70
|
export async function resolveId(
|
|
49
71
|
reader: NamesReader,
|
|
@@ -139,3 +161,50 @@ export async function resolvePair(
|
|
|
139
161
|
|
|
140
162
|
return { wallet: wallet === zeroAddress ? null : wallet, idAgrees }
|
|
141
163
|
}
|
|
164
|
+
|
|
165
|
+
/// One account a wallet proved, as the wallet's list reports it.
|
|
166
|
+
export interface Account {
|
|
167
|
+
/// The platform the account is on, as `platformId` derives it.
|
|
168
|
+
platformId: `0x${string}`
|
|
169
|
+
/// The account id, byte for byte as the platform issued it.
|
|
170
|
+
userId: string
|
|
171
|
+
/// The handle this account proved most recently, as normalized on chain.
|
|
172
|
+
handle: string
|
|
173
|
+
/// True while the handle node still points back at this account.
|
|
174
|
+
///
|
|
175
|
+
/// False once another account proves the same handle: the string stays as
|
|
176
|
+
/// the last thing this account was known as, and the flag says not to route
|
|
177
|
+
/// by it.
|
|
178
|
+
handleCurrent: boolean
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/// How many accounts a wallet holds, on every platform together.
|
|
182
|
+
export async function accountCount(reader: NamesReader, wallet: Address): Promise<bigint> {
|
|
183
|
+
return read<bigint>(reader, 'accountCount', [wallet])
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/// A page of the accounts a wallet holds, on every platform together: the
|
|
187
|
+
/// indices `[from, from + limit)` of its list, counted from zero and clipped
|
|
188
|
+
/// to the list. A `from` past the end answers an empty page. A reader that
|
|
189
|
+
/// wants one platform filters a page by `platformId`.
|
|
190
|
+
///
|
|
191
|
+
/// Order is arbitrary and changes when an account leaves the list, so two
|
|
192
|
+
/// pages read across a removal may overlap or skip. A reader that needs every
|
|
193
|
+
/// account reads `accountCount` and the pages against one block.
|
|
194
|
+
///
|
|
195
|
+
/// A list is as long as its wallet made it, and a call's gas is not. A caller
|
|
196
|
+
/// enumerating a wallet it did not choose keeps `limit` small and pages.
|
|
197
|
+
export async function accountsOf(
|
|
198
|
+
reader: NamesReader,
|
|
199
|
+
wallet: Address,
|
|
200
|
+
from: bigint,
|
|
201
|
+
limit: bigint,
|
|
202
|
+
): Promise<Account[]> {
|
|
203
|
+
const page = await read<readonly Account[]>(reader, 'accountsOf', [wallet, from, limit])
|
|
204
|
+
return page.map(({ platformId, userId, handle, handleCurrent }) => ({
|
|
205
|
+
platformId,
|
|
206
|
+
userId,
|
|
207
|
+
handle,
|
|
208
|
+
handleCurrent,
|
|
209
|
+
}))
|
|
210
|
+
}
|