@settlemint/sdk-eas 2.2.2-pr4ad9f335 → 2.2.2-pr5e99366e
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 +366 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,12 +27,378 @@
|
|
|
27
27
|
## Table of Contents
|
|
28
28
|
|
|
29
29
|
- [About](#about)
|
|
30
|
+
- [API Reference](#api-reference)
|
|
31
|
+
- [Functions](#functions)
|
|
32
|
+
- [buildSchemaString()](#buildschemastring)
|
|
33
|
+
- [registerSchema()](#registerschema)
|
|
34
|
+
- [validateEthereumAddress()](#validateethereumaddress)
|
|
35
|
+
- [validateFieldName()](#validatefieldname)
|
|
36
|
+
- [validateFieldType()](#validatefieldtype)
|
|
37
|
+
- [validateSchemaFields()](#validateschemafields)
|
|
38
|
+
- [Interfaces](#interfaces)
|
|
39
|
+
- [RegisterSchemaOptions](#registerschemaoptions)
|
|
40
|
+
- [SchemaField](#schemafield)
|
|
41
|
+
- [Type Aliases](#type-aliases)
|
|
42
|
+
- [EASFieldType](#easfieldtype)
|
|
43
|
+
- [Variables](#variables)
|
|
44
|
+
- [EAS\_FIELD\_TYPES](#eas_field_types)
|
|
30
45
|
- [Contributing](#contributing)
|
|
31
46
|
- [License](#license)
|
|
32
47
|
|
|
33
48
|
## About
|
|
34
49
|
|
|
35
50
|
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.
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
### Functions
|
|
55
|
+
|
|
56
|
+
#### buildSchemaString()
|
|
57
|
+
|
|
58
|
+
> **buildSchemaString**(`fields`): `string`
|
|
59
|
+
|
|
60
|
+
Defined in: [schema.ts:166](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L166)
|
|
61
|
+
|
|
62
|
+
Builds an EAS schema string from an array of fields.
|
|
63
|
+
|
|
64
|
+
##### Parameters
|
|
65
|
+
|
|
66
|
+
| Parameter | Type | Description |
|
|
67
|
+
| ------ | ------ | ------ |
|
|
68
|
+
| `fields` | [`SchemaField`](#schemafield)[] | The fields to include in the schema |
|
|
69
|
+
|
|
70
|
+
##### Returns
|
|
71
|
+
|
|
72
|
+
`string`
|
|
73
|
+
|
|
74
|
+
The EAS-compatible schema string
|
|
75
|
+
|
|
76
|
+
##### Throws
|
|
77
|
+
|
|
78
|
+
Error if any field is invalid
|
|
79
|
+
|
|
80
|
+
##### Example
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { buildSchemaString, SchemaField } from '@settlemint/sdk-eas';
|
|
84
|
+
|
|
85
|
+
const fields: SchemaField[] = [
|
|
86
|
+
{ name: "userAddress", type: "address" },
|
|
87
|
+
{ name: "age", type: "uint8" },
|
|
88
|
+
{ name: "isActive", type: "bool" }
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const schemaString = buildSchemaString(fields);
|
|
92
|
+
// Result: "address userAddress, uint8 age, bool isActive"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
#### registerSchema()
|
|
98
|
+
|
|
99
|
+
> **registerSchema**(`options`): `Promise`\<`string`\>
|
|
100
|
+
|
|
101
|
+
Defined in: [schema.ts:246](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L246)
|
|
102
|
+
|
|
103
|
+
Registers a new schema with EAS.
|
|
104
|
+
|
|
105
|
+
##### Parameters
|
|
106
|
+
|
|
107
|
+
| Parameter | Type | Description |
|
|
108
|
+
| ------ | ------ | ------ |
|
|
109
|
+
| `options` | [`RegisterSchemaOptions`](#registerschemaoptions) | The schema registration options |
|
|
110
|
+
|
|
111
|
+
##### Returns
|
|
112
|
+
|
|
113
|
+
`Promise`\<`string`\>
|
|
114
|
+
|
|
115
|
+
A promise that resolves to the schema UID
|
|
116
|
+
|
|
117
|
+
##### Throws
|
|
118
|
+
|
|
119
|
+
Error if the schema registration fails
|
|
120
|
+
|
|
121
|
+
##### Example
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { registerSchema, SchemaField } from '@settlemint/sdk-eas';
|
|
125
|
+
|
|
126
|
+
const fields: SchemaField[] = [
|
|
127
|
+
{ name: "userAddress", type: "address" },
|
|
128
|
+
{ name: "age", type: "uint8" }
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
const schemaUID = await registerSchema({
|
|
132
|
+
fields,
|
|
133
|
+
resolverAddress: "0x1234567890123456789012345678901234567890",
|
|
134
|
+
revocable: true
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
console.log(`Schema registered with UID: ${schemaUID}`);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
***
|
|
141
|
+
|
|
142
|
+
#### validateEthereumAddress()
|
|
143
|
+
|
|
144
|
+
> **validateEthereumAddress**(`address`): `void`
|
|
145
|
+
|
|
146
|
+
Defined in: [schema.ts:214](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L214)
|
|
147
|
+
|
|
148
|
+
Validates an Ethereum address.
|
|
149
|
+
|
|
150
|
+
##### Parameters
|
|
151
|
+
|
|
152
|
+
| Parameter | Type | Description |
|
|
153
|
+
| ------ | ------ | ------ |
|
|
154
|
+
| `address` | `string` | The address to validate |
|
|
155
|
+
|
|
156
|
+
##### Returns
|
|
157
|
+
|
|
158
|
+
`void`
|
|
159
|
+
|
|
160
|
+
##### Throws
|
|
161
|
+
|
|
162
|
+
Error if the address is invalid
|
|
163
|
+
|
|
164
|
+
##### Example
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { validateEthereumAddress } from '@settlemint/sdk-eas';
|
|
168
|
+
|
|
169
|
+
// Valid address
|
|
170
|
+
validateEthereumAddress("0x1234567890123456789012345678901234567890"); // OK
|
|
171
|
+
|
|
172
|
+
// Invalid addresses
|
|
173
|
+
validateEthereumAddress("0x123"); // Throws: "Invalid Ethereum address format"
|
|
174
|
+
validateEthereumAddress(""); // Throws: "Resolver address cannot be empty"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
***
|
|
178
|
+
|
|
179
|
+
#### validateFieldName()
|
|
180
|
+
|
|
181
|
+
> **validateFieldName**(`name`): `void`
|
|
182
|
+
|
|
183
|
+
Defined in: [schema.ts:71](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L71)
|
|
184
|
+
|
|
185
|
+
Validates a schema field name.
|
|
186
|
+
|
|
187
|
+
##### Parameters
|
|
188
|
+
|
|
189
|
+
| Parameter | Type | Description |
|
|
190
|
+
| ------ | ------ | ------ |
|
|
191
|
+
| `name` | `string` | The field name to validate |
|
|
192
|
+
|
|
193
|
+
##### Returns
|
|
194
|
+
|
|
195
|
+
`void`
|
|
196
|
+
|
|
197
|
+
##### Throws
|
|
198
|
+
|
|
199
|
+
Error if the name is invalid
|
|
200
|
+
|
|
201
|
+
##### Example
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import { validateFieldName } from '@settlemint/sdk-eas';
|
|
205
|
+
|
|
206
|
+
// Valid names
|
|
207
|
+
validateFieldName("userAddress"); // OK
|
|
208
|
+
validateFieldName("user_address"); // OK
|
|
209
|
+
|
|
210
|
+
// Invalid names
|
|
211
|
+
validateFieldName("user address"); // Throws: "Field name cannot contain spaces"
|
|
212
|
+
validateFieldName("123user"); // Throws: "Field name must start with a letter or underscore"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
***
|
|
216
|
+
|
|
217
|
+
#### validateFieldType()
|
|
218
|
+
|
|
219
|
+
> **validateFieldType**(`type`): asserts type is "string" \| "address" \| "bool" \| "bytes" \| "bytes32" \| "uint256" \| "int256" \| "uint8" \| "int8"
|
|
220
|
+
|
|
221
|
+
Defined in: [schema.ts:101](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L101)
|
|
222
|
+
|
|
223
|
+
Validates a schema field type.
|
|
224
|
+
|
|
225
|
+
##### Parameters
|
|
226
|
+
|
|
227
|
+
| Parameter | Type | Description |
|
|
228
|
+
| ------ | ------ | ------ |
|
|
229
|
+
| `type` | `string` | The field type to validate |
|
|
230
|
+
|
|
231
|
+
##### Returns
|
|
232
|
+
|
|
233
|
+
asserts type is "string" \| "address" \| "bool" \| "bytes" \| "bytes32" \| "uint256" \| "int256" \| "uint8" \| "int8"
|
|
234
|
+
|
|
235
|
+
##### Throws
|
|
236
|
+
|
|
237
|
+
Error if the type is invalid
|
|
238
|
+
|
|
239
|
+
##### Example
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import { validateFieldType } from '@settlemint/sdk-eas';
|
|
243
|
+
|
|
244
|
+
// Valid types
|
|
245
|
+
validateFieldType("string"); // OK
|
|
246
|
+
validateFieldType("address"); // OK
|
|
247
|
+
|
|
248
|
+
// Invalid types
|
|
249
|
+
validateFieldType("invalidType"); // Throws: "Invalid field type: invalidType"
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
***
|
|
253
|
+
|
|
254
|
+
#### validateSchemaFields()
|
|
255
|
+
|
|
256
|
+
> **validateSchemaFields**(`fields`): `void`
|
|
257
|
+
|
|
258
|
+
Defined in: [schema.ts:130](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L130)
|
|
259
|
+
|
|
260
|
+
Validates an array of schema fields.
|
|
261
|
+
|
|
262
|
+
##### Parameters
|
|
263
|
+
|
|
264
|
+
| Parameter | Type | Description |
|
|
265
|
+
| ------ | ------ | ------ |
|
|
266
|
+
| `fields` | [`SchemaField`](#schemafield)[] | The fields to validate |
|
|
267
|
+
|
|
268
|
+
##### Returns
|
|
269
|
+
|
|
270
|
+
`void`
|
|
271
|
+
|
|
272
|
+
##### Throws
|
|
273
|
+
|
|
274
|
+
Error if any field is invalid
|
|
275
|
+
|
|
276
|
+
##### Example
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import { validateSchemaFields, SchemaField } from '@settlemint/sdk-eas';
|
|
280
|
+
|
|
281
|
+
const fields: SchemaField[] = [
|
|
282
|
+
{ name: "userAddress", type: "address" },
|
|
283
|
+
{ name: "age", type: "uint8" }
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
validateSchemaFields(fields); // OK
|
|
287
|
+
|
|
288
|
+
// Invalid fields
|
|
289
|
+
validateSchemaFields([]); // Throws: "Schema must have at least one field"
|
|
290
|
+
validateSchemaFields([
|
|
291
|
+
{ name: "userAddress", type: "address" },
|
|
292
|
+
{ name: "userAddress", type: "uint8" }
|
|
293
|
+
]); // Throws: "Duplicate field name: userAddress"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Interfaces
|
|
297
|
+
|
|
298
|
+
#### RegisterSchemaOptions
|
|
299
|
+
|
|
300
|
+
Defined in: [schema.ts:187](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L187)
|
|
301
|
+
|
|
302
|
+
Options for registering a schema.
|
|
303
|
+
|
|
304
|
+
##### Example
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
import { RegisterSchemaOptions, SchemaField } from '@settlemint/sdk-eas';
|
|
308
|
+
|
|
309
|
+
const options: RegisterSchemaOptions = {
|
|
310
|
+
fields: [
|
|
311
|
+
{ name: "userAddress", type: "address" },
|
|
312
|
+
{ name: "age", type: "uint8" }
|
|
313
|
+
],
|
|
314
|
+
resolverAddress: "0x1234567890123456789012345678901234567890",
|
|
315
|
+
revocable: true
|
|
316
|
+
};
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
##### Properties
|
|
320
|
+
|
|
321
|
+
| Property | Type | Description | Defined in |
|
|
322
|
+
| ------ | ------ | ------ | ------ |
|
|
323
|
+
| <a id="fields"></a> `fields` | [`SchemaField`](#schemafield)[] | The fields that make up the schema | [schema.ts:189](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L189) |
|
|
324
|
+
| <a id="resolveraddress"></a> `resolverAddress` | `string` | The Ethereum address of the resolver | [schema.ts:191](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L191) |
|
|
325
|
+
| <a id="revocable"></a> `revocable` | `boolean` | Whether attestations using this schema can be revoked | [schema.ts:193](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L193) |
|
|
326
|
+
|
|
327
|
+
***
|
|
328
|
+
|
|
329
|
+
#### SchemaField
|
|
330
|
+
|
|
331
|
+
Defined in: [schema.ts:45](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L45)
|
|
332
|
+
|
|
333
|
+
Interface for defining a schema field.
|
|
334
|
+
|
|
335
|
+
##### Example
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
import { SchemaField } from '@settlemint/sdk-eas';
|
|
339
|
+
|
|
340
|
+
const field: SchemaField = {
|
|
341
|
+
name: "userAddress",
|
|
342
|
+
type: "address",
|
|
343
|
+
description: "The Ethereum address of the user"
|
|
344
|
+
};
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
##### Properties
|
|
348
|
+
|
|
349
|
+
| Property | Type | Description | Defined in |
|
|
350
|
+
| ------ | ------ | ------ | ------ |
|
|
351
|
+
| <a id="description"></a> `description?` | `string` | Optional description of the field | [schema.ts:51](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L51) |
|
|
352
|
+
| <a id="name"></a> `name` | `string` | The name of the field | [schema.ts:47](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L47) |
|
|
353
|
+
| <a id="type"></a> `type` | `"string"` \| `"address"` \| `"bool"` \| `"bytes"` \| `"bytes32"` \| `"uint256"` \| `"int256"` \| `"uint8"` \| `"int8"` | The type of the field | [schema.ts:49](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L49) |
|
|
354
|
+
|
|
355
|
+
### Type Aliases
|
|
356
|
+
|
|
357
|
+
#### EASFieldType
|
|
358
|
+
|
|
359
|
+
> **EASFieldType** = keyof *typeof* [`EAS_FIELD_TYPES`](#eas_field_types)
|
|
360
|
+
|
|
361
|
+
Defined in: [schema.ts:30](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L30)
|
|
362
|
+
|
|
363
|
+
Type representing all valid EAS field types.
|
|
364
|
+
|
|
365
|
+
### Variables
|
|
366
|
+
|
|
367
|
+
#### EAS\_FIELD\_TYPES
|
|
368
|
+
|
|
369
|
+
> `const` **EAS\_FIELD\_TYPES**: `object`
|
|
370
|
+
|
|
371
|
+
Defined in: [schema.ts:15](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L15)
|
|
372
|
+
|
|
373
|
+
Supported EAS schema field types.
|
|
374
|
+
Maps user-friendly type names to EAS-compatible type strings.
|
|
375
|
+
|
|
376
|
+
##### Type declaration
|
|
377
|
+
|
|
378
|
+
| Name | Type | Default value | Defined in |
|
|
379
|
+
| ------ | ------ | ------ | ------ |
|
|
380
|
+
| <a id="address"></a> `address` | `"address"` | `"address"` | [schema.ts:17](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L17) |
|
|
381
|
+
| <a id="bool"></a> `bool` | `"bool"` | `"bool"` | [schema.ts:18](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L18) |
|
|
382
|
+
| <a id="bytes"></a> `bytes` | `"bytes"` | `"bytes"` | [schema.ts:19](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L19) |
|
|
383
|
+
| <a id="bytes32"></a> `bytes32` | `"bytes32"` | `"bytes32"` | [schema.ts:20](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L20) |
|
|
384
|
+
| <a id="int256"></a> `int256` | `"int256"` | `"int256"` | [schema.ts:22](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L22) |
|
|
385
|
+
| <a id="int8"></a> `int8` | `"int8"` | `"int8"` | [schema.ts:24](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L24) |
|
|
386
|
+
| <a id="string"></a> `string` | `"string"` | `"string"` | [schema.ts:16](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L16) |
|
|
387
|
+
| <a id="uint256"></a> `uint256` | `"uint256"` | `"uint256"` | [schema.ts:21](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L21) |
|
|
388
|
+
| <a id="uint8"></a> `uint8` | `"uint8"` | `"uint8"` | [schema.ts:23](https://github.com/settlemint/sdk/blob/v2.2.2/sdk/eas/src/schema.ts#L23) |
|
|
389
|
+
|
|
390
|
+
##### Example
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
import { EAS_FIELD_TYPES } from '@settlemint/sdk-eas';
|
|
394
|
+
|
|
395
|
+
// Use in type definitions
|
|
396
|
+
type MyFieldType = keyof typeof EAS_FIELD_TYPES;
|
|
397
|
+
|
|
398
|
+
// Check if a type is supported
|
|
399
|
+
const isValidType = "string" in EAS_FIELD_TYPES;
|
|
400
|
+
```
|
|
401
|
+
|
|
36
402
|
## Contributing
|
|
37
403
|
|
|
38
404
|
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.
|
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-pr5e99366e",
|
|
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-pr5e99366e",
|
|
55
55
|
"viem": "^2.7.9"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {},
|