@settlemint/sdk-eas 2.3.14 → 2.4.0-main1ce5f55f

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,8 +1,8 @@
1
- import { SchemaRegistry } from "@ethereum-attestation-service/eas-sdk";
2
- import { AccessTokenSchema, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
3
- import { getPublicClient, getWalletClient } from "@settlemint/sdk-viem";
4
- import { isAddress } from "viem";
5
- import { JsonRpcProvider, Wallet } from "ethers";
1
+ /* SettleMint EAS SDK - Portal Optimized */
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";
6
6
 
7
7
  //#region rolldown:runtime
8
8
  var __defProp = Object.defineProperty;
@@ -13,6 +13,79 @@ var __export = (target, all) => {
13
13
  });
14
14
  };
15
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
+
16
89
  //#endregion
17
90
  //#region ../../node_modules/zod/dist/esm/v4/core/core.js
18
91
  function $constructor(name, initializer$2, params) {
@@ -10778,194 +10851,523 @@ var classic_default = external_exports;
10778
10851
  var v4_default = classic_default;
10779
10852
 
10780
10853
  //#endregion
10781
- //#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");
10782
10856
  /**
10783
- * Schema for validating EAS client configuration options.
10784
- * Extends the base Viem client options with EAS-specific requirements.
10857
+ * Zod schema for EASClientOptions.
10785
10858
  */
10786
- const ClientOptionsSchema = object({
10787
- schemaRegistryAddress: string$1().refine(isAddress, "Invalid Ethereum address format"),
10788
- attestationAddress: string$1().refine(isAddress, "Invalid Ethereum address format"),
10789
- accessToken: AccessTokenSchema,
10790
- chainId: string$1().min(1),
10791
- chainName: string$1().min(1),
10792
- 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()
10793
10865
  });
10794
10866
 
10795
10867
  //#endregion
10796
- //#region src/ethers-adapter.ts
10868
+ //#region src/eas.ts
10869
+ const LOGGER = createLogger();
10870
+ const DEFAULT_GAS_LIMIT = "0x3d0900";
10797
10871
  /**
10798
- * 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
+ * ```
10799
10887
  */
10800
- function publicClientToProvider(client) {
10801
- const { chain, transport } = client;
10802
- if (!chain) throw new Error("Chain is required");
10803
- const network = {
10804
- chainId: chain.id,
10805
- name: chain.name,
10806
- ensAddress: chain.contracts?.ensRegistry?.address
10807
- };
10808
- if (transport.type === "fallback") {
10809
- const providers = transport.transports.map(({ value }) => {
10810
- if (!value?.url) return null;
10811
- try {
10812
- return new JsonRpcProvider(value.url, network);
10813
- } catch {
10814
- 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");
10815
11041
  }
10816
- }).filter((provider) => provider != null);
10817
- if (providers.length === 0) throw new Error("No valid RPC URLs found");
10818
- 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
+ }
10819
11050
  }
10820
- return new JsonRpcProvider(transport.url, network);
10821
- }
10822
- /**
10823
- * Converts a viem WalletClient to an ethers Wallet
10824
- */
10825
- function walletClientToSigner(client) {
10826
- const { account, chain, transport } = client;
10827
- if (!chain) throw new Error("Chain is required");
10828
- if (!account) throw new Error("Account is required");
10829
- const network = {
10830
- chainId: chain.id,
10831
- name: chain.name,
10832
- ensAddress: chain.contracts?.ensRegistry?.address
10833
- };
10834
- const provider = new JsonRpcProvider(transport.url, network);
10835
- const privateKey = account.privateKey;
10836
- if (!privateKey || typeof privateKey !== "string") {
10837
- throw new Error("Private key is required and must be a string");
10838
- }
10839
- return new Wallet(privateKey, provider);
10840
- }
10841
-
10842
- //#endregion
10843
- //#region src/types.ts
10844
- /**
10845
- * Supported field types for EAS schema fields.
10846
- * Maps to the Solidity types that can be used in EAS schemas.
10847
- */
10848
- const EAS_FIELD_TYPES = {
10849
- string: "string",
10850
- address: "address",
10851
- bool: "bool",
10852
- bytes: "bytes",
10853
- bytes32: "bytes32",
10854
- uint256: "uint256",
10855
- int256: "int256",
10856
- uint8: "uint8",
10857
- int8: "int8"
10858
- };
10859
-
10860
- //#endregion
10861
- //#region src/validation.ts
10862
- function validateFieldName(name) {
10863
- if (!name) {
10864
- 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
+ }
10865
11117
  }
10866
- if (name.includes(" ")) {
10867
- 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
+ }
10868
11256
  }
