@settlemint/sdk-eas 2.3.4 → 2.3.5-prfde1f9e5
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 +221 -84
- package/dist/browser/eas.d.ts +1012 -37
- package/dist/browser/eas.js +885 -112
- package/dist/browser/eas.js.map +1 -1
- package/dist/eas.cjs +893 -110
- package/dist/eas.cjs.map +1 -1
- package/dist/eas.d.cts +1012 -37
- package/dist/eas.d.ts +1012 -37
- package/dist/eas.js +885 -112
- package/dist/eas.js.map +1 -1
- package/package.json +3 -5
package/dist/eas.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getPublicClient, getWalletClient } from "@settlemint/sdk-viem";
|
|
2
|
+
import { createPortalClient } from "@settlemint/sdk-portal";
|
|
3
|
+
import { ApplicationAccessTokenSchema, UrlOrPathSchema } from "@settlemint/sdk-utils/validation";
|
|
5
4
|
import { isAddress } from "viem";
|
|
6
|
-
import { JsonRpcProvider, Wallet } from "ethers";
|
|
7
5
|
|
|
8
6
|
//#region rolldown:runtime
|
|
9
7
|
var __defProp = Object.defineProperty;
|
|
@@ -14,6 +12,356 @@ var __export = (target, all) => {
|
|
|
14
12
|
});
|
|
15
13
|
};
|
|
16
14
|
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/abis.ts
|
|
17
|
+
/**
|
|
18
|
+
* EAS Schema Registry ABI
|
|
19
|
+
* Contains the essential functions for schema registration and retrieval
|
|
20
|
+
*/
|
|
21
|
+
const SCHEMA_REGISTRY_ABI = [
|
|
22
|
+
{
|
|
23
|
+
type: "function",
|
|
24
|
+
name: "register",
|
|
25
|
+
inputs: [
|
|
26
|
+
{
|
|
27
|
+
name: "schema",
|
|
28
|
+
type: "string",
|
|
29
|
+
internalType: "string"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "resolver",
|
|
33
|
+
type: "address",
|
|
34
|
+
internalType: "contract ISchemaResolver"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "revocable",
|
|
38
|
+
type: "bool",
|
|
39
|
+
internalType: "bool"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
outputs: [{
|
|
43
|
+
name: "",
|
|
44
|
+
type: "bytes32",
|
|
45
|
+
internalType: "bytes32"
|
|
46
|
+
}],
|
|
47
|
+
stateMutability: "nonpayable"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "function",
|
|
51
|
+
name: "getSchema",
|
|
52
|
+
inputs: [{
|
|
53
|
+
name: "uid",
|
|
54
|
+
type: "bytes32",
|
|
55
|
+
internalType: "bytes32"
|
|
56
|
+
}],
|
|
57
|
+
outputs: [{
|
|
58
|
+
name: "",
|
|
59
|
+
type: "tuple",
|
|
60
|
+
internalType: "struct SchemaRecord",
|
|
61
|
+
components: [
|
|
62
|
+
{
|
|
63
|
+
name: "uid",
|
|
64
|
+
type: "bytes32",
|
|
65
|
+
internalType: "bytes32"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "resolver",
|
|
69
|
+
type: "address",
|
|
70
|
+
internalType: "contract ISchemaResolver"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "revocable",
|
|
74
|
+
type: "bool",
|
|
75
|
+
internalType: "bool"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "schema",
|
|
79
|
+
type: "string",
|
|
80
|
+
internalType: "string"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}],
|
|
84
|
+
stateMutability: "view"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "event",
|
|
88
|
+
name: "Registered",
|
|
89
|
+
inputs: [
|
|
90
|
+
{
|
|
91
|
+
name: "uid",
|
|
92
|
+
type: "bytes32",
|
|
93
|
+
indexed: true,
|
|
94
|
+
internalType: "bytes32"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "registerer",
|
|
98
|
+
type: "address",
|
|
99
|
+
indexed: true,
|
|
100
|
+
internalType: "address"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "schema",
|
|
104
|
+
type: "tuple",
|
|
105
|
+
indexed: false,
|
|
106
|
+
internalType: "struct SchemaRecord",
|
|
107
|
+
components: [
|
|
108
|
+
{
|
|
109
|
+
name: "uid",
|
|
110
|
+
type: "bytes32",
|
|
111
|
+
internalType: "bytes32"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "resolver",
|
|
115
|
+
type: "address",
|
|
116
|
+
internalType: "contract ISchemaResolver"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "revocable",
|
|
120
|
+
type: "bool",
|
|
121
|
+
internalType: "bool"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "schema",
|
|
125
|
+
type: "string",
|
|
126
|
+
internalType: "string"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
anonymous: false
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
/**
|
|
135
|
+
* EAS Attestation Service ABI
|
|
136
|
+
* Contains the essential functions for attestation creation, revocation, and retrieval
|
|
137
|
+
*/
|
|
138
|
+
const EAS_ABI = [
|
|
139
|
+
{
|
|
140
|
+
type: "function",
|
|
141
|
+
name: "attest",
|
|
142
|
+
inputs: [{
|
|
143
|
+
name: "request",
|
|
144
|
+
type: "tuple",
|
|
145
|
+
internalType: "struct AttestationRequest",
|
|
146
|
+
components: [{
|
|
147
|
+
name: "schema",
|
|
148
|
+
type: "bytes32",
|
|
149
|
+
internalType: "bytes32"
|
|
150
|
+
}, {
|
|
151
|
+
name: "data",
|
|
152
|
+
type: "tuple",
|
|
153
|
+
internalType: "struct AttestationRequestData",
|
|
154
|
+
components: [
|
|
155
|
+
{
|
|
156
|
+
name: "recipient",
|
|
157
|
+
type: "address",
|
|
158
|
+
internalType: "address"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "expirationTime",
|
|
162
|
+
type: "uint64",
|
|
163
|
+
internalType: "uint64"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "revocable",
|
|
167
|
+
type: "bool",
|
|
168
|
+
internalType: "bool"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "refUID",
|
|
172
|
+
type: "bytes32",
|
|
173
|
+
internalType: "bytes32"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "data",
|
|
177
|
+
type: "bytes",
|
|
178
|
+
internalType: "bytes"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "value",
|
|
182
|
+
type: "uint256",
|
|
183
|
+
internalType: "uint256"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}]
|
|
187
|
+
}],
|
|
188
|
+
outputs: [{
|
|
189
|
+
name: "",
|
|
190
|
+
type: "bytes32",
|
|
191
|
+
internalType: "bytes32"
|
|
192
|
+
}],
|
|
193
|
+
stateMutability: "payable"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: "function",
|
|
197
|
+
name: "revoke",
|
|
198
|
+
inputs: [{
|
|
199
|
+
name: "request",
|
|
200
|
+
type: "tuple",
|
|
201
|
+
internalType: "struct RevocationRequest",
|
|
202
|
+
components: [{
|
|
203
|
+
name: "schema",
|
|
204
|
+
type: "bytes32",
|
|
205
|
+
internalType: "bytes32"
|
|
206
|
+
}, {
|
|
207
|
+
name: "data",
|
|
208
|
+
type: "tuple",
|
|
209
|
+
internalType: "struct RevocationRequestData",
|
|
210
|
+
components: [{
|
|
211
|
+
name: "uid",
|
|
212
|
+
type: "bytes32",
|
|
213
|
+
internalType: "bytes32"
|
|
214
|
+
}, {
|
|
215
|
+
name: "value",
|
|
216
|
+
type: "uint256",
|
|
217
|
+
internalType: "uint256"
|
|
218
|
+
}]
|
|
219
|
+
}]
|
|
220
|
+
}],
|
|
221
|
+
outputs: [],
|
|
222
|
+
stateMutability: "payable"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "function",
|
|
226
|
+
name: "getAttestation",
|
|
227
|
+
inputs: [{
|
|
228
|
+
name: "uid",
|
|
229
|
+
type: "bytes32",
|
|
230
|
+
internalType: "bytes32"
|
|
231
|
+
}],
|
|
232
|
+
outputs: [{
|
|
233
|
+
name: "",
|
|
234
|
+
type: "tuple",
|
|
235
|
+
internalType: "struct Attestation",
|
|
236
|
+
components: [
|
|
237
|
+
{
|
|
238
|
+
name: "uid",
|
|
239
|
+
type: "bytes32",
|
|
240
|
+
internalType: "bytes32"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "schema",
|
|
244
|
+
type: "bytes32",
|
|
245
|
+
internalType: "bytes32"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "time",
|
|
249
|
+
type: "uint64",
|
|
250
|
+
internalType: "uint64"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "expirationTime",
|
|
254
|
+
type: "uint64",
|
|
255
|
+
internalType: "uint64"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "revocationTime",
|
|
259
|
+
type: "uint64",
|
|
260
|
+
internalType: "uint64"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "refUID",
|
|
264
|
+
type: "bytes32",
|
|
265
|
+
internalType: "bytes32"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "recipient",
|
|
269
|
+
type: "address",
|
|
270
|
+
internalType: "address"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "attester",
|
|
274
|
+
type: "address",
|
|
275
|
+
internalType: "address"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "revocable",
|
|
279
|
+
type: "bool",
|
|
280
|
+
internalType: "bool"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "data",
|
|
284
|
+
type: "bytes",
|
|
285
|
+
internalType: "bytes"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}],
|
|
289
|
+
stateMutability: "view"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
type: "event",
|
|
293
|
+
name: "Attested",
|
|
294
|
+
inputs: [
|
|
295
|
+
{
|
|
296
|
+
name: "recipient",
|
|
297
|
+
type: "address",
|
|
298
|
+
indexed: true,
|
|
299
|
+
internalType: "address"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "attester",
|
|
303
|
+
type: "address",
|
|
304
|
+
indexed: true,
|
|
305
|
+
internalType: "address"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: "uid",
|
|
309
|
+
type: "bytes32",
|
|
310
|
+
indexed: false,
|
|
311
|
+
internalType: "bytes32"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "schemaUID",
|
|
315
|
+
type: "bytes32",
|
|
316
|
+
indexed: true,
|
|
317
|
+
internalType: "bytes32"
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
anonymous: false
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
type: "event",
|
|
324
|
+
name: "Revoked",
|
|
325
|
+
inputs: [
|
|
326
|
+
{
|
|
327
|
+
name: "recipient",
|
|
328
|
+
type: "address",
|
|
329
|
+
indexed: true,
|
|
330
|
+
internalType: "address"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: "attester",
|
|
334
|
+
type: "address",
|
|
335
|
+
indexed: true,
|
|
336
|
+
internalType: "address"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: "uid",
|
|
340
|
+
type: "bytes32",
|
|
341
|
+
indexed: false,
|
|
342
|
+
internalType: "bytes32"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "schemaUID",
|
|
346
|
+
type: "bytes32",
|
|
347
|
+
indexed: true,
|
|
348
|
+
internalType: "bytes32"
|
|
349
|
+
}
|
|
350
|
+
],
|
|
351
|
+
anonymous: false
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
/**
|
|
355
|
+
* Default ABIs for EAS Portal integration
|
|
356
|
+
*/
|
|
357
|
+
const DEFAULT_EAS_ABIS = [{
|
|
358
|
+
name: "SchemaRegistry",
|
|
359
|
+
abi: JSON.stringify(SCHEMA_REGISTRY_ABI)
|
|
360
|
+
}, {
|
|
361
|
+
name: "EAS",
|
|
362
|
+
abi: JSON.stringify(EAS_ABI)
|
|
363
|
+
}];
|
|
364
|
+
|
|
17
365
|
//#endregion
|
|
18
366
|
//#region ../../node_modules/zod/dist/esm/v4/core/core.js
|
|
19
367
|
function $constructor(name, initializer$2, params) {
|
|
@@ -10209,69 +10557,108 @@ var classic_default = external_exports;
|
|
|
10209
10557
|
var v4_default = classic_default;
|
|
10210
10558
|
|
|
10211
10559
|
//#endregion
|
|
10212
|
-
//#region src/client-options.schema.ts
|
|
10560
|
+
//#region src/portal-client-options.schema.ts
|
|
10213
10561
|
/**
|
|
10214
|
-
*
|
|
10215
|
-
*
|
|
10562
|
+
* ABI source configuration for EAS contracts.
|
|
10563
|
+
* Priority: hardcoded (default) > custom (user override) > predeployed (Portal's ABIs)
|
|
10216
10564
|
*/
|
|
10217
|
-
const
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10565
|
+
const abiSourceSchema = discriminatedUnion("type", [
|
|
10566
|
+
object({ type: literal("hardcoded") }),
|
|
10567
|
+
object({
|
|
10568
|
+
type: literal("custom"),
|
|
10569
|
+
easAbi: custom((val) => Array.isArray(val)),
|
|
10570
|
+
schemaRegistryAbi: custom((val) => Array.isArray(val))
|
|
10571
|
+
}),
|
|
10572
|
+
object({
|
|
10573
|
+
type: literal("predeployed"),
|
|
10574
|
+
abiNames: array(string()).optional().default(["eas"])
|
|
10575
|
+
})
|
|
10576
|
+
]);
|
|
10577
|
+
/**
|
|
10578
|
+
* Configuration options for the EAS Portal client
|
|
10579
|
+
*/
|
|
10580
|
+
const portalClientOptionsSchema = object({
|
|
10581
|
+
instance: UrlOrPathSchema,
|
|
10582
|
+
accessToken: ApplicationAccessTokenSchema,
|
|
10583
|
+
easContractAddress: string().refine(isAddress, "Invalid EAS contract address format"),
|
|
10584
|
+
schemaRegistryContractAddress: string().refine(isAddress, "Invalid Schema Registry address format"),
|
|
10585
|
+
abiSource: abiSourceSchema.optional().default({ type: "hardcoded" }),
|
|
10586
|
+
wsUrl: string().url().optional(),
|
|
10587
|
+
timeout: number().positive().optional().default(3e4),
|
|
10588
|
+
debug: boolean().optional().default(false),
|
|
10589
|
+
cache: _enum([
|
|
10590
|
+
"default",
|
|
10591
|
+
"force-cache",
|
|
10592
|
+
"no-cache",
|
|
10593
|
+
"no-store",
|
|
10594
|
+
"only-if-cached",
|
|
10595
|
+
"reload"
|
|
10596
|
+
]).optional()
|
|
10224
10597
|
});
|
|
10598
|
+
/**
|
|
10599
|
+
* Validates EAS Portal client options.
|
|
10600
|
+
*
|
|
10601
|
+
* @param options - The options to validate
|
|
10602
|
+
* @returns The validated options
|
|
10603
|
+
* @throws If validation fails
|
|
10604
|
+
*
|
|
10605
|
+
* @example
|
|
10606
|
+
* ```typescript
|
|
10607
|
+
* import { validatePortalClientOptions } from "@settlemint/sdk-eas";
|
|
10608
|
+
*
|
|
10609
|
+
* const options = validatePortalClientOptions({
|
|
10610
|
+
* instance: "https://portal.settlemint.com",
|
|
10611
|
+
* accessToken: "your-token",
|
|
10612
|
+
* easContractAddress: "0x...",
|
|
10613
|
+
* schemaRegistryContractAddress: "0x...",
|
|
10614
|
+
* });
|
|
10615
|
+
* ```
|
|
10616
|
+
*/
|
|
10617
|
+
function validatePortalClientOptions(options) {
|
|
10618
|
+
return portalClientOptionsSchema.parse(options);
|
|
10619
|
+
}
|
|
10225
10620
|
|
|
10226
10621
|
//#endregion
|
|
10227
|
-
//#region src/
|
|
10622
|
+
//#region src/portal-types.ts
|
|
10228
10623
|
/**
|
|
10229
|
-
*
|
|
10624
|
+
* EAS-specific error codes
|
|
10230
10625
|
*/
|
|
10231
|
-
function
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
} catch {
|
|
10245
|
-
return null;
|
|
10246
|
-
}
|
|
10247
|
-
}).filter((provider) => provider != null);
|
|
10248
|
-
if (providers.length === 0) throw new Error("No valid RPC URLs found");
|
|
10249
|
-
return providers[0];
|
|
10250
|
-
}
|
|
10251
|
-
return new JsonRpcProvider(transport.url, network);
|
|
10252
|
-
}
|
|
10626
|
+
let EASErrorCode = /* @__PURE__ */ function(EASErrorCode$1) {
|
|
10627
|
+
EASErrorCode$1["INVALID_SCHEMA"] = "INVALID_SCHEMA";
|
|
10628
|
+
EASErrorCode$1["SCHEMA_NOT_FOUND"] = "SCHEMA_NOT_FOUND";
|
|
10629
|
+
EASErrorCode$1["ATTESTATION_NOT_FOUND"] = "ATTESTATION_NOT_FOUND";
|
|
10630
|
+
EASErrorCode$1["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
10631
|
+
EASErrorCode$1["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
|
|
10632
|
+
EASErrorCode$1["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
|
|
10633
|
+
EASErrorCode$1["EXPIRED_ATTESTATION"] = "EXPIRED_ATTESTATION";
|
|
10634
|
+
EASErrorCode$1["NON_REVOCABLE"] = "NON_REVOCABLE";
|
|
10635
|
+
EASErrorCode$1["ALREADY_REVOKED"] = "ALREADY_REVOKED";
|
|
10636
|
+
EASErrorCode$1["PORTAL_ERROR"] = "PORTAL_ERROR";
|
|
10637
|
+
return EASErrorCode$1;
|
|
10638
|
+
}({});
|
|
10253
10639
|
/**
|
|
10254
|
-
*
|
|
10640
|
+
* Enhanced error class for EAS Portal operations
|
|
10255
10641
|
*/
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10642
|
+
var EASPortalError = class extends Error {
|
|
10643
|
+
code;
|
|
10644
|
+
transactionHash;
|
|
10645
|
+
revertReason;
|
|
10646
|
+
gasEstimate;
|
|
10647
|
+
constructor(message, code, options) {
|
|
10648
|
+
super(message);
|
|
10649
|
+
this.name = "EASPortalError";
|
|
10650
|
+
this.code = code;
|
|
10651
|
+
this.transactionHash = options?.transactionHash;
|
|
10652
|
+
this.revertReason = options?.revertReason;
|
|
10653
|
+
this.gasEstimate = options?.gasEstimate;
|
|
10654
|
+
if (options?.cause) {
|
|
10655
|
+
this.cause = options.cause;
|
|
10656
|
+
}
|
|
10269
10657
|
}
|
|
10270
|
-
|
|
10271
|
-
}
|
|
10658
|
+
};
|
|
10272
10659
|
|
|
10273
10660
|
//#endregion
|
|
10274
|
-
//#region src/
|
|
10661
|
+
//#region src/schema.ts
|
|
10275
10662
|
/**
|
|
10276
10663
|
* Supported field types for EAS schema fields.
|
|
10277
10664
|
* Maps to the Solidity types that can be used in EAS schemas.
|
|
@@ -10289,7 +10676,7 @@ const EAS_FIELD_TYPES = {
|
|
|
10289
10676
|
};
|
|
10290
10677
|
|
|
10291
10678
|
//#endregion
|
|
10292
|
-
//#region src/validation.ts
|
|
10679
|
+
//#region src/utils/validation.ts
|
|
10293
10680
|
function validateFieldName(name) {
|
|
10294
10681
|
if (!name) {
|
|
10295
10682
|
throw new Error("Field name cannot be empty");
|
|
@@ -10325,78 +10712,464 @@ function buildSchemaString(fields) {
|
|
|
10325
10712
|
return fields.map((field) => `${field.type} ${field.name}`).join(", ");
|
|
10326
10713
|
}
|
|
10327
10714
|
|
|
10715
|
+
//#endregion
|
|
10716
|
+
//#region src/eas-portal-client.ts
|
|
10717
|
+
/**
|
|
10718
|
+
* EAS Portal client for interacting with Ethereum Attestation Service contracts via Portal.
|
|
10719
|
+
* Supports multiple ABI sources with priority: hardcoded (default) > custom (user override) > predeployed (Portal's ABIs).
|
|
10720
|
+
*/
|
|
10721
|
+
var EASPortalClient = class {
|
|
10722
|
+
portalClient;
|
|
10723
|
+
options;
|
|
10724
|
+
easAbi;
|
|
10725
|
+
schemaRegistryAbi;
|
|
10726
|
+
/**
|
|
10727
|
+
* Creates a new EAS Portal client instance.
|
|
10728
|
+
*
|
|
10729
|
+
* @param options - Configuration options for the client
|
|
10730
|
+
*
|
|
10731
|
+
* @example
|
|
10732
|
+
* ```typescript
|
|
10733
|
+
* import { EASPortalClient } from "@settlemint/sdk-eas";
|
|
10734
|
+
*
|
|
10735
|
+
* // Using default hardcoded ABIs
|
|
10736
|
+
* const client = new EASPortalClient({
|
|
10737
|
+
* instance: "https://portal.settlemint.com",
|
|
10738
|
+
* accessToken: "your-token",
|
|
10739
|
+
* easContractAddress: "0x...",
|
|
10740
|
+
* schemaRegistryContractAddress: "0x...",
|
|
10741
|
+
* });
|
|
10742
|
+
*
|
|
10743
|
+
* // Using custom ABIs
|
|
10744
|
+
* const clientWithCustomAbis = new EASPortalClient({
|
|
10745
|
+
* instance: "https://portal.settlemint.com",
|
|
10746
|
+
* accessToken: "your-token",
|
|
10747
|
+
* easContractAddress: "0x...",
|
|
10748
|
+
* schemaRegistryContractAddress: "0x...",
|
|
10749
|
+
* abiSource: {
|
|
10750
|
+
* type: "custom",
|
|
10751
|
+
* easAbi: customEasAbi,
|
|
10752
|
+
* schemaRegistryAbi: customSchemaRegistryAbi,
|
|
10753
|
+
* },
|
|
10754
|
+
* });
|
|
10755
|
+
*
|
|
10756
|
+
* // Using predeployed ABIs
|
|
10757
|
+
* const clientWithPredeployed = new EASPortalClient({
|
|
10758
|
+
* instance: "https://portal.settlemint.com",
|
|
10759
|
+
* accessToken: "your-token",
|
|
10760
|
+
* easContractAddress: "0x...",
|
|
10761
|
+
* schemaRegistryContractAddress: "0x...",
|
|
10762
|
+
* abiSource: {
|
|
10763
|
+
* type: "predeployed",
|
|
10764
|
+
* abiNames: ["eas"],
|
|
10765
|
+
* },
|
|
10766
|
+
* });
|
|
10767
|
+
* ```
|
|
10768
|
+
*/
|
|
10769
|
+
constructor(options) {
|
|
10770
|
+
this.options = validatePortalClientOptions(options);
|
|
10771
|
+
const { client } = createPortalClient({
|
|
10772
|
+
instance: this.options.instance,
|
|
10773
|
+
accessToken: this.options.accessToken
|
|
10774
|
+
});
|
|
10775
|
+
this.portalClient = client;
|
|
10776
|
+
this.setAbis();
|
|
10777
|
+
}
|
|
10778
|
+
/**
|
|
10779
|
+
* Sets the ABIs based on the configured source priority.
|
|
10780
|
+
* Priority: hardcoded (default) > custom (user override) > predeployed (Portal's ABIs)
|
|
10781
|
+
*/
|
|
10782
|
+
setAbis() {
|
|
10783
|
+
const { abiSource } = this.options;
|
|
10784
|
+
switch (abiSource.type) {
|
|
10785
|
+
case "custom":
|
|
10786
|
+
this.easAbi = abiSource.easAbi;
|
|
10787
|
+
this.schemaRegistryAbi = abiSource.schemaRegistryAbi;
|
|
10788
|
+
if (this.options.debug) {
|
|
10789
|
+
console.log("Using custom ABIs provided by user");
|
|
10790
|
+
}
|
|
10791
|
+
break;
|
|
10792
|
+
case "predeployed":
|
|
10793
|
+
console.warn("Predeployed ABIs not yet supported, falling back to hardcoded ABIs");
|
|
10794
|
+
this.easAbi = EAS_ABI;
|
|
10795
|
+
this.schemaRegistryAbi = SCHEMA_REGISTRY_ABI;
|
|
10796
|
+
break;
|
|
10797
|
+
default:
|
|
10798
|
+
this.easAbi = EAS_ABI;
|
|
10799
|
+
this.schemaRegistryAbi = SCHEMA_REGISTRY_ABI;
|
|
10800
|
+
if (this.options.debug) {
|
|
10801
|
+
console.log("Using hardcoded standard EAS ABIs");
|
|
10802
|
+
}
|
|
10803
|
+
break;
|
|
10804
|
+
}
|
|
10805
|
+
}
|
|
10806
|
+
/**
|
|
10807
|
+
* Creates a new attestation on-chain.
|
|
10808
|
+
*
|
|
10809
|
+
* @param request - The attestation request data
|
|
10810
|
+
* @returns Promise resolving to transaction result
|
|
10811
|
+
* @throws EASPortalError if the operation fails
|
|
10812
|
+
*/
|
|
10813
|
+
async attest(request) {
|
|
10814
|
+
try {
|
|
10815
|
+
const result = await this.executeContractWrite("attest", [request]);
|
|
10816
|
+
return {
|
|
10817
|
+
hash: result.hash,
|
|
10818
|
+
success: true
|
|
10819
|
+
};
|
|
10820
|
+
} catch (error$34) {
|
|
10821
|
+
throw this.createError(EASErrorCode.TRANSACTION_FAILED, `Failed to create attestation: ${error$34}`);
|
|
10822
|
+
}
|
|
10823
|
+
}
|
|
10824
|
+
/**
|
|
10825
|
+
* Creates multiple attestations in a single transaction.
|
|
10826
|
+
*
|
|
10827
|
+
* @param requests - Array of attestation requests
|
|
10828
|
+
* @returns Promise resolving to transaction result
|
|
10829
|
+
* @throws EASPortalError if the operation fails
|
|
10830
|
+
*/
|
|
10831
|
+
async multiAttest(requests) {
|
|
10832
|
+
try {
|
|
10833
|
+
const result = await this.executeContractWrite("multiAttest", [requests]);
|
|
10834
|
+
return {
|
|
10835
|
+
hash: result.hash,
|
|
10836
|
+
success: true
|
|
10837
|
+
};
|
|
10838
|
+
} catch (error$34) {
|
|
10839
|
+
throw this.createError(EASErrorCode.TRANSACTION_FAILED, `Failed to create multiple attestations: ${error$34}`);
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
/**
|
|
10843
|
+
* Revokes an existing attestation.
|
|
10844
|
+
*
|
|
10845
|
+
* @param uid - The UID of the attestation to revoke
|
|
10846
|
+
* @param value - Optional ETH value to send with the transaction
|
|
10847
|
+
* @returns Promise resolving to transaction result
|
|
10848
|
+
* @throws EASPortalError if the operation fails
|
|
10849
|
+
*/
|
|
10850
|
+
async revoke(uid, value) {
|
|
10851
|
+
try {
|
|
10852
|
+
const result = await this.executeContractWrite("revoke", [{
|
|
10853
|
+
schema: uid,
|
|
10854
|
+
data: {
|
|
10855
|
+
uid,
|
|
10856
|
+
value: value || 0n
|
|
10857
|
+
}
|
|
10858
|
+
}]);
|
|
10859
|
+
return {
|
|
10860
|
+
hash: result.hash,
|
|
10861
|
+
success: true
|
|
10862
|
+
};
|
|
10863
|
+
} catch (error$34) {
|
|
10864
|
+
throw this.createError(EASErrorCode.TRANSACTION_FAILED, `Failed to revoke attestation: ${error$34}`);
|
|
10865
|
+
}
|
|
10866
|
+
}
|
|
10867
|
+
/**
|
|
10868
|
+
* Registers a new schema in the Schema Registry.
|
|
10869
|
+
* Supports both schema strings and schema fields with automatic validation.
|
|
10870
|
+
*
|
|
10871
|
+
* @param request - The schema registration request (schema string OR fields)
|
|
10872
|
+
* @returns Promise resolving to transaction result
|
|
10873
|
+
* @throws EASPortalError if the operation fails or validation fails
|
|
10874
|
+
*
|
|
10875
|
+
* @example
|
|
10876
|
+
* ```typescript
|
|
10877
|
+
* // Option 1: Using schema string
|
|
10878
|
+
* const result1 = await client.registerSchema({
|
|
10879
|
+
* schema: "address user, uint256 score",
|
|
10880
|
+
* resolver: "0x0000000000000000000000000000000000000000",
|
|
10881
|
+
* revocable: true,
|
|
10882
|
+
* });
|
|
10883
|
+
*
|
|
10884
|
+
* // Option 2: Using schema fields (with automatic validation)
|
|
10885
|
+
* const result2 = await client.registerSchema({
|
|
10886
|
+
* fields: [
|
|
10887
|
+
* { name: "user", type: "address", description: "User's wallet address" },
|
|
10888
|
+
* { name: "score", type: "uint256", description: "User's reputation score" }
|
|
10889
|
+
* ],
|
|
10890
|
+
* resolver: "0x0000000000000000000000000000000000000000",
|
|
10891
|
+
* revocable: true,
|
|
10892
|
+
* });
|
|
10893
|
+
* ```
|
|
10894
|
+
*/
|
|
10895
|
+
async registerSchema(request) {
|
|
10896
|
+
try {
|
|
10897
|
+
let schemaString;
|
|
10898
|
+
if (request.fields) {
|
|
10899
|
+
validateSchemaFields(request.fields);
|
|
10900
|
+
schemaString = buildSchemaString(request.fields);
|
|
10901
|
+
if (this.options.debug) {
|
|
10902
|
+
console.log(`Built schema string from fields: ${schemaString}`);
|
|
10903
|
+
console.log(`Fields validated: ${request.fields.length} fields`);
|
|
10904
|
+
}
|
|
10905
|
+
} else if (request.schema) {
|
|
10906
|
+
schemaString = request.schema;
|
|
10907
|
+
if (this.options.debug) {
|
|
10908
|
+
console.log(`Using provided schema string: ${schemaString}`);
|
|
10909
|
+
}
|
|
10910
|
+
} else {
|
|
10911
|
+
throw this.createError(EASErrorCode.INVALID_SCHEMA, "Either 'schema' string or 'fields' array must be provided");
|
|
10912
|
+
}
|
|
10913
|
+
const result = await this.executeSchemaRegistryWrite("register", [
|
|
10914
|
+
schemaString,
|
|
10915
|
+
request.resolver,
|
|
10916
|
+
request.revocable
|
|
10917
|
+
]);
|
|
10918
|
+
return {
|
|
10919
|
+
hash: result.hash,
|
|
10920
|
+
success: true
|
|
10921
|
+
};
|
|
10922
|
+
} catch (error$34) {
|
|
10923
|
+
if (error$34 instanceof EASPortalError) {
|
|
10924
|
+
throw error$34;
|
|
10925
|
+
}
|
|
10926
|
+
if (error$34 instanceof Error && error$34.message.includes("Field")) {
|
|
10927
|
+
throw this.createError(EASErrorCode.INVALID_SCHEMA, `Schema validation failed: ${error$34.message}`);
|
|
10928
|
+
}
|
|
10929
|
+
throw this.createError(EASErrorCode.TRANSACTION_FAILED, `Failed to register schema: ${error$34}`);
|
|
10930
|
+
}
|
|
10931
|
+
}
|
|
10932
|
+
/**
|
|
10933
|
+
* Retrieves an attestation by its UID.
|
|
10934
|
+
*
|
|
10935
|
+
* @param uid - The UID of the attestation
|
|
10936
|
+
* @returns Promise resolving to attestation data
|
|
10937
|
+
* @throws EASPortalError if the attestation is not found
|
|
10938
|
+
*/
|
|
10939
|
+
async getAttestation(uid) {
|
|
10940
|
+
try {
|
|
10941
|
+
const result = await this.executeContractRead("getAttestation", [uid]);
|
|
10942
|
+
const attestation = result;
|
|
10943
|
+
return {
|
|
10944
|
+
uid,
|
|
10945
|
+
schema: attestation.schema,
|
|
10946
|
+
attester: attestation.attester,
|
|
10947
|
+
recipient: attestation.recipient,
|
|
10948
|
+
time: attestation.time,
|
|
10949
|
+
expirationTime: attestation.expirationTime,
|
|
10950
|
+
revocable: attestation.revocable,
|
|
10951
|
+
refUID: attestation.refUID,
|
|
10952
|
+
data: attestation.data,
|
|
10953
|
+
value: attestation.value
|
|
10954
|
+
};
|
|
10955
|
+
} catch (error$34) {
|
|
10956
|
+
throw this.createError(EASErrorCode.ATTESTATION_NOT_FOUND, `Attestation not found: ${error$34}`);
|
|
10957
|
+
}
|
|
10958
|
+
}
|
|
10959
|
+
/**
|
|
10960
|
+
* Retrieves a schema by its UID.
|
|
10961
|
+
*
|
|
10962
|
+
* @param uid - The UID of the schema
|
|
10963
|
+
* @returns Promise resolving to schema data
|
|
10964
|
+
* @throws EASPortalError if the schema is not found
|
|
10965
|
+
*/
|
|
10966
|
+
async getSchema(uid) {
|
|
10967
|
+
try {
|
|
10968
|
+
const result = await this.executeSchemaRegistryRead("getSchema", [uid]);
|
|
10969
|
+
const schema = result;
|
|
10970
|
+
return {
|
|
10971
|
+
uid,
|
|
10972
|
+
resolver: schema.resolver,
|
|
10973
|
+
revocable: schema.revocable,
|
|
10974
|
+
schema: schema.schema
|
|
10975
|
+
};
|
|
10976
|
+
} catch (error$34) {
|
|
10977
|
+
throw this.createError(EASErrorCode.SCHEMA_NOT_FOUND, `Schema not found: ${error$34}`);
|
|
10978
|
+
}
|
|
10979
|
+
}
|
|
10980
|
+
/**
|
|
10981
|
+
* Checks if an attestation is valid (exists and not revoked).
|
|
10982
|
+
*
|
|
10983
|
+
* @param uid - The UID of the attestation
|
|
10984
|
+
* @returns Promise resolving to boolean indicating validity
|
|
10985
|
+
*/
|
|
10986
|
+
async isValidAttestation(uid) {
|
|
10987
|
+
try {
|
|
10988
|
+
const result = await this.executeContractRead("isValidAttestation", [uid]);
|
|
10989
|
+
return result;
|
|
10990
|
+
} catch (error$34) {
|
|
10991
|
+
if (this.options.debug) {
|
|
10992
|
+
console.warn(`Failed to check attestation validity: ${error$34}`);
|
|
10993
|
+
}
|
|
10994
|
+
return false;
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
/**
|
|
10998
|
+
* Gets the current timestamp from the EAS contract.
|
|
10999
|
+
*
|
|
11000
|
+
* @returns Promise resolving to current timestamp
|
|
11001
|
+
*/
|
|
11002
|
+
async getTimestamp() {
|
|
11003
|
+
try {
|
|
11004
|
+
const result = await this.executeContractRead("getTimestamp", []);
|
|
11005
|
+
return result;
|
|
11006
|
+
} catch (error$34) {
|
|
11007
|
+
throw this.createError(EASErrorCode.TRANSACTION_FAILED, `Failed to get timestamp: ${error$34}`);
|
|
11008
|
+
}
|
|
11009
|
+
}
|
|
11010
|
+
/**
|
|
11011
|
+
* Executes a write operation on the EAS contract.
|
|
11012
|
+
*
|
|
11013
|
+
* @param functionName - The function name to call
|
|
11014
|
+
* @param args - The function arguments
|
|
11015
|
+
* @returns Promise resolving to transaction result
|
|
11016
|
+
*/
|
|
11017
|
+
async executeContractWrite(functionName, args) {
|
|
11018
|
+
return { hash: "0x..." };
|
|
11019
|
+
}
|
|
11020
|
+
/**
|
|
11021
|
+
* Executes a write operation on the Schema Registry contract.
|
|
11022
|
+
*
|
|
11023
|
+
* @param functionName - The function name to call
|
|
11024
|
+
* @param args - The function arguments
|
|
11025
|
+
* @returns Promise resolving to transaction result
|
|
11026
|
+
*/
|
|
11027
|
+
async executeSchemaRegistryWrite(functionName, args) {
|
|
11028
|
+
return { hash: "0x..." };
|
|
11029
|
+
}
|
|
11030
|
+
/**
|
|
11031
|
+
* Executes a read operation on the EAS contract.
|
|
11032
|
+
*
|
|
11033
|
+
* @param functionName - The function name to call
|
|
11034
|
+
* @param args - The function arguments
|
|
11035
|
+
* @returns Promise resolving to the result
|
|
11036
|
+
*/
|
|
11037
|
+
async executeContractRead(functionName, args) {
|
|
11038
|
+
return {};
|
|
11039
|
+
}
|
|
11040
|
+
/**
|
|
11041
|
+
* Executes a read operation on the Schema Registry contract.
|
|
11042
|
+
*
|
|
11043
|
+
* @param functionName - The function name to call
|
|
11044
|
+
* @param args - The function arguments
|
|
11045
|
+
* @returns Promise resolving to the result
|
|
11046
|
+
*/
|
|
11047
|
+
async executeSchemaRegistryRead(functionName, args) {
|
|
11048
|
+
return {};
|
|
11049
|
+
}
|
|
11050
|
+
/**
|
|
11051
|
+
* Creates a standardized EAS Portal error.
|
|
11052
|
+
*
|
|
11053
|
+
* @param code - Error code
|
|
11054
|
+
* @param message - Error message
|
|
11055
|
+
* @returns EASPortalError instance
|
|
11056
|
+
*/
|
|
11057
|
+
createError(code, message) {
|
|
11058
|
+
return new EASPortalError(message, code);
|
|
11059
|
+
}
|
|
11060
|
+
/**
|
|
11061
|
+
* Gets the Portal client instance for advanced operations.
|
|
11062
|
+
*
|
|
11063
|
+
* @returns The underlying Portal client
|
|
11064
|
+
*/
|
|
11065
|
+
getPortalClient() {
|
|
11066
|
+
return this.portalClient;
|
|
11067
|
+
}
|
|
11068
|
+
/**
|
|
11069
|
+
* Gets the current configuration options.
|
|
11070
|
+
*
|
|
11071
|
+
* @returns The client configuration
|
|
11072
|
+
*/
|
|
11073
|
+
getOptions() {
|
|
11074
|
+
return { ...this.options };
|
|
11075
|
+
}
|
|
11076
|
+
/**
|
|
11077
|
+
* Gets the currently configured ABIs.
|
|
11078
|
+
*
|
|
11079
|
+
* @returns Object containing the EAS and Schema Registry ABIs
|
|
11080
|
+
*/
|
|
11081
|
+
getAbis() {
|
|
11082
|
+
return {
|
|
11083
|
+
easAbi: this.easAbi,
|
|
11084
|
+
schemaRegistryAbi: this.schemaRegistryAbi
|
|
11085
|
+
};
|
|
11086
|
+
}
|
|
11087
|
+
};
|
|
11088
|
+
|
|
10328
11089
|
//#endregion
|
|
10329
11090
|
//#region src/eas.ts
|
|
10330
11091
|
/**
|
|
10331
|
-
* Creates an EAS client for interacting with the Ethereum Attestation Service.
|
|
11092
|
+
* Creates an EAS client for interacting with the Ethereum Attestation Service via Portal.
|
|
11093
|
+
* This is the main entry point for the EAS SDK, now powered by Portal.
|
|
10332
11094
|
*
|
|
10333
|
-
* @param options - Configuration options for the client
|
|
10334
|
-
* @returns An
|
|
11095
|
+
* @param options - Configuration options for the Portal-based client
|
|
11096
|
+
* @returns An EAS Portal client instance with enhanced methods
|
|
10335
11097
|
* @throws Will throw an error if the options fail validation
|
|
10336
11098
|
*
|
|
10337
11099
|
* @example
|
|
10338
11100
|
* ```ts
|
|
10339
11101
|
* import { createEASClient } from '@settlemint/sdk-eas';
|
|
10340
11102
|
*
|
|
10341
|
-
* const
|
|
10342
|
-
*
|
|
10343
|
-
* attestationAddress: "0x1234567890123456789012345678901234567890",
|
|
11103
|
+
* const eas = createEASClient({
|
|
11104
|
+
* instance: "https://portal.settlemint.com",
|
|
10344
11105
|
* accessToken: "your-access-token",
|
|
10345
|
-
*
|
|
10346
|
-
*
|
|
10347
|
-
*
|
|
11106
|
+
* easContractAddress: "0x1234567890123456789012345678901234567890",
|
|
11107
|
+
* schemaRegistryContractAddress: "0x1234567890123456789012345678901234567890",
|
|
11108
|
+
* });
|
|
11109
|
+
*
|
|
11110
|
+
* // Register a schema with string
|
|
11111
|
+
* const result = await eas.registerSchema({
|
|
11112
|
+
* schema: "address user, uint256 score",
|
|
11113
|
+
* resolver: "0x0000000000000000000000000000000000000000",
|
|
11114
|
+
* revocable: true,
|
|
11115
|
+
* });
|
|
11116
|
+
*
|
|
11117
|
+
* // Or register schema with fields (automatic validation)
|
|
11118
|
+
* const schemaResult = await eas.registerSchema({
|
|
11119
|
+
* fields: [
|
|
11120
|
+
* { name: "user", type: "address" },
|
|
11121
|
+
* { name: "score", type: "uint256" }
|
|
11122
|
+
* ],
|
|
11123
|
+
* resolver: "0x0000000000000000000000000000000000000000",
|
|
11124
|
+
* revocable: true,
|
|
11125
|
+
* });
|
|
11126
|
+
*
|
|
11127
|
+
* // Create attestations
|
|
11128
|
+
* const attestation = await eas.attest({
|
|
11129
|
+
* schema: "0x...",
|
|
11130
|
+
* data: {
|
|
11131
|
+
* recipient: "0x...",
|
|
11132
|
+
* expirationTime: 0n,
|
|
11133
|
+
* revocable: true,
|
|
11134
|
+
* refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
11135
|
+
* data: "0x...",
|
|
11136
|
+
* value: 0n,
|
|
11137
|
+
* },
|
|
10348
11138
|
* });
|
|
10349
11139
|
* ```
|
|
10350
11140
|
*/
|
|
10351
11141
|
function createEASClient(options) {
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
} catch (error$34) {
|
|
10382
|
-
throw new Error(`Failed to register schema: ${error$34.message}`, { cause: error$34 });
|
|
10383
|
-
}
|
|
10384
|
-
}
|
|
10385
|
-
async function getSchema(uid) {
|
|
10386
|
-
try {
|
|
10387
|
-
await provider.getNetwork();
|
|
10388
|
-
const schema = await schemaRegistry.getSchema({ uid });
|
|
10389
|
-
return schema.toString();
|
|
10390
|
-
} catch (error$34) {
|
|
10391
|
-
throw new Error(`Failed to get schema: ${error$34.message}`);
|
|
10392
|
-
}
|
|
10393
|
-
}
|
|
10394
|
-
return {
|
|
10395
|
-
registerSchema,
|
|
10396
|
-
getSchema
|
|
10397
|
-
};
|
|
11142
|
+
const validatedOptions = validatePortalClientOptions(options);
|
|
11143
|
+
return new EASPortalClient(validatedOptions);
|
|
11144
|
+
}
|
|
11145
|
+
/**
|
|
11146
|
+
* Validates schema fields and builds a schema string without requiring a client instance.
|
|
11147
|
+
* Useful for pre-validation or building schema strings for external use.
|
|
11148
|
+
*
|
|
11149
|
+
* @param fields - Array of schema fields to validate
|
|
11150
|
+
* @returns The validated schema string
|
|
11151
|
+
* @throws Error if validation fails
|
|
11152
|
+
*
|
|
11153
|
+
* @example
|
|
11154
|
+
* ```typescript
|
|
11155
|
+
* import { validateAndBuildSchema } from "@settlemint/sdk-eas";
|
|
11156
|
+
*
|
|
11157
|
+
* try {
|
|
11158
|
+
* const schemaString = validateAndBuildSchema([
|
|
11159
|
+
* { name: "user", type: "address", description: "User's wallet address" },
|
|
11160
|
+
* { name: "score", type: "uint256", description: "User's reputation score" }
|
|
11161
|
+
* ]);
|
|
11162
|
+
* console.log("Schema is valid:", schemaString); // "address user, uint256 score"
|
|
11163
|
+
* } catch (error) {
|
|
11164
|
+
* console.error("Schema validation failed:", error.message);
|
|
11165
|
+
* }
|
|
11166
|
+
* ```
|
|
11167
|
+
*/
|
|
11168
|
+
function validateAndBuildSchema(fields) {
|
|
11169
|
+
validateSchemaFields(fields);
|
|
11170
|
+
return buildSchemaString(fields);
|
|
10398
11171
|
}
|
|
10399
11172
|
|
|
10400
11173
|
//#endregion
|
|
10401
|
-
export { EAS_FIELD_TYPES, createEASClient };
|
|
11174
|
+
export { DEFAULT_EAS_ABIS, EASErrorCode, EASPortalClient, EASPortalError, EAS_ABI, EAS_FIELD_TYPES, SCHEMA_REGISTRY_ABI, buildSchemaString, createEASClient, validateAndBuildSchema, validatePortalClientOptions, validateSchemaFields };
|
|
10402
11175
|
//# sourceMappingURL=eas.js.map
|