@settlemint/sdk-eas 2.2.2-pr75b59b5f → 2.2.2-pr8fc22dc7

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 CHANGED
@@ -27,12 +27,378 @@
27
27
  ## Table of Contents
28
28
 
29
29
  - [About](#about)
30
+ - [API Reference](#api-reference)
31
+ - [Functions](#functions)
32
+ - [buildSchemaString()](#buildschemastring)
33
+ - [registerSchema()](#registerschema)
34
+ - [validateEthereumAddress()](#validateethereumaddress)
35
+ - [validateFieldName()](#validatefieldname)
36
+ - [validateFieldType()](#validatefieldtype)
37
+ - [validateSchemaFields()](#validateschemafields)
38
+ - [Interfaces](#interfaces)
39
+ - [RegisterSchemaOptions](#registerschemaoptions)
40
+ - [SchemaField](#schemafield)
41
+ - [Type Aliases](#type-aliases)
42
+ - [EASFieldType](#easfieldtype)
43
+ - [Variables](#variables)
44
+ - [EAS\_FIELD\_TYPES](#eas_field_types)
30
45
  - [Contributing](#contributing)
31
46
  - [License](#license)
32
47
 
33
48
  ## About
34
49
 
35
50
  The SettleMint EAS SDK provides a lightweight wrapper for the Ethereum Attestation Service (EAS), enabling developers to easily create, manage, and verify attestations within their applications. It simplifies the process of working with EAS by handling contract interactions, schema management, and The Graph integration, while ensuring proper integration with the SettleMint platform. This allows developers to quickly implement document verification, identity attestation, and other EAS-based features without manual setup.
51
+
52
+ ## API Reference
53
+
54
+ ### Functions
55
+
56
+ #### buildSchemaString()
57
+
58
+ > **buildSchemaString**(`fields`): `string`
59
+
60
+ Defined in: [schema.ts:166](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L166)
61
+
62
+ Builds an EAS schema string from an array of fields.
63
+
64
+ ##### Parameters
65
+
66
+ | Parameter | Type | Description |
67
+ | ------ | ------ | ------ |
68
+ | `fields` | [`SchemaField`](#schemafield)[] | The fields to include in the schema |
69
+
70
+ ##### Returns
71
+
72
+ `string`
73
+
74
+ The EAS-compatible schema string
75
+
76
+ ##### Throws
77
+
78
+ Error if any field is invalid
79
+
80
+ ##### Example
81
+
82
+ ```ts
83
+ import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';
84
+
85
+ const fields: SchemaField[] = [
86
+ { name: "userAddress", type: "address" },
87
+ { name: "age", type: "uint8" },
88
+ { name: "isActive", type: "bool" }
89
+ ];
90
+
91
+ const schemaString = buildSchemaString(fields);
92
+ // Result: "address userAddress, uint8 age, bool isActive"
93
+ ```
94
+
95
+ ***
96
+
97
+ #### registerSchema()
98
+
99
+ > **registerSchema**(`options`): `Promise`\<`string`\>
100
+
101
+ Defined in: [schema.ts:246](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L246)
102
+
103
+ Registers a new schema with EAS.
104
+
105
+ ##### Parameters
106
+
107
+ | Parameter | Type | Description |
108
+ | ------ | ------ | ------ |
109
+ | `options` | [`RegisterSchemaOptions`](#registerschemaoptions) | The schema registration options |
110
+
111
+ ##### Returns
112
+
113
+ `Promise`\<`string`\>
114
+
115
+ A promise that resolves to the schema UID
116
+
117
+ ##### Throws
118
+
119
+ Error if the schema registration fails
120
+
121
+ ##### Example
122
+
123
+ ```ts
124
+ import { registerSchema, SchemaField } from '@settlemint/sdk-eas';
125
+
126
+ const fields: SchemaField[] = [
127
+ { name: "userAddress", type: "address" },
128
+ { name: "age", type: "uint8" }
129
+ ];
130
+
131
+ const schemaUID = await registerSchema({
132
+ fields,
133
+ resolverAddress: "0x1234567890123456789012345678901234567890",
134
+ revocable: true
135
+ });
136
+
137
+ console.log(`Schema registered with UID: ${schemaUID}`);
138
+ ```
139
+
140
+ ***
141
+
142
+ #### validateEthereumAddress()
143
+
144
+ > **validateEthereumAddress**(`address`): `void`
145
+
146
+ Defined in: [schema.ts:214](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L214)
147
+
148
+ Validates an Ethereum address.
149
+
150
+ ##### Parameters
151
+
152
+ | Parameter | Type | Description |
153
+ | ------ | ------ | ------ |
154
+ | `address` | `string` | The address to validate |
155
+
156
+ ##### Returns
157
+
158
+ `void`
159
+
160
+ ##### Throws
161
+
162
+ Error if the address is invalid
163
+
164
+ ##### Example
165
+
166
+ ```ts
167
+ import { validateEthereumAddress } from '@settlemint/sdk-eas';
168
+
169
+ // Valid address
170
+ validateEthereumAddress("0x1234567890123456789012345678901234567890"); // OK
171
+
172
+ // Invalid addresses
173
+ validateEthereumAddress("0x123"); // Throws: "Invalid Ethereum address format"
174
+ validateEthereumAddress(""); // Throws: "Resolver address cannot be empty"
175
+ ```
176
+
177
+ ***
178
+
179
+ #### validateFieldName()
180
+
181
+ > **validateFieldName**(`name`): `void`
182
+
183
+ Defined in: [schema.ts:71](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L71)
184
+
185
+ Validates a schema field name.
186
+
187
+ ##### Parameters
188
+
189
+ | Parameter | Type | Description |
190
+ | ------ | ------ | ------ |
191
+ | `name` | `string` | The field name to validate |
192
+
193
+ ##### Returns
194
+
195
+ `void`
196
+
197
+ ##### Throws
198
+
199
+ Error if the name is invalid
200
+
201
+ ##### Example
202
+
203
+ ```ts
204
+ import { validateFieldName } from '@settlemint/sdk-eas';
205
+
206
+ // Valid names
207
+ validateFieldName("userAddress"); // OK
208
+ validateFieldName("user_address"); // OK
209
+
210
+ // Invalid names
211
+ validateFieldName("user address"); // Throws: "Field name cannot contain spaces"
212
+ validateFieldName("123user"); // Throws: "Field name must start with a letter or underscore"
213
+ ```
214
+
215
+ ***
216
+
217
+ #### validateFieldType()
218
+
219
+ > **validateFieldType**(`type`): asserts type is "string" \| "address" \| "bool" \| "bytes" \| "bytes32" \| "uint256" \| "int256" \| "uint8" \| "int8"
220
+
221
+ Defined in: [schema.ts:101](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L101)
222
+
223
+ Validates a schema field type.
224
+
225
+ ##### Parameters
226
+
227
+ | Parameter | Type | Description |
228
+ | ------ | ------ | ------ |
229
+ | `type` | `string` | The field type to validate |
230
+
231
+ ##### Returns
232
+
233
+ asserts type is "string" \| "address" \| "bool" \| "bytes" \| "bytes32" \| "uint256" \| "int256" \| "uint8" \| "int8"
234
+
235
+ ##### Throws
236
+
237
+ Error if the type is invalid
238
+
239
+ ##### Example
240
+
241
+ ```ts
242
+ import { validateFieldType } from '@settlemint/sdk-eas';
243
+
244
+ // Valid types
245
+ validateFieldType("string"); // OK
246
+ validateFieldType("address"); // OK
247
+
248
+ // Invalid types
249
+ validateFieldType("invalidType"); // Throws: "Invalid field type: invalidType"
250
+ ```
251
+
252
+ ***
253
+
254
+ #### validateSchemaFields()
255
+
256
+ > **validateSchemaFields**(`fields`): `void`
257
+
258
+ Defined in: [schema.ts:130](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L130)
259
+
260
+ Validates an array of schema fields.
261
+
262
+ ##### Parameters
263
+
264
+ | Parameter | Type | Description |
265
+ | ------ | ------ | ------ |
266
+ | `fields` | [`SchemaField`](#schemafield)[] | The fields to validate |
267
+
268
+ ##### Returns
269
+
270
+ `void`
271
+
272
+ ##### Throws
273
+
274
+ Error if any field is invalid
275
+
276
+ ##### Example
277
+
278
+ ```ts
279
+ import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';
280
+
281
+ const fields: SchemaField[] = [
282
+ { name: "userAddress", type: "address" },
283
+ { name: "age", type: "uint8" }
284
+ ];
285
+
286
+ validateSchemaFields(fields); // OK
287
+
288
+ // Invalid fields
289
+ validateSchemaFields([]); // Throws: "Schema must have at least one field"
290
+ validateSchemaFields([
291
+ { name: "userAddress", type: "address" },
292
+ { name: "userAddress", type: "uint8" }
293
+ ]); // Throws: "Duplicate field name: userAddress"
294
+ ```
295
+
296
+ ### Interfaces
297
+
298
+ #### RegisterSchemaOptions
299
+
300
+ Defined in: [schema.ts:187](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L187)
301
+
302
+ Options for registering a schema.
303
+
304
+ ##### Example
305
+
306
+ ```ts
307
+ import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';
308
+
309
+ const options: RegisterSchemaOptions = {
310
+ fields: [
311
+ { name: "userAddress", type: "address" },
312
+ { name: "age", type: "uint8" }
313
+ ],
314
+ resolverAddress: "0x1234567890123456789012345678901234567890",
315
+ revocable: true
316
+ };
317
+ ```
318
+
319
+ ##### Properties
320
+
321
+ | Property | Type | Description | Defined in |
322
+ | ------ | ------ | ------ | ------ |
323
+ | <a id="fields"></a> `fields` | [`SchemaField`](#schemafield)[] | The fields that make up the schema | [schema.ts:189](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L189) |
324
+ | <a id="resolveraddress"></a> `resolverAddress` | `string` | The Ethereum address of the resolver | [schema.ts:191](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L191) |
325
+ | <a id="revocable"></a> `revocable` | `boolean` | Whether attestations using this schema can be revoked | [schema.ts:193](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L193) |
326
+
327
+ ***
328
+
329
+ #### SchemaField
330
+
331
+ Defined in: [schema.ts:45](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L45)
332
+
333
+ Interface for defining a schema field.
334
+
335
+ ##### Example
336
+
337
+ ```ts
338
+ import { SchemaField } from '@settlemint/sdk-eas';
339
+
340
+ const field: SchemaField = {
341
+ name: "userAddress",
342
+ type: "address",
343
+ description: "The Ethereum address of the user"
344
+ };
345
+ ```
346
+
347
+ ##### Properties
348
+
349
+ | Property | Type | Description | Defined in |
350
+ | ------ | ------ | ------ | ------ |
351
+ | <a id="description"></a> `description?` | `string` | Optional description of the field | [schema.ts:51](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L51) |
352
+ | <a id="name"></a> `name` | `string` | The name of the field | [schema.ts:47](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L47) |
353
+ | <a id="type"></a> `type` | `"string"` \| `"address"` \| `"bool"` \| `"bytes"` \| `"bytes32"` \| `"uint256"` \| `"int256"` \| `"uint8"` \| `"int8"` | The type of the field | [schema.ts:49](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L49) |
354
+
355
+ ### Type Aliases
356
+
357
+ #### EASFieldType
358
+
359
+ > **EASFieldType** = keyof *typeof* [`EAS_FIELD_TYPES`](#eas_field_types)
360
+
361
+ Defined in: [schema.ts:30](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L30)
362
+
363
+ Type representing all valid EAS field types.
364
+
365
+ ### Variables
366
+
367
+ #### EAS\_FIELD\_TYPES
368
+
369
+ > `const` **EAS\_FIELD\_TYPES**: `object`
370
+
371
+ Defined in: [schema.ts:15](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L15)
372
+
373
+ Supported EAS schema field types.
374
+ Maps user-friendly type names to EAS-compatible type strings.
375
+
376
+ ##### Type declaration
377
+
378
+ | Name | Type | Default value | Defined in |
379
+ | ------ | ------ | ------ | ------ |
380
+ | <a id="address"></a> `address` | `"address"` | `"address"` | [schema.ts:17](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L17) |
381
+ | <a id="bool"></a> `bool` | `"bool"` | `"bool"` | [schema.ts:18](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L18) |
382
+ | <a id="bytes"></a> `bytes` | `"bytes"` | `"bytes"` | [schema.ts:19](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L19) |
383
+ | <a id="bytes32"></a> `bytes32` | `"bytes32"` | `"bytes32"` | [schema.ts:20](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L20) |
384
+ | <a id="int256"></a> `int256` | `"int256"` | `"int256"` | [schema.ts:22](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L22) |
385
+ | <a id="int8"></a> `int8` | `"int8"` | `"int8"` | [schema.ts:24](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L24) |
386
+ | <a id="string"></a> `string` | `"string"` | `"string"` | [schema.ts:16](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L16) |
387
+ | <a id="uint256"></a> `uint256` | `"uint256"` | `"uint256"` | [schema.ts:21](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L21) |
388
+ | <a id="uint8"></a> `uint8` | `"uint8"` | `"uint8"` | [schema.ts:23](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L23) |
389
+
390
+ ##### Example
391
+
392
+ ```ts
393
+ import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';
394
+
395
+ // Use in type definitions
396
+ type MyFieldType = keyof typeof EAS_FIELD_TYPES;
397
+
398
+ // Check if a type is supported
399
+ const isValidType = "string" in EAS_FIELD_TYPES;
400
+ ```
401
+
36
402
  ## Contributing
37
403
 
38
404
  We welcome contributions from the community! Please check out our [Contributing](https://github.com/settlemint/sdk/blob/main/.github/CONTRIBUTING.md) guide to learn how you can help improve the SettleMint SDK through bug reports, feature requests, documentation updates, or code contributions.
package/dist/eas.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var viem=require('viem');var o={string:"string",address:"address",bool:"bool",bytes:"bytes",bytes32:"bytes32",uint256:"uint256",int256:"int256",uint8:"uint8",int8:"int8"};function a(e){if(!e)throw new Error("Field name cannot be empty");if(e.includes(" "))throw new Error("Field name cannot contain spaces");if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw new Error("Field name must start with a letter or underscore and contain only alphanumeric characters and underscores")}function c(e){if(!(e in o))throw new Error(`Invalid field type: ${e}. Must be one of: ${Object.keys(o).join(", ")}`)}function r(e){if(!e||e.length===0)throw new Error("Schema must have at least one field");let t=new Set;for(let n of e){if(a(n.name),c(n.type),t.has(n.name))throw new Error(`Duplicate field name: ${n.name}`);t.add(n.name);}}function l(e){return r(e),e.map(t=>`${t.type} ${t.name}`).join(", ")}function m(e){if(!e)throw new Error("Resolver address cannot be empty");if(!viem.isAddress(e))throw new Error("Invalid Ethereum address format")}async function p(e){let{fields:t,resolverAddress:n,revocable:i}=e;r(t),m(n);let s=l(t);return console.log(`[EAS] Registering schema: ${s}`),console.log(`[EAS] Resolver: ${n}`),console.log(`[EAS] Revocable: ${i}`),`0x${"0".repeat(64)}`}function S(){return {submitAttestation(){console.log("[EAS] Submitting attestation");},parseAttestation(){console.log("[EAS] Parsing attestation");},createSchema(){console.log("[EAS] Creating schema");},getSchema(){console.log("[EAS] Getting schema");},getAttestations(){console.log("[EAS] Getting attestations");}}}exports.EAS_FIELD_TYPES=o;exports.buildSchemaString=l;exports.createEASClient=S;exports.registerSchema=p;exports.validateEthereumAddress=m;exports.validateFieldName=a;exports.validateFieldType=c;exports.validateSchemaFields=r;//# sourceMappingURL=eas.cjs.map
2
+ //# sourceMappingURL=eas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/eas.ts"],"names":["EAS_FIELD_TYPES","validateFieldName","name","validateFieldType","type","validateSchemaFields","fields","seenNames","field","buildSchemaString","validateEthereumAddress","address","isAddress","registerSchema","options","resolverAddress","revocable","schemaString","createEASClient"],"mappings":"sCAcO,IAAMA,CAAkB,CAAA,CAC7B,MAAQ,CAAA,QAAA,CACR,OAAS,CAAA,SAAA,CACT,IAAM,CAAA,MAAA,CACN,MAAO,OACP,CAAA,OAAA,CAAS,SACT,CAAA,OAAA,CAAS,SACT,CAAA,MAAA,CAAQ,QACR,CAAA,KAAA,CAAO,OACP,CAAA,IAAA,CAAM,MACR,EA8CO,SAASC,CAAAA,CAAkBC,CAAoB,CAAA,CACpD,GAAI,CAACA,CAAAA,CACH,MAAM,IAAI,KAAM,CAAA,4BAA4B,CAE9C,CAAA,GAAIA,CAAK,CAAA,QAAA,CAAS,GAAG,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MAAM,IAAI,KAAM,CAAA,kCAAkC,CAEpD,CAAA,GAAI,CAACC,cAAAA,CAAUD,CAAO,CAAA,CACpB,MAAM,IAAI,KAAM,CAAA,iCAAiC,CAErD,CAyBA,eAAsBE,CAAAA,CAAeC,EAAiD,CACpF,GAAM,CAAE,MAAA,CAAAR,CAAQ,CAAA,eAAA,CAAAS,CAAiB,CAAA,SAAA,CAAAC,CAAU,CAAIF,CAAAA,CAAAA,CAG/CT,CAAqBC,CAAAA,CAAM,CAG3BI,CAAAA,CAAAA,CAAwBK,CAAe,CAAA,CAGvC,IAAME,CAAeR,CAAAA,CAAAA,CAAkBH,CAAM,CAAA,CAI7C,OAAQ,OAAA,CAAA,GAAA,CAAI,CAA6BW,0BAAAA,EAAAA,CAAY,CAAE,CAAA,CAAA,CACvD,OAAQ,CAAA,GAAA,CAAI,CAAmBF,gBAAAA,EAAAA,CAAe,CAAE,CAAA,CAAA,CAChD,QAAQ,GAAI,CAAA,CAAA,iBAAA,EAAoBC,CAAS,CAAA,CAAE,CAGpC,CAAA,CAAA,EAAA,EAAK,GAAI,CAAA,MAAA,CAAO,EAAE,CAAC,CAC5B,CAAA,CCvQO,SAASE,CAAAA,EAAkB,CAChC,OAAO,CACL,iBAAoB,EAAA,CAClB,OAAQ,CAAA,GAAA,CAAI,8BAA8B,EAC5C,CAEA,CAAA,gBAAA,EAAmB,CACjB,OAAA,CAAQ,GAAI,CAAA,2BAA2B,EACzC,CAAA,CAEA,YAAe,EAAA,CACb,QAAQ,GAAI,CAAA,uBAAuB,EACrC,CAAA,CAEA,SAAY,EAAA,CACV,OAAQ,CAAA,GAAA,CAAI,sBAAsB,EACpC,CAAA,CAEA,eAAkB,EAAA,CAChB,OAAQ,CAAA,GAAA,CAAI,4BAA4B,EAC1C,CACF,CACF","file":"eas.cjs","sourcesContent":["/**\n * Supported EAS schema field types.\n * Maps user-friendly type names to EAS-compatible type strings.\n * @example\n * ```ts\n * import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';\n *\n * // Use in type definitions\n * type MyFieldType = keyof typeof EAS_FIELD_TYPES;\n *\n * // Check if a type is supported\n * const isValidType = \"string\" in EAS_FIELD_TYPES;\n * ```\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\n/**\n * Type representing all valid EAS field types.\n */\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Interface for defining a schema field.\n * @example\n * ```ts\n * import { SchemaField } from '@settlemint/sdk-eas';\n *\n * const field: SchemaField = {\n * name: \"userAddress\",\n * type: \"address\",\n * description: \"The Ethereum address of the user\"\n * };\n * ```\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The type of the field */\n type: EASFieldType;\n /** Optional description of the field */\n description?: string;\n}\n\n/**\n * Validates a schema field name.\n * @param name - The field name to validate\n * @throws Error if the name is invalid\n * @example\n * ```ts\n * import { validateFieldName } from '@settlemint/sdk-eas';\n *\n * // Valid names\n * validateFieldName(\"userAddress\"); // OK\n * validateFieldName(\"user_address\"); // OK\n *\n * // Invalid names\n * validateFieldName(\"user address\"); // Throws: \"Field name cannot contain spaces\"\n * validateFieldName(\"123user\"); // Throws: \"Field name must start with a letter or underscore\"\n * ```\n */\nexport function validateFieldName(name: string): void {\n if (!name) {\n throw new Error(\"Field name cannot be empty\");\n }\n if (name.includes(\" \")) {\n throw new Error(\"Field name cannot contain spaces\");\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(\n \"Field name must start with a letter or underscore and contain only alphanumeric characters and underscores\",\n );\n }\n}\n\n/**\n * Validates a schema field type.\n * @param type - The field type to validate\n * @throws Error if the type is invalid\n * @example\n * ```ts\n * import { validateFieldType } from '@settlemint/sdk-eas';\n *\n * // Valid types\n * validateFieldType(\"string\"); // OK\n * validateFieldType(\"address\"); // OK\n *\n * // Invalid types\n * validateFieldType(\"invalidType\"); // Throws: \"Invalid field type: invalidType\"\n * ```\n */\nexport function validateFieldType(type: string): asserts type is EASFieldType {\n if (!(type in EAS_FIELD_TYPES)) {\n throw new Error(`Invalid field type: ${type}. Must be one of: ${Object.keys(EAS_FIELD_TYPES).join(\", \")}`);\n }\n}\n\n/**\n * Validates an array of schema fields.\n * @param fields - The fields to validate\n * @throws Error if any field is invalid\n * @example\n * ```ts\n * import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ];\n *\n * validateSchemaFields(fields); // OK\n *\n * // Invalid fields\n * validateSchemaFields([]); // Throws: \"Schema must have at least one field\"\n * validateSchemaFields([\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"userAddress\", type: \"uint8\" }\n * ]); // Throws: \"Duplicate field name: userAddress\"\n * ```\n */\nexport function validateSchemaFields(fields: SchemaField[]): void {\n if (!fields || fields.length === 0) {\n throw new Error(\"Schema must have at least one field\");\n }\n\n const seenNames = new Set<string>();\n for (const field of fields) {\n validateFieldName(field.name);\n validateFieldType(field.type);\n\n if (seenNames.has(field.name)) {\n throw new Error(`Duplicate field name: ${field.name}`);\n }\n seenNames.add(field.name);\n }\n}\n\n/**\n * Builds an EAS schema string from an array of fields.\n * @param fields - The fields to include in the schema\n * @returns The EAS-compatible schema string\n * @throws Error if any field is invalid\n * @example\n * ```ts\n * import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" },\n * { name: \"isActive\", type: \"bool\" }\n * ];\n *\n * const schemaString = buildSchemaString(fields);\n * // Result: \"address userAddress, uint8 age, bool isActive\"\n * ```\n */\nexport function buildSchemaString(fields: SchemaField[]): string {\n validateSchemaFields(fields);\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n}\n\n/**\n * Options for registering a schema.\n * @example\n * ```ts\n * import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';\n *\n * const options: RegisterSchemaOptions = {\n * fields: [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ],\n * resolverAddress: \"0x1234567890123456789012345678901234567890\",\n * revocable: true\n * };\n * ```\n */\nexport interface RegisterSchemaOptions {\n /** The fields that make up the schema */\n fields: SchemaField[];\n /** The Ethereum address of the resolver */\n resolverAddress: string;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\nimport { isAddress } from \"viem\";\n\n/**\n * Validates an Ethereum address.\n * @param address - The address to validate\n * @throws Error if the address is invalid\n * @example\n * ```ts\n * import { validateEthereumAddress } from '@settlemint/sdk-eas';\n *\n * // Valid address\n * validateEthereumAddress(\"0x1234567890123456789012345678901234567890\"); // OK\n *\n * // Invalid addresses\n * validateEthereumAddress(\"0x123\"); // Throws: \"Invalid Ethereum address format\"\n * validateEthereumAddress(\"\"); // Throws: \"Resolver address cannot be empty\"\n * ```\n */\nexport function validateEthereumAddress(address: string): void {\n if (!address) {\n throw new Error(\"Resolver address cannot be empty\");\n }\n if (!isAddress(address)) {\n throw new Error(\"Invalid Ethereum address format\");\n }\n}\n\n/**\n * Registers a new schema with EAS.\n * @param options - The schema registration options\n * @returns A promise that resolves to the schema UID\n * @throws Error if the schema registration fails\n * @example\n * ```ts\n * import { registerSchema, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ];\n *\n * const schemaUID = await registerSchema({\n * fields,\n * resolverAddress: \"0x1234567890123456789012345678901234567890\",\n * revocable: true\n * });\n *\n * console.log(`Schema registered with UID: ${schemaUID}`);\n * ```\n */\nexport async function registerSchema(options: RegisterSchemaOptions): Promise<string> {\n const { fields, resolverAddress, revocable } = options;\n\n // Validate the schema fields\n validateSchemaFields(fields);\n\n // Validate the resolver address\n validateEthereumAddress(resolverAddress);\n\n // Build the schema string\n const schemaString = buildSchemaString(fields);\n\n // TODO: Implement actual EAS SDK registration\n // This is a placeholder that will be replaced with actual EAS SDK integration\n console.log(`[EAS] Registering schema: ${schemaString}`);\n console.log(`[EAS] Resolver: ${resolverAddress}`);\n console.log(`[EAS] Revocable: ${revocable}`);\n\n // Return a mock UID for now\n return `0x${\"0\".repeat(64)}`;\n}\n","export * from \"./schema.js\";\n\nexport function createEASClient() {\n return {\n submitAttestation() {\n console.log(\"[EAS] Submitting attestation\");\n },\n\n parseAttestation() {\n console.log(\"[EAS] Parsing attestation\");\n },\n\n createSchema() {\n console.log(\"[EAS] Creating schema\");\n },\n\n getSchema() {\n console.log(\"[EAS] Getting schema\");\n },\n\n getAttestations() {\n console.log(\"[EAS] Getting attestations\");\n },\n };\n}\n"]}
package/dist/eas.d.cts ADDED
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Supported EAS schema field types.
3
+ * Maps user-friendly type names to EAS-compatible type strings.
4
+ * @example
5
+ * ```ts
6
+ * import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';
7
+ *
8
+ * // Use in type definitions
9
+ * type MyFieldType = keyof typeof EAS_FIELD_TYPES;
10
+ *
11
+ * // Check if a type is supported
12
+ * const isValidType = "string" in EAS_FIELD_TYPES;
13
+ * ```
14
+ */
15
+ declare const EAS_FIELD_TYPES: {
16
+ readonly string: "string";
17
+ readonly address: "address";
18
+ readonly bool: "bool";
19
+ readonly bytes: "bytes";
20
+ readonly bytes32: "bytes32";
21
+ readonly uint256: "uint256";
22
+ readonly int256: "int256";
23
+ readonly uint8: "uint8";
24
+ readonly int8: "int8";
25
+ };
26
+ /**
27
+ * Type representing all valid EAS field types.
28
+ */
29
+ type EASFieldType = keyof typeof EAS_FIELD_TYPES;
30
+ /**
31
+ * Interface for defining a schema field.
32
+ * @example
33
+ * ```ts
34
+ * import { SchemaField } from '@settlemint/sdk-eas';
35
+ *
36
+ * const field: SchemaField = {
37
+ * name: "userAddress",
38
+ * type: "address",
39
+ * description: "The Ethereum address of the user"
40
+ * };
41
+ * ```
42
+ */
43
+ interface SchemaField {
44
+ /** The name of the field */
45
+ name: string;
46
+ /** The type of the field */
47
+ type: EASFieldType;
48
+ /** Optional description of the field */
49
+ description?: string;
50
+ }
51
+ /**
52
+ * Validates a schema field name.
53
+ * @param name - The field name to validate
54
+ * @throws Error if the name is invalid
55
+ * @example
56
+ * ```ts
57
+ * import { validateFieldName } from '@settlemint/sdk-eas';
58
+ *
59
+ * // Valid names
60
+ * validateFieldName("userAddress"); // OK
61
+ * validateFieldName("user_address"); // OK
62
+ *
63
+ * // Invalid names
64
+ * validateFieldName("user address"); // Throws: "Field name cannot contain spaces"
65
+ * validateFieldName("123user"); // Throws: "Field name must start with a letter or underscore"
66
+ * ```
67
+ */
68
+ declare function validateFieldName(name: string): void;
69
+ /**
70
+ * Validates a schema field type.
71
+ * @param type - The field type to validate
72
+ * @throws Error if the type is invalid
73
+ * @example
74
+ * ```ts
75
+ * import { validateFieldType } from '@settlemint/sdk-eas';
76
+ *
77
+ * // Valid types
78
+ * validateFieldType("string"); // OK
79
+ * validateFieldType("address"); // OK
80
+ *
81
+ * // Invalid types
82
+ * validateFieldType("invalidType"); // Throws: "Invalid field type: invalidType"
83
+ * ```
84
+ */
85
+ declare function validateFieldType(type: string): asserts type is EASFieldType;
86
+ /**
87
+ * Validates an array of schema fields.
88
+ * @param fields - The fields to validate
89
+ * @throws Error if any field is invalid
90
+ * @example
91
+ * ```ts
92
+ * import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';
93
+ *
94
+ * const fields: SchemaField[] = [
95
+ * { name: "userAddress", type: "address" },
96
+ * { name: "age", type: "uint8" }
97
+ * ];
98
+ *
99
+ * validateSchemaFields(fields); // OK
100
+ *
101
+ * // Invalid fields
102
+ * validateSchemaFields([]); // Throws: "Schema must have at least one field"
103
+ * validateSchemaFields([
104
+ * { name: "userAddress", type: "address" },
105
+ * { name: "userAddress", type: "uint8" }
106
+ * ]); // Throws: "Duplicate field name: userAddress"
107
+ * ```
108
+ */
109
+ declare function validateSchemaFields(fields: SchemaField[]): void;
110
+ /**
111
+ * Builds an EAS schema string from an array of fields.
112
+ * @param fields - The fields to include in the schema
113
+ * @returns The EAS-compatible schema string
114
+ * @throws Error if any field is invalid
115
+ * @example
116
+ * ```ts
117
+ * import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';
118
+ *
119
+ * const fields: SchemaField[] = [
120
+ * { name: "userAddress", type: "address" },
121
+ * { name: "age", type: "uint8" },
122
+ * { name: "isActive", type: "bool" }
123
+ * ];
124
+ *
125
+ * const schemaString = buildSchemaString(fields);
126
+ * // Result: "address userAddress, uint8 age, bool isActive"
127
+ * ```
128
+ */
129
+ declare function buildSchemaString(fields: SchemaField[]): string;
130
+ /**
131
+ * Options for registering a schema.
132
+ * @example
133
+ * ```ts
134
+ * import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';
135
+ *
136
+ * const options: RegisterSchemaOptions = {
137
+ * fields: [
138
+ * { name: "userAddress", type: "address" },
139
+ * { name: "age", type: "uint8" }
140
+ * ],
141
+ * resolverAddress: "0x1234567890123456789012345678901234567890",
142
+ * revocable: true
143
+ * };
144
+ * ```
145
+ */
146
+ interface RegisterSchemaOptions {
147
+ /** The fields that make up the schema */
148
+ fields: SchemaField[];
149
+ /** The Ethereum address of the resolver */
150
+ resolverAddress: string;
151
+ /** Whether attestations using this schema can be revoked */
152
+ revocable: boolean;
153
+ }
154
+ /**
155
+ * Validates an Ethereum address.
156
+ * @param address - The address to validate
157
+ * @throws Error if the address is invalid
158
+ * @example
159
+ * ```ts
160
+ * import { validateEthereumAddress } from '@settlemint/sdk-eas';
161
+ *
162
+ * // Valid address
163
+ * validateEthereumAddress("0x1234567890123456789012345678901234567890"); // OK
164
+ *
165
+ * // Invalid addresses
166
+ * validateEthereumAddress("0x123"); // Throws: "Invalid Ethereum address format"
167
+ * validateEthereumAddress(""); // Throws: "Resolver address cannot be empty"
168
+ * ```
169
+ */
170
+ declare function validateEthereumAddress(address: string): void;
171
+ /**
172
+ * Registers a new schema with EAS.
173
+ * @param options - The schema registration options
174
+ * @returns A promise that resolves to the schema UID
175
+ * @throws Error if the schema registration fails
176
+ * @example
177
+ * ```ts
178
+ * import { registerSchema, SchemaField } from '@settlemint/sdk-eas';
179
+ *
180
+ * const fields: SchemaField[] = [
181
+ * { name: "userAddress", type: "address" },
182
+ * { name: "age", type: "uint8" }
183
+ * ];
184
+ *
185
+ * const schemaUID = await registerSchema({
186
+ * fields,
187
+ * resolverAddress: "0x1234567890123456789012345678901234567890",
188
+ * revocable: true
189
+ * });
190
+ *
191
+ * console.log(`Schema registered with UID: ${schemaUID}`);
192
+ * ```
193
+ */
194
+ declare function registerSchema(options: RegisterSchemaOptions): Promise<string>;
195
+
196
+ declare function createEASClient(): {
197
+ submitAttestation(): void;
198
+ parseAttestation(): void;
199
+ createSchema(): void;
200
+ getSchema(): void;
201
+ getAttestations(): void;
202
+ };
203
+
204
+ export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/eas.d.ts ADDED
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Supported EAS schema field types.
3
+ * Maps user-friendly type names to EAS-compatible type strings.
4
+ * @example
5
+ * ```ts
6
+ * import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';
7
+ *
8
+ * // Use in type definitions
9
+ * type MyFieldType = keyof typeof EAS_FIELD_TYPES;
10
+ *
11
+ * // Check if a type is supported
12
+ * const isValidType = "string" in EAS_FIELD_TYPES;
13
+ * ```
14
+ */
15
+ declare const EAS_FIELD_TYPES: {
16
+ readonly string: "string";
17
+ readonly address: "address";
18
+ readonly bool: "bool";
19
+ readonly bytes: "bytes";
20
+ readonly bytes32: "bytes32";
21
+ readonly uint256: "uint256";
22
+ readonly int256: "int256";
23
+ readonly uint8: "uint8";
24
+ readonly int8: "int8";
25
+ };
26
+ /**
27
+ * Type representing all valid EAS field types.
28
+ */
29
+ type EASFieldType = keyof typeof EAS_FIELD_TYPES;
30
+ /**
31
+ * Interface for defining a schema field.
32
+ * @example
33
+ * ```ts
34
+ * import { SchemaField } from '@settlemint/sdk-eas';
35
+ *
36
+ * const field: SchemaField = {
37
+ * name: "userAddress",
38
+ * type: "address",
39
+ * description: "The Ethereum address of the user"
40
+ * };
41
+ * ```
42
+ */
43
+ interface SchemaField {
44
+ /** The name of the field */
45
+ name: string;
46
+ /** The type of the field */
47
+ type: EASFieldType;
48
+ /** Optional description of the field */
49
+ description?: string;
50
+ }
51
+ /**
52
+ * Validates a schema field name.
53
+ * @param name - The field name to validate
54
+ * @throws Error if the name is invalid
55
+ * @example
56
+ * ```ts
57
+ * import { validateFieldName } from '@settlemint/sdk-eas';
58
+ *
59
+ * // Valid names
60
+ * validateFieldName("userAddress"); // OK
61
+ * validateFieldName("user_address"); // OK
62
+ *
63
+ * // Invalid names
64
+ * validateFieldName("user address"); // Throws: "Field name cannot contain spaces"
65
+ * validateFieldName("123user"); // Throws: "Field name must start with a letter or underscore"
66
+ * ```
67
+ */
68
+ declare function validateFieldName(name: string): void;
69
+ /**
70
+ * Validates a schema field type.
71
+ * @param type - The field type to validate
72
+ * @throws Error if the type is invalid
73
+ * @example
74
+ * ```ts
75
+ * import { validateFieldType } from '@settlemint/sdk-eas';
76
+ *
77
+ * // Valid types
78
+ * validateFieldType("string"); // OK
79
+ * validateFieldType("address"); // OK
80
+ *
81
+ * // Invalid types
82
+ * validateFieldType("invalidType"); // Throws: "Invalid field type: invalidType"
83
+ * ```
84
+ */
85
+ declare function validateFieldType(type: string): asserts type is EASFieldType;
86
+ /**
87
+ * Validates an array of schema fields.
88
+ * @param fields - The fields to validate
89
+ * @throws Error if any field is invalid
90
+ * @example
91
+ * ```ts
92
+ * import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';
93
+ *
94
+ * const fields: SchemaField[] = [
95
+ * { name: "userAddress", type: "address" },
96
+ * { name: "age", type: "uint8" }
97
+ * ];
98
+ *
99
+ * validateSchemaFields(fields); // OK
100
+ *
101
+ * // Invalid fields
102
+ * validateSchemaFields([]); // Throws: "Schema must have at least one field"
103
+ * validateSchemaFields([
104
+ * { name: "userAddress", type: "address" },
105
+ * { name: "userAddress", type: "uint8" }
106
+ * ]); // Throws: "Duplicate field name: userAddress"
107
+ * ```
108
+ */
109
+ declare function validateSchemaFields(fields: SchemaField[]): void;
110
+ /**
111
+ * Builds an EAS schema string from an array of fields.
112
+ * @param fields - The fields to include in the schema
113
+ * @returns The EAS-compatible schema string
114
+ * @throws Error if any field is invalid
115
+ * @example
116
+ * ```ts
117
+ * import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';
118
+ *
119
+ * const fields: SchemaField[] = [
120
+ * { name: "userAddress", type: "address" },
121
+ * { name: "age", type: "uint8" },
122
+ * { name: "isActive", type: "bool" }
123
+ * ];
124
+ *
125
+ * const schemaString = buildSchemaString(fields);
126
+ * // Result: "address userAddress, uint8 age, bool isActive"
127
+ * ```
128
+ */
129
+ declare function buildSchemaString(fields: SchemaField[]): string;
130
+ /**
131
+ * Options for registering a schema.
132
+ * @example
133
+ * ```ts
134
+ * import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';
135
+ *
136
+ * const options: RegisterSchemaOptions = {
137
+ * fields: [
138
+ * { name: "userAddress", type: "address" },
139
+ * { name: "age", type: "uint8" }
140
+ * ],
141
+ * resolverAddress: "0x1234567890123456789012345678901234567890",
142
+ * revocable: true
143
+ * };
144
+ * ```
145
+ */
146
+ interface RegisterSchemaOptions {
147
+ /** The fields that make up the schema */
148
+ fields: SchemaField[];
149
+ /** The Ethereum address of the resolver */
150
+ resolverAddress: string;
151
+ /** Whether attestations using this schema can be revoked */
152
+ revocable: boolean;
153
+ }
154
+ /**
155
+ * Validates an Ethereum address.
156
+ * @param address - The address to validate
157
+ * @throws Error if the address is invalid
158
+ * @example
159
+ * ```ts
160
+ * import { validateEthereumAddress } from '@settlemint/sdk-eas';
161
+ *
162
+ * // Valid address
163
+ * validateEthereumAddress("0x1234567890123456789012345678901234567890"); // OK
164
+ *
165
+ * // Invalid addresses
166
+ * validateEthereumAddress("0x123"); // Throws: "Invalid Ethereum address format"
167
+ * validateEthereumAddress(""); // Throws: "Resolver address cannot be empty"
168
+ * ```
169
+ */
170
+ declare function validateEthereumAddress(address: string): void;
171
+ /**
172
+ * Registers a new schema with EAS.
173
+ * @param options - The schema registration options
174
+ * @returns A promise that resolves to the schema UID
175
+ * @throws Error if the schema registration fails
176
+ * @example
177
+ * ```ts
178
+ * import { registerSchema, SchemaField } from '@settlemint/sdk-eas';
179
+ *
180
+ * const fields: SchemaField[] = [
181
+ * { name: "userAddress", type: "address" },
182
+ * { name: "age", type: "uint8" }
183
+ * ];
184
+ *
185
+ * const schemaUID = await registerSchema({
186
+ * fields,
187
+ * resolverAddress: "0x1234567890123456789012345678901234567890",
188
+ * revocable: true
189
+ * });
190
+ *
191
+ * console.log(`Schema registered with UID: ${schemaUID}`);
192
+ * ```
193
+ */
194
+ declare function registerSchema(options: RegisterSchemaOptions): Promise<string>;
195
+
196
+ declare function createEASClient(): {
197
+ submitAttestation(): void;
198
+ parseAttestation(): void;
199
+ createSchema(): void;
200
+ getSchema(): void;
201
+ getAttestations(): void;
202
+ };
203
+
204
+ export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/eas.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import {isAddress}from'viem';var o={string:"string",address:"address",bool:"bool",bytes:"bytes",bytes32:"bytes32",uint256:"uint256",int256:"int256",uint8:"uint8",int8:"int8"};function a(e){if(!e)throw new Error("Field name cannot be empty");if(e.includes(" "))throw new Error("Field name cannot contain spaces");if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw new Error("Field name must start with a letter or underscore and contain only alphanumeric characters and underscores")}function c(e){if(!(e in o))throw new Error(`Invalid field type: ${e}. Must be one of: ${Object.keys(o).join(", ")}`)}function r(e){if(!e||e.length===0)throw new Error("Schema must have at least one field");let t=new Set;for(let n of e){if(a(n.name),c(n.type),t.has(n.name))throw new Error(`Duplicate field name: ${n.name}`);t.add(n.name);}}function l(e){return r(e),e.map(t=>`${t.type} ${t.name}`).join(", ")}function m(e){if(!e)throw new Error("Resolver address cannot be empty");if(!isAddress(e))throw new Error("Invalid Ethereum address format")}async function p(e){let{fields:t,resolverAddress:n,revocable:i}=e;r(t),m(n);let s=l(t);return console.log(`[EAS] Registering schema: ${s}`),console.log(`[EAS] Resolver: ${n}`),console.log(`[EAS] Revocable: ${i}`),`0x${"0".repeat(64)}`}function S(){return {submitAttestation(){console.log("[EAS] Submitting attestation");},parseAttestation(){console.log("[EAS] Parsing attestation");},createSchema(){console.log("[EAS] Creating schema");},getSchema(){console.log("[EAS] Getting schema");},getAttestations(){console.log("[EAS] Getting attestations");}}}export{o as EAS_FIELD_TYPES,l as buildSchemaString,S as createEASClient,p as registerSchema,m as validateEthereumAddress,a as validateFieldName,c as validateFieldType,r as validateSchemaFields};//# sourceMappingURL=eas.mjs.map
2
+ //# sourceMappingURL=eas.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/eas.ts"],"names":["EAS_FIELD_TYPES","validateFieldName","name","validateFieldType","type","validateSchemaFields","fields","seenNames","field","buildSchemaString","validateEthereumAddress","address","isAddress","registerSchema","options","resolverAddress","revocable","schemaString","createEASClient"],"mappings":"6BAcO,IAAMA,CAAkB,CAAA,CAC7B,MAAQ,CAAA,QAAA,CACR,OAAS,CAAA,SAAA,CACT,IAAM,CAAA,MAAA,CACN,MAAO,OACP,CAAA,OAAA,CAAS,SACT,CAAA,OAAA,CAAS,SACT,CAAA,MAAA,CAAQ,Q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CAAA,CAEA,eAAkB,EAAA,CAChB,OAAQ,CAAA,GAAA,CAAI,4BAA4B,EAC1C,CACF,CACF","file":"eas.mjs","sourcesContent":["/**\n * Supported EAS schema field types.\n * Maps user-friendly type names to EAS-compatible type strings.\n * @example\n * ```ts\n * import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';\n *\n * // Use in type definitions\n * type MyFieldType = keyof typeof EAS_FIELD_TYPES;\n *\n * // Check if a type is supported\n * const isValidType = \"string\" in EAS_FIELD_TYPES;\n * ```\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\n/**\n * Type representing all valid EAS field types.\n */\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Interface for defining a schema field.\n * @example\n * ```ts\n * import { SchemaField } from '@settlemint/sdk-eas';\n *\n * const field: SchemaField = {\n * name: \"userAddress\",\n * type: \"address\",\n * description: \"The Ethereum address of the user\"\n * };\n * ```\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The type of the field */\n type: EASFieldType;\n /** Optional description of the field */\n description?: string;\n}\n\n/**\n * Validates a schema field name.\n * @param name - The field name to validate\n * @throws Error if the name is invalid\n * @example\n * ```ts\n * import { validateFieldName } from '@settlemint/sdk-eas';\n *\n * // Valid names\n * validateFieldName(\"userAddress\"); // OK\n * validateFieldName(\"user_address\"); // OK\n *\n * // Invalid names\n * validateFieldName(\"user address\"); // Throws: \"Field name cannot contain spaces\"\n * validateFieldName(\"123user\"); // Throws: \"Field name must start with a letter or underscore\"\n * ```\n */\nexport function validateFieldName(name: string): void {\n if (!name) {\n throw new Error(\"Field name cannot be empty\");\n }\n if (name.includes(\" \")) {\n throw new Error(\"Field name cannot contain spaces\");\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(\n \"Field name must start with a letter or underscore and contain only alphanumeric characters and underscores\",\n );\n }\n}\n\n/**\n * Validates a schema field type.\n * @param type - The field type to validate\n * @throws Error if the type is invalid\n * @example\n * ```ts\n * import { validateFieldType } from '@settlemint/sdk-eas';\n *\n * // Valid types\n * validateFieldType(\"string\"); // OK\n * validateFieldType(\"address\"); // OK\n *\n * // Invalid types\n * validateFieldType(\"invalidType\"); // Throws: \"Invalid field type: invalidType\"\n * ```\n */\nexport function validateFieldType(type: string): asserts type is EASFieldType {\n if (!(type in EAS_FIELD_TYPES)) {\n throw new Error(`Invalid field type: ${type}. Must be one of: ${Object.keys(EAS_FIELD_TYPES).join(\", \")}`);\n }\n}\n\n/**\n * Validates an array of schema fields.\n * @param fields - The fields to validate\n * @throws Error if any field is invalid\n * @example\n * ```ts\n * import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ];\n *\n * validateSchemaFields(fields); // OK\n *\n * // Invalid fields\n * validateSchemaFields([]); // Throws: \"Schema must have at least one field\"\n * validateSchemaFields([\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"userAddress\", type: \"uint8\" }\n * ]); // Throws: \"Duplicate field name: userAddress\"\n * ```\n */\nexport function validateSchemaFields(fields: SchemaField[]): void {\n if (!fields || fields.length === 0) {\n throw new Error(\"Schema must have at least one field\");\n }\n\n const seenNames = new Set<string>();\n for (const field of fields) {\n validateFieldName(field.name);\n validateFieldType(field.type);\n\n if (seenNames.has(field.name)) {\n throw new Error(`Duplicate field name: ${field.name}`);\n }\n seenNames.add(field.name);\n }\n}\n\n/**\n * Builds an EAS schema string from an array of fields.\n * @param fields - The fields to include in the schema\n * @returns The EAS-compatible schema string\n * @throws Error if any field is invalid\n * @example\n * ```ts\n * import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" },\n * { name: \"isActive\", type: \"bool\" }\n * ];\n *\n * const schemaString = buildSchemaString(fields);\n * // Result: \"address userAddress, uint8 age, bool isActive\"\n * ```\n */\nexport function buildSchemaString(fields: SchemaField[]): string {\n validateSchemaFields(fields);\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n}\n\n/**\n * Options for registering a schema.\n * @example\n * ```ts\n * import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';\n *\n * const options: RegisterSchemaOptions = {\n * fields: [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ],\n * resolverAddress: \"0x1234567890123456789012345678901234567890\",\n * revocable: true\n * };\n * ```\n */\nexport interface RegisterSchemaOptions {\n /** The fields that make up the schema */\n fields: SchemaField[];\n /** The Ethereum address of the resolver */\n resolverAddress: string;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\nimport { isAddress } from \"viem\";\n\n/**\n * Validates an Ethereum address.\n * @param address - The address to validate\n * @throws Error if the address is invalid\n * @example\n * ```ts\n * import { validateEthereumAddress } from '@settlemint/sdk-eas';\n *\n * // Valid address\n * validateEthereumAddress(\"0x1234567890123456789012345678901234567890\"); // OK\n *\n * // Invalid addresses\n * validateEthereumAddress(\"0x123\"); // Throws: \"Invalid Ethereum address format\"\n * validateEthereumAddress(\"\"); // Throws: \"Resolver address cannot be empty\"\n * ```\n */\nexport function validateEthereumAddress(address: string): void {\n if (!address) {\n throw new Error(\"Resolver address cannot be empty\");\n }\n if (!isAddress(address)) {\n throw new Error(\"Invalid Ethereum address format\");\n }\n}\n\n/**\n * Registers a new schema with EAS.\n * @param options - The schema registration options\n * @returns A promise that resolves to the schema UID\n * @throws Error if the schema registration fails\n * @example\n * ```ts\n * import { registerSchema, SchemaField } from '@settlemint/sdk-eas';\n *\n * const fields: SchemaField[] = [\n * { name: \"userAddress\", type: \"address\" },\n * { name: \"age\", type: \"uint8\" }\n * ];\n *\n * const schemaUID = await registerSchema({\n * fields,\n * resolverAddress: \"0x1234567890123456789012345678901234567890\",\n * revocable: true\n * });\n *\n * console.log(`Schema registered with UID: ${schemaUID}`);\n * ```\n */\nexport async function registerSchema(options: RegisterSchemaOptions): Promise<string> {\n const { fields, resolverAddress, revocable } = options;\n\n // Validate the schema fields\n validateSchemaFields(fields);\n\n // Validate the resolver address\n validateEthereumAddress(resolverAddress);\n\n // Build the schema string\n const schemaString = buildSchemaString(fields);\n\n // TODO: Implement actual EAS SDK registration\n // This is a placeholder that will be replaced with actual EAS SDK integration\n console.log(`[EAS] Registering schema: ${schemaString}`);\n console.log(`[EAS] Resolver: ${resolverAddress}`);\n console.log(`[EAS] Revocable: ${revocable}`);\n\n // Return a mock UID for now\n return `0x${\"0\".repeat(64)}`;\n}\n","export * from \"./schema.js\";\n\nexport function createEASClient() {\n return {\n submitAttestation() {\n console.log(\"[EAS] Submitting attestation\");\n },\n\n parseAttestation() {\n console.log(\"[EAS] Parsing attestation\");\n },\n\n createSchema() {\n console.log(\"[EAS] Creating schema\");\n },\n\n getSchema() {\n console.log(\"[EAS] Getting schema\");\n },\n\n getAttestations() {\n console.log(\"[EAS] Getting attestations\");\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@settlemint/sdk-eas",
3
3
  "description": "Ethereum Attestation Service (EAS) integration for SettleMint SDK",
4
- "version": "2.2.2-pr75b59b5f",
4
+ "version": "2.2.2-pr8fc22dc7",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -21,19 +21,19 @@
21
21
  "email": "support@settlemint.com"
22
22
  },
23
23
  "files": ["dist"],
24
- "main": "./dist/index.cjs",
25
- "module": "./dist/index.mjs",
26
- "types": "./dist/index.d.ts",
24
+ "main": "./dist/eas.cjs",
25
+ "module": "./dist/eas.mjs",
26
+ "types": "./dist/eas.d.ts",
27
27
  "exports": {
28
28
  "./package.json": "./package.json",
29
29
  ".": {
30
30
  "import": {
31
- "types": "./dist/index.d.ts",
32
- "default": "./dist/index.mjs"
31
+ "types": "./dist/eas.d.ts",
32
+ "default": "./dist/eas.mjs"
33
33
  },
34
34
  "require": {
35
- "types": "./dist/index.d.cts",
36
- "default": "./dist/index.cjs"
35
+ "types": "./dist/eas.d.cts",
36
+ "default": "./dist/eas.cjs"
37
37
  }
38
38
  }
39
39
  },
@@ -47,11 +47,11 @@
47
47
  "typecheck": "tsc --noEmit",
48
48
  "publish-npm": "bun publish --tag ${TAG} --access public || exit 0",
49
49
  "prepack": "cp ../../LICENSE .",
50
- "docs": "typedoc --options '../../typedoc.config.mjs' --entryPoints src/index.ts --out ./docs"
50
+ "docs": "typedoc --options '../../typedoc.config.mjs' --entryPoints src/eas.ts --out ./docs"
51
51
  },
52
52
  "devDependencies": {},
53
53
  "dependencies": {
54
- "@settlemint/sdk-utils": "2.2.2-pr75b59b5f",
54
+ "@settlemint/sdk-utils": "2.2.2-pr8fc22dc7",
55
55
  "viem": "^2.7.9"
56
56
  },
57
57
  "peerDependencies": {},
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';var o={string:"string",address:"address",bool:"bool",bytes:"bytes",bytes32:"bytes32",uint256:"uint256",int256:"int256",uint8:"uint8",int8:"int8"};function a(e){if(!e)throw new Error("Field name cannot be empty");if(e.includes(" "))throw new Error("Field name cannot contain spaces");if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw new Error("Field name must start with a letter or underscore and contain only alphanumeric characters and underscores")}function c(e){if(!(e in o))throw new Error(`Invalid field type: ${e}. Must be one of: ${Object.keys(o).join(", ")}`)}function r(e){if(!e||e.length===0)throw new Error("Schema must have at least one field");let t=new Set;for(let n of e){if(a(n.name),c(n.type),t.has(n.name))throw new Error(`Duplicate field name: ${n.name}`);t.add(n.name);}}function l(e){return r(e),e.map(t=>`${t.type} ${t.name}`).join(", ")}function d(e){if(!e)throw new Error("Resolver address cannot be empty");if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error("Invalid Ethereum address format")}async function m(e){let{fields:t,resolverAddress:n,revocable:i}=e;r(t),d(n);let s=l(t);return console.log(`[EAS] Registering schema: ${s}`),console.log(`[EAS] Resolver: ${n}`),console.log(`[EAS] Revocable: ${i}`),`0x${"0".repeat(64)}`}function p(){return {submitAttestation(){console.log("[EAS] Submitting attestation");},parseAttestation(){console.log("[EAS] Parsing attestation");},createSchema(){console.log("[EAS] Creating schema");},getSchema(){console.log("[EAS] Getting schema");},getAttestations(){console.log("[EAS] Getting attestations");}}}exports.EAS_FIELD_TYPES=o;exports.buildSchemaString=l;exports.createEASClient=p;exports.registerSchema=m;exports.validateEthereumAddress=d;exports.validateFieldName=a;exports.validateFieldType=c;exports.validateSchemaFields=r;//# sourceMappingURL=index.cjs.map
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schema.ts","../src/index.ts"],"names":["EAS_FIELD_TYPES","validateFieldName","name","validateFieldType","type","validateSchemaFields","fields","seenNames","field","buildSchemaString","validateEthereumAddress","address","registerSchema","options","resolverAddress","revocable","schemaString","createEASClient"],"mappings":"aAIO,IAAMA,CAAkB,CAAA,CAC7B,MAAQ,CAAA,QAAA,CACR,OAAS,CAAA,SAAA,CACT,IAAM,CAAA,MAAA,CACN,KAAO,CAAA,OAAA,CACP,OAAS,CAAA,SAAA,CACT,QAAS,SACT,CAAA,MAAA,CAAQ,QACR,CAAA,KAAA,CAAO,OACP,CAAA,IAAA,CAAM,MACR,EAwBO,SAASC,CAAAA,CAAkBC,CAAoB,CAAA,CACpD,GAAI,CAACA,CACH,CAAA,MAAM,IAAI,KAAM,CAAA,4BAA4B,CAE9C,CAAA,GAAIA,CAAK,CAAA,QAAA,CAAS,GAAG,CAAA,CACnB,MAAM,IAAI,KAAM,CAAA,kCAAkC,CAEpD,CAAA,GAAI,CAAC,0BAAA,CAA2B,KAAKA,CAAI,CAAA,CACvC,MAAM,IAAI,KACR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AAO,CAAA,CACrC,MAAM,IAAI,KAAM,CAAA,iCAAiC,CAErD,CAQA,eAAsBC,CAAAA,CAAeC,CAAiD,CAAA,CACpF,GAAM,CAAE,MAAA,CAAAP,CAAQ,CAAA,eAAA,CAAAQ,CAAiB,CAAA,SAAA,CAAAC,CAAU,CAAA,CAAIF,CAG/CR,CAAAA,CAAAA,CAAqBC,CAAM,CAAA,CAG3BI,CAAwBI,CAAAA,CAAe,CAGvC,CAAA,IAAME,EAAeP,CAAkBH,CAAAA,CAAM,CAI7C,CAAA,OAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,0BAAA,EAA6BU,CAAY,CAAA,CAAE,CACvD,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,gBAAA,EAAmBF,CAAe,CAAA,CAAE,CAChD,CAAA,OAAA,CAAQ,IAAI,CAAoBC,iBAAAA,EAAAA,CAAS,CAAE,CAAA,CAAA,CAGpC,CAAK,EAAA,EAAA,GAAA,CAAI,MAAO,CAAA,EAAE,CAAC,CAAA,CAC5B,CClJO,SAASE,CAAkB,EAAA,CAChC,OAAO,CACL,mBAAoB,CAClB,OAAA,CAAQ,GAAI,CAAA,8BAA8B,EAC5C,CAAA,CAEA,gBAAmB,EAAA,CACjB,OAAQ,CAAA,GAAA,CAAI,2BAA2B,EACzC,CAEA,CAAA,YAAA,EAAe,CACb,OAAA,CAAQ,IAAI,uBAAuB,EACrC,CAEA,CAAA,SAAA,EAAY,CACV,OAAA,CAAQ,GAAI,CAAA,sBAAsB,EACpC,CAAA,CAEA,eAAkB,EAAA,CAChB,OAAQ,CAAA,GAAA,CAAI,4BAA4B,EAC1C,CACF,CACF","file":"index.cjs","sourcesContent":["/**\n * Supported EAS schema field types.\n * Maps user-friendly type names to EAS-compatible type strings.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\n/**\n * Type representing all valid EAS field types.\n */\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Interface for defining a schema field.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The type of the field */\n type: EASFieldType;\n /** Optional description of the field */\n description?: string;\n}\n\n/**\n * Validates a schema field name.\n * @param name - The field name to validate\n * @throws Error if the name is invalid\n */\nexport function validateFieldName(name: string): void {\n if (!name) {\n throw new Error(\"Field name cannot be empty\");\n }\n if (name.includes(\" \")) {\n throw new Error(\"Field name cannot contain spaces\");\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(\n \"Field name must start with a letter or underscore and contain only alphanumeric characters and underscores\",\n );\n }\n}\n\n/**\n * Validates a schema field type.\n * @param type - The field type to validate\n * @throws Error if the type is invalid\n */\nexport function validateFieldType(type: string): asserts type is EASFieldType {\n if (!(type in EAS_FIELD_TYPES)) {\n throw new Error(`Invalid field type: ${type}. Must be one of: ${Object.keys(EAS_FIELD_TYPES).join(\", \")}`);\n }\n}\n\n/**\n * Validates an array of schema fields.\n * @param fields - The fields to validate\n * @throws Error if any field is invalid\n */\nexport function validateSchemaFields(fields: SchemaField[]): void {\n if (!fields || fields.length === 0) {\n throw new Error(\"Schema must have at least one field\");\n }\n\n const seenNames = new Set<string>();\n for (const field of fields) {\n validateFieldName(field.name);\n validateFieldType(field.type);\n\n if (seenNames.has(field.name)) {\n throw new Error(`Duplicate field name: ${field.name}`);\n }\n seenNames.add(field.name);\n }\n}\n\n/**\n * Builds an EAS schema string from an array of fields.\n * @param fields - The fields to include in the schema\n * @returns The EAS-compatible schema string\n * @throws Error if any field is invalid\n */\nexport function buildSchemaString(fields: SchemaField[]): string {\n validateSchemaFields(fields);\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n}\n\n/**\n * Options for registering a schema.\n */\nexport interface RegisterSchemaOptions {\n /** The fields that make up the schema */\n fields: SchemaField[];\n /** The Ethereum address of the resolver */\n resolverAddress: string;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Validates an Ethereum address.\n * @param address - The address to validate\n * @throws Error if the address is invalid\n */\nexport function validateEthereumAddress(address: string): void {\n if (!address) {\n throw new Error(\"Resolver address cannot be empty\");\n }\n if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {\n throw new Error(\"Invalid Ethereum address format\");\n }\n}\n\n/**\n * Registers a new schema with EAS.\n * @param options - The schema registration options\n * @returns A promise that resolves to the schema UID\n * @throws Error if the schema registration fails\n */\nexport async function registerSchema(options: RegisterSchemaOptions): Promise<string> {\n const { fields, resolverAddress, revocable } = options;\n\n // Validate the schema fields\n validateSchemaFields(fields);\n\n // Validate the resolver address\n validateEthereumAddress(resolverAddress);\n\n // Build the schema string\n const schemaString = buildSchemaString(fields);\n\n // TODO: Implement actual EAS SDK registration\n // This is a placeholder that will be replaced with actual EAS SDK integration\n console.log(`[EAS] Registering schema: ${schemaString}`);\n console.log(`[EAS] Resolver: ${resolverAddress}`);\n console.log(`[EAS] Revocable: ${revocable}`);\n\n // Return a mock UID for now\n return `0x${\"0\".repeat(64)}`;\n}\n","export * from \"./schema.js\";\n\nexport function createEASClient() {\n return {\n submitAttestation() {\n console.log(\"[EAS] Submitting attestation\");\n },\n\n parseAttestation() {\n console.log(\"[EAS] Parsing attestation\");\n },\n\n createSchema() {\n console.log(\"[EAS] Creating schema\");\n },\n\n getSchema() {\n console.log(\"[EAS] Getting schema\");\n },\n\n getAttestations() {\n console.log(\"[EAS] Getting attestations\");\n },\n };\n}\n"]}
package/dist/index.d.cts DELETED
@@ -1,89 +0,0 @@
1
- /**
2
- * Supported EAS schema field types.
3
- * Maps user-friendly type names to EAS-compatible type strings.
4
- */
5
- declare const EAS_FIELD_TYPES: {
6
- readonly string: "string";
7
- readonly address: "address";
8
- readonly bool: "bool";
9
- readonly bytes: "bytes";
10
- readonly bytes32: "bytes32";
11
- readonly uint256: "uint256";
12
- readonly int256: "int256";
13
- readonly uint8: "uint8";
14
- readonly int8: "int8";
15
- };
16
- /**
17
- * Type representing all valid EAS field types.
18
- */
19
- type EASFieldType = keyof typeof EAS_FIELD_TYPES;
20
- /**
21
- * Interface for defining a schema field.
22
- */
23
- interface SchemaField {
24
- /** The name of the field */
25
- name: string;
26
- /** The type of the field */
27
- type: EASFieldType;
28
- /** Optional description of the field */
29
- description?: string;
30
- }
31
- /**
32
- * Validates a schema field name.
33
- * @param name - The field name to validate
34
- * @throws Error if the name is invalid
35
- */
36
- declare function validateFieldName(name: string): void;
37
- /**
38
- * Validates a schema field type.
39
- * @param type - The field type to validate
40
- * @throws Error if the type is invalid
41
- */
42
- declare function validateFieldType(type: string): asserts type is EASFieldType;
43
- /**
44
- * Validates an array of schema fields.
45
- * @param fields - The fields to validate
46
- * @throws Error if any field is invalid
47
- */
48
- declare function validateSchemaFields(fields: SchemaField[]): void;
49
- /**
50
- * Builds an EAS schema string from an array of fields.
51
- * @param fields - The fields to include in the schema
52
- * @returns The EAS-compatible schema string
53
- * @throws Error if any field is invalid
54
- */
55
- declare function buildSchemaString(fields: SchemaField[]): string;
56
- /**
57
- * Options for registering a schema.
58
- */
59
- interface RegisterSchemaOptions {
60
- /** The fields that make up the schema */
61
- fields: SchemaField[];
62
- /** The Ethereum address of the resolver */
63
- resolverAddress: string;
64
- /** Whether attestations using this schema can be revoked */
65
- revocable: boolean;
66
- }
67
- /**
68
- * Validates an Ethereum address.
69
- * @param address - The address to validate
70
- * @throws Error if the address is invalid
71
- */
72
- declare function validateEthereumAddress(address: string): void;
73
- /**
74
- * Registers a new schema with EAS.
75
- * @param options - The schema registration options
76
- * @returns A promise that resolves to the schema UID
77
- * @throws Error if the schema registration fails
78
- */
79
- declare function registerSchema(options: RegisterSchemaOptions): Promise<string>;
80
-
81
- declare function createEASClient(): {
82
- submitAttestation(): void;
83
- parseAttestation(): void;
84
- createSchema(): void;
85
- getSchema(): void;
86
- getAttestations(): void;
87
- };
88
-
89
- export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/index.d.ts DELETED
@@ -1,89 +0,0 @@
1
- /**
2
- * Supported EAS schema field types.
3
- * Maps user-friendly type names to EAS-compatible type strings.
4
- */
5
- declare const EAS_FIELD_TYPES: {
6
- readonly string: "string";
7
- readonly address: "address";
8
- readonly bool: "bool";
9
- readonly bytes: "bytes";
10
- readonly bytes32: "bytes32";
11
- readonly uint256: "uint256";
12
- readonly int256: "int256";
13
- readonly uint8: "uint8";
14
- readonly int8: "int8";
15
- };
16
- /**
17
- * Type representing all valid EAS field types.
18
- */
19
- type EASFieldType = keyof typeof EAS_FIELD_TYPES;
20
- /**
21
- * Interface for defining a schema field.
22
- */
23
- interface SchemaField {
24
- /** The name of the field */
25
- name: string;
26
- /** The type of the field */
27
- type: EASFieldType;
28
- /** Optional description of the field */
29
- description?: string;
30
- }
31
- /**
32
- * Validates a schema field name.
33
- * @param name - The field name to validate
34
- * @throws Error if the name is invalid
35
- */
36
- declare function validateFieldName(name: string): void;
37
- /**
38
- * Validates a schema field type.
39
- * @param type - The field type to validate
40
- * @throws Error if the type is invalid
41
- */
42
- declare function validateFieldType(type: string): asserts type is EASFieldType;
43
- /**
44
- * Validates an array of schema fields.
45
- * @param fields - The fields to validate
46
- * @throws Error if any field is invalid
47
- */
48
- declare function validateSchemaFields(fields: SchemaField[]): void;
49
- /**
50
- * Builds an EAS schema string from an array of fields.
51
- * @param fields - The fields to include in the schema
52
- * @returns The EAS-compatible schema string
53
- * @throws Error if any field is invalid
54
- */
55
- declare function buildSchemaString(fields: SchemaField[]): string;
56
- /**
57
- * Options for registering a schema.
58
- */
59
- interface RegisterSchemaOptions {
60
- /** The fields that make up the schema */
61
- fields: SchemaField[];
62
- /** The Ethereum address of the resolver */
63
- resolverAddress: string;
64
- /** Whether attestations using this schema can be revoked */
65
- revocable: boolean;
66
- }
67
- /**
68
- * Validates an Ethereum address.
69
- * @param address - The address to validate
70
- * @throws Error if the address is invalid
71
- */
72
- declare function validateEthereumAddress(address: string): void;
73
- /**
74
- * Registers a new schema with EAS.
75
- * @param options - The schema registration options
76
- * @returns A promise that resolves to the schema UID
77
- * @throws Error if the schema registration fails
78
- */
79
- declare function registerSchema(options: RegisterSchemaOptions): Promise<string>;
80
-
81
- declare function createEASClient(): {
82
- submitAttestation(): void;
83
- parseAttestation(): void;
84
- createSchema(): void;
85
- getSchema(): void;
86
- getAttestations(): void;
87
- };
88
-
89
- export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- var o={string:"string",address:"address",bool:"bool",bytes:"bytes",bytes32:"bytes32",uint256:"uint256",int256:"int256",uint8:"uint8",int8:"int8"};function a(e){if(!e)throw new Error("Field name cannot be empty");if(e.includes(" "))throw new Error("Field name cannot contain spaces");if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw new Error("Field name must start with a letter or underscore and contain only alphanumeric characters and underscores")}function c(e){if(!(e in o))throw new Error(`Invalid field type: ${e}. Must be one of: ${Object.keys(o).join(", ")}`)}function r(e){if(!e||e.length===0)throw new Error("Schema must have at least one field");let t=new Set;for(let n of e){if(a(n.name),c(n.type),t.has(n.name))throw new Error(`Duplicate field name: ${n.name}`);t.add(n.name);}}function l(e){return r(e),e.map(t=>`${t.type} ${t.name}`).join(", ")}function d(e){if(!e)throw new Error("Resolver address cannot be empty");if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error("Invalid Ethereum address format")}async function m(e){let{fields:t,resolverAddress:n,revocable:i}=e;r(t),d(n);let s=l(t);return console.log(`[EAS] Registering schema: ${s}`),console.log(`[EAS] Resolver: ${n}`),console.log(`[EAS] Revocable: ${i}`),`0x${"0".repeat(64)}`}function p(){return {submitAttestation(){console.log("[EAS] Submitting attestation");},parseAttestation(){console.log("[EAS] Parsing attestation");},createSchema(){console.log("[EAS] Creating schema");},getSchema(){console.log("[EAS] Getting schema");},getAttestations(){console.log("[EAS] Getting attestations");}}}export{o as EAS_FIELD_TYPES,l as buildSchemaString,p as createEASClient,m as registerSchema,d as validateEthereumAddress,a as validateFieldName,c as validateFieldType,r as validateSchemaFields};//# sourceMappingURL=index.mjs.map
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schema.ts","../src/index.ts"],"names":["EAS_FIELD_TYPES","validateFieldName","name","validateFieldType","type","validateSchemaFields","fields","seenNames","field","buildSchemaString","validateEthereumAddress","address","registerSchema","options","resolverAddress","revocable","schemaString","createEASClient"],"mappings":"AAIO,IAAMA,CAAkB,CAAA,CAC7B,MAAQ,CAAA,QAAA,CACR,OAAS,CAAA,SAAA,CACT,IAAM,CAAA,MAAA,CACN,KAAO,CAAA,OAAA,CACP,OAAS,CAAA,SAAA,CACT,QAAS,SACT,CAAA,MAAA,CAAQ,QACR,CAAA,KAAA,CAAO,OACP,CAAA,IAAA,CAAM,MACR,EAwBO,SAASC,CAAAA,CAAkBC,CAAoB,CAAA,CACpD,GAAI,CAACA,CACH,CAAA,MAAM,IAAI,KAAM,CAAA,4BAA4B,CAE9C,CAAA,GAAIA,CAAK,CAAA,QAAA,CAAS,GAAG,CAAA,CACnB,MAAM,IAAI,KAAM,CAAA,kCAAkC,CAEpD,CAAA,GAAI,CAAC,0BAAA,CAA2B,KAAKA,CAAI,CAAA,CACvC,MAAM,IAAI,KACR,CAAA,4GACF,CAEJ,CAOO,SAASC,CAAAA,CAAkBC,CAA4C,CAAA,CAC5E,GAAI,EAAEA,CAAQJ,IAAAA,CAAAA,CAAAA,CACZ,MAAM,IAAI,KAAA,CAAM,CAAuBI,oBAAAA,EAAAA,CAAI,CAAqB,kBAAA,EAAA,MAAA,CAAO,IAAKJ,CAAAA,CAAe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CAAqBC,CAAM,CAAA,CAG3BI,CAAwBI,CAAAA,CAAe,CAGvC,CAAA,IAAME,EAAeP,CAAkBH,CAAAA,CAAM,CAI7C,CAAA,OAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,0BAAA,EAA6BU,CAAY,CAAA,CAAE,CACvD,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,gBAAA,EAAmBF,CAAe,CAAA,CAAE,CAChD,CAAA,OAAA,CAAQ,IAAI,CAAoBC,iBAAAA,EAAAA,CAAS,CAAE,CAAA,CAAA,CAGpC,CAAK,EAAA,EAAA,GAAA,CAAI,MAAO,CAAA,EAAE,CAAC,CAAA,CAC5B,CClJO,SAASE,CAAkB,EAAA,CAChC,OAAO,CACL,mBAAoB,CAClB,OAAA,CAAQ,GAAI,CAAA,8BAA8B,EAC5C,CAAA,CAEA,gBAAmB,EAAA,CACjB,OAAQ,CAAA,GAAA,CAAI,2BAA2B,EACzC,CAEA,CAAA,YAAA,EAAe,CACb,OAAA,CAAQ,IAAI,uBAAuB,EACrC,CAEA,CAAA,SAAA,EAAY,CACV,OAAA,CAAQ,GAAI,CAAA,sBAAsB,EACpC,CAAA,CAEA,eAAkB,EAAA,CAChB,OAAQ,CAAA,GAAA,CAAI,4BAA4B,EAC1C,CACF,CACF","file":"index.mjs","sourcesContent":["/**\n * Supported EAS schema field types.\n * Maps user-friendly type names to EAS-compatible type strings.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\n/**\n * Type representing all valid EAS field types.\n */\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Interface for defining a schema field.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The type of the field */\n type: EASFieldType;\n /** Optional description of the field */\n description?: string;\n}\n\n/**\n * Validates a schema field name.\n * @param name - The field name to validate\n * @throws Error if the name is invalid\n */\nexport function validateFieldName(name: string): void {\n if (!name) {\n throw new Error(\"Field name cannot be empty\");\n }\n if (name.includes(\" \")) {\n throw new Error(\"Field name cannot contain spaces\");\n }\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(\n \"Field name must start with a letter or underscore and contain only alphanumeric characters and underscores\",\n );\n }\n}\n\n/**\n * Validates a schema field type.\n * @param type - The field type to validate\n * @throws Error if the type is invalid\n */\nexport function validateFieldType(type: string): asserts type is EASFieldType {\n if (!(type in EAS_FIELD_TYPES)) {\n throw new Error(`Invalid field type: ${type}. Must be one of: ${Object.keys(EAS_FIELD_TYPES).join(\", \")}`);\n }\n}\n\n/**\n * Validates an array of schema fields.\n * @param fields - The fields to validate\n * @throws Error if any field is invalid\n */\nexport function validateSchemaFields(fields: SchemaField[]): void {\n if (!fields || fields.length === 0) {\n throw new Error(\"Schema must have at least one field\");\n }\n\n const seenNames = new Set<string>();\n for (const field of fields) {\n validateFieldName(field.name);\n validateFieldType(field.type);\n\n if (seenNames.has(field.name)) {\n throw new Error(`Duplicate field name: ${field.name}`);\n }\n seenNames.add(field.name);\n }\n}\n\n/**\n * Builds an EAS schema string from an array of fields.\n * @param fields - The fields to include in the schema\n * @returns The EAS-compatible schema string\n * @throws Error if any field is invalid\n */\nexport function buildSchemaString(fields: SchemaField[]): string {\n validateSchemaFields(fields);\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n}\n\n/**\n * Options for registering a schema.\n */\nexport interface RegisterSchemaOptions {\n /** The fields that make up the schema */\n fields: SchemaField[];\n /** The Ethereum address of the resolver */\n resolverAddress: string;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Validates an Ethereum address.\n * @param address - The address to validate\n * @throws Error if the address is invalid\n */\nexport function validateEthereumAddress(address: string): void {\n if (!address) {\n throw new Error(\"Resolver address cannot be empty\");\n }\n if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {\n throw new Error(\"Invalid Ethereum address format\");\n }\n}\n\n/**\n * Registers a new schema with EAS.\n * @param options - The schema registration options\n * @returns A promise that resolves to the schema UID\n * @throws Error if the schema registration fails\n */\nexport async function registerSchema(options: RegisterSchemaOptions): Promise<string> {\n const { fields, resolverAddress, revocable } = options;\n\n // Validate the schema fields\n validateSchemaFields(fields);\n\n // Validate the resolver address\n validateEthereumAddress(resolverAddress);\n\n // Build the schema string\n const schemaString = buildSchemaString(fields);\n\n // TODO: Implement actual EAS SDK registration\n // This is a placeholder that will be replaced with actual EAS SDK integration\n console.log(`[EAS] Registering schema: ${schemaString}`);\n console.log(`[EAS] Resolver: ${resolverAddress}`);\n console.log(`[EAS] Revocable: ${revocable}`);\n\n // Return a mock UID for now\n return `0x${\"0\".repeat(64)}`;\n}\n","export * from \"./schema.js\";\n\nexport function createEASClient() {\n return {\n submitAttestation() {\n console.log(\"[EAS] Submitting attestation\");\n },\n\n parseAttestation() {\n console.log(\"[EAS] Parsing attestation\");\n },\n\n createSchema() {\n console.log(\"[EAS] Creating schema\");\n },\n\n getSchema() {\n console.log(\"[EAS] Getting schema\");\n },\n\n getAttestations() {\n console.log(\"[EAS] Getting attestations\");\n },\n };\n}\n"]}