@settlemint/sdk-eas 2.3.13 → 2.3.14-main79ecef1f

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.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import "node:module";
2
- import { SchemaRegistry } from "@ethereum-attestation-service/eas-sdk";
3
- import { AccessTokenSchema, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
4
- import { getPublicClient, getWalletClient } from "@settlemint/sdk-viem";
5
- import { isAddress } from "viem";
6
- import { JsonRpcProvider, Wallet } from "ethers";
2
+ import { createPortalClient, waitForTransactionReceipt } from "@settlemint/sdk-portal";
3
+ import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
4
+ import { ApplicationAccessTokenSchema, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
5
+ import { isAddress, zeroAddress } from "viem";
7
6
 
8
7
  //#region rolldown:runtime
9
8
  var __defProp = Object.defineProperty;
@@ -14,6 +13,79 @@ var __export = (target, all) => {
14
13
  });
15
14
  };
16
15
 
16
+ //#endregion
17
+ //#region src/portal/operations.ts
18
+ const GraphQLOperations = { mutations: {
19
+ deploySchemaRegistry: (graphql) => graphql(`
20
+ mutation DeployContractEASSchemaRegistry(
21
+ $from: String!
22
+ $constructorArguments: DeployContractEASSchemaRegistryInput!
23
+ $gasLimit: String!
24
+ ) {
25
+ DeployContractEASSchemaRegistry(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {
26
+ transactionHash
27
+ }
28
+ }`),
29
+ deployEAS: (graphql) => graphql(`
30
+ mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {
31
+ DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {
32
+ transactionHash
33
+ }
34
+ }`),
35
+ registerSchema: (graphql) => graphql(`
36
+ mutation EASSchemaRegistryRegister(
37
+ $address: String!
38
+ $from: String!
39
+ $input: EASSchemaRegistryRegisterInput!
40
+ $gasLimit: String!
41
+ ) {
42
+ EASSchemaRegistryRegister(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
43
+ transactionHash
44
+ }
45
+ }`),
46
+ attest: (graphql) => graphql(`
47
+ mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {
48
+ EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
49
+ transactionHash
50
+ }
51
+ }`),
52
+ multiAttest: (graphql) => graphql(`
53
+ mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {
54
+ EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
55
+ transactionHash
56
+ }
57
+ }`),
58
+ revoke: (graphql) => graphql(`
59
+ mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {
60
+ EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
61
+ transactionHash
62
+ }
63
+ }`)
64
+ } };
65
+
66
+ //#endregion
67
+ //#region src/schema.ts
68
+ /**
69
+ * Common address constants
70
+ */
71
+ const ZERO_ADDRESS = zeroAddress;
72
+ const ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
73
+ /**
74
+ * Supported field types for EAS schema fields.
75
+ * Maps to the Solidity types that can be used in EAS schemas.
76
+ */
77
+ const EAS_FIELD_TYPES = {
78
+ string: "string",
79
+ address: "address",
80
+ bool: "bool",
81
+ bytes: "bytes",
82
+ bytes32: "bytes32",
83
+ uint256: "uint256",
84
+ int256: "int256",
85
+ uint8: "uint8",
86
+ int8: "int8"
87
+ };
88
+
17
89
  //#endregion
18
90
  //#region ../../node_modules/zod/dist/esm/v4/core/core.js
