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