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

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 ADDED
@@ -0,0 +1,42 @@
1
+ <p align="center">
2
+ <img src="https://github.com/settlemint/sdk/blob/main/logo.svg" width="200px" align="center" alt="SettleMint logo" />
3
+ <h1 align="center">SettleMint SDK</h1>
4
+ <p align="center">
5
+ ✨ <a href="https://settlemint.com">https://settlemint.com</a> ✨
6
+ <br/>
7
+ Integrate SettleMint into your application with ease.
8
+ </p>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/settlemint/sdk/actions?query=branch%3Amain"><img src="https://github.com/settlemint/sdk/actions/workflows/build.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
13
+ <a href="https://fsl.software" rel="nofollow"><img src="https://img.shields.io/npm/l/@settlemint/sdk-eas" alt="License"></a>
14
+ <a href="https://www.npmjs.com/package/@settlemint/sdk-eas" rel="nofollow"><img src="https://img.shields.io/npm/dw/@settlemint/sdk-eas" alt="npm"></a>
15
+ <a href="https://github.com/settlemint/sdk" rel="nofollow"><img src="https://img.shields.io/github/stars/settlemint/sdk" alt="stars"></a>
16
+ </p>
17
+
18
+ <div align="center">
19
+ <a href="https://console.settlemint.com/documentation">Documentation</a>
20
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
+ <a href="https://www.npmjs.com/package/@settlemint/sdk-eas">NPM</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://github.com/settlemint/sdk/issues">Issues</a>
24
+ <br />
25
+ </div>
26
+
27
+ ## Table of Contents
28
+
29
+ - [About](#about)
30
+ - [Contributing](#contributing)
31
+ - [License](#license)
32
+
33
+ ## About
34
+
35
+ 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.
36
+ ## Contributing
37
+
38
+ 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.
39
+
40
+ ## License
41
+
42
+ The SettleMint SDK is released under the [FSL Software License](https://fsl.software). See the [LICENSE](https://github.com/settlemint/sdk/blob/main/LICENSE) file for more details.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';function t(){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.createEASClient=t;//# sourceMappingURL=index.cjs.map
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
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["createEASClient"],"mappings":"aAAO,SAASA,GAAkB,CAChC,OAAO,CACL,iBAAA,EAAoB,CAClB,OAAQ,CAAA,GAAA,CAAI,8BAA8B,EAC5C,EAEA,gBAAmB,EAAA,CACjB,QAAQ,GAAI,CAAA,2BAA2B,EACzC,CAEA,CAAA,YAAA,EAAe,CACb,OAAA,CAAQ,IAAI,uBAAuB,EACrC,EAEA,SAAY,EAAA,CACV,QAAQ,GAAI,CAAA,sBAAsB,EACpC,CAAA,CAEA,iBAAkB,CAChB,OAAA,CAAQ,IAAI,4BAA4B,EAC1C,CACF,CACF","file":"index.cjs","sourcesContent":["export 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"]}
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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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 CHANGED
@@ -1,3 +1,83 @@
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
+
1
81
  declare function createEASClient(): {
2
82
  submitAttestation(): void;
3
83
  parseAttestation(): void;
@@ -6,4 +86,4 @@ declare function createEASClient(): {
6
86
  getAttestations(): void;
7
87
  };
8
88
 
9
- export { createEASClient };
89
+ export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,83 @@
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
+
1
81
  declare function createEASClient(): {
2
82
  submitAttestation(): void;
3
83
  parseAttestation(): void;
@@ -6,4 +86,4 @@ declare function createEASClient(): {
6
86
  getAttestations(): void;
7
87
  };
8
88
 
9
- export { createEASClient };
89
+ export { type EASFieldType, EAS_FIELD_TYPES, type RegisterSchemaOptions, type SchemaField, buildSchemaString, createEASClient, registerSchema, validateEthereumAddress, validateFieldName, validateFieldType, validateSchemaFields };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- function t(){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{t as createEASClient};//# sourceMappingURL=index.mjs.map
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
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["createEASClient"],"mappings":"AAAO,SAASA,GAAkB,CAChC,OAAO,CACL,iBAAA,EAAoB,CAClB,OAAQ,CAAA,GAAA,CAAI,8BAA8B,EAC5C,EAEA,gBAAmB,EAAA,CACjB,QAAQ,GAAI,CAAA,2BAA2B,EACzC,CAEA,CAAA,YAAA,EAAe,CACb,OAAA,CAAQ,IAAI,uBAAuB,EACrC,EAEA,SAAY,EAAA,CACV,QAAQ,GAAI,CAAA,sBAAsB,EACpC,CAAA,CAEA,iBAAkB,CAChB,OAAA,CAAQ,IAAI,4BAA4B,EAC1C,CACF,CACF","file":"index.mjs","sourcesContent":["export 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"]}
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,KAA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":["/**\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/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-pr5ceade05",
4
+ "version": "2.2.2-pr75b59b5f",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {},
53
53
  "dependencies": {
54
- "@settlemint/sdk-utils": "2.2.2-pr5ceade05",
54
+ "@settlemint/sdk-utils": "2.2.2-pr75b59b5f",
55
55
  "viem": "^2.7.9"
56
56
  },
57
57
  "peerDependencies": {},