@settlemint/sdk-eas 2.3.5-prad3d4392 → 2.3.5-prb695ce87

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/eas.d.cts CHANGED
@@ -1,30 +1,11 @@
1
- import { z } from "zod/v4";
1
+ import { GraphQLClient } from "graphql-request";
2
+ import { Address, Hex } from "viem";
2
3
 
3
- //#region src/client-options.schema.d.ts
4
+ //#region src/types.d.ts
4
5
  /**
5
- * Schema for validating EAS client configuration options.
6
- * Extends the base Viem client options with EAS-specific requirements.
6
+ * Supported field types for EAS schema fields.
7
+ * Maps to the Solidity types that can be used in EAS schemas.
7
8
  */
8
- /**
9
- * Schema for validating EAS client configuration options.
10
- * Extends the base Viem client options with EAS-specific requirements.
11
- */
12
- declare const ClientOptionsSchema: z.ZodObject<{
13
- schemaRegistryAddress: z.ZodString;
14
- attestationAddress: z.ZodString;
15
- accessToken: z.ZodString;
16
- chainId: z.ZodString;
17
- chainName: z.ZodString;
18
- rpcUrl: z.ZodString;
19
- }, z.core.$strip>;
20
- /**
21
- * Configuration options for creating an EAS client.
22
- * Combines EAS-specific options with base Viem client options.
23
- */
24
- type ClientOptions = z.infer<typeof ClientOptionsSchema>;
25
-
26
- //#endregion
27
- //#region src/types.d.ts
28
9
  /**
29
10
  * Supported field types for EAS schema fields.
30
11
  * Maps to the Solidity types that can be used in EAS schemas.
@@ -52,8 +33,28 @@ interface SchemaField {
52
33
  /** Optional description of the field's purpose */
53
34
  description?: string;
54
35
  }
36
+ /**
37
+ * Configuration options for the EAS client
38
+ */
39
+ interface EASClientOptions {
40
+ instance: string;
41
+ accessToken: string;
42
+ easContractAddress?: Address;
43
+ schemaRegistryContractAddress?: Address;
44
+ debug?: boolean;
45
+ }
46
+ /**
47
+ * Schema registration request
48
+ */
49
+ interface SchemaRequest {
50
+ schema?: string;
51
+ fields?: SchemaField[];
52
+ resolver: Address;
53
+ revocable: boolean;
54
+ }
55
55
  /**
56
56
  * Options for registering a new schema in the EAS Schema Registry.
57
+ * @deprecated Use SchemaRequest instead
57
58
  */
