@settlemint/sdk-eas 2.3.4 → 2.3.5-prfde1f9e5
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 +221 -84
- package/dist/browser/eas.d.ts +1012 -37
- package/dist/browser/eas.js +885 -112
- package/dist/browser/eas.js.map +1 -1
- package/dist/eas.cjs +893 -110
- package/dist/eas.cjs.map +1 -1
- package/dist/eas.d.cts +1012 -37
- package/dist/eas.d.ts +1012 -37
- package/dist/eas.js +885 -112
- package/dist/eas.js.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -27,23 +27,133 @@
|
|
|
27
27
|
## Table of Contents
|
|
28
28
|
|
|
29
29
|
- [About](#about)
|
|
30
|
+
- [Installation](#installation)
|
|
31
|
+
- [Quick Start](#quick-start)
|
|
32
|
+
- [ABI Configuration](#abi-configuration)
|
|
30
33
|
- [API Reference](#api-reference)
|
|
31
34
|
- [Functions](#functions)
|
|
32
35
|
- [createEASClient()](#createeasclient)
|
|
36
|
+
- [Classes](#classes)
|
|
37
|
+
- [EASPortalClient](#easportalclient)
|
|
33
38
|
- [Interfaces](#interfaces)
|
|
34
|
-
- [
|
|
39
|
+
- [PortalClientOptions](#portalclientoptions)
|
|
35
40
|
- [SchemaField](#schemafield)
|
|
36
41
|
- [Type Aliases](#type-aliases)
|
|
37
|
-
- [
|
|
42
|
+
- [AbiSource](#abisource)
|
|
38
43
|
- [Variables](#variables)
|
|
39
|
-
- [ClientOptionsSchema](#clientoptionsschema)
|
|
40
44
|
- [EAS\_FIELD\_TYPES](#eas_field_types)
|
|
45
|
+
- [Error Handling](#error-handling)
|
|
41
46
|
- [Contributing](#contributing)
|
|
42
47
|
- [License](#license)
|
|
43
48
|
|
|
44
49
|
## About
|
|
45
50
|
|
|
46
|
-
The SettleMint EAS SDK provides a
|
|
51
|
+
The SettleMint EAS SDK provides a Portal-based wrapper for the Ethereum Attestation Service (EAS), enabling developers to easily create, manage, and verify attestations within their applications. It leverages SettleMint's Portal infrastructure for enhanced features like real-time monitoring, flexible ABI support, and improved error handling.
|
|
52
|
+
|
|
53
|
+
**Key Features:**
|
|
54
|
+
- **Portal Integration**: Uses SettleMint's Portal GraphQL API for all contract interactions
|
|
55
|
+
- **Flexible ABI Support**: Hardcoded, custom, and predeployed ABI options with clear priority
|
|
56
|
+
- **Type Safety**: Full TypeScript support with proper type inference
|
|
57
|
+
- **Error Handling**: EAS-specific error codes and detailed error information
|
|
58
|
+
- **Real-time Monitoring**: Transaction status monitoring capabilities
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install @settlemint/sdk-eas
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { createEASClient } from "@settlemint/sdk-eas";
|
|
70
|
+
|
|
71
|
+
const client = createEASClient({
|
|
72
|
+
instance: "https://portal.settlemint.com",
|
|
73
|
+
accessToken: "your-access-token",
|
|
74
|
+
easContractAddress: "0x...", // Your EAS contract address
|
|
75
|
+
schemaRegistryContractAddress: "0x...", // Your Schema Registry address
|
|
76
|
+
// abiSource defaults to { type: "hardcoded" } - uses standard EAS ABIs
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Register a schema
|
|
80
|
+
const result = await client.registerSchema({
|
|
81
|
+
schema: "address user, uint256 score",
|
|
82
|
+
resolver: "0x0000000000000000000000000000000000000000",
|
|
83
|
+
revocable: true,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log("Transaction Hash:", result.hash);
|
|
87
|
+
|
|
88
|
+
// Create an attestation
|
|
89
|
+
const attestation = await client.attest({
|
|
90
|
+
schema: "0x...", // Schema UID
|
|
91
|
+
data: {
|
|
92
|
+
recipient: "0x...",
|
|
93
|
+
expirationTime: 0n,
|
|
94
|
+
revocable: true,
|
|
95
|
+
refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
96
|
+
data: "0x...", // Encoded attestation data
|
|
97
|
+
value: 0n,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Get an attestation
|
|
102
|
+
const attestationData = await client.getAttestation("0x...");
|
|
103
|
+
console.log("Attestation:", attestationData);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## ABI Configuration
|
|
107
|
+
|
|
108
|
+
The EAS SDK supports three ABI sources with the following priority:
|
|
109
|
+
|
|
110
|
+
### 1. Hardcoded ABIs (Default)
|
|
111
|
+
Uses standard EAS ABIs built into the SDK:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const client = createEASClient({
|
|
115
|
+
instance: "https://portal.settlemint.com",
|
|
116
|
+
accessToken: "your-token",
|
|
117
|
+
easContractAddress: "0x...",
|
|
118
|
+
schemaRegistryContractAddress: "0x...",
|
|
119
|
+
// abiSource defaults to { type: "hardcoded" }
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 2. Custom ABIs (User Override)
|
|
124
|
+
Override with your own ABIs:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { EAS_ABI, SCHEMA_REGISTRY_ABI } from "@settlemint/sdk-eas";
|
|
128
|
+
|
|
129
|
+
const client = createEASClient({
|
|
130
|
+
instance: "https://portal.settlemint.com",
|
|
131
|
+
accessToken: "your-token",
|
|
132
|
+
easContractAddress: "0x...",
|
|
133
|
+
schemaRegistryContractAddress: "0x...",
|
|
134
|
+
abiSource: {
|
|
135
|
+
type: "custom",
|
|
136
|
+
easAbi: EAS_ABI, // or your custom ABI
|
|
137
|
+
schemaRegistryAbi: SCHEMA_REGISTRY_ABI, // or your custom ABI
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 3. Predeployed ABIs (Portal's ABIs)
|
|
143
|
+
Use Portal's predeployed ABIs:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const client = createEASClient({
|
|
147
|
+
instance: "https://portal.settlemint.com",
|
|
148
|
+
accessToken: "your-token",
|
|
149
|
+
easContractAddress: "0x...",
|
|
150
|
+
schemaRegistryContractAddress: "0x...",
|
|
151
|
+
abiSource: {
|
|
152
|
+
type: "predeployed",
|
|
153
|
+
abiNames: ["eas"], // Optional, defaults to ["eas"]
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
47
157
|
|
|
48
158
|
## API Reference
|
|
49
159
|
|
|
@@ -51,38 +161,21 @@ The SettleMint EAS SDK provides a lightweight wrapper for the Ethereum Attestati
|
|
|
51
161
|
|
|
52
162
|
#### createEASClient()
|
|
53
163
|
|
|
54
|
-
> **createEASClient**(`options`): `
|
|
164
|
+
> **createEASClient**(`options`): [`EASPortalClient`](#easportalclient)
|
|
55
165
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Creates an EAS client for interacting with the Ethereum Attestation Service.
|
|
166
|
+
Creates a Portal-based EAS client for interacting with the Ethereum Attestation Service.
|
|
59
167
|
|
|
60
168
|
##### Parameters
|
|
61
169
|
|
|
62
170
|
| Parameter | Type | Description |
|
|
63
171
|
| ------ | ------ | ------ |
|
|
64
|
-
| `options` |
|
|
65
|
-
| `options.accessToken` | `string` | Access token for the RPC provider (must start with 'sm_aat_' or 'sm_pat_') |
|
|
66
|
-
| `options.attestationAddress` | `string` | The address of the EAS Attestation contract |
|
|
67
|
-
| `options.chainId` | `string` | The chain ID to connect to |
|
|
68
|
-
| `options.chainName` | `string` | The name of the chain to connect to |
|
|
69
|
-
| `options.rpcUrl` | `string` | The RPC URL to connect to (must be a valid URL) |
|
|
70
|
-
| `options.schemaRegistryAddress` | `string` | The address of the EAS Schema Registry contract |
|
|
172
|
+
| `options` | [`PortalClientOptions`](#portalclientoptions) | Configuration options for the Portal-based client |
|
|
71
173
|
|
|
72
174
|
##### Returns
|
|
73
175
|
|
|
74
|
-
`
|
|
75
|
-
|
|
76
|
-
An object containing the EAS client instance
|
|
77
|
-
|
|
78
|
-
| Name | Type | Defined in |
|
|
79
|
-
| ------ | ------ | ------ |
|
|
80
|
-
| `getSchema()` | (`uid`) => `Promise`\<`string`\> | [sdk/eas/src/eas.ts:96](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/eas.ts#L96) |
|
|
81
|
-
| `registerSchema()` | (`options`) => `Promise`\<`string`\> | [sdk/eas/src/eas.ts:95](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/eas.ts#L95) |
|
|
176
|
+
[`EASPortalClient`](#easportalclient)
|
|
82
177
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Will throw an error if the options fail validation
|
|
178
|
+
An EAS Portal client instance
|
|
86
179
|
|
|
87
180
|
##### Example
|
|
88
181
|
|
|
@@ -90,93 +183,137 @@ Will throw an error if the options fail validation
|
|
|
90
183
|
import { createEASClient } from '@settlemint/sdk-eas';
|
|
91
184
|
|
|
92
185
|
const client = createEASClient({
|
|
93
|
-
|
|
94
|
-
attestationAddress: "0x1234567890123456789012345678901234567890",
|
|
186
|
+
instance: "https://portal.settlemint.com",
|
|
95
187
|
accessToken: "your-access-token",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
rpcUrl: "http://localhost:8545"
|
|
188
|
+
easContractAddress: "0x...",
|
|
189
|
+
schemaRegistryContractAddress: "0x...",
|
|
99
190
|
});
|
|
100
191
|
```
|
|
101
192
|
|
|
102
|
-
###
|
|
193
|
+
### Classes
|
|
103
194
|
|
|
104
|
-
####
|
|
195
|
+
#### EASPortalClient
|
|
105
196
|
|
|
106
|
-
|
|
197
|
+
The main client class for interacting with EAS contracts via Portal.
|
|
107
198
|
|
|
108
|
-
|
|
199
|
+
##### Methods
|
|
109
200
|
|
|
110
|
-
|
|
201
|
+
- `registerSchema(request: SchemaRequest): Promise<TransactionResult>` - Register a new schema
|
|
202
|
+
- `attest(request: AttestationRequest): Promise<TransactionResult>` - Create an attestation
|
|
203
|
+
- `multiAttest(requests: AttestationRequest[]): Promise<TransactionResult>` - Create multiple attestations
|
|
204
|
+
- `revoke(uid: Hex, value?: bigint): Promise<TransactionResult>` - Revoke an attestation
|
|
205
|
+
- `getAttestation(uid: Hex): Promise<AttestationData>` - Retrieve attestation data
|
|
206
|
+
- `getSchema(uid: Hex): Promise<SchemaData>` - Retrieve schema data
|
|
207
|
+
- `isValidAttestation(uid: Hex): Promise<boolean>` - Check if attestation is valid
|
|
208
|
+
- `getTimestamp(): Promise<bigint>` - Get current contract timestamp
|
|
209
|
+
- `getPortalClient(): unknown` - Access underlying Portal client
|
|
210
|
+
- `getOptions(): PortalClientOptions` - Get client configuration
|
|
211
|
+
- `getAbis(): { easAbi: Abi; schemaRegistryAbi: Abi }` - Get current ABIs
|
|
111
212
|
|
|
112
|
-
|
|
113
|
-
| ------ | ------ | ------ | ------ |
|
|
114
|
-
| <a id="fields"></a> `fields` | [`SchemaField`](#schemafield)[] | Array of fields that make up the schema | [sdk/eas/src/types.ts:36](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/types.ts#L36) |
|
|
115
|
-
| <a id="resolveraddress"></a> `resolverAddress` | `string` | Address of the resolver contract that will handle attestations | [sdk/eas/src/types.ts:38](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/types.ts#L38) |
|
|
116
|
-
| <a id="revocable"></a> `revocable` | `boolean` | Whether attestations using this schema can be revoked | [sdk/eas/src/types.ts:40](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/types.ts#L40) |
|
|
213
|
+
### Interfaces
|
|
117
214
|
|
|
118
|
-
|
|
215
|
+
#### PortalClientOptions
|
|
119
216
|
|
|
120
|
-
|
|
217
|
+
Configuration options for the EAS Portal client.
|
|
218
|
+
|
|
219
|
+
##### Properties
|
|
121
220
|
|
|
122
|
-
|
|
221
|
+
| Property | Type | Description |
|
|
222
|
+
| ------ | ------ | ------ |
|
|
223
|
+
| `instance` | `string` | Portal instance URL or path |
|
|
224
|
+
| `accessToken` | `string` | Access token for Portal authentication |
|
|
225
|
+
| `easContractAddress` | `string` | The address of the EAS Attestation contract |
|
|
226
|
+
| `schemaRegistryContractAddress` | `string` | The address of the EAS Schema Registry contract |
|
|
227
|
+
| `abiSource?` | [`AbiSource`](#abisource) | ABI source configuration (defaults to hardcoded) |
|
|
228
|
+
| `wsUrl?` | `string` | Optional WebSocket URL for real-time monitoring |
|
|
229
|
+
| `timeout?` | `number` | Request timeout in milliseconds (default: 30000) |
|
|
230
|
+
| `debug?` | `boolean` | Enable debug logging (default: false) |
|
|
231
|
+
| `cache?` | `string` | Cache configuration for GraphQL requests |
|
|
232
|
+
|
|
233
|
+
#### SchemaField
|
|
123
234
|
|
|
124
235
|
Represents a single field in an EAS schema.
|
|
125
236
|
|
|
126
237
|
##### Properties
|
|
127
238
|
|
|
128
|
-
| Property | Type | Description |
|
|
129
|
-
| ------ | ------ | ------ |
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
239
|
+
| Property | Type | Description |
|
|
240
|
+
| ------ | ------ | ------ |
|
|
241
|
+
| `name` | `string` | The name of the field |
|
|
242
|
+
| `type` | `EASFieldType` | The Solidity type of the field |
|
|
243
|
+
| `description?` | `string` | Optional description of the field's purpose |
|
|
133
244
|
|
|
134
245
|
### Type Aliases
|
|
135
246
|
|
|
136
|
-
####
|
|
247
|
+
#### AbiSource
|
|
137
248
|
|
|
138
|
-
|
|
249
|
+
Configuration for ABI sources with priority system.
|
|
139
250
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
251
|
+
```typescript
|
|
252
|
+
type AbiSource =
|
|
253
|
+
| { type: "hardcoded" }
|
|
254
|
+
| { type: "custom"; easAbi: Abi; schemaRegistryAbi: Abi }
|
|
255
|
+
| { type: "predeployed"; abiNames?: string[] };
|
|
256
|
+
```
|
|
144
257
|
|
|
145
258
|
### Variables
|
|
146
259
|
|
|
147
|
-
#### ClientOptionsSchema
|
|
148
|
-
|
|
149
|
-
> `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodString`; `attestationAddress`: `ZodString`; `chainId`: `ZodString`; `chainName`: `ZodString`; `rpcUrl`: `ZodString`; `schemaRegistryAddress`: `ZodString`; \}, `$strip`\>
|
|
150
|
-
|
|
151
|
-
Defined in: [sdk/eas/src/client-options.schema.ts:9](https://github.com/settlemint/sdk/blob/v2.3.4/sdk/eas/src/client-options.schema.ts#L9)
|
|
152
|
-
|
|
153
|
-
Schema for validating EAS client configuration options.
|
|
154
|
-
Extends the base Viem client options with EAS-specific requirements.
|
|
155
|
-
|
|
156
|
-
***
|
|
157
|
-
|
|
158
260
|
#### EAS\_FIELD\_TYPES
|
|
159
261
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
262
|
+
Supported field types for EAS schema fields. Maps to the Solidity types that can be used in EAS schemas.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const EAS_FIELD_TYPES = {
|
|
266
|
+
string: "string",
|
|
267
|
+
address: "address",
|
|
268
|
+
bool: "bool",
|
|
269
|
+
bytes: "bytes",
|
|
270
|
+
bytes32: "bytes32",
|
|
271
|
+
uint256: "uint256",
|
|
272
|
+
int256: "int256",
|
|
273
|
+
uint8: "uint8",
|
|
274
|
+
int8: "int8",
|
|
275
|
+
} as const;
|
|
276
|
+
```
|
|
166
277
|
|
|
167
|
-
|
|
278
|
+
## Error Handling
|
|
279
|
+
|
|
280
|
+
The SDK provides comprehensive error handling with EAS-specific error codes:
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
import { EASErrorCode, EASPortalError } from "@settlemint/sdk-eas";
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
await client.getAttestation("invalid-uid");
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (error instanceof EASPortalError) {
|
|
289
|
+
switch (error.code) {
|
|
290
|
+
case EASErrorCode.ATTESTATION_NOT_FOUND:
|
|
291
|
+
console.log("Attestation not found");
|
|
292
|
+
break;
|
|
293
|
+
case EASErrorCode.TRANSACTION_FAILED:
|
|
294
|
+
console.log("Transaction failed");
|
|
295
|
+
break;
|
|
296
|
+
case EASErrorCode.SCHEMA_NOT_FOUND:
|
|
297
|
+
console.log("Schema not found");
|
|
298
|
+
break;
|
|
299
|
+
// ... other error codes
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
168
304
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
305
|
+
### Available Error Codes
|
|
306
|
+
|
|
307
|
+
- `INVALID_SCHEMA` - Schema validation failed
|
|
308
|
+
- `SCHEMA_NOT_FOUND` - Schema not found
|
|
309
|
+
- `ATTESTATION_NOT_FOUND` - Attestation not found
|
|
310
|
+
- `UNAUTHORIZED` - Unauthorized access
|
|
311
|
+
- `TRANSACTION_FAILED` - Transaction execution failed
|
|
312
|
+
- `INVALID_SIGNATURE` - Invalid signature
|
|
313
|
+
- `EXPIRED_ATTESTATION` - Attestation has expired
|
|
314
|
+
- `NON_REVOCABLE` - Attestation cannot be revoked
|
|
315
|
+
- `ALREADY_REVOKED` - Attestation already revoked
|
|
316
|
+
- `PORTAL_ERROR` - Portal-specific error
|
|
180
317
|
|
|
181
318
|
## Contributing
|
|
182
319
|
|