@settlemint/sdk-eas 2.3.5-pr37a28299 → 2.3.5-pr4254bb99

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.
@@ -1,30 +1,15 @@
1
- import { z } from "zod/v4";
1
+ import { createPortalClient } from "@settlemint/sdk-portal";
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
+ * Common address constants
7
7
  */
8
8
  /**
9
- * Schema for validating EAS client configuration options.
10
- * Extends the base Viem client options with EAS-specific requirements.
9
+ * Common address constants
11
10
  */
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
11
+ declare const ZERO_ADDRESS: Address;
12
+ declare const ZERO_BYTES32: Hex;
28
13
  /**
29
14
  * Supported field types for EAS schema fields.
30
15
  * Maps to the Solidity types that can be used in EAS schemas.
@@ -53,45 +38,317 @@ interface SchemaField {
53
38
  description?: string;
54
39
  }
55
40
  /**
56
- * Options for registering a new schema in the EAS Schema Registry.
41
+ * Configuration options for the EAS client
42
+ */
43
+ interface EASClientOptions {
44
+ /** Portal GraphQL endpoint URL */
45
+ instance: string;
46
+ /** Portal access token */
47
+ accessToken: string;
48
+ /** Optional EAS contract address (if already deployed) */
49
+ easContractAddress?: Address;
50
+ /** Optional Schema Registry contract address (if already deployed) */
51
+ schemaRegistryContractAddress?: Address;
52
+ /** Enable debug logging */
53
+ debug?: boolean;
54
+ }
55
+ /**
56
+ * Schema registration request
57
57
  */