58
59
  interface RegisterSchemaOptions {
59
60
  /** Array of fields that make up the schema */
@@ -63,35 +64,178 @@ interface RegisterSchemaOptions {
63
64
  /** Whether attestations using this schema can be revoked */
64
65
  revocable: boolean;
65
66
  }
67
+ /**
68
+ * Attestation data structure
69
+ */
70
+ interface AttestationData {
71
+ recipient: Address;
72
+ expirationTime: bigint;
73
+ revocable: boolean;
74
+ refUID: Hex;
75
+ data: Hex;
76
+ value: bigint;
77
+ }
78
+ /**
79
+ * Attestation request
80
+ */
81
+ interface AttestationRequest {
82
+ schema: Hex;
83
+ data: AttestationData;
84
+ }
85
+ /**
86
+ * Transaction result
87
+ */
88
+ interface TransactionResult {
89
+ hash: Hex;
90
+ success: boolean;
91
+ }
92
+ /**
93
+ * Schema data from registry
94
+ */
95
+ interface SchemaData {
96
+ uid: Hex;
97
+ resolver: Address;
98
+ revocable: boolean;
99
+ schema: string;
100
+ }
101
+ /**
102
+ * Attestation data from contract
103
+ */
104
+ interface AttestationInfo {
105
+ uid: Hex;
106
+ schema: Hex;
107
+ attester: Address;
108
+ recipient: Address;
109
+ time: bigint;
110
+ expirationTime: bigint;
111
+ revocable: boolean;
112
+ refUID: Hex;
113
+ data: Hex;
114
+ value: bigint;
115
+ }
116
+ /**
117
+ * Options for retrieving schemas
118
+ */
119
+ interface GetSchemasOptions extends Record<string, unknown> {
120
+ limit?: number;
121
+ offset?: number;
122
+ resolver?: Address;
123
+ }
124
+ /**
125
+ * Options for retrieving attestations
126
+ */
127
+ interface GetAttestationsOptions extends Record<string, unknown> {
128
+ limit?: number;
129
+ offset?: number;
130
+ schema?: Hex;
131
+ attester?: Address;
132
+ recipient?: Address;
133
+ }
134
+ /**
135
+ * Contract deployment result
136
+ */
137
+ interface DeploymentResult {
138
+ easAddress: Address;
139
+ schemaRegistryAddress: Address;
140
+ } //#endregion
141
+ //#region src/utils/validation.d.ts
142
+ declare function validateFieldName(name: string): void;
143
+ declare function validateFieldType(type: string): asserts type is EASFieldType;
144
+ declare function validateSchemaFields(fields: SchemaField[]): void;
145
+ declare function buildSchemaString(fields: SchemaField[]): string;
66
146
 
67
147
  //#endregion
68
148
  //#region src/eas.d.ts
69
149
  /**
70
- * Creates an EAS client for interacting with the Ethereum Attestation Service.
71
- *
72
- * @param options - Configuration options for the client
73
- * @returns An object containing the EAS client instance
74
- * @throws Will throw an error if the options fail validation
75
- *
76
- * @example
77
- * ```ts
78
- * import { createEASClient } from '@settlemint/sdk-eas';
79
- *
80
- * const client = createEASClient({
81
- * schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
82
- * attestationAddress: "0x1234567890123456789012345678901234567890",
83
- * accessToken: "your-access-token",
84
- * chainId: "1",
85
- * chainName: "Ethereum",
86
- * rpcUrl: "http://localhost:8545"
87
- * });
88
- * ```
150
+ * Main EAS client class
89
151
  */
90
- declare function createEASClient(options: ClientOptions): {
91
- registerSchema: (options: RegisterSchemaOptions) => Promise<string>;
92
- getSchema: (uid: string) => Promise<string>;
93
- };
152
+ declare class EASClient {
153
+ private options;
154
+ private portalClient;
155
+ private deployedAddresses?;
156
+ constructor(options: EASClientOptions);
157
+ /**
158
+ * Deploy EAS contracts (if needed)
159
+ */
160
+ deploy(): Promise<DeploymentResult>;
161
+ /**
162
+ * Get the EAS contract address (from options or deployment)
163
+ */
164
+ private getEASAddress;
165
+ /**
166
+ * Get the Schema Registry contract address (from options or deployment)
167
+ */
168
+ private getSchemaRegistryAddress;
169
+ /**
170
+ * Register a new schema
171
+ */
172
+ registerSchema(request: SchemaRequest): Promise<TransactionResult>;
173
+ /**
174
+ * Create an attestation
175
+ */
176
+ attest(request: AttestationRequest): Promise<TransactionResult>;
177
+ /**
178
+ * Create multiple attestations
179
+ */
180
+ multiAttest(requests: AttestationRequest[]): Promise<TransactionResult>;
181
+ /**
182
+ * Revoke an attestation
183
+ */
184
+ revoke(uid: Hex, value?: bigint): Promise<TransactionResult>;
185
+ /**
186
+ * Get a schema by UID
187
+ */
188
+ getSchema(uid: Hex): Promise<SchemaData>;
189
+ /**
190
+ * Get all schemas (paginated)
191
+ */
192
+ getSchemas(options?: GetSchemasOptions): Promise<SchemaData[]>;
193
+ /**
194
+ * Get an attestation by UID
195
+ */
196
+ getAttestation(uid: Hex): Promise<AttestationInfo>;
197
+ /**
198
+ * Get attestations (paginated)
199
+ */
200
+ getAttestations(options?: GetAttestationsOptions): Promise<AttestationInfo[]>;
201
+ /**
202
+ * Check if an attestation is valid
203
+ */
204
+ isValidAttestation(uid: Hex): Promise<boolean>;
205
+ /**
206
+ * Get the current timestamp from the contract
207
+ */
208
+ getTimestamp(): Promise<bigint>;
209
+ /**
210
+ * Get client configuration
211
+ */
212
+ getOptions(): EASClientOptions;
213
+ /**
214
+ * Get the Portal client instance for advanced operations
215
+ */
216
+ getPortalClient(): GraphQLClient;
217
+ /**
218
+ * Get current contract addresses (from options or deployment)
219
+ */
220
+ getContractAddresses(): {
221
+ easAddress?: Address;
222
+ schemaRegistryAddress?: Address;
223
+ };
224
+ /**
225
+ * Mock Portal GraphQL call - replace with actual implementation later
226
+ * This provides a clean way to add real Portal calls
227
+ */
228
+ private mockPortalCall;
229
+ /**
230
+ * Build schema string from fields - utility method
231
+ */
232
+ private buildSchemaString;
233
+ }
234
+ /**
235
+ * Create a new EAS client instance
236
+ */
237
+ declare function createEASClient(options: EASClientOptions): EASClient;
94
238
 
95
239
  //#endregion
96
- export { ClientOptions, ClientOptionsSchema, EASFieldType, EAS_FIELD_TYPES, RegisterSchemaOptions, SchemaField, createEASClient };
240
+ export { AttestationData, AttestationInfo, AttestationRequest, DeploymentResult, EASClient, EASClientOptions, EASFieldType, EAS_FIELD_TYPES, GetAttestationsOptions, GetSchemasOptions, RegisterSchemaOptions, SchemaData, SchemaField, SchemaRequest, TransactionResult, buildSchemaString, createEASClient, validateSchemaFields };
97
241
  //# sourceMappingURL=eas.d.cts.map
package/dist/eas.d.ts CHANGED
@@ -1,30 +1,11 @@
1
- import { z } from "zod/v4";
1
+ import { GraphQLClient } from "graphql-request";
2
+ import { Address, Hex } from "viem";
2
3
 
3
- //#region src/client-options.schema.d.ts
4
+ //#region src/types.d.ts
4
5
  /**
5
- * Schema for validating EAS client configuration options.
6
- * Extends the base Viem client options with EAS-specific requirements.
6
+ * Supported field types for EAS schema fields.
7
+ * Maps to the Solidity types that can be used in EAS schemas.
7
8
  */
8
- /**
9
- * Schema for validating EAS client configuration options.
10
- * Extends the base Viem client options with EAS-specific requirements.
11
- */
12
- declare const ClientOptionsSchema: z.ZodObject<{
13
- schemaRegistryAddress: z.ZodString;
14
- attestationAddress: z.ZodString;
15
- accessToken: z.ZodString;
16
- chainId: z.ZodString;
17
- chainName: z.ZodString;
18
- rpcUrl: z.ZodString;
19
- }, z.core.$strip>;
20
- /**
21
- * Configuration options for creating an EAS client.
22
- * Combines EAS-specific options with base Viem client options.
23
- */
24
- type ClientOptions = z.infer<typeof ClientOptionsSchema>;
25
-
26
- //#endregion
27
- //#region src/types.d.ts
28
9
  /**
29
10
  * Supported field types for EAS schema fields.
30
11
  * Maps to the Solidity types that can be used in EAS schemas.
@@ -52,8 +33,28 @@ interface SchemaField {
52
33
  /** Optional description of the field's purpose */
53
34
  description?: string;
54
35
  }