19
91
  function $constructor(name, initializer$2, params) {
@@ -10779,194 +10851,523 @@ var classic_default = external_exports;
10779
10851
  var v4_default = classic_default;
10780
10852
 
10781
10853
  //#endregion
10782
- //#region src/client-options.schema.ts
10854
+ //#region src/utils/validation.ts
10855
+ const ethAddressSchema = custom((val) => typeof val === "string" && isAddress(val), "Invalid Ethereum address");
10783
10856
  /**
10784
- * Schema for validating EAS client configuration options.
10785
- * Extends the base Viem client options with EAS-specific requirements.
10857
+ * Zod schema for EASClientOptions.
10786
10858
  */
10787
- const ClientOptionsSchema = object({
10788
- schemaRegistryAddress: string$1().refine(isAddress, "Invalid Ethereum address format"),
10789
- attestationAddress: string$1().refine(isAddress, "Invalid Ethereum address format"),
10790
- accessToken: AccessTokenSchema,
10791
- chainId: string$1().min(1),
10792
- chainName: string$1().min(1),
10793
- rpcUrl: UrlSchema
10859
+ const EASClientOptionsSchema = object({
10860
+ instance: UrlSchema,
10861
+ accessToken: ApplicationAccessTokenSchema.optional(),
10862
+ easContractAddress: ethAddressSchema.optional(),
10863
+ schemaRegistryContractAddress: ethAddressSchema.optional(),
10864
+ debug: boolean$1().optional()
10794
10865
  });
10795
10866
 
10796
10867
  //#endregion
10797
- //#region src/ethers-adapter.ts
10868
+ //#region src/eas.ts
10869
+ const LOGGER = createLogger();
10870
+ const DEFAULT_GAS_LIMIT = "0x3d0900";
10798
10871
  /**
10799
- * Converts a viem PublicClient to an ethers JsonRpcProvider
10872
+ * Main EAS client class for interacting with Ethereum Attestation Service via Portal
10873
+ *
10874
+ * @example
10875
+ * ```typescript
10876
+ * import { createEASClient } from "@settlemint/sdk-eas";
10877
+ *
10878
+ * const easClient = createEASClient({
10879
+ * instance: "https://your-portal-instance.settlemint.com",
10880
+ * accessToken: "your-access-token"
10881
+ * });
10882
+ *
10883
+ * // Deploy EAS contracts
10884
+ * const deployment = await easClient.deploy("0x1234...deployer-address");
10885
+ * console.log("EAS deployed at:", deployment.easAddress);
10886
+ * ```
10800
10887
  */
10801
- function publicClientToProvider(client) {
10802
- const { chain, transport } = client;
10803
- if (!chain) throw new Error("Chain is required");
10804
- const network = {
10805
- chainId: chain.id,
10806
- name: chain.name,
10807
- ensAddress: chain.contracts?.ensRegistry?.address
10808
- };
10809
- if (transport.type === "fallback") {
10810
- const providers = transport.transports.map(({ value }) => {
10811
- if (!value?.url) return null;
10812
- try {
10813
- return new JsonRpcProvider(value.url, network);
10814
- } catch {
10815
- return null;
10888
+ var EASClient = class {
10889
+ options;
10890
+ portalClient;
10891
+ portalGraphql;
10892
+ deployedAddresses;
10893
+ /**
10894
+ * Create a new EAS client instance
10895
+ *
10896
+ * @param options - Configuration options for the EAS client
10897
+ */
10898
+ constructor(options) {
10899
+ this.options = validate(EASClientOptionsSchema, options);
10900
+ const { client: portalClient, graphql: portalGraphql } = createPortalClient({
10901
+ instance: this.options.instance,
10902
+ accessToken: this.options.accessToken
10903
+ }, { fetch: requestLogger(LOGGER, "portal", fetch) });
10904
+ this.portalClient = portalClient;
10905
+ this.portalGraphql = portalGraphql;
10906
+ }
10907
+ /**
10908
+ * Deploy EAS contracts via Portal
10909
+ *
10910
+ * @param deployerAddress - The address that will deploy the contracts
10911
+ * @param forwarderAddress - Optional trusted forwarder address (defaults to zero address)
10912
+ * @param gasLimit - Optional gas limit for deployment transactions (defaults to "0x7a1200")
10913
+ * @returns Promise resolving to deployment result with contract addresses and transaction hashes
10914
+ *
10915
+ * @example
10916
+ * ```typescript
10917
+ * import { createEASClient } from "@settlemint/sdk-eas";
10918
+ *
10919
+ * const easClient = createEASClient({
10920
+ * instance: "https://your-portal-instance.settlemint.com",
10921
+ * accessToken: "your-access-token"
10922
+ * });
10923
+ *
10924
+ * const deployment = await easClient.deploy(
10925
+ * "0x1234567890123456789012345678901234567890", // deployer address
10926
+ * "0x0000000000000000000000000000000000000000", // forwarder (optional)
10927
+ * "0x7a1200" // gas limit (optional)
10928
+ * );
10929
+ *
10930
+ * console.log("Schema Registry:", deployment.schemaRegistryAddress);
10931
+ * console.log("EAS Contract:", deployment.easAddress);
10932
+ * ```
10933
+ */
10934
+ async deploy(deployerAddress, forwarderAddress, gasLimit) {
10935
+ const defaultForwarder = forwarderAddress || ZERO_ADDRESS;
10936
+ const defaultGasLimit = gasLimit || "0x7a1200";
10937
+ try {
10938
+ const schemaRegistryResponse = await this.portalClient.request(GraphQLOperations.mutations.deploySchemaRegistry(this.portalGraphql), {
10939
+ from: deployerAddress,
10940
+ constructorArguments: { forwarder: defaultForwarder },
10941
+ gasLimit: defaultGasLimit
10942
+ });
10943
+ if (!schemaRegistryResponse.DeployContractEASSchemaRegistry?.transactionHash) {
10944
+ throw new Error("Schema Registry deployment failed - no transaction hash returned");
10945
+ }
10946
+ const schemaRegistryTxHash = schemaRegistryResponse.DeployContractEASSchemaRegistry.transactionHash;
10947
+ const schemaRegistryTransaction = await waitForTransactionReceipt(schemaRegistryTxHash, {
10948
+ portalGraphqlEndpoint: this.options.instance,
10949
+ accessToken: this.options.accessToken,
10950
+ timeout: 6e4
10951
+ });
10952
+ if (!schemaRegistryTransaction?.receipt?.contractAddress) {
10953
+ throw new Error("Schema Registry deployment failed - could not get contract address from transaction receipt.");
10954
+ }
10955
+ const schemaRegistryAddress = schemaRegistryTransaction.receipt.contractAddress;
10956
+ const easResponse = await this.portalClient.request(GraphQLOperations.mutations.deployEAS(this.portalGraphql), {
10957
+ from: deployerAddress,
10958
+ constructorArguments: {
10959
+ registry: schemaRegistryAddress,
10960
+ forwarder: defaultForwarder
10961
+ },
10962
+ gasLimit: defaultGasLimit
10963
+ });
10964
+ if (!easResponse.DeployContractEAS?.transactionHash) {
10965
+ throw new Error("EAS deployment failed - no transaction hash returned");
10966
+ }
10967
+ const easTxHash = easResponse.DeployContractEAS.transactionHash;
10968
+ const easTransaction = await waitForTransactionReceipt(easTxHash, {
10969
+ portalGraphqlEndpoint: this.options.instance,
10970
+ accessToken: this.options.accessToken,
10971
+ timeout: 6e4
10972
+ });
10973
+ if (!easTransaction?.receipt?.contractAddress) {
10974
+ throw new Error("EAS deployment failed - could not get contract address from transaction receipt.");
10975
+ }
10976
+ const easAddress = easTransaction.receipt.contractAddress;
10977
+ this.deployedAddresses = {
10978
+ easAddress,
10979
+ schemaRegistryAddress,
10980
+ easTransactionHash: easTxHash,
10981
+ schemaRegistryTransactionHash: schemaRegistryTxHash
10982
+ };
10983
+ return this.deployedAddresses;
10984
+ } catch (err) {
10985
+ const error$37 = err;
10986
+ throw new Error(`Failed to deploy EAS contracts: ${error$37.message}`);
10987
+ }
10988
+ }
10989
+ /**
10990
+ * Register a new schema in the EAS Schema Registry
10991
+ *
10992
+ * @param request - Schema registration request containing schema definition
10993
+ * @param fromAddress - Address that will register the schema
10994
+ * @param gasLimit - Optional gas limit for the transaction (defaults to "0x3d0900")
10995
+ * @returns Promise resolving to transaction result
10996
+ *
10997
+ * @example
10998
+ * ```typescript
10999
+ * import { createEASClient } from "@settlemint/sdk-eas";
11000
+ *
11001
+ * const easClient = createEASClient({
11002
+ * instance: "https://your-portal-instance.settlemint.com",
11003
+ * accessToken: "your-access-token"
11004
+ * });
11005
+ *
11006
+ * const schemaResult = await easClient.registerSchema(
11007
+ * {
11008
+ * schema: "uint256 eventId, uint8 voteIndex",
11009
+ * resolver: "0x0000000000000000000000000000000000000000",
11010
+ * revocable: true
11011
+ * },
11012
+ * "0x1234567890123456789012345678901234567890" // from address
11013
+ * );
11014
+ *
11015
+ * console.log("Schema registered:", schemaResult.hash);
11016
+ * ```
11017
+ */
11018
+ async registerSchema(request, fromAddress, gasLimit) {
11019
+ const schemaRegistryAddress = this.getSchemaRegistryAddress();
11020
+ let schemaString = request.schema;
11021
+ if (request.fields && !schemaString) {
11022
+ schemaString = this.buildSchemaString(request.fields);
11023
+ }
11024
+ if (!schemaString) {
11025
+ throw new Error("Schema string is required. Provide either 'schema' or 'fields'.");
11026
+ }
11027
+ try {
11028
+ const response = await this.portalClient.request(GraphQLOperations.mutations.registerSchema(this.portalGraphql), {
11029
+ address: schemaRegistryAddress,
11030
+ from: fromAddress,
11031
+ input: {
11032
+ schema: schemaString,
11033
+ resolver: request.resolver,
11034
+ revocable: request.revocable
11035
+ },
11036
+ gasLimit: gasLimit || DEFAULT_GAS_LIMIT
11037
+ });
11038
+ const transactionHash = response.EASSchemaRegistryRegister?.transactionHash;
11039
+ if (!transactionHash) {
11040
+ throw new Error("No transaction hash returned from Portal");
10816
11041
  }
10817
- }).filter((provider) => provider != null);
10818
- if (providers.length === 0) throw new Error("No valid RPC URLs found");
10819
- return providers[0];
11042
+ return {
11043
+ hash: transactionHash,
11044
+ success: true
11045
+ };
11046
+ } catch (err) {
11047
+ const error$37 = err;
11048
+ throw new Error(`Failed to register schema: ${error$37.message}`);
11049
+ }
10820
11050
  }
10821
- return new JsonRpcProvider(transport.url, network);
10822
- }
10823
- /**
10824
- * Converts a viem WalletClient to an ethers Wallet
10825
- */
10826
- function walletClientToSigner(client) {
10827
- const { account, chain, transport } = client;
10828
- if (!chain) throw new Error("Chain is required");
10829
- if (!account) throw new Error("Account is required");
10830
- const network = {
10831
- chainId: chain.id,
10832
- name: chain.name,
10833
- ensAddress: chain.contracts?.ensRegistry?.address
10834
- };
10835
- const provider = new JsonRpcProvider(transport.url, network);
10836
- const privateKey = account.privateKey;
10837
- if (!privateKey || typeof privateKey !== "string") {
10838
- throw new Error("Private key is required and must be a string");
10839
- }
10840
- return new Wallet(privateKey, provider);
10841
- }
10842
-
10843
- //#endregion
10844
- //#region src/types.ts
10845
- /**
10846
- * Supported field types for EAS schema fields.
10847
- * Maps to the Solidity types that can be used in EAS schemas.
10848
- */
10849
- const EAS_FIELD_TYPES = {
10850
- string: "string",
10851
- address: "address",
10852
- bool: "bool",
10853
- bytes: "bytes",
10854
- bytes32: "bytes32",
10855
- uint256: "uint256",
10856
- int256: "int256",
10857
- uint8: "uint8",
10858
- int8: "int8"
10859
- };
10860
-
10861
- //#endregion
10862
- //#region src/validation.ts
10863
- function validateFieldName(name) {
10864
- if (!name) {
10865
- throw new Error("Field name cannot be empty");
11051
+ /**
11052
+ * Create an attestation
11053
+ *
11054
+ * @param request - Attestation request containing schema and data
11055
+ * @param fromAddress - Address that will create the attestation
11056
+ * @param gasLimit - Optional gas limit for the transaction (defaults to "0x3d0900")
11057
+ * @returns Promise resolving to transaction result
11058
+ *
11059
+ * @example
11060
+ * ```typescript
11061
+ * import { createEASClient } from "@settlemint/sdk-eas";
11062
+ *
11063
+ * const easClient = createEASClient({
11064
+ * instance: "https://your-portal-instance.settlemint.com",
11065
+ * accessToken: "your-access-token"
11066
+ * });
11067
+ *
11068
+ * const attestationResult = await easClient.attest(
11069
+ * {
11070
+ * schema: "0x1234567890123456789012345678901234567890123456789012345678901234",
11071
+ * data: {
11072
+ * recipient: "0x1234567890123456789012345678901234567890",
11073
+ * expirationTime: BigInt(0), // No expiration
11074
+ * revocable: true,
11075
+ * refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
11076
+ * data: "0x1234", // ABI-encoded data
11077
+ * value: BigInt(0)
11078
+ * }
11079
+ * },
11080
+ * "0x1234567890123456789012345678901234567890" // from address
11081
+ * );
11082
+ *
11083
+ * console.log("Attestation created:", attestationResult.hash);
11084
+ * ```
11085
+ */
11086
+ async attest(request, fromAddress, gasLimit) {
11087
+ const easAddress = this.getEASAddress();
11088
+ try {
11089
+ const response = await this.portalClient.request(GraphQLOperations.mutations.attest(this.portalGraphql), {
11090
+ address: easAddress,
11091
+ from: fromAddress,
11092
+ input: { request: {
11093
+ schema: request.schema,
11094
+ data: {
11095
+ recipient: request.data.recipient,
11096
+ expirationTime: request.data.expirationTime.toString(),
11097
+ revocable: request.data.revocable,
11098
+ refUID: request.data.refUID,
11099
+ data: request.data.data,
11100
+ value: request.data.value?.toString() || "0"
11101
+ }
11102
+ } },
11103
+ gasLimit: gasLimit || DEFAULT_GAS_LIMIT
11104
+ });
11105
+ const transactionHash = response.EASAttest?.transactionHash;
11106
+ if (!transactionHash) {
11107
+ throw new Error("No transaction hash returned from Portal");
11108
+ }
11109
+ return {
11110
+ hash: transactionHash,
11111
+ success: true
11112
+ };
11113
+ } catch (err) {
11114
+ const error$37 = err;
11115
+ throw new Error(`Failed to create attestation: ${error$37.message}`);
11116
+ }
10866
11117
  }
10867
- if (name.includes(" ")) {
10868
- throw new Error("Field name cannot contain spaces");
11118
+ /**
11119
+ * Create multiple attestations in a single transaction
11120
+ *
11121
+ * @param requests - Array of attestation requests
11122
+ * @param fromAddress - Address that will create the attestations
11123
+ * @param gasLimit - Optional gas limit for the transaction (defaults to "0x3d0900")
11124
+ * @returns Promise resolving to transaction result
11125
+ *
11126
+ * @example
11127
+ * ```typescript
11128
+ * import { createEASClient } from "@settlemint/sdk-eas";
11129
+ *
11130
+ * const easClient = createEASClient({
11131
+ * instance: "https://your-portal-instance.settlemint.com",
11132
+ * accessToken: "your-access-token"
11133
+ * });
11134
+ *
11135
+ * const multiAttestResult = await easClient.multiAttest(
11136
+ * [
11137
+ * {
11138
+ * schema: "0x1234567890123456789012345678901234567890123456789012345678901234",
11139
+ * data: {
11140
+ * recipient: "0x1234567890123456789012345678901234567890",
11141
+ * expirationTime: BigInt(0),
11142
+ * revocable: true,
11143
+ * refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
11144
+ * data: "0x1234",
11145
+ * value: BigInt(0)
11146
+ * }
11147
+ * },
11148
+ * {
11149
+ * schema: "0x5678901234567890123456789012345678901234567890123456789012345678",
11150
+ * data: {
11151
+ * recipient: "0x5678901234567890123456789012345678901234",
11152
+ * expirationTime: BigInt(0),
11153
+ * revocable: false,
11154
+ * refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
11155
+ * data: "0x5678",
11156
+ * value: BigInt(0)
11157
+ * }
11158
+ * }
11159
+ * ],
11160
+ * "0x1234567890123456789012345678901234567890" // from address
11161
+ * );
11162
+ *
11163
+ * console.log("Multiple attestations created:", multiAttestResult.hash);
11164
+ * ```
11165
+ */
11166
+ async multiAttest(requests, fromAddress, gasLimit) {
11167
+ if (requests.length === 0) {
11168
+ throw new Error("At least one attestation request is required");
11169
+ }
11170
+ const easAddress = this.getEASAddress();
11171
+ try {
11172
+ const response = await this.portalClient.request(GraphQLOperations.mutations.multiAttest(this.portalGraphql), {
11173
+ address: easAddress,
11174
+ from: fromAddress,
11175
+ input: { multiRequests: requests.map((req) => ({
11176
+ schema: req.schema,
11177
+ data: [{
11178
+ recipient: req.data.recipient,
11179
+ expirationTime: req.data.expirationTime.toString(),
11180
+ revocable: req.data.revocable,
11181
+ refUID: req.data.refUID,
11182
+ data: req.data.data,
11183
+ value: req.data.value?.toString() || "0"
11184
+ }]
11185
+ })) },
11186
+ gasLimit: gasLimit || DEFAULT_GAS_LIMIT
11187
+ });
11188
+ const transactionHash = response.EASMultiAttest?.transactionHash;
11189
+ if (!transactionHash) {
11190
+ throw new Error("No transaction hash returned from Portal");
11191
+ }
11192
+ return {
11193
+ hash: transactionHash,
11194
+ success: true
11195
+ };
11196
+ } catch (err) {
11197
+ const error$37 = err;
11198
+ throw new Error(`Failed to create multiple attestations: ${error$37.message}`);
11199
+ }
11200
+ }
11201
+ /**
11202
+ * Revoke an existing attestation
11203
+ *
11204
+ * @param schemaUID - UID of the schema used for the attestation
11205
+ * @param attestationUID - UID of the attestation to revoke
11206
+ * @param fromAddress - Address that will revoke the attestation
11207
+ * @param value - Optional ETH value to send with the revocation
11208
+ * @param gasLimit - Optional gas limit for the transaction (defaults to "0x3d0900")
11209
+ * @returns Promise resolving to transaction result
11210
+ *
11211
+ * @example
11212
+ * ```typescript
11213
+ * import { createEASClient } from "@settlemint/sdk-eas";
11214
+ *
11215
+ * const easClient = createEASClient({
11216
+ * instance: "https://your-portal-instance.settlemint.com",
11217
+ * accessToken: "your-access-token"
11218
+ * });
11219
+ *
11220
+ * const revokeResult = await easClient.revoke(
11221
+ * "0x1234567890123456789012345678901234567890123456789012345678901234", // schema UID
11222
+ * "0x5678901234567890123456789012345678901234567890123456789012345678", // attestation UID
11223
+ * "0x1234567890123456789012345678901234567890", // from address
11224
+ * BigInt(0) // value (optional)
11225
+ * );
11226
+ *
11227
+ * console.log("Attestation revoked:", revokeResult.hash);
11228
+ * ```
11229
+ */
11230
+ async revoke(schemaUID, attestationUID, fromAddress, value, gasLimit) {
11231
+ try {
11232
+ const response = await this.portalClient.request(GraphQLOperations.mutations.revoke(this.portalGraphql), {
11233
+ address: this.getEASAddress(),
11234
+ from: fromAddress,
11235
+ input: { request: {
11236
+ schema: schemaUID,
11237
+ data: {
11238
+ uid: attestationUID,
11239
+ value: value?.toString() || "0"
11240
+ }
11241
+ } },
11242
+ gasLimit: gasLimit || DEFAULT_GAS_LIMIT
11243
+ });
11244
+ const transactionHash = response.EASRevoke?.transactionHash;
11245
+ if (!transactionHash) {
11246
+ throw new Error("No transaction hash returned from Portal");
11247
+ }
11248
+ return {
11249
+ hash: transactionHash,
11250
+ success: true
11251
+ };
11252
+ } catch (err) {
11253
+ const error$37 = err;
11254
+ throw new Error(`Failed to revoke attestation: ${error$37.message}`);
11255
+ }
10869
11256
  }
10870
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {
10871
- throw new Error("Field name must start with a letter or underscore and contain only alphanumeric characters and underscores");
11257
+ /**
11258
+ * Get a schema by UID
11259
+ *
11260
+ * TODO: Implement using The Graph subgraph for EAS data queries
11261
+ */
11262
+ async getSchema(uid) {
11263
+ throw new Error(`Schema queries not implemented yet. Use The Graph subgraph for reading schema data. Schema UID: ${uid}`);
10872
11264
  }
10873
- }
10874
- function validateFieldType(type) {
10875
- if (!(type in EAS_FIELD_TYPES)) {
10876
- throw new Error(`Invalid field type: ${type}. Must be one of: ${Object.keys(EAS_FIELD_TYPES).join(", ")}`);
11265
+ /**
11266
+ * Get all schemas with pagination
11267
+ *
11268
+ * TODO: Implement using The Graph subgraph for EAS data queries
11269
+ */
11270
+ async getSchemas(options) {
11271
+ throw new Error("Schema listing not implemented yet. Use The Graph subgraph for reading schema data.");
10877
11272
  }
10878
- }
10879
- function validateSchemaFields(fields) {
10880
- if (!fields || fields.length === 0) {
10881
- throw new Error("Schema must have at least one field");
11273
+ /**
11274
+ * Get an attestation by UID
11275
+ *
11276
+ * TODO: Implement using The Graph subgraph for EAS data queries
11277
+ */
11278
+ async getAttestation(uid) {
11279
+ throw new Error(`Attestation queries not implemented yet. Use The Graph subgraph for reading attestation data. Attestation UID: ${uid}`);
10882
11280
  }
10883
- const seenNames = new Set();
10884
- for (const field of fields) {
10885
- validateFieldName(field.name);
10886
- validateFieldType(field.type);
10887
- if (seenNames.has(field.name)) {
10888
- throw new Error(`Duplicate field name: ${field.name}`);
11281
+ /**
11282
+ * Get attestations with pagination and filtering
11283
+ *
11284
+ * TODO: Implement using The Graph subgraph for EAS data queries
11285
+ */
11286
+ async getAttestations(options) {
11287
+ throw new Error("Attestation listing not implemented yet. Use The Graph subgraph for reading attestation data.");
11288
+ }
11289
+ /**
11290
+ * Check if an attestation is valid
11291
+ *
11292
+ * TODO: Implement using The Graph subgraph for EAS data queries
11293
+ */
11294
+ async isValidAttestation(uid) {
11295
+ return false;
11296
+ }
11297
+ /**
11298
+ * Get the current timestamp from the contract
11299
+ *
11300
+ * TODO: Fix Portal GraphQL query parameter encoding or use The Graph subgraph
11301
+ */
11302
+ async getTimestamp() {
11303
+ throw new Error("Timestamp query not implemented yet. Fix Portal query parameters or use The Graph subgraph.");
11304
+ }
11305
+ /**
11306
+ * Get client configuration
11307
+ */
11308
+ getOptions() {
11309
+ return { ...this.options };
11310
+ }
11311
+ /**
11312
+ * Get the Portal client instance for advanced operations
11313
+ */
11314
+ getPortalClient() {
11315
+ return this.portalClient;
11316
+ }
11317
+ /**
11318
+ * Get current contract addresses
11319
+ */
11320
+ getContractAddresses() {
11321
+ return {
11322
+ easAddress: this.options.easContractAddress || this.deployedAddresses?.easAddress,
11323
+ schemaRegistryAddress: this.options.schemaRegistryContractAddress || this.deployedAddresses?.schemaRegistryAddress
11324
+ };
11325
+ }
11326
+ getEASAddress() {
11327
+ if (this.options.easContractAddress) {
11328
+ return this.options.easContractAddress;
11329
+ }
11330
+ if (this.deployedAddresses?.easAddress) {
11331
+ return this.deployedAddresses.easAddress;
10889
11332
  }
10890
- seenNames.add(field.name);
11333
+ throw new Error("EAS contract address not available. Please provide it in options or deploy contracts first.");
10891
11334
  }
10892
- }
10893
- function buildSchemaString(fields) {
10894
- validateSchemaFields(fields);
10895
- return fields.map((field) => `${field.type} ${field.name}`).join(", ");
10896
- }
10897
-
10898
- //#endregion
10899
- //#region src/eas.ts
11335
+ getSchemaRegistryAddress() {
11336
+ if (this.options.schemaRegistryContractAddress) {
11337
+ return this.options.schemaRegistryContractAddress;
11338
+ }
11339
+ if (this.deployedAddresses?.schemaRegistryAddress) {
11340
+ return this.deployedAddresses.schemaRegistryAddress;
11341
+ }
11342
+ throw new Error("Schema Registry contract address not available. Please provide it in options or deploy contracts first.");
11343
+ }
11344
+ buildSchemaString(fields) {
11345
+ return fields.map((field) => `${field.type} ${field.name}`).join(", ");
11346
+ }
11347
+ };
10900
11348
  /**
10901
- * Creates an EAS client for interacting with the Ethereum Attestation Service.
11349
+ * Create an EAS client instance
10902
11350
  *
10903
- * @param options - Configuration options for the client
10904
- * @returns An object containing the EAS client instance
10905
- * @throws Will throw an error if the options fail validation
11351
+ * @param options - Configuration options for the EAS client
11352
+ * @returns EAS client instance
10906
11353
  *
10907
11354
  * @example
10908
- * ```ts
10909
- * import { createEASClient } from '@settlemint/sdk-eas';
11355
+ * ```typescript
11356
+ * import { createEASClient } from "@settlemint/sdk-eas";
10910
11357
  *
10911
- * const client = createEASClient({
10912
- * schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
10913
- * attestationAddress: "0x1234567890123456789012345678901234567890",
10914
- * accessToken: "your-access-token",
10915
- * chainId: "1",
10916
- * chainName: "Ethereum",
10917
- * rpcUrl: "http://localhost:8545"
11358
+ * const easClient = createEASClient({
11359
+ * instance: "https://your-portal-instance.settlemint.com",
11360
+ * accessToken: "your-access-token"
10918
11361
  * });
11362
+ *
11363
+ * // Use the client
11364
+ * const deployment = await easClient.deploy("0x1234...deployer-address");
10919
11365
  * ```
10920
11366
  */
10921
11367
  function createEASClient(options) {
10922
- validate(ClientOptionsSchema, options);
10923
- const publicClient = getPublicClient({
10924
- accessToken: options.accessToken,
10925
- chainId: options.chainId,
10926
- chainName: options.chainName,
10927
- rpcUrl: options.rpcUrl
10928
- });
10929
- const walletClient = getWalletClient({
10930
- accessToken: options.accessToken,
10931
- chainId: options.chainId,
10932
- chainName: options.chainName,
10933
- rpcUrl: options.rpcUrl
10934
- })();
10935
- const provider = publicClientToProvider(publicClient);
10936
- const wallet = walletClientToSigner(walletClient);
10937
- const schemaRegistry = new SchemaRegistry(options.schemaRegistryAddress);
10938
- schemaRegistry.connect(wallet);
10939
- async function registerSchema(options$1) {
10940
- validateSchemaFields(options$1.fields);
10941
- const schema = buildSchemaString(options$1.fields);
10942
- try {
10943
- await provider.getNetwork();
10944
- const tx = await schemaRegistry.register({
10945
- schema,
10946
- resolverAddress: options$1.resolverAddress,
10947
- revocable: options$1.revocable
10948
- });
10949
- await tx.wait();
10950
- return tx.toString();
10951
- } catch (error$37) {
10952
- throw new Error(`Failed to register schema: ${error$37.message}`, { cause: error$37 });
10953
- }
10954
- }
10955
- async function getSchema(uid) {
10956
- try {
10957
- await provider.getNetwork();
10958
- const schema = await schemaRegistry.getSchema({ uid });
10959
- return schema.toString();
10960
- } catch (error$37) {
10961
- throw new Error(`Failed to get schema: ${error$37.message}`);
10962
- }
10963
- }
10964
- return {
10965
- registerSchema,
10966
- getSchema
10967
- };
11368
+ return new EASClient(options);
10968
11369
  }
10969
11370
 
10970
11371
  //#endregion
10971
- export { EAS_FIELD_TYPES, createEASClient };
11372
+ export { EASClient, EASClientOptionsSchema, EAS_FIELD_TYPES, GraphQLOperations, ZERO_ADDRESS, ZERO_BYTES32, createEASClient };
10972
11373
  //# sourceMappingURL=eas.js.map