58
- interface RegisterSchemaOptions {
59
- /** Array of fields that make up the schema */
60
- fields: SchemaField[];
61
- /** Address of the resolver contract that will handle attestations */
62
- resolverAddress: string;
58
+ interface SchemaRequest {
59
+ /** Schema fields (alternative to schema string) */
60
+ fields?: SchemaField[];
61
+ /** Raw schema string (alternative to fields) */
62
+ schema?: string;
63
+ /** Resolver contract address (use ZERO_ADDRESS for no resolver) */
64
+ resolver: Address;
63
65
  /** Whether attestations using this schema can be revoked */
64
66
  revocable: boolean;
65
67
  }
68
+ /**
69
+ * Attestation data structure
70
+ */
71
+ interface AttestationData {
72
+ /** Recipient of the attestation */
73
+ recipient: Address;
74
+ /** Expiration time (0 for no expiration) */
75
+ expirationTime: bigint;
76
+ /** Whether this attestation can be revoked */
77
+ revocable: boolean;
78
+ /** Reference UID (use ZERO_BYTES32 for no reference) */
79
+ refUID: Hex;
80
+ /** Encoded attestation data */
81
+ data: Hex;
82
+ /** Value sent with the attestation */
83
+ value: bigint;
84
+ }
85
+ /**
86
+ * Attestation request
87
+ */
88
+ interface AttestationRequest {
89
+ /** Schema UID to attest against */
90
+ schema: Hex;
91
+ /** Attestation data */
92
+ data: AttestationData;
93
+ }
94
+ /**
95
+ * Transaction result
96
+ */
97
+ interface TransactionResult {
98
+ /** Transaction hash */
99
+ hash: Hex;
100
+ /** Whether the transaction was successful */
101
+ success: boolean;
102
+ }
103
+ /**
104
+ * Schema information
105
+ */
106
+ interface SchemaData {
107
+ /** Schema UID */
108
+ uid: Hex;
109
+ /** Resolver contract address */
110
+ resolver: Address;
111
+ /** Whether attestations can be revoked */
112
+ revocable: boolean;
113
+ /** Schema string */
114
+ schema: string;
115
+ }
116
+ /**
117
+ * Attestation information
118
+ */
119
+ interface AttestationInfo {
120
+ /** Attestation UID */
121
+ uid: Hex;
122
+ /** Schema UID */
123
+ schema: Hex;
124
+ /** Address that created the attestation */
125
+ attester: Address;
126
+ /** Recipient of the attestation */
127
+ recipient: Address;
128
+ /** Creation timestamp */
129
+ time: bigint;
130
+ /** Expiration timestamp */
131
+ expirationTime: bigint;
132
+ /** Whether this attestation can be revoked */
133
+ revocable: boolean;
134
+ /** Reference UID */
135
+ refUID: Hex;
136
+ /** Encoded attestation data */
137
+ data: Hex;
138
+ /** Value sent with the attestation */
139
+ value: bigint;
140
+ }
141
+ /**
142
+ * Options for retrieving schemas
143
+ */
144
+ interface GetSchemasOptions {
145
+ /** Maximum number of schemas to return */
146
+ limit?: number;
147
+ /** Number of schemas to skip */
148
+ offset?: number;
149
+ }
150
+ /**
151
+ * Options for retrieving attestations
152
+ */
153
+ interface GetAttestationsOptions {
154
+ /** Maximum number of attestations to return */
155
+ limit?: number;
156
+ /** Number of attestations to skip */
157
+ offset?: number;
158
+ /** Filter by schema UID */
159
+ schema?: Hex;
160
+ /** Filter by attester address */
161
+ attester?: Address;
162
+ /** Filter by recipient address */
163
+ recipient?: Address;
164
+ }
165
+ /**
166
+ * Contract deployment result
167
+ */
168
+ interface DeploymentResult {
169
+ /** Deployed EAS contract address */
170
+ easAddress: Address;
171
+ /** Deployed Schema Registry contract address */
172
+ schemaRegistryAddress: Address;
173
+ }
174
+ /**
175
+ * @deprecated Use SchemaRequest instead
176
+ */
177
+ interface RegisterSchemaOptions extends SchemaRequest {}
178
+ /**
179
+ * @internal
180
+ * Portal transaction response structure
181
+ */
182
+ interface PortalTransactionResponse {
183
+ transactionHash?: string;
184
+ contractAddress?: string;
185
+ }
186
+ /**
187
+ * @internal
188
+ * Portal schema response structure
189
+ */
190
+ interface PortalSchemaResponse {
191
+ EASSchemaRegistry?: {
192
+ getSchema?: {
193
+ uid: string;
194
+ resolver: string;
195
+ revocable: boolean;
196
+ schema: string;
197
+ };
198
+ };
199
+ }
200
+ /**
201
+ * @internal
202
+ * Portal attestation response structure
203
+ */
204
+ interface PortalAttestationResponse {
205
+ EAS?: {
206
+ getAttestation?: {
207
+ uid: string;
208
+ schema: string;
209
+ attester: string;
210
+ recipient: string;
211
+ time: string;
212
+ expirationTime: string;
213
+ revocable: boolean;
214
+ refUID: string;
215
+ data: string;
216
+ };
217
+ isAttestationValid?: boolean;
218
+ getTimestamp?: string;
219
+ };
220
+ }
221
+ /**
222
+ * @internal
223
+ * Portal contracts response structure
224
+ */
225
+ interface PortalContractsResponse {
226
+ getContractsEasSchemaRegistry?: {
227
+ count: number;
228
+ records: Array<{
229
+ address: string;
230
+ abiName: string;
231
+ createdAt: string;
232
+ }>;
233
+ };
234
+ getContractsEas?: {
235
+ count: number;
236
+ records: Array<{
237
+ address: string;
238
+ abiName: string;
239
+ createdAt: string;
240
+ }>;
241
+ };
242
+ } //#endregion
243
+ //#region src/utils/validation.d.ts
244
+ declare function validateFieldName(name: string): void;
245
+ declare function validateFieldType(type: string): asserts type is EASFieldType;
246
+ declare function validateSchemaFields(fields: SchemaField[]): void;
247
+ declare function buildSchemaString(fields: SchemaField[]): string;
66
248
 
67
249
  //#endregion
68
250
  //#region src/eas.d.ts
69
251
  /**
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
- * ```
89
- */
90
- declare function createEASClient(options: ClientOptions): {
91
- registerSchema: (options: RegisterSchemaOptions) => Promise<string>;
92
- getSchema: (uid: string) => Promise<string>;
93
- };
252
+ * Main EAS client class for interacting with Ethereum Attestation Service via Portal
253
+ */
254
+ declare class EASClient {
255
+ private options;
256
+ private portalClient;
257
+ private deployedAddresses?;
258
+ constructor(options: EASClientOptions);
259
+ /**
260
+ * Deploy EAS contracts via Portal
261
+ * @param deployerAddress - Address to deploy contracts from
262
+ * @param forwarderAddress - Optional forwarder address for meta-transactions (defaults to zero address)
263
+ * @param gasLimit - Optional gas limit for deployment transactions
264
+ */
265
+ deploy(deployerAddress: Address, forwarderAddress?: Address, gasLimit?: string): Promise<DeploymentResult>;
266
+ /**
267
+ * Get the EAS contract address
268
+ */
269
+ private getEASAddress;
270
+ /**
271
+ * Get the Schema Registry contract address
272
+ */
273
+ private getSchemaRegistryAddress;
274
+ /**
275
+ * Register a new schema in the EAS Schema Registry
276
+ * @param request - Schema registration request
277
+ * @param fromAddress - Address to send transaction from
278
+ * @param gasLimit - Optional gas limit for the transaction
279
+ */
280
+ registerSchema(request: SchemaRequest, fromAddress: Address, gasLimit?: string): Promise<TransactionResult>;
281
+ /**
282
+ * Create an attestation
283
+ * @param request - Attestation request
284
+ * @param fromAddress - Address to send transaction from
285
+ * @param gasLimit - Optional gas limit for the transaction
286
+ */
287
+ attest(request: AttestationRequest, fromAddress: Address, gasLimit?: string): Promise<TransactionResult>;
288
+ /**
289
+ * Create multiple attestations in a single transaction
290
+ * @param requests - Array of attestation requests
291
+ * @param fromAddress - Address to send transaction from
292
+ * @param gasLimit - Optional gas limit for the transaction
293
+ */
294
+ multiAttest(requests: AttestationRequest[], fromAddress: Address, gasLimit?: string): Promise<TransactionResult>;
295
+ /**
296
+ * Revoke an attestation
297
+ * @param uid - UID of the attestation to revoke
298
+ * @param fromAddress - Address to send transaction from
299
+ * @param value - Optional value to send with revocation
300
+ * @param gasLimit - Optional gas limit for the transaction
301
+ */
302
+ revoke(uid: Hex, fromAddress: Address, value?: bigint, gasLimit?: string): Promise<TransactionResult>;
303
+ /**
304
+ * Get a schema by UID
305
+ */
306
+ getSchema(uid: Hex): Promise<SchemaData>;
307
+ /**
308
+ * Get all schemas with pagination
309
+ */
310
+ getSchemas(options?: GetSchemasOptions): Promise<SchemaData[]>;
311
+ /**
312
+ * Get an attestation by UID
313
+ */
314
+ getAttestation(uid: Hex): Promise<AttestationInfo>;
315
+ /**
316
+ * Get attestations with pagination and filtering
317
+ */
318
+ getAttestations(options?: GetAttestationsOptions): Promise<AttestationInfo[]>;
319
+ /**
320
+ * Check if an attestation is valid
321
+ */
322
+ isValidAttestation(uid: Hex): Promise<boolean>;
323
+ /**
324
+ * Get the current timestamp from the contract
325
+ */
326
+ getTimestamp(): Promise<bigint>;
327
+ /**
328
+ * Get client configuration
329
+ */
330
+ getOptions(): EASClientOptions;
331
+ /**
332
+ * Get the Portal client instance for advanced operations
333
+ */
334
+ getPortalClient(): ReturnType<typeof createPortalClient>["client"];
335
+ /**
336
+ * Get current contract addresses
337
+ */
338
+ getContractAddresses(): {
339
+ easAddress?: Address;
340
+ schemaRegistryAddress?: Address;
341
+ };
342
+ /**
343
+ * Build schema string from fields
344
+ */
345
+ private buildSchemaString;
346
+ }
347
+ /**
348
+ * Create a new EAS client instance
349
+ */
350
+ declare function createEASClient(options: EASClientOptions): EASClient;
94
351
 
95
352
  //#endregion
96
- export { ClientOptions, ClientOptionsSchema, EASFieldType, EAS_FIELD_TYPES, RegisterSchemaOptions, SchemaField, createEASClient };
353
+ export { AttestationData, AttestationInfo, AttestationRequest, DeploymentResult, EASClient, EASClientOptions, EASFieldType, EAS_FIELD_TYPES, GetAttestationsOptions, GetSchemasOptions, RegisterSchemaOptions, SchemaData, SchemaField, SchemaRequest, TransactionResult, ZERO_ADDRESS, ZERO_BYTES32, buildSchemaString, createEASClient, validateSchemaFields };
97
354
  //# sourceMappingURL=eas.d.ts.map