10869
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {
10870
- 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}`);
10871
11264
  }
10872
- }
10873
- function validateFieldType(type) {
10874
- if (!(type in EAS_FIELD_TYPES)) {
10875
- 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.");
10876
11272
  }
10877
- }
10878
- function validateSchemaFields(fields) {
10879
- if (!fields || fields.length === 0) {
10880
- 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}`);
10881
11280
  }
10882
- const seenNames = new Set();
10883
- for (const field of fields) {
10884
- validateFieldName(field.name);
10885
- validateFieldType(field.type);
10886
- if (seenNames.has(field.name)) {
10887
- 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;
10888
11332
  }
10889
- seenNames.add(field.name);
11333
+ throw new Error("EAS contract address not available. Please provide it in options or deploy contracts first.");
10890
11334
  }
10891
- }
10892
- function buildSchemaString(fields) {
10893
- validateSchemaFields(fields);
10894
- return fields.map((field) => `${field.type} ${field.name}`).join(", ");
10895
- }
10896
-
10897
- //#endregion
10898
- //#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
+ };
10899
11348
  /**
10900
- * Creates an EAS client for interacting with the Ethereum Attestation Service.
11349
+ * Create an EAS client instance
10901
11350
  *
10902
- * @param options - Configuration options for the client
10903
- * @returns An object containing the EAS client instance
10904
- * @throws Will throw an error if the options fail validation
11351
+ * @param options - Configuration options for the EAS client
11352
+ * @returns EAS client instance
10905
11353
  *
10906
11354
  * @example
10907
- * ```ts
10908
- * import { createEASClient } from '@settlemint/sdk-eas';
11355
+ * ```typescript
11356
+ * import { createEASClient } from "@settlemint/sdk-eas";
10909
11357
  *
10910
- * const client = createEASClient({
10911
- * schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
10912
- * attestationAddress: "0x1234567890123456789012345678901234567890",
10913
- * accessToken: "your-access-token",
10914
- * chainId: "1",
10915
- * chainName: "Ethereum",
10916
- * rpcUrl: "http://localhost:8545"
11358
+ * const easClient = createEASClient({
11359
+ * instance: "https://your-portal-instance.settlemint.com",
11360
+ * accessToken: "your-access-token"
10917
11361
  * });
11362
+ *
11363
+ * // Use the client
11364
+ * const deployment = await easClient.deploy("0x1234...deployer-address");
10918
11365
  * ```
10919
11366
  */
10920
11367
  function createEASClient(options) {
10921
- validate(ClientOptionsSchema, options);
10922
- const publicClient = getPublicClient({
10923
- accessToken: options.accessToken,
10924
- chainId: options.chainId,
10925
- chainName: options.chainName,
10926
- rpcUrl: options.rpcUrl
10927
- });
10928
- const walletClient = getWalletClient({
10929
- accessToken: options.accessToken,
10930
- chainId: options.chainId,
10931
- chainName: options.chainName,
10932
- rpcUrl: options.rpcUrl
10933
- })();
10934
- const provider = publicClientToProvider(publicClient);
10935
- const wallet = walletClientToSigner(walletClient);
10936
- const schemaRegistry = new SchemaRegistry(options.schemaRegistryAddress);
10937
- schemaRegistry.connect(wallet);
10938
- async function registerSchema(options$1) {
10939
- validateSchemaFields(options$1.fields);
10940
- const schema = buildSchemaString(options$1.fields);
10941
- try {
10942
- await provider.getNetwork();
10943
- const tx = await schemaRegistry.register({
10944
- schema,
10945
- resolverAddress: options$1.resolverAddress,
10946
- revocable: options$1.revocable
10947
- });
10948
- await tx.wait();
10949
- return tx.toString();
10950
- } catch (error$37) {
10951
- throw new Error(`Failed to register schema: ${error$37.message}`, { cause: error$37 });
10952
- }
10953
- }
10954
- async function getSchema(uid) {
10955
- try {
10956
- await provider.getNetwork();
10957
- const schema = await schemaRegistry.getSchema({ uid });
10958
- return schema.toString();
10959
- } catch (error$37) {
10960
- throw new Error(`Failed to get schema: ${error$37.message}`);
10961
- }
10962
- }
10963
- return {
10964
- registerSchema,
10965
- getSchema
10966
- };
11368
+ return new EASClient(options);
10967
11369
  }
10968
11370
 
10969
11371
  //#endregion
10970
- export { EAS_FIELD_TYPES, createEASClient };
11372
+ export { EASClient, EASClientOptionsSchema, EAS_FIELD_TYPES, GraphQLOperations, ZERO_ADDRESS, ZERO_BYTES32, createEASClient };
10971
11373
  //# sourceMappingURL=eas.js.map