@settlemint/sdk-eas 2.2.2-maine75a53e7 → 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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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=
|
|
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
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["createEASClient"],"mappings":"
|
|
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,CAAQ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AiD,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
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{
|
|
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
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["createEASClient"],"mappings":"
|
|
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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,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"]}
|
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-
|
|
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-
|
|
54
|
+
"@settlemint/sdk-utils": "2.2.2-pr75b59b5f",
|
|
55
55
|
"viem": "^2.7.9"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {},
|