@settlemint/sdk-eas 2.3.5-prfde1f9e5 → 2.3.6
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 +84 -221
- package/dist/browser/eas.d.ts +37 -1012
- package/dist/browser/eas.js +112 -885
- package/dist/browser/eas.js.map +1 -1
- package/dist/eas.cjs +110 -893
- package/dist/eas.cjs.map +1 -1
- package/dist/eas.d.cts +37 -1012
- package/dist/eas.d.ts +37 -1012
- package/dist/eas.js +112 -885
- package/dist/eas.js.map +1 -1
- package/package.json +5 -3
package/dist/eas.cjs
CHANGED
|
@@ -27,360 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
}) : target, mod));
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
const
|
|
30
|
+
const __ethereum_attestation_service_eas_sdk = __toESM(require("@ethereum-attestation-service/eas-sdk"));
|
|
31
31
|
const __settlemint_sdk_utils_validation = __toESM(require("@settlemint/sdk-utils/validation"));
|
|
32
|
+
const __settlemint_sdk_viem = __toESM(require("@settlemint/sdk-viem"));
|
|
32
33
|
const viem = __toESM(require("viem"));
|
|
34
|
+
const ethers = __toESM(require("ethers"));
|
|
33
35
|
|
|
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
|
|
384
36
|
//#region ../../node_modules/zod/dist/esm/v4/core/core.js
|
|
385
37
|
function $constructor(name, initializer$2, params) {
|
|
386
38
|
const Parent = params?.Parent ?? Object;
|
|
@@ -10575,108 +10227,69 @@ var classic_default = external_exports;
|
|
|
10575
10227
|
var v4_default = classic_default;
|
|
10576
10228
|
|
|
10577
10229
|
//#endregion
|
|
10578
|
-
//#region src/
|
|
10230
|
+
//#region src/client-options.schema.ts
|
|
10579
10231
|
/**
|
|
10580
|
-
*
|
|
10581
|
-
*
|
|
10232
|
+
* Schema for validating EAS client configuration options.
|
|
10233
|
+
* Extends the base Viem client options with EAS-specific requirements.
|
|
10582
10234
|
*/
|
|
10583
|
-
const
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
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()
|
|
10235
|
+
const ClientOptionsSchema = object({
|
|
10236
|
+
schemaRegistryAddress: string().refine(viem.isAddress, "Invalid Ethereum address format"),
|
|
10237
|
+
attestationAddress: string().refine(viem.isAddress, "Invalid Ethereum address format"),
|
|
10238
|
+
accessToken: __settlemint_sdk_utils_validation.AccessTokenSchema,
|
|
10239
|
+
chainId: string().min(1),
|
|
10240
|
+
chainName: string().min(1),
|
|
10241
|
+
rpcUrl: __settlemint_sdk_utils_validation.UrlSchema
|
|
10615
10242
|
});
|
|
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
|
-
}
|
|
10638
10243
|
|
|
10639
10244
|
//#endregion
|
|
10640
|
-
//#region src/
|
|
10245
|
+
//#region src/ethers-adapter.ts
|
|
10641
10246
|
/**
|
|
10642
|
-
*
|
|
10247
|
+
* Converts a viem PublicClient to an ethers JsonRpcProvider
|
|
10643
10248
|
*/
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10249
|
+
function publicClientToProvider(client) {
|
|
10250
|
+
const { chain, transport } = client;
|
|
10251
|
+
if (!chain) throw new Error("Chain is required");
|
|
10252
|
+
const network = {
|
|
10253
|
+
chainId: chain.id,
|
|
10254
|
+
name: chain.name,
|
|
10255
|
+
ensAddress: chain.contracts?.ensRegistry?.address
|
|
10256
|
+
};
|
|
10257
|
+
if (transport.type === "fallback") {
|
|
10258
|
+
const providers = transport.transports.map(({ value }) => {
|
|
10259
|
+
if (!value?.url) return null;
|
|
10260
|
+
try {
|
|
10261
|
+
return new ethers.JsonRpcProvider(value.url, network);
|
|
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
|
+
}
|
|
10657
10271
|
/**
|
|
10658
|
-
*
|
|
10272
|
+
* Converts a viem WalletClient to an ethers Wallet
|
|
10659
10273
|
*/
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
this.cause = options.cause;
|
|
10674
|
-
}
|
|
10274
|
+
function walletClientToSigner(client) {
|
|
10275
|
+
const { account, chain, transport } = client;
|
|
10276
|
+
if (!chain) throw new Error("Chain is required");
|
|
10277
|
+
if (!account) throw new Error("Account is required");
|
|
10278
|
+
const network = {
|
|
10279
|
+
chainId: chain.id,
|
|
10280
|
+
name: chain.name,
|
|
10281
|
+
ensAddress: chain.contracts?.ensRegistry?.address
|
|
10282
|
+
};
|
|
10283
|
+
const provider = new ethers.JsonRpcProvider(transport.url, network);
|
|
10284
|
+
const privateKey = account.privateKey;
|
|
10285
|
+
if (!privateKey || typeof privateKey !== "string") {
|
|
10286
|
+
throw new Error("Private key is required and must be a string");
|
|
10675
10287
|
}
|
|
10676
|
-
|
|
10288
|
+
return new ethers.Wallet(privateKey, provider);
|
|
10289
|
+
}
|
|
10677
10290
|
|
|
10678
10291
|
//#endregion
|
|
10679
|
-
//#region src/
|
|
10292
|
+
//#region src/types.ts
|
|
10680
10293
|
/**
|
|
10681
10294
|
* Supported field types for EAS schema fields.
|
|
10682
10295
|
* Maps to the Solidity types that can be used in EAS schemas.
|
|
@@ -10694,7 +10307,7 @@ const EAS_FIELD_TYPES = {
|
|
|
10694
10307
|
};
|
|
10695
10308
|
|
|
10696
10309
|
//#endregion
|
|
10697
|
-
//#region src/
|
|
10310
|
+
//#region src/validation.ts
|
|
10698
10311
|
function validateFieldName(name) {
|
|
10699
10312
|
if (!name) {
|
|
10700
10313
|
throw new Error("Field name cannot be empty");
|
|
@@ -10730,475 +10343,79 @@ function buildSchemaString(fields) {
|
|
|
10730
10343
|
return fields.map((field) => `${field.type} ${field.name}`).join(", ");
|
|
10731
10344
|
}
|
|
10732
10345
|
|
|
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
|
-
|
|
11107
10346
|
//#endregion
|
|
11108
10347
|
//#region src/eas.ts
|
|
11109
10348
|
/**
|
|
11110
|
-
* Creates an EAS client for interacting with the Ethereum Attestation Service
|
|
11111
|
-
* This is the main entry point for the EAS SDK, now powered by Portal.
|
|
10349
|
+
* Creates an EAS client for interacting with the Ethereum Attestation Service.
|
|
11112
10350
|
*
|
|
11113
|
-
* @param options - Configuration options for the
|
|
11114
|
-
* @returns An EAS
|
|
10351
|
+
* @param options - Configuration options for the client
|
|
10352
|
+
* @returns An object containing the EAS client instance
|
|
11115
10353
|
* @throws Will throw an error if the options fail validation
|
|
11116
10354
|
*
|
|
11117
10355
|
* @example
|
|
11118
10356
|
* ```ts
|
|
11119
10357
|
* import { createEASClient } from '@settlemint/sdk-eas';
|
|
11120
10358
|
*
|
|
11121
|
-
* const
|
|
11122
|
-
*
|
|
10359
|
+
* const client = createEASClient({
|
|
10360
|
+
* schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
|
|
10361
|
+
* attestationAddress: "0x1234567890123456789012345678901234567890",
|
|
11123
10362
|
* accessToken: "your-access-token",
|
|
11124
|
-
*
|
|
11125
|
-
*
|
|
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
|
-
* },
|
|
10363
|
+
* chainId: "1",
|
|
10364
|
+
* chainName: "Ethereum",
|
|
10365
|
+
* rpcUrl: "http://localhost:8545"
|
|
11156
10366
|
* });
|
|
11157
10367
|
* ```
|
|
11158
10368
|
*/
|
|
11159
10369
|
function createEASClient(options) {
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
10370
|
+
(0, __settlemint_sdk_utils_validation.validate)(ClientOptionsSchema, options);
|
|
10371
|
+
const publicClient = (0, __settlemint_sdk_viem.getPublicClient)({
|
|
10372
|
+
accessToken: options.accessToken,
|
|
10373
|
+
chainId: options.chainId,
|
|
10374
|
+
chainName: options.chainName,
|
|
10375
|
+
rpcUrl: options.rpcUrl
|
|
10376
|
+
});
|
|
10377
|
+
const walletClient = (0, __settlemint_sdk_viem.getWalletClient)({
|
|
10378
|
+
accessToken: options.accessToken,
|
|
10379
|
+
chainId: options.chainId,
|
|
10380
|
+
chainName: options.chainName,
|
|
10381
|
+
rpcUrl: options.rpcUrl
|
|
10382
|
+
})();
|
|
10383
|
+
const provider = publicClientToProvider(publicClient);
|
|
10384
|
+
const wallet = walletClientToSigner(walletClient);
|
|
10385
|
+
const schemaRegistry = new __ethereum_attestation_service_eas_sdk.SchemaRegistry(options.schemaRegistryAddress);
|
|
10386
|
+
schemaRegistry.connect(wallet);
|
|
10387
|
+
async function registerSchema(options$1) {
|
|
10388
|
+
validateSchemaFields(options$1.fields);
|
|
10389
|
+
const schema = buildSchemaString(options$1.fields);
|
|
10390
|
+
try {
|
|
10391
|
+
await provider.getNetwork();
|
|
10392
|
+
const tx = await schemaRegistry.register({
|
|
10393
|
+
schema,
|
|
10394
|
+
resolverAddress: options$1.resolverAddress,
|
|
10395
|
+
revocable: options$1.revocable
|
|
10396
|
+
});
|
|
10397
|
+
await tx.wait();
|
|
10398
|
+
return tx.toString();
|
|
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
|
+
};
|
|
11189
10416
|
}
|
|
11190
10417
|
|
|
11191
10418
|
//#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;
|
|
11197
10419
|
exports.EAS_FIELD_TYPES = EAS_FIELD_TYPES;
|
|
11198
|
-
exports.SCHEMA_REGISTRY_ABI = SCHEMA_REGISTRY_ABI;
|
|
11199
|
-
exports.buildSchemaString = buildSchemaString;
|
|
11200
10420
|
exports.createEASClient = createEASClient;
|
|
11201
|
-
exports.validateAndBuildSchema = validateAndBuildSchema;
|
|
11202
|
-
exports.validatePortalClientOptions = validatePortalClientOptions;
|
|
11203
|
-
exports.validateSchemaFields = validateSchemaFields;
|
|
11204
10421
|
//# sourceMappingURL=eas.cjs.map
|