36
+ /**
37
+ * Configuration options for the EAS client
38
+ */
39
+ interface EASClientOptions {
40
+ instance: string;
41
+ accessToken: string;
42
+ easContractAddress?: Address;
43
+ schemaRegistryContractAddress?: Address;
44
+ debug?: boolean;
45
+ }
46
+ /**
47
+ * Schema registration request
48
+ */
49
+ interface SchemaRequest {
50
+ schema?: string;
51
+ fields?: SchemaField[];
52
+ resolver: Address;
53
+ revocable: boolean;
54
+ }
55
55
  /**
56
56
  * Options for registering a new schema in the EAS Schema Registry.
57
+ * @deprecated Use SchemaRequest instead
57
58
  */
58
59
  interface RegisterSchemaOptions {
59
60
  /** Array of fields that make up the schema */
@@ -63,35 +64,178 @@ interface RegisterSchemaOptions {
63
64
  /** Whether attestations using this schema can be revoked */
64
65
  revocable: boolean;
65
66
  }
67
+ /**
68
+ * Attestation data structure
69
+ */
70
+ interface AttestationData {
71
+ recipient: Address;
72
+ expirationTime: bigint;
73
+ revocable: boolean;
74
+ refUID: Hex;
75
+ data: Hex;
76
+ value: bigint;
77
+ }
78
+ /**
79
+ * Attestation request
80
+ */
81
+ interface AttestationRequest {
82
+ schema: Hex;
83
+ data: AttestationData;
84
+ }
85
+ /**
86
+ * Transaction result
87
+ */
88
+ interface TransactionResult {
89
+ hash: Hex;
90
+ success: boolean;
91
+ }
92
+ /**
93
+ * Schema data from registry
94
+ */
95
+ interface SchemaData {
96
+ uid: Hex;
97
+ resolver: Address;
98
+ revocable: boolean;
99
+ schema: string;
100
+ }
101
+ /**
102
+ * Attestation data from contract
103
+ */
104
+ interface AttestationInfo {
105
+ uid: Hex;
106
+ schema: Hex;
107
+ attester: Address;
108
+ recipient: Address;
109
+ time: bigint;
110
+ expirationTime: bigint;
111
+ revocable: boolean;
112
+ refUID: Hex;
113
+ data: Hex;
114
+ value: bigint;
115
+ }
116
+ /**
117
+ * Options for retrieving schemas
118
+ */
119
+ interface GetSchemasOptions extends Record<string, unknown> {
120
+ limit?: number;
121
+ offset?: number;
122
+ resolver?: Address;
123
+ }
124
+ /**
125
+ * Options for retrieving attestations
126
+ */
127
+ interface GetAttestationsOptions extends Record<string, unknown> {
128
+ limit?: number;
129
+ offset?: number;
130
+ schema?: Hex;
131
+ attester?: Address;
132
+ recipient?: Address;
133
+ }
134
+ /**
135
+ * Contract deployment result
136
+ */
137
+ interface DeploymentResult {
138
+ easAddress: Address;
139
+ schemaRegistryAddress: Address;
140
+ } //#endregion
141
+ //#region src/utils/validation.d.ts
142
+ declare function validateFieldName(name: string): void;
143
+ declare function validateFieldType(type: string): asserts type is EASFieldType;
144
+ declare function validateSchemaFields(fields: SchemaField[]): void;
145
+ declare function buildSchemaString(fields: SchemaField[]): string;
66
146
 
67
147
  //#endregion
68
148
  //#region src/eas.d.ts
69
149
  /**
70
- * Creates an EAS client for interacting with the Ethereum Attestation Service.
71
- *
72
- * @param options - Configuration options for the client
73
- * @returns An object containing the EAS client instance
74
- * @throws Will throw an error if the options fail validation
75
- *
76
- * @example
77
- * ```ts
78
- * import { createEASClient } from '@settlemint/sdk-eas';
79
- *
80
- * const client = createEASClient({
81
- * schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
82
- * attestationAddress: "0x1234567890123456789012345678901234567890",
83
- * accessToken: "your-access-token",
84
- * chainId: "1",
85
- * chainName: "Ethereum",
86
- * rpcUrl: "http://localhost:8545"
87
- * });
88
- * ```
150
+ * Main EAS client class
89
151
  */
90
- declare function createEASClient(options: ClientOptions): {
91
- registerSchema: (options: RegisterSchemaOptions) => Promise<string>;
92
- getSchema: (uid: string) => Promise<string>;
93
- };
152
+ declare class EASClient {
153
+ private options;
154
+ private portalClient;
155
+ private deployedAddresses?;
156
+ constructor(options: EASClientOptions);
157
+ /**
158
+ * Deploy EAS contracts (if needed)
159
+ */
160
+ deploy(): Promise<DeploymentResult>;
161
+ /**
162
+ * Get the EAS contract address (from options or deployment)
163
+ */
164
+ private getEASAddress;
165
+ /**
166
+ * Get the Schema Registry contract address (from options or deployment)
167
+ */
168
+ private getSchemaRegistryAddress;
169
+ /**
170
+ * Register a new schema
171
+ */
172
+ registerSchema(request: SchemaRequest): Promise<TransactionResult>;
173
+ /**
174
+ * Create an attestation
175
+ */
176
+ attest(request: AttestationRequest): Promise<TransactionResult>;
177
+ /**
178
+ * Create multiple attestations
179
+ */
180
+ multiAttest(requests: AttestationRequest[]): Promise<TransactionResult>;
181
+ /**
182
+ * Revoke an attestation
183
+ */
184
+ revoke(uid: Hex, value?: bigint): Promise<TransactionResult>;
185
+ /**
186
+ * Get a schema by UID
187
+ */
188
+ getSchema(uid: Hex): Promise<SchemaData>;
189
+ /**
190
+ * Get all schemas (paginated)
191
+ */
192
+ getSchemas(options?: GetSchemasOptions): Promise<SchemaData[]>;
193
+ /**
194
+ * Get an attestation by UID
195
+ */
196
+ getAttestation(uid: Hex): Promise<AttestationInfo>;
197
+ /**
198
+ * Get attestations (paginated)
199
+ */
200
+ getAttestations(options?: GetAttestationsOptions): Promise<AttestationInfo[]>;
201
+ /**
202
+ * Check if an attestation is valid
203
+ */
204
+ isValidAttestation(uid: Hex): Promise<boolean>;
205
+ /**
206
+ * Get the current timestamp from the contract
207
+ */
208
+ getTimestamp(): Promise<bigint>;
209
+ /**
210
+ * Get client configuration
211
+ */
212
+ getOptions(): EASClientOptions;
213
+ /**
214
+ * Get the Portal client instance for advanced operations
215
+ */
216
+ getPortalClient(): GraphQLClient;
217
+ /**
218
+ * Get current contract addresses (from options or deployment)
219
+ */
220
+ getContractAddresses(): {
221
+ easAddress?: Address;
222
+ schemaRegistryAddress?: Address;
223
+ };
224
+ /**
225
+ * Mock Portal GraphQL call - replace with actual implementation later
226
+ * This provides a clean way to add real Portal calls
227
+ */
228
+ private mockPortalCall;
229
+ /**
230
+ * Build schema string from fields - utility method
231
+ */
232
+ private buildSchemaString;
233
+ }
234
+ /**
235
+ * Create a new EAS client instance
236
+ */
237
+ declare function createEASClient(options: EASClientOptions): EASClient;
94
238
 
95
239
  //#endregion
96
- export { ClientOptions, ClientOptionsSchema, EASFieldType, EAS_FIELD_TYPES, RegisterSchemaOptions, SchemaField, createEASClient };
240
+ export { AttestationData, AttestationInfo, AttestationRequest, DeploymentResult, EASClient, EASClientOptions, EASFieldType, EAS_FIELD_TYPES, GetAttestationsOptions, GetSchemasOptions, RegisterSchemaOptions, SchemaData, SchemaField, SchemaRequest, TransactionResult, buildSchemaString, createEASClient, validateSchemaFields };
97
241
  //# sourceMappingURL=eas.d.ts.map