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