@settlemint/sdk-eas 2.6.2 → 2.6.3-pr2085fb82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -94
- package/dist/browser/eas.d.ts +0 -1
- package/dist/browser/eas.js.map +1 -1
- package/dist/eas.cjs +10 -5
- package/dist/eas.cjs.map +1 -1
- package/dist/eas.d.cts +0 -1
- package/dist/eas.d.ts +0 -1
- package/dist/eas.js.map +1 -1
- package/package.json +4 -4
package/dist/browser/eas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eas.js","names":[],"sources":["../../src/portal/operations.ts","../../src/schema.ts","../../src/utils/validation.ts","../../src/eas.ts"],"sourcesContent":["import type { PortalClient } from \"./portal-client.js\";\n\nexport const GraphQLOperations = {\n mutations: {\n deploySchemaRegistry: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEASSchemaRegistry(\n $from: String!\n $constructorArguments: DeployContractEASSchemaRegistryInput!\n $gasLimit: String!\n ) {\n DeployContractEASSchemaRegistry(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n deployEAS: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {\n DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n registerSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASSchemaRegistryRegister(\n $address: String!\n $from: String!\n $input: EASSchemaRegistryRegisterInput!\n $gasLimit: String!\n ) {\n EASSchemaRegistryRegister(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n attest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {\n EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n multiAttest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {\n EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n revoke: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {\n EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n },\n\n queries: {\n getSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASSchemaRegistryGetSchema($address: String!, $uid: String!) {\n EASSchemaRegistry(address: $address) {\n getSchema(uid: $uid) {\n uid\n resolver\n revocable\n schema\n }\n }\n }`),\n\n getAttestation: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetAttestation($address: String!, $uid: String!) {\n EAS(address: $address) {\n getAttestation(uid: $uid) {\n uid\n schema\n attester\n recipient\n time\n expirationTime\n revocable\n refUID\n data\n revocationTime\n }\n }\n }`),\n\n isAttestationValid: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASIsAttestationValid($address: String!, $uid: String!) {\n EAS(address: $address) {\n isAttestationValid(uid: $uid)\n }\n }`),\n\n getTimestamp: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetTimestamp($address: String!, $data: String!) {\n EAS(address: $address) {\n getTimestamp(data: $data)\n }\n }`),\n },\n};\n","import { type Address, type Hex, zeroAddress } from \"viem\";\nimport type { z } from \"zod\";\nimport type { EASClientOptionsSchema } from \"./utils/validation.js\";\n\n/**\n * Common address constants\n */\nexport const ZERO_ADDRESS = zeroAddress;\nexport const ZERO_BYTES32 = \"0x0000000000000000000000000000000000000000000000000000000000000000\" as Hex;\n\n/**\n * Supported field types for EAS schema fields.\n * Maps to the Solidity types that can be used in EAS schemas.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Represents a single field in an EAS schema.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The Solidity type of the field */\n type: EASFieldType;\n /** Optional description of the field's purpose */\n description?: string;\n}\n\n/**\n * Configuration options for the EAS client\n */\nexport type EASClientOptions = z.infer<typeof EASClientOptionsSchema>;\n\n/**\n * Schema registration request\n */\nexport interface SchemaRequest {\n /** Schema fields (alternative to schema string) */\n fields?: SchemaField[];\n /** Raw schema string (alternative to fields) */\n schema?: string;\n /** Resolver contract address (use ZERO_ADDRESS for no resolver) */\n resolver: Address;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Attestation data structure\n */\nexport interface AttestationData {\n /** Recipient of the attestation */\n recipient: Address;\n /** Expiration time (0 for no expiration) */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID (use ZERO_BYTES32 for no reference) */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Attestation request\n */\nexport interface AttestationRequest {\n /** Schema UID to attest against */\n schema: Hex;\n /** Attestation data */\n data: AttestationData;\n}\n\n/**\n * Transaction result\n */\nexport interface TransactionResult {\n /** Transaction hash */\n hash: Hex;\n /** Whether the transaction was successful */\n success: boolean;\n}\n\n/**\n * Schema information\n */\nexport interface SchemaData {\n /** Schema UID */\n uid: Hex;\n /** Resolver contract address */\n resolver: Address;\n /** Whether attestations can be revoked */\n revocable: boolean;\n /** Schema string */\n schema: string;\n}\n\n/**\n * Attestation information\n */\nexport interface AttestationInfo {\n /** Attestation UID */\n uid: Hex;\n /** Schema UID */\n schema: Hex;\n /** Address that created the attestation */\n attester: Address;\n /** Recipient of the attestation */\n recipient: Address;\n /** Creation timestamp */\n time: bigint;\n /** Expiration timestamp */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Options for retrieving schemas\n */\nexport interface GetSchemasOptions {\n /** Maximum number of schemas to return */\n limit?: number;\n /** Number of schemas to skip */\n offset?: number;\n}\n\n/**\n * Options for retrieving attestations\n */\nexport interface GetAttestationsOptions {\n /** Maximum number of attestations to return */\n limit?: number;\n /** Number of attestations to skip */\n offset?: number;\n /** Filter by schema UID */\n schema?: Hex;\n /** Filter by attester address */\n attester?: Address;\n /** Filter by recipient address */\n recipient?: Address;\n}\n\n/**\n * Contract deployment result\n */\nexport interface DeploymentResult {\n /** Deployed EAS contract address */\n easAddress: Address;\n /** Deployed Schema Registry contract address */\n schemaRegistryAddress: Address;\n /** EAS deployment transaction hash (when address not immediately available) */\n easTransactionHash?: Hex;\n /** Schema Registry deployment transaction hash (when address not immediately available) */\n schemaRegistryTransactionHash?: Hex;\n}\n\n/**\n * @deprecated Use SchemaRequest instead\n * @internal\n */\nexport interface RegisterSchemaOptions extends SchemaRequest {}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { type Address, isAddress } from \"viem\";\nimport { z } from \"zod\";\n\nconst ethAddressSchema = z.custom<Address>(\n (val) => typeof val === \"string\" && isAddress(val),\n \"Invalid Ethereum address\",\n);\n\n/**\n * Zod schema for EASClientOptions.\n */\nexport const EASClientOptionsSchema = z.object({\n /**\n * The EAS instance URL\n */\n instance: UrlSchema,\n /**\n * The application access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The EAS contract address\n */\n easContractAddress: ethAddressSchema.optional(),\n /**\n * The schema registry contract address\n */\n schemaRegistryContractAddress: ethAddressSchema.optional(),\n /**\n * Whether to enable debug mode\n */\n debug: z.boolean().optional(),\n});\n","import { createPortalClient, waitForTransactionReceipt } from \"@settlemint/sdk-portal\";\nimport { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport type { Address, Hex } from \"viem\";\nimport { GraphQLOperations } from \"./portal/operations.js\";\nimport type { PortalClient } from \"./portal/portal-client.js\";\nimport type { introspection } from \"./portal/portal-env.d.ts\";\nimport {\n type AttestationInfo,\n type AttestationRequest,\n type DeploymentResult,\n type EASClientOptions,\n type GetAttestationsOptions,\n type GetSchemasOptions,\n type SchemaData,\n type SchemaField,\n type SchemaRequest,\n type TransactionResult,\n ZERO_ADDRESS,\n} from \"./schema.js\";\nimport { EASClientOptionsSchema } from \"./utils/validation.js\";\n\nconst LOGGER = createLogger();\n\nconst DEFAULT_GAS_LIMIT = \"0x3d0900\";\n\n/**\n * Main EAS client class for interacting with Ethereum Attestation Service via Portal\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Deploy EAS contracts\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * console.log(\"EAS deployed at:\", deployment.easAddress);\n * ```\n */\nexport class EASClient {\n private readonly options: EASClientOptions;\n private readonly portalClient: PortalClient[\"client\"];\n private readonly portalGraphql: PortalClient[\"graphql\"];\n private deployedAddresses?: DeploymentResult;\n\n /**\n * Create a new EAS client instance\n *\n * @param options - Configuration options for the EAS client\n */\n constructor(options: EASClientOptions) {\n this.options = validate(EASClientOptionsSchema, options);\n\n const { client: portalClient, graphql: portalGraphql } = createPortalClient<{\n introspection: introspection;\n disableMasking: true;\n scalars: {\n // Change unknown to the type you are using to store metadata\n JSON: unknown;\n };\n }>(\n {\n instance: this.options.instance,\n accessToken: this.options.accessToken,\n },\n {\n fetch: requestLogger(LOGGER, \"portal\", fetch) as typeof fetch,\n },\n );\n\n this.portalClient = portalClient;\n this.portalGraphql = portalGraphql;\n }\n\n /**\n * Deploy EAS contracts via Portal\n *\n * @param deployerAddress - The address that will deploy the contracts\n * @param forwarderAddress - Optional trusted forwarder address (defaults to zero address)\n * @param gasLimit - Optional gas limit for deployment transactions (defaults to \"0x7a1200\")\n * @returns Promise resolving to deployment result with contract addresses and transaction hashes\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const deployment = await easClient.deploy(\n * \"0x1234567890123456789012345678901234567890\", // deployer address\n * \"0x0000000000000000000000000000000000000000\", // forwarder (optional)\n * \"0x7a1200\" // gas limit (optional)\n * );\n *\n * console.log(\"Schema Registry:\", deployment.schemaRegistryAddress);\n * console.log(\"EAS Contract:\", deployment.easAddress);\n * ```\n */\n public async deploy(\n deployerAddress: Address,\n forwarderAddress?: Address,\n gasLimit?: string,\n ): Promise<DeploymentResult> {\n const defaultForwarder = forwarderAddress || ZERO_ADDRESS;\n const defaultGasLimit = gasLimit || \"0x7a1200\";\n\n try {\n // Deploy Schema Registry first\n const schemaRegistryResponse = await this.portalClient.request(\n GraphQLOperations.mutations.deploySchemaRegistry(this.portalGraphql),\n {\n from: deployerAddress,\n constructorArguments: {\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n },\n );\n\n if (!schemaRegistryResponse.DeployContractEASSchemaRegistry?.transactionHash) {\n throw new Error(\"Schema Registry deployment failed - no transaction hash returned\");\n }\n\n const schemaRegistryTxHash = schemaRegistryResponse.DeployContractEASSchemaRegistry.transactionHash;\n\n // Wait for Schema Registry deployment and get contract address\n const schemaRegistryTransaction = await waitForTransactionReceipt(schemaRegistryTxHash as Hex, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!schemaRegistryTransaction?.receipt?.contractAddress) {\n throw new Error(\"Schema Registry deployment failed - could not get contract address from transaction receipt.\");\n }\n\n const schemaRegistryAddress = schemaRegistryTransaction.receipt.contractAddress;\n\n // Deploy EAS contract with correct Schema Registry address\n const easResponse = await this.portalClient.request(GraphQLOperations.mutations.deployEAS(this.portalGraphql), {\n from: deployerAddress,\n constructorArguments: {\n registry: schemaRegistryAddress,\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n });\n if (!easResponse.DeployContractEAS?.transactionHash) {\n throw new Error(\"EAS deployment failed - no transaction hash returned\");\n }\n\n const easTxHash = easResponse.DeployContractEAS.transactionHash as Hex;\n\n // Wait for EAS deployment and get contract address\n const easTransaction = await waitForTransactionReceipt(easTxHash, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!easTransaction?.receipt?.contractAddress) {\n throw new Error(\"EAS deployment failed - could not get contract address from transaction receipt.\");\n }\n const easAddress = easTransaction.receipt.contractAddress;\n\n this.deployedAddresses = {\n easAddress,\n schemaRegistryAddress,\n easTransactionHash: easTxHash as Hex,\n schemaRegistryTransactionHash: schemaRegistryTxHash as Hex,\n };\n\n return this.deployedAddresses;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to deploy EAS contracts: ${error.message}`);\n }\n }\n\n /**\n * Register a new schema in the EAS Schema Registry\n *\n * @param request - Schema registration request containing schema definition\n * @param fromAddress - Address that will register the schema\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const schemaResult = await easClient.registerSchema(\n * {\n * schema: \"uint256 eventId, uint8 voteIndex\",\n * resolver: \"0x0000000000000000000000000000000000000000\",\n * revocable: true\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Schema registered:\", schemaResult.hash);\n * ```\n */\n public async registerSchema(\n request: SchemaRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n let schemaString = request.schema;\n if (request.fields && !schemaString) {\n schemaString = this.buildSchemaString(request.fields);\n }\n\n if (!schemaString) {\n throw new Error(\"Schema string is required. Provide either 'schema' or 'fields'.\");\n }\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.registerSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n from: fromAddress,\n input: {\n schema: schemaString,\n resolver: request.resolver,\n revocable: request.revocable,\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASSchemaRegistryRegister?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to register schema: ${error.message}`);\n }\n }\n\n /**\n * Create an attestation\n *\n * @param request - Attestation request containing schema and data\n * @param fromAddress - Address that will create the attestation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const attestationResult = await easClient.attest(\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0), // No expiration\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\", // ABI-encoded data\n * value: BigInt(0)\n * }\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Attestation created:\", attestationResult.hash);\n * ```\n */\n public async attest(\n request: AttestationRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.attest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n request: {\n schema: request.schema,\n data: {\n recipient: request.data.recipient,\n expirationTime: request.data.expirationTime.toString(),\n revocable: request.data.revocable,\n refUID: request.data.refUID,\n data: request.data.data,\n value: request.data.value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create attestation: ${error.message}`);\n }\n }\n\n /**\n * Create multiple attestations in a single transaction\n *\n * @param requests - Array of attestation requests\n * @param fromAddress - Address that will create the attestations\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const multiAttestResult = await easClient.multiAttest(\n * [\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0),\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\",\n * value: BigInt(0)\n * }\n * },\n * {\n * schema: \"0x5678901234567890123456789012345678901234567890123456789012345678\",\n * data: {\n * recipient: \"0x5678901234567890123456789012345678901234\",\n * expirationTime: BigInt(0),\n * revocable: false,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x5678\",\n * value: BigInt(0)\n * }\n * }\n * ],\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Multiple attestations created:\", multiAttestResult.hash);\n * ```\n */\n public async multiAttest(\n requests: AttestationRequest[],\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n if (requests.length === 0) {\n throw new Error(\"At least one attestation request is required\");\n }\n\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.multiAttest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n multiRequests: requests.map((req) => ({\n schema: req.schema,\n data: [\n {\n recipient: req.data.recipient,\n expirationTime: req.data.expirationTime.toString(),\n revocable: req.data.revocable,\n refUID: req.data.refUID,\n data: req.data.data,\n value: req.data.value?.toString() || \"0\",\n },\n ],\n })),\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASMultiAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create multiple attestations: ${error.message}`);\n }\n }\n\n /**\n * Revoke an existing attestation\n *\n * @param schemaUID - UID of the schema used for the attestation\n * @param attestationUID - UID of the attestation to revoke\n * @param fromAddress - Address that will revoke the attestation\n * @param value - Optional ETH value to send with the revocation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const revokeResult = await easClient.revoke(\n * \"0x1234567890123456789012345678901234567890123456789012345678901234\", // schema UID\n * \"0x5678901234567890123456789012345678901234567890123456789012345678\", // attestation UID\n * \"0x1234567890123456789012345678901234567890\", // from address\n * BigInt(0) // value (optional)\n * );\n *\n * console.log(\"Attestation revoked:\", revokeResult.hash);\n * ```\n */\n public async revoke(\n schemaUID: Hex,\n attestationUID: Hex,\n fromAddress: Address,\n value?: bigint,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.revoke(this.portalGraphql), {\n address: this.getEASAddress(),\n from: fromAddress,\n input: {\n request: {\n schema: schemaUID,\n data: {\n uid: attestationUID,\n value: value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASRevoke?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to revoke attestation: ${error.message}`);\n }\n }\n\n /**\n * Get a schema by UID\n */\n public async getSchema(uid: Hex): Promise<SchemaData> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n uid: uid,\n });\n\n const schemaResult = response.EASSchemaRegistry?.getSchema;\n\n if (!schemaResult) {\n throw new Error(`Schema not found: ${uid}`);\n }\n\n return {\n uid: schemaResult.uid as Hex,\n resolver: schemaResult.resolver as Address,\n revocable: Boolean(schemaResult.revocable),\n schema: schemaResult.schema || \"\",\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get schema: ${error.message}`);\n }\n }\n\n /**\n * Get all schemas with pagination\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all schemas.\n * Consider using getSchema() for individual schema lookups.\n */\n public async getSchemas(_options?: GetSchemasOptions): Promise<SchemaData[]> {\n throw new Error(\n \"Schema listing not implemented yet. Portal's direct contract queries don't support listing all schemas. Use getSchema() for individual schema lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Get an attestation by UID\n */\n public async getAttestation(uid: Hex): Promise<AttestationInfo> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getAttestation(this.portalGraphql), {\n address: easAddress,\n uid: uid,\n });\n\n const attestationResult = response.EAS?.getAttestation;\n\n if (!attestationResult) {\n throw new Error(`Attestation not found: ${uid}`);\n }\n\n return {\n uid: attestationResult.uid as Hex,\n schema: attestationResult.schema as Hex,\n attester: attestationResult.attester as Address,\n recipient: attestationResult.recipient as Address,\n time: attestationResult.time ? BigInt(attestationResult.time) : BigInt(0),\n expirationTime: attestationResult.expirationTime ? BigInt(attestationResult.expirationTime) : BigInt(0),\n revocable: Boolean(attestationResult.revocable),\n refUID: attestationResult.refUID as Hex,\n data: attestationResult.data as Hex,\n value: BigInt(0), // Note: Portal schema doesn't include value, defaulting to 0\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get attestation: ${error.message}`);\n }\n }\n\n /**\n * Get attestations with pagination and filtering\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all attestations.\n * Consider using getAttestation() for individual attestation lookups.\n */\n public async getAttestations(_options?: GetAttestationsOptions): Promise<AttestationInfo[]> {\n throw new Error(\n \"Attestation listing not implemented yet. Portal's direct contract queries don't support listing all attestations. Use getAttestation() for individual attestation lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Check if an attestation is valid\n */\n public async isValidAttestation(uid: Hex): Promise<boolean> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(\n GraphQLOperations.queries.isAttestationValid(this.portalGraphql),\n {\n address: easAddress,\n uid: uid,\n },\n );\n\n return response.EAS?.isAttestationValid ?? false;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to check attestation validity: ${error.message}`);\n }\n }\n\n /**\n * Get the timestamp for specific data\n *\n * @param data - The data to get timestamp for\n * @returns The timestamp when the data was timestamped\n */\n public async getTimestamp(data: Hex): Promise<bigint> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getTimestamp(this.portalGraphql), {\n address: easAddress,\n data: data,\n });\n\n const timestampResult = response.EAS?.getTimestamp;\n\n if (timestampResult === undefined || timestampResult === null) {\n throw new Error(`No timestamp found for data: ${data}`);\n }\n\n return BigInt(timestampResult);\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get timestamp: ${error.message}`);\n }\n }\n\n /**\n * Get client configuration\n */\n public getOptions(): EASClientOptions {\n return { ...this.options };\n }\n\n /**\n * Get the Portal client instance for advanced operations\n */\n public getPortalClient(): PortalClient[\"client\"] {\n return this.portalClient;\n }\n\n /**\n * Get current contract addresses\n */\n public getContractAddresses(): { easAddress?: Address; schemaRegistryAddress?: Address } {\n return {\n easAddress: this.options.easContractAddress || this.deployedAddresses?.easAddress,\n schemaRegistryAddress:\n this.options.schemaRegistryContractAddress || this.deployedAddresses?.schemaRegistryAddress,\n };\n }\n\n private getEASAddress(): Address {\n if (this.options.easContractAddress) {\n return this.options.easContractAddress;\n }\n if (this.deployedAddresses?.easAddress) {\n return this.deployedAddresses.easAddress;\n }\n throw new Error(\"EAS contract address not available. Please provide it in options or deploy contracts first.\");\n }\n\n private getSchemaRegistryAddress(): Address {\n if (this.options.schemaRegistryContractAddress) {\n return this.options.schemaRegistryContractAddress;\n }\n if (this.deployedAddresses?.schemaRegistryAddress) {\n return this.deployedAddresses.schemaRegistryAddress;\n }\n throw new Error(\n \"Schema Registry contract address not available. Please provide it in options or deploy contracts first.\",\n );\n }\n\n private buildSchemaString(fields: SchemaField[]): string {\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n }\n}\n\n/**\n * Create an EAS client instance\n *\n * @param options - Configuration options for the EAS client\n * @returns EAS client instance\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Use the client\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * ```\n */\nexport function createEASClient(options: EASClientOptions): EASClient {\n return new EASClient(options);\n}\n\n// Re-export GraphQL operations for advanced usage\nexport { GraphQLOperations } from \"./portal/operations.js\";\n// Re-export types and constants\nexport type {\n AttestationData,\n AttestationInfo,\n AttestationRequest,\n DeploymentResult,\n EASClientOptions,\n EASFieldType,\n GetAttestationsOptions,\n GetSchemasOptions,\n RegisterSchemaOptions,\n SchemaData,\n SchemaField,\n SchemaRequest,\n TransactionResult,\n} from \"./schema.js\";\nexport { EAS_FIELD_TYPES, ZERO_ADDRESS, ZERO_BYTES32 } from \"./schema.js\";\n// Re-export validation utilities\nexport { EASClientOptionsSchema } from \"./utils/validation.js\";\n"],"mappings":";;;;;;;;AAEA,MAAa,oBAAoB;CAC/B,WAAW;EACT,uBAAuB,YACrB,QAAQ;;;;;;;;;;EAWV,YAAY,YACV,QAAQ;;;;;;EAOV,iBAAiB,YACf,QAAQ;;;;;;;;;;;EAYV,SAAS,YACP,QAAQ;;;;;;EAOV,cAAc,YACZ,QAAQ;;;;;;EAOV,SAAS,YACP,QAAQ;;;;;;;CAQZ,SAAS;EACP,YAAY,YACV,QAAQ;;;;;;;;;;;EAYV,iBAAiB,YACf,QAAQ;;;;;;;;;;;;;;;;;EAkBV,qBAAqB,YACnB,QAAQ;;;;;;EAOV,eAAe,YACb,QAAQ;;;;;;;;;;;;;;ACjGd,MAAa,eAAe;AAC5B,MAAa,eAAe;;;;;AAM5B,MAAa,kBAAkB;CAC7B,QAAQ;CACR,SAAS;CACT,MAAM;CACN,OAAO;CACP,SAAS;CACT,SAAS;CACT,QAAQ;CACR,OAAO;CACP,MAAM;;;;;ACnBR,MAAM,mBAAmB,EAAE,QACxB,QAAQ,OAAO,QAAQ,YAAY,UAAU,MAC9C;;;;AAMF,MAAa,yBAAyB,EAAE,OAAO;CA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;;;;CAMd,AAAO,uBAAkF;AACvF,SAAO;GACL,YAAY,KAAK,QAAQ,sBAAsB,KAAK,mBAAmB;GACvE,uBACE,KAAK,QAAQ,iCAAiC,KAAK,mBAAmB;;;CAI5E,AAAQ,gBAAyB;AAC/B,MAAI,KAAK,QAAQ,oBAAoB;AACnC,UAAO,KAAK,QAAQ;;AAEtB,MAAI,KAAK,mBAAmB,YAAY;AACtC,UAAO,KAAK,kBAAkB;;AAEhC,QAAM,IAAI,MAAM;;CAGlB,AAAQ,2BAAoC;AAC1C,MAAI,KAAK,QAAQ,+BAA+B;AAC9C,UAAO,KAAK,QAAQ;;AAEtB,MAAI,KAAK,mBAAmB,uBAAuB;AACjD,UAAO,KAAK,kBAAkB;;AAEhC,QAAM,IAAI,MACR;;CAIJ,AAAQ,kBAAkB,QAA+B;AACvD,SAAO,OAAO,KAAK,UAAU,GAAG,MAAM,KAAK,GAAG,MAAM,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;AAuBrE,SAAgB,gBAAgB,SAAsC;AACpE,QAAO,IAAI,UAAU"}
|
|
1
|
+
{"version":3,"file":"eas.js","names":[],"sources":["../../src/portal/operations.ts","../../src/schema.ts","../../src/utils/validation.ts","../../src/eas.ts"],"sourcesContent":["import type { PortalClient } from \"./portal-client.js\";\n\nexport const GraphQLOperations = {\n mutations: {\n deploySchemaRegistry: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEASSchemaRegistry(\n $from: String!\n $constructorArguments: DeployContractEASSchemaRegistryInput!\n $gasLimit: String!\n ) {\n DeployContractEASSchemaRegistry(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n deployEAS: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {\n DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n registerSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASSchemaRegistryRegister(\n $address: String!\n $from: String!\n $input: EASSchemaRegistryRegisterInput!\n $gasLimit: String!\n ) {\n EASSchemaRegistryRegister(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n attest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {\n EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n multiAttest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {\n EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n revoke: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {\n EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n },\n\n queries: {\n getSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASSchemaRegistryGetSchema($address: String!, $uid: String!) {\n EASSchemaRegistry(address: $address) {\n getSchema(uid: $uid) {\n uid\n resolver\n revocable\n schema\n }\n }\n }`),\n\n getAttestation: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetAttestation($address: String!, $uid: String!) {\n EAS(address: $address) {\n getAttestation(uid: $uid) {\n uid\n schema\n attester\n recipient\n time\n expirationTime\n revocable\n refUID\n data\n revocationTime\n }\n }\n }`),\n\n isAttestationValid: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASIsAttestationValid($address: String!, $uid: String!) {\n EAS(address: $address) {\n isAttestationValid(uid: $uid)\n }\n }`),\n\n getTimestamp: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetTimestamp($address: String!, $data: String!) {\n EAS(address: $address) {\n getTimestamp(data: $data)\n }\n }`),\n },\n};\n","import { type Address, type Hex, zeroAddress } from \"viem\";\nimport type { z } from \"zod\";\nimport type { EASClientOptionsSchema } from \"./utils/validation.js\";\n\n/**\n * Common address constants\n */\nexport const ZERO_ADDRESS = zeroAddress;\nexport const ZERO_BYTES32 = \"0x0000000000000000000000000000000000000000000000000000000000000000\" as Hex;\n\n/**\n * Supported field types for EAS schema fields.\n * Maps to the Solidity types that can be used in EAS schemas.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Represents a single field in an EAS schema.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The Solidity type of the field */\n type: EASFieldType;\n /** Optional description of the field's purpose */\n description?: string;\n}\n\n/**\n * Configuration options for the EAS client\n */\nexport type EASClientOptions = z.infer<typeof EASClientOptionsSchema>;\n\n/**\n * Schema registration request\n */\nexport interface SchemaRequest {\n /** Schema fields (alternative to schema string) */\n fields?: SchemaField[];\n /** Raw schema string (alternative to fields) */\n schema?: string;\n /** Resolver contract address (use ZERO_ADDRESS for no resolver) */\n resolver: Address;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Attestation data structure\n */\nexport interface AttestationData {\n /** Recipient of the attestation */\n recipient: Address;\n /** Expiration time (0 for no expiration) */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID (use ZERO_BYTES32 for no reference) */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Attestation request\n */\nexport interface AttestationRequest {\n /** Schema UID to attest against */\n schema: Hex;\n /** Attestation data */\n data: AttestationData;\n}\n\n/**\n * Transaction result\n */\nexport interface TransactionResult {\n /** Transaction hash */\n hash: Hex;\n /** Whether the transaction was successful */\n success: boolean;\n}\n\n/**\n * Schema information\n */\nexport interface SchemaData {\n /** Schema UID */\n uid: Hex;\n /** Resolver contract address */\n resolver: Address;\n /** Whether attestations can be revoked */\n revocable: boolean;\n /** Schema string */\n schema: string;\n}\n\n/**\n * Attestation information\n */\nexport interface AttestationInfo {\n /** Attestation UID */\n uid: Hex;\n /** Schema UID */\n schema: Hex;\n /** Address that created the attestation */\n attester: Address;\n /** Recipient of the attestation */\n recipient: Address;\n /** Creation timestamp */\n time: bigint;\n /** Expiration timestamp */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Options for retrieving schemas\n */\nexport interface GetSchemasOptions {\n /** Maximum number of schemas to return */\n limit?: number;\n /** Number of schemas to skip */\n offset?: number;\n}\n\n/**\n * Options for retrieving attestations\n */\nexport interface GetAttestationsOptions {\n /** Maximum number of attestations to return */\n limit?: number;\n /** Number of attestations to skip */\n offset?: number;\n /** Filter by schema UID */\n schema?: Hex;\n /** Filter by attester address */\n attester?: Address;\n /** Filter by recipient address */\n recipient?: Address;\n}\n\n/**\n * Contract deployment result\n */\nexport interface DeploymentResult {\n /** Deployed EAS contract address */\n easAddress: Address;\n /** Deployed Schema Registry contract address */\n schemaRegistryAddress: Address;\n /** EAS deployment transaction hash (when address not immediately available) */\n easTransactionHash?: Hex;\n /** Schema Registry deployment transaction hash (when address not immediately available) */\n schemaRegistryTransactionHash?: Hex;\n}\n\n/**\n * @deprecated Use SchemaRequest instead\n * @internal\n */\nexport interface RegisterSchemaOptions extends SchemaRequest {}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { type Address, isAddress } from \"viem\";\nimport { z } from \"zod\";\n\nconst ethAddressSchema = z.custom<Address>(\n (val) => typeof val === \"string\" && isAddress(val),\n \"Invalid Ethereum address\",\n);\n\n/**\n * Zod schema for EASClientOptions.\n */\nexport const EASClientOptionsSchema = z.object({\n /**\n * The EAS instance URL\n */\n instance: UrlSchema,\n /**\n * The application access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The EAS contract address\n */\n easContractAddress: ethAddressSchema.optional(),\n /**\n * The schema registry contract address\n */\n schemaRegistryContractAddress: ethAddressSchema.optional(),\n /**\n * Whether to enable debug mode\n */\n debug: z.boolean().optional(),\n});\n","import { createPortalClient, waitForTransactionReceipt } from \"@settlemint/sdk-portal\";\nimport { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport type { Address, Hex } from \"viem\";\nimport { GraphQLOperations } from \"./portal/operations.js\";\nimport type { PortalClient } from \"./portal/portal-client.js\";\nimport type { introspection } from \"./portal/portal-env.d.ts\";\nimport {\n type AttestationInfo,\n type AttestationRequest,\n type DeploymentResult,\n type EASClientOptions,\n type GetAttestationsOptions,\n type GetSchemasOptions,\n type SchemaData,\n type SchemaField,\n type SchemaRequest,\n type TransactionResult,\n ZERO_ADDRESS,\n} from \"./schema.js\";\nimport { EASClientOptionsSchema } from \"./utils/validation.js\";\n\nconst LOGGER = createLogger();\n\nconst DEFAULT_GAS_LIMIT = \"0x3d0900\";\n\n/**\n * Main EAS client class for interacting with Ethereum Attestation Service via Portal\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Deploy EAS contracts\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * console.log(\"EAS deployed at:\", deployment.easAddress);\n * ```\n */\nexport class EASClient {\n private readonly options: EASClientOptions;\n private readonly portalClient: PortalClient[\"client\"];\n private readonly portalGraphql: PortalClient[\"graphql\"];\n private deployedAddresses?: DeploymentResult;\n\n /**\n * Create a new EAS client instance\n *\n * @param options - Configuration options for the EAS client\n */\n constructor(options: EASClientOptions) {\n this.options = validate(EASClientOptionsSchema, options);\n\n const { client: portalClient, graphql: portalGraphql } = createPortalClient<{\n introspection: introspection;\n disableMasking: true;\n scalars: {\n // Change unknown to the type you are using to store metadata\n JSON: unknown;\n };\n }>(\n {\n instance: this.options.instance,\n accessToken: this.options.accessToken,\n },\n {\n fetch: requestLogger(LOGGER, \"portal\", fetch) as typeof fetch,\n },\n );\n\n this.portalClient = portalClient;\n this.portalGraphql = portalGraphql;\n }\n\n /**\n * Deploy EAS contracts via Portal\n *\n * @param deployerAddress - The address that will deploy the contracts\n * @param forwarderAddress - Optional trusted forwarder address (defaults to zero address)\n * @param gasLimit - Optional gas limit for deployment transactions (defaults to \"0x7a1200\")\n * @returns Promise resolving to deployment result with contract addresses and transaction hashes\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const deployment = await easClient.deploy(\n * \"0x1234567890123456789012345678901234567890\", // deployer address\n * \"0x0000000000000000000000000000000000000000\", // forwarder (optional)\n * \"0x7a1200\" // gas limit (optional)\n * );\n *\n * console.log(\"Schema Registry:\", deployment.schemaRegistryAddress);\n * console.log(\"EAS Contract:\", deployment.easAddress);\n * ```\n */\n public async deploy(\n deployerAddress: Address,\n forwarderAddress?: Address,\n gasLimit?: string,\n ): Promise<DeploymentResult> {\n const defaultForwarder = forwarderAddress || ZERO_ADDRESS;\n const defaultGasLimit = gasLimit || \"0x7a1200\";\n\n try {\n // Deploy Schema Registry first\n const schemaRegistryResponse = await this.portalClient.request(\n GraphQLOperations.mutations.deploySchemaRegistry(this.portalGraphql),\n {\n from: deployerAddress,\n constructorArguments: {\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n },\n );\n\n if (!schemaRegistryResponse.DeployContractEASSchemaRegistry?.transactionHash) {\n throw new Error(\"Schema Registry deployment failed - no transaction hash returned\");\n }\n\n const schemaRegistryTxHash = schemaRegistryResponse.DeployContractEASSchemaRegistry.transactionHash;\n\n // Wait for Schema Registry deployment and get contract address\n const schemaRegistryTransaction = await waitForTransactionReceipt(schemaRegistryTxHash as Hex, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!schemaRegistryTransaction?.receipt?.contractAddress) {\n throw new Error(\"Schema Registry deployment failed - could not get contract address from transaction receipt.\");\n }\n\n const schemaRegistryAddress = schemaRegistryTransaction.receipt.contractAddress;\n\n // Deploy EAS contract with correct Schema Registry address\n const easResponse = await this.portalClient.request(GraphQLOperations.mutations.deployEAS(this.portalGraphql), {\n from: deployerAddress,\n constructorArguments: {\n registry: schemaRegistryAddress,\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n });\n if (!easResponse.DeployContractEAS?.transactionHash) {\n throw new Error(\"EAS deployment failed - no transaction hash returned\");\n }\n\n const easTxHash = easResponse.DeployContractEAS.transactionHash as Hex;\n\n // Wait for EAS deployment and get contract address\n const easTransaction = await waitForTransactionReceipt(easTxHash, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!easTransaction?.receipt?.contractAddress) {\n throw new Error(\"EAS deployment failed - could not get contract address from transaction receipt.\");\n }\n const easAddress = easTransaction.receipt.contractAddress;\n\n this.deployedAddresses = {\n easAddress,\n schemaRegistryAddress,\n easTransactionHash: easTxHash as Hex,\n schemaRegistryTransactionHash: schemaRegistryTxHash as Hex,\n };\n\n return this.deployedAddresses;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to deploy EAS contracts: ${error.message}`);\n }\n }\n\n /**\n * Register a new schema in the EAS Schema Registry\n *\n * @param request - Schema registration request containing schema definition\n * @param fromAddress - Address that will register the schema\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const schemaResult = await easClient.registerSchema(\n * {\n * schema: \"uint256 eventId, uint8 voteIndex\",\n * resolver: \"0x0000000000000000000000000000000000000000\",\n * revocable: true\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Schema registered:\", schemaResult.hash);\n * ```\n */\n public async registerSchema(\n request: SchemaRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n let schemaString = request.schema;\n if (request.fields && !schemaString) {\n schemaString = this.buildSchemaString(request.fields);\n }\n\n if (!schemaString) {\n throw new Error(\"Schema string is required. Provide either 'schema' or 'fields'.\");\n }\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.registerSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n from: fromAddress,\n input: {\n schema: schemaString,\n resolver: request.resolver,\n revocable: request.revocable,\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASSchemaRegistryRegister?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to register schema: ${error.message}`);\n }\n }\n\n /**\n * Create an attestation\n *\n * @param request - Attestation request containing schema and data\n * @param fromAddress - Address that will create the attestation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const attestationResult = await easClient.attest(\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0), // No expiration\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\", // ABI-encoded data\n * value: BigInt(0)\n * }\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Attestation created:\", attestationResult.hash);\n * ```\n */\n public async attest(\n request: AttestationRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.attest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n request: {\n schema: request.schema,\n data: {\n recipient: request.data.recipient,\n expirationTime: request.data.expirationTime.toString(),\n revocable: request.data.revocable,\n refUID: request.data.refUID,\n data: request.data.data,\n value: request.data.value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create attestation: ${error.message}`);\n }\n }\n\n /**\n * Create multiple attestations in a single transaction\n *\n * @param requests - Array of attestation requests\n * @param fromAddress - Address that will create the attestations\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const multiAttestResult = await easClient.multiAttest(\n * [\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0),\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\",\n * value: BigInt(0)\n * }\n * },\n * {\n * schema: \"0x5678901234567890123456789012345678901234567890123456789012345678\",\n * data: {\n * recipient: \"0x5678901234567890123456789012345678901234\",\n * expirationTime: BigInt(0),\n * revocable: false,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x5678\",\n * value: BigInt(0)\n * }\n * }\n * ],\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Multiple attestations created:\", multiAttestResult.hash);\n * ```\n */\n public async multiAttest(\n requests: AttestationRequest[],\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n if (requests.length === 0) {\n throw new Error(\"At least one attestation request is required\");\n }\n\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.multiAttest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n multiRequests: requests.map((req) => ({\n schema: req.schema,\n data: [\n {\n recipient: req.data.recipient,\n expirationTime: req.data.expirationTime.toString(),\n revocable: req.data.revocable,\n refUID: req.data.refUID,\n data: req.data.data,\n value: req.data.value?.toString() || \"0\",\n },\n ],\n })),\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASMultiAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create multiple attestations: ${error.message}`);\n }\n }\n\n /**\n * Revoke an existing attestation\n *\n * @param schemaUID - UID of the schema used for the attestation\n * @param attestationUID - UID of the attestation to revoke\n * @param fromAddress - Address that will revoke the attestation\n * @param value - Optional ETH value to send with the revocation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const revokeResult = await easClient.revoke(\n * \"0x1234567890123456789012345678901234567890123456789012345678901234\", // schema UID\n * \"0x5678901234567890123456789012345678901234567890123456789012345678\", // attestation UID\n * \"0x1234567890123456789012345678901234567890\", // from address\n * BigInt(0) // value (optional)\n * );\n *\n * console.log(\"Attestation revoked:\", revokeResult.hash);\n * ```\n */\n public async revoke(\n schemaUID: Hex,\n attestationUID: Hex,\n fromAddress: Address,\n value?: bigint,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.revoke(this.portalGraphql), {\n address: this.getEASAddress(),\n from: fromAddress,\n input: {\n request: {\n schema: schemaUID,\n data: {\n uid: attestationUID,\n value: value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASRevoke?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to revoke attestation: ${error.message}`);\n }\n }\n\n /**\n * Get a schema by UID\n */\n public async getSchema(uid: Hex): Promise<SchemaData> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n uid: uid,\n });\n\n const schemaResult = response.EASSchemaRegistry?.getSchema;\n\n if (!schemaResult) {\n throw new Error(`Schema not found: ${uid}`);\n }\n\n return {\n uid: schemaResult.uid as Hex,\n resolver: schemaResult.resolver as Address,\n revocable: Boolean(schemaResult.revocable),\n schema: schemaResult.schema || \"\",\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get schema: ${error.message}`);\n }\n }\n\n /**\n * Get all schemas with pagination\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all schemas.\n * Consider using getSchema() for individual schema lookups.\n */\n public async getSchemas(_options?: GetSchemasOptions): Promise<SchemaData[]> {\n throw new Error(\n \"Schema listing not implemented yet. Portal's direct contract queries don't support listing all schemas. Use getSchema() for individual schema lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Get an attestation by UID\n */\n public async getAttestation(uid: Hex): Promise<AttestationInfo> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getAttestation(this.portalGraphql), {\n address: easAddress,\n uid: uid,\n });\n\n const attestationResult = response.EAS?.getAttestation;\n\n if (!attestationResult) {\n throw new Error(`Attestation not found: ${uid}`);\n }\n\n return {\n uid: attestationResult.uid as Hex,\n schema: attestationResult.schema as Hex,\n attester: attestationResult.attester as Address,\n recipient: attestationResult.recipient as Address,\n time: attestationResult.time ? BigInt(attestationResult.time) : BigInt(0),\n expirationTime: attestationResult.expirationTime ? BigInt(attestationResult.expirationTime) : BigInt(0),\n revocable: Boolean(attestationResult.revocable),\n refUID: attestationResult.refUID as Hex,\n data: attestationResult.data as Hex,\n value: BigInt(0), // Note: Portal schema doesn't include value, defaulting to 0\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get attestation: ${error.message}`);\n }\n }\n\n /**\n * Get attestations with pagination and filtering\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all attestations.\n * Consider using getAttestation() for individual attestation lookups.\n */\n public async getAttestations(_options?: GetAttestationsOptions): Promise<AttestationInfo[]> {\n throw new Error(\n \"Attestation listing not implemented yet. Portal's direct contract queries don't support listing all attestations. Use getAttestation() for individual attestation lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Check if an attestation is valid\n */\n public async isValidAttestation(uid: Hex): Promise<boolean> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(\n GraphQLOperations.queries.isAttestationValid(this.portalGraphql),\n {\n address: easAddress,\n uid: uid,\n },\n );\n\n return response.EAS?.isAttestationValid ?? false;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to check attestation validity: ${error.message}`);\n }\n }\n\n /**\n * Get the timestamp for specific data\n *\n * @param data - The data to get timestamp for\n * @returns The timestamp when the data was timestamped\n */\n public async getTimestamp(data: Hex): Promise<bigint> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getTimestamp(this.portalGraphql), {\n address: easAddress,\n data: data,\n });\n\n const timestampResult = response.EAS?.getTimestamp;\n\n if (timestampResult === undefined || timestampResult === null) {\n throw new Error(`No timestamp found for data: ${data}`);\n }\n\n return BigInt(timestampResult);\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get timestamp: ${error.message}`);\n }\n }\n\n /**\n * Get client configuration\n */\n public getOptions(): EASClientOptions {\n return { ...this.options };\n }\n\n /**\n * Get the Portal client instance for advanced operations\n */\n public getPortalClient(): PortalClient[\"client\"] {\n return this.portalClient;\n }\n\n /**\n * Get current contract addresses\n */\n public getContractAddresses(): { easAddress?: Address; schemaRegistryAddress?: Address } {\n return {\n easAddress: this.options.easContractAddress || this.deployedAddresses?.easAddress,\n schemaRegistryAddress:\n this.options.schemaRegistryContractAddress || this.deployedAddresses?.schemaRegistryAddress,\n };\n }\n\n private getEASAddress(): Address {\n if (this.options.easContractAddress) {\n return this.options.easContractAddress;\n }\n if (this.deployedAddresses?.easAddress) {\n return this.deployedAddresses.easAddress;\n }\n throw new Error(\"EAS contract address not available. Please provide it in options or deploy contracts first.\");\n }\n\n private getSchemaRegistryAddress(): Address {\n if (this.options.schemaRegistryContractAddress) {\n return this.options.schemaRegistryContractAddress;\n }\n if (this.deployedAddresses?.schemaRegistryAddress) {\n return this.deployedAddresses.schemaRegistryAddress;\n }\n throw new Error(\n \"Schema Registry contract address not available. Please provide it in options or deploy contracts first.\",\n );\n }\n\n private buildSchemaString(fields: SchemaField[]): string {\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n }\n}\n\n/**\n * Create an EAS client instance\n *\n * @param options - Configuration options for the EAS client\n * @returns EAS client instance\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Use the client\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * ```\n */\nexport function createEASClient(options: EASClientOptions): EASClient {\n return new EASClient(options);\n}\n\n// Re-export GraphQL operations for advanced usage\nexport { GraphQLOperations } from \"./portal/operations.js\";\n// Re-export types and constants\nexport type {\n AttestationData,\n AttestationInfo,\n AttestationRequest,\n DeploymentResult,\n EASClientOptions,\n EASFieldType,\n GetAttestationsOptions,\n GetSchemasOptions,\n RegisterSchemaOptions,\n SchemaData,\n SchemaField,\n SchemaRequest,\n TransactionResult,\n} from \"./schema.js\";\nexport { EAS_FIELD_TYPES, ZERO_ADDRESS, ZERO_BYTES32 } from \"./schema.js\";\n// Re-export validation utilities\nexport { EASClientOptionsSchema } from \"./utils/validation.js\";\n"],"mappings":";;;;;;;;AAEA,MAAa,oBAAoB;CAC/B,WAAW;EACT,uBAAuB,YACrB,QAAQ;;;;;;;;;WASH;EAEP,YAAY,YACV,QAAQ;;;;;WAKH;EAEP,iBAAiB,YACf,QAAQ;;;;;;;;;;WAUH;EAEP,SAAS,YACP,QAAQ;;;;;WAKH;EAEP,cAAc,YACZ,QAAQ;;;;;WAKH;EAEP,SAAS,YACP,QAAQ;;;;;WAKH;EACR;CAED,SAAS;EACP,YAAY,YACV,QAAQ;;;;;;;;;;WAUH;EAEP,iBAAiB,YACf,QAAQ;;;;;;;;;;;;;;;;WAgBH;EAEP,qBAAqB,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BAAmB,YAAY;AACtC,UAAO,KAAK,kBAAkB;;AAEhC,QAAM,IAAI,MAAM,8FAA8F;;CAGhH,AAAQ,2BAAoC;AAC1C,MAAI,KAAK,QAAQ,+BAA+B;AAC9C,UAAO,KAAK,QAAQ;;AAEtB,MAAI,KAAK,mBAAmB,uBAAuB;AACjD,UAAO,KAAK,kBAAkB;;AAEhC,QAAM,IAAI,MACR,0GACD;;CAGH,AAAQ,kBAAkB,QAA+B;AACvD,SAAO,OAAO,KAAK,UAAU,GAAG,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;;AAuB1E,SAAgB,gBAAgB,SAAsC;AACpE,QAAO,IAAI,UAAU,QAAQ"}
|
package/dist/eas.cjs
CHANGED
|
@@ -22,11 +22,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let __settlemint_sdk_portal = require("@settlemint/sdk-portal");
|
|
26
|
+
__settlemint_sdk_portal = __toESM(__settlemint_sdk_portal);
|
|
27
|
+
let __settlemint_sdk_utils_logging = require("@settlemint/sdk-utils/logging");
|
|
28
|
+
__settlemint_sdk_utils_logging = __toESM(__settlemint_sdk_utils_logging);
|
|
29
|
+
let __settlemint_sdk_utils_validation = require("@settlemint/sdk-utils/validation");
|
|
30
|
+
__settlemint_sdk_utils_validation = __toESM(__settlemint_sdk_utils_validation);
|
|
31
|
+
let viem = require("viem");
|
|
32
|
+
viem = __toESM(viem);
|
|
33
|
+
let zod = require("zod");
|
|
34
|
+
zod = __toESM(zod);
|
|
30
35
|
|
|
31
36
|
//#region src/portal/operations.ts
|
|
32
37
|
const GraphQLOperations = {
|
package/dist/eas.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eas.cjs","names":["zeroAddress","z","UrlSchema","ApplicationAccessTokenSchema"],"sources":["../src/portal/operations.ts","../src/schema.ts","../src/utils/validation.ts","../src/eas.ts"],"sourcesContent":["import type { PortalClient } from \"./portal-client.js\";\n\nexport const GraphQLOperations = {\n mutations: {\n deploySchemaRegistry: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEASSchemaRegistry(\n $from: String!\n $constructorArguments: DeployContractEASSchemaRegistryInput!\n $gasLimit: String!\n ) {\n DeployContractEASSchemaRegistry(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n deployEAS: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {\n DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n registerSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASSchemaRegistryRegister(\n $address: String!\n $from: String!\n $input: EASSchemaRegistryRegisterInput!\n $gasLimit: String!\n ) {\n EASSchemaRegistryRegister(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n attest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {\n EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n multiAttest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {\n EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n revoke: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {\n EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n },\n\n queries: {\n getSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASSchemaRegistryGetSchema($address: String!, $uid: String!) {\n EASSchemaRegistry(address: $address) {\n getSchema(uid: $uid) {\n uid\n resolver\n revocable\n schema\n }\n }\n }`),\n\n getAttestation: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetAttestation($address: String!, $uid: String!) {\n EAS(address: $address) {\n getAttestation(uid: $uid) {\n uid\n schema\n attester\n recipient\n time\n expirationTime\n revocable\n refUID\n data\n revocationTime\n }\n }\n }`),\n\n isAttestationValid: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASIsAttestationValid($address: String!, $uid: String!) {\n EAS(address: $address) {\n isAttestationValid(uid: $uid)\n }\n }`),\n\n getTimestamp: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetTimestamp($address: String!, $data: String!) {\n EAS(address: $address) {\n getTimestamp(data: $data)\n }\n }`),\n },\n};\n","import { type Address, type Hex, zeroAddress } from \"viem\";\nimport type { z } from \"zod\";\nimport type { EASClientOptionsSchema } from \"./utils/validation.js\";\n\n/**\n * Common address constants\n */\nexport const ZERO_ADDRESS = zeroAddress;\nexport const ZERO_BYTES32 = \"0x0000000000000000000000000000000000000000000000000000000000000000\" as Hex;\n\n/**\n * Supported field types for EAS schema fields.\n * Maps to the Solidity types that can be used in EAS schemas.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Represents a single field in an EAS schema.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The Solidity type of the field */\n type: EASFieldType;\n /** Optional description of the field's purpose */\n description?: string;\n}\n\n/**\n * Configuration options for the EAS client\n */\nexport type EASClientOptions = z.infer<typeof EASClientOptionsSchema>;\n\n/**\n * Schema registration request\n */\nexport interface SchemaRequest {\n /** Schema fields (alternative to schema string) */\n fields?: SchemaField[];\n /** Raw schema string (alternative to fields) */\n schema?: string;\n /** Resolver contract address (use ZERO_ADDRESS for no resolver) */\n resolver: Address;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Attestation data structure\n */\nexport interface AttestationData {\n /** Recipient of the attestation */\n recipient: Address;\n /** Expiration time (0 for no expiration) */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID (use ZERO_BYTES32 for no reference) */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Attestation request\n */\nexport interface AttestationRequest {\n /** Schema UID to attest against */\n schema: Hex;\n /** Attestation data */\n data: AttestationData;\n}\n\n/**\n * Transaction result\n */\nexport interface TransactionResult {\n /** Transaction hash */\n hash: Hex;\n /** Whether the transaction was successful */\n success: boolean;\n}\n\n/**\n * Schema information\n */\nexport interface SchemaData {\n /** Schema UID */\n uid: Hex;\n /** Resolver contract address */\n resolver: Address;\n /** Whether attestations can be revoked */\n revocable: boolean;\n /** Schema string */\n schema: string;\n}\n\n/**\n * Attestation information\n */\nexport interface AttestationInfo {\n /** Attestation UID */\n uid: Hex;\n /** Schema UID */\n schema: Hex;\n /** Address that created the attestation */\n attester: Address;\n /** Recipient of the attestation */\n recipient: Address;\n /** Creation timestamp */\n time: bigint;\n /** Expiration timestamp */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Options for retrieving schemas\n */\nexport interface GetSchemasOptions {\n /** Maximum number of schemas to return */\n limit?: number;\n /** Number of schemas to skip */\n offset?: number;\n}\n\n/**\n * Options for retrieving attestations\n */\nexport interface GetAttestationsOptions {\n /** Maximum number of attestations to return */\n limit?: number;\n /** Number of attestations to skip */\n offset?: number;\n /** Filter by schema UID */\n schema?: Hex;\n /** Filter by attester address */\n attester?: Address;\n /** Filter by recipient address */\n recipient?: Address;\n}\n\n/**\n * Contract deployment result\n */\nexport interface DeploymentResult {\n /** Deployed EAS contract address */\n easAddress: Address;\n /** Deployed Schema Registry contract address */\n schemaRegistryAddress: Address;\n /** EAS deployment transaction hash (when address not immediately available) */\n easTransactionHash?: Hex;\n /** Schema Registry deployment transaction hash (when address not immediately available) */\n schemaRegistryTransactionHash?: Hex;\n}\n\n/**\n * @deprecated Use SchemaRequest instead\n * @internal\n */\nexport interface RegisterSchemaOptions extends SchemaRequest {}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { type Address, isAddress } from \"viem\";\nimport { z } from \"zod\";\n\nconst ethAddressSchema = z.custom<Address>(\n (val) => typeof val === \"string\" && isAddress(val),\n \"Invalid Ethereum address\",\n);\n\n/**\n * Zod schema for EASClientOptions.\n */\nexport const EASClientOptionsSchema = z.object({\n /**\n * The EAS instance URL\n */\n instance: UrlSchema,\n /**\n * The application access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The EAS contract address\n */\n easContractAddress: ethAddressSchema.optional(),\n /**\n * The schema registry contract address\n */\n schemaRegistryContractAddress: ethAddressSchema.optional(),\n /**\n * Whether to enable debug mode\n */\n debug: z.boolean().optional(),\n});\n","import { createPortalClient, waitForTransactionReceipt } from \"@settlemint/sdk-portal\";\nimport { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport type { Address, Hex } from \"viem\";\nimport { GraphQLOperations } from \"./portal/operations.js\";\nimport type { PortalClient } from \"./portal/portal-client.js\";\nimport type { introspection } from \"./portal/portal-env.d.ts\";\nimport {\n type AttestationInfo,\n type AttestationRequest,\n type DeploymentResult,\n type EASClientOptions,\n type GetAttestationsOptions,\n type GetSchemasOptions,\n type SchemaData,\n type SchemaField,\n type SchemaRequest,\n type TransactionResult,\n ZERO_ADDRESS,\n} from \"./schema.js\";\nimport { EASClientOptionsSchema } from \"./utils/validation.js\";\n\nconst LOGGER = createLogger();\n\nconst DEFAULT_GAS_LIMIT = \"0x3d0900\";\n\n/**\n * Main EAS client class for interacting with Ethereum Attestation Service via Portal\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Deploy EAS contracts\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * console.log(\"EAS deployed at:\", deployment.easAddress);\n * ```\n */\nexport class EASClient {\n private readonly options: EASClientOptions;\n private readonly portalClient: PortalClient[\"client\"];\n private readonly portalGraphql: PortalClient[\"graphql\"];\n private deployedAddresses?: DeploymentResult;\n\n /**\n * Create a new EAS client instance\n *\n * @param options - Configuration options for the EAS client\n */\n constructor(options: EASClientOptions) {\n this.options = validate(EASClientOptionsSchema, options);\n\n const { client: portalClient, graphql: portalGraphql } = createPortalClient<{\n introspection: introspection;\n disableMasking: true;\n scalars: {\n // Change unknown to the type you are using to store metadata\n JSON: unknown;\n };\n }>(\n {\n instance: this.options.instance,\n accessToken: this.options.accessToken,\n },\n {\n fetch: requestLogger(LOGGER, \"portal\", fetch) as typeof fetch,\n },\n );\n\n this.portalClient = portalClient;\n this.portalGraphql = portalGraphql;\n }\n\n /**\n * Deploy EAS contracts via Portal\n *\n * @param deployerAddress - The address that will deploy the contracts\n * @param forwarderAddress - Optional trusted forwarder address (defaults to zero address)\n * @param gasLimit - Optional gas limit for deployment transactions (defaults to \"0x7a1200\")\n * @returns Promise resolving to deployment result with contract addresses and transaction hashes\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const deployment = await easClient.deploy(\n * \"0x1234567890123456789012345678901234567890\", // deployer address\n * \"0x0000000000000000000000000000000000000000\", // forwarder (optional)\n * \"0x7a1200\" // gas limit (optional)\n * );\n *\n * console.log(\"Schema Registry:\", deployment.schemaRegistryAddress);\n * console.log(\"EAS Contract:\", deployment.easAddress);\n * ```\n */\n public async deploy(\n deployerAddress: Address,\n forwarderAddress?: Address,\n gasLimit?: string,\n ): Promise<DeploymentResult> {\n const defaultForwarder = forwarderAddress || ZERO_ADDRESS;\n const defaultGasLimit = gasLimit || \"0x7a1200\";\n\n try {\n // Deploy Schema Registry first\n const schemaRegistryResponse = await this.portalClient.request(\n GraphQLOperations.mutations.deploySchemaRegistry(this.portalGraphql),\n {\n from: deployerAddress,\n constructorArguments: {\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n },\n );\n\n if (!schemaRegistryResponse.DeployContractEASSchemaRegistry?.transactionHash) {\n throw new Error(\"Schema Registry deployment failed - no transaction hash returned\");\n }\n\n const schemaRegistryTxHash = schemaRegistryResponse.DeployContractEASSchemaRegistry.transactionHash;\n\n // Wait for Schema Registry deployment and get contract address\n const schemaRegistryTransaction = await waitForTransactionReceipt(schemaRegistryTxHash as Hex, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!schemaRegistryTransaction?.receipt?.contractAddress) {\n throw new Error(\"Schema Registry deployment failed - could not get contract address from transaction receipt.\");\n }\n\n const schemaRegistryAddress = schemaRegistryTransaction.receipt.contractAddress;\n\n // Deploy EAS contract with correct Schema Registry address\n const easResponse = await this.portalClient.request(GraphQLOperations.mutations.deployEAS(this.portalGraphql), {\n from: deployerAddress,\n constructorArguments: {\n registry: schemaRegistryAddress,\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n });\n if (!easResponse.DeployContractEAS?.transactionHash) {\n throw new Error(\"EAS deployment failed - no transaction hash returned\");\n }\n\n const easTxHash = easResponse.DeployContractEAS.transactionHash as Hex;\n\n // Wait for EAS deployment and get contract address\n const easTransaction = await waitForTransactionReceipt(easTxHash, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!easTransaction?.receipt?.contractAddress) {\n throw new Error(\"EAS deployment failed - could not get contract address from transaction receipt.\");\n }\n const easAddress = easTransaction.receipt.contractAddress;\n\n this.deployedAddresses = {\n easAddress,\n schemaRegistryAddress,\n easTransactionHash: easTxHash as Hex,\n schemaRegistryTransactionHash: schemaRegistryTxHash as Hex,\n };\n\n return this.deployedAddresses;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to deploy EAS contracts: ${error.message}`);\n }\n }\n\n /**\n * Register a new schema in the EAS Schema Registry\n *\n * @param request - Schema registration request containing schema definition\n * @param fromAddress - Address that will register the schema\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const schemaResult = await easClient.registerSchema(\n * {\n * schema: \"uint256 eventId, uint8 voteIndex\",\n * resolver: \"0x0000000000000000000000000000000000000000\",\n * revocable: true\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Schema registered:\", schemaResult.hash);\n * ```\n */\n public async registerSchema(\n request: SchemaRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n let schemaString = request.schema;\n if (request.fields && !schemaString) {\n schemaString = this.buildSchemaString(request.fields);\n }\n\n if (!schemaString) {\n throw new Error(\"Schema string is required. Provide either 'schema' or 'fields'.\");\n }\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.registerSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n from: fromAddress,\n input: {\n schema: schemaString,\n resolver: request.resolver,\n revocable: request.revocable,\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASSchemaRegistryRegister?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to register schema: ${error.message}`);\n }\n }\n\n /**\n * Create an attestation\n *\n * @param request - Attestation request containing schema and data\n * @param fromAddress - Address that will create the attestation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const attestationResult = await easClient.attest(\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0), // No expiration\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\", // ABI-encoded data\n * value: BigInt(0)\n * }\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Attestation created:\", attestationResult.hash);\n * ```\n */\n public async attest(\n request: AttestationRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.attest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n request: {\n schema: request.schema,\n data: {\n recipient: request.data.recipient,\n expirationTime: request.data.expirationTime.toString(),\n revocable: request.data.revocable,\n refUID: request.data.refUID,\n data: request.data.data,\n value: request.data.value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create attestation: ${error.message}`);\n }\n }\n\n /**\n * Create multiple attestations in a single transaction\n *\n * @param requests - Array of attestation requests\n * @param fromAddress - Address that will create the attestations\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const multiAttestResult = await easClient.multiAttest(\n * [\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0),\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\",\n * value: BigInt(0)\n * }\n * },\n * {\n * schema: \"0x5678901234567890123456789012345678901234567890123456789012345678\",\n * data: {\n * recipient: \"0x5678901234567890123456789012345678901234\",\n * expirationTime: BigInt(0),\n * revocable: false,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x5678\",\n * value: BigInt(0)\n * }\n * }\n * ],\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Multiple attestations created:\", multiAttestResult.hash);\n * ```\n */\n public async multiAttest(\n requests: AttestationRequest[],\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n if (requests.length === 0) {\n throw new Error(\"At least one attestation request is required\");\n }\n\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.multiAttest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n multiRequests: requests.map((req) => ({\n schema: req.schema,\n data: [\n {\n recipient: req.data.recipient,\n expirationTime: req.data.expirationTime.toString(),\n revocable: req.data.revocable,\n refUID: req.data.refUID,\n data: req.data.data,\n value: req.data.value?.toString() || \"0\",\n },\n ],\n })),\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASMultiAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create multiple attestations: ${error.message}`);\n }\n }\n\n /**\n * Revoke an existing attestation\n *\n * @param schemaUID - UID of the schema used for the attestation\n * @param attestationUID - UID of the attestation to revoke\n * @param fromAddress - Address that will revoke the attestation\n * @param value - Optional ETH value to send with the revocation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const revokeResult = await easClient.revoke(\n * \"0x1234567890123456789012345678901234567890123456789012345678901234\", // schema UID\n * \"0x5678901234567890123456789012345678901234567890123456789012345678\", // attestation UID\n * \"0x1234567890123456789012345678901234567890\", // from address\n * BigInt(0) // value (optional)\n * );\n *\n * console.log(\"Attestation revoked:\", revokeResult.hash);\n * ```\n */\n public async revoke(\n schemaUID: Hex,\n attestationUID: Hex,\n fromAddress: Address,\n value?: bigint,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.revoke(this.portalGraphql), {\n address: this.getEASAddress(),\n from: fromAddress,\n input: {\n request: {\n schema: schemaUID,\n data: {\n uid: attestationUID,\n value: value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASRevoke?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to revoke attestation: ${error.message}`);\n }\n }\n\n /**\n * Get a schema by UID\n */\n public async getSchema(uid: Hex): Promise<SchemaData> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n uid: uid,\n });\n\n const schemaResult = response.EASSchemaRegistry?.getSchema;\n\n if (!schemaResult) {\n throw new Error(`Schema not found: ${uid}`);\n }\n\n return {\n uid: schemaResult.uid as Hex,\n resolver: schemaResult.resolver as Address,\n revocable: Boolean(schemaResult.revocable),\n schema: schemaResult.schema || \"\",\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get schema: ${error.message}`);\n }\n }\n\n /**\n * Get all schemas with pagination\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all schemas.\n * Consider using getSchema() for individual schema lookups.\n */\n public async getSchemas(_options?: GetSchemasOptions): Promise<SchemaData[]> {\n throw new Error(\n \"Schema listing not implemented yet. Portal's direct contract queries don't support listing all schemas. Use getSchema() for individual schema lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Get an attestation by UID\n */\n public async getAttestation(uid: Hex): Promise<AttestationInfo> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getAttestation(this.portalGraphql), {\n address: easAddress,\n uid: uid,\n });\n\n const attestationResult = response.EAS?.getAttestation;\n\n if (!attestationResult) {\n throw new Error(`Attestation not found: ${uid}`);\n }\n\n return {\n uid: attestationResult.uid as Hex,\n schema: attestationResult.schema as Hex,\n attester: attestationResult.attester as Address,\n recipient: attestationResult.recipient as Address,\n time: attestationResult.time ? BigInt(attestationResult.time) : BigInt(0),\n expirationTime: attestationResult.expirationTime ? BigInt(attestationResult.expirationTime) : BigInt(0),\n revocable: Boolean(attestationResult.revocable),\n refUID: attestationResult.refUID as Hex,\n data: attestationResult.data as Hex,\n value: BigInt(0), // Note: Portal schema doesn't include value, defaulting to 0\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get attestation: ${error.message}`);\n }\n }\n\n /**\n * Get attestations with pagination and filtering\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all attestations.\n * Consider using getAttestation() for individual attestation lookups.\n */\n public async getAttestations(_options?: GetAttestationsOptions): Promise<AttestationInfo[]> {\n throw new Error(\n \"Attestation listing not implemented yet. Portal's direct contract queries don't support listing all attestations. Use getAttestation() for individual attestation lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Check if an attestation is valid\n */\n public async isValidAttestation(uid: Hex): Promise<boolean> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(\n GraphQLOperations.queries.isAttestationValid(this.portalGraphql),\n {\n address: easAddress,\n uid: uid,\n },\n );\n\n return response.EAS?.isAttestationValid ?? false;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to check attestation validity: ${error.message}`);\n }\n }\n\n /**\n * Get the timestamp for specific data\n *\n * @param data - The data to get timestamp for\n * @returns The timestamp when the data was timestamped\n */\n public async getTimestamp(data: Hex): Promise<bigint> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getTimestamp(this.portalGraphql), {\n address: easAddress,\n data: data,\n });\n\n const timestampResult = response.EAS?.getTimestamp;\n\n if (timestampResult === undefined || timestampResult === null) {\n throw new Error(`No timestamp found for data: ${data}`);\n }\n\n return BigInt(timestampResult);\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get timestamp: ${error.message}`);\n }\n }\n\n /**\n * Get client configuration\n */\n public getOptions(): EASClientOptions {\n return { ...this.options };\n }\n\n /**\n * Get the Portal client instance for advanced operations\n */\n public getPortalClient(): PortalClient[\"client\"] {\n return this.portalClient;\n }\n\n /**\n * Get current contract addresses\n */\n public getContractAddresses(): { easAddress?: Address; schemaRegistryAddress?: Address } {\n return {\n easAddress: this.options.easContractAddress || this.deployedAddresses?.easAddress,\n schemaRegistryAddress:\n this.options.schemaRegistryContractAddress || this.deployedAddresses?.schemaRegistryAddress,\n };\n }\n\n private getEASAddress(): Address {\n if (this.options.easContractAddress) {\n return this.options.easContractAddress;\n }\n if (this.deployedAddresses?.easAddress) {\n return this.deployedAddresses.easAddress;\n }\n throw new Error(\"EAS contract address not available. Please provide it in options or deploy contracts first.\");\n }\n\n private getSchemaRegistryAddress(): Address {\n if (this.options.schemaRegistryContractAddress) {\n return this.options.schemaRegistryContractAddress;\n }\n if (this.deployedAddresses?.schemaRegistryAddress) {\n return this.deployedAddresses.schemaRegistryAddress;\n }\n throw new Error(\n \"Schema Registry contract address not available. Please provide it in options or deploy contracts first.\",\n );\n }\n\n private buildSchemaString(fields: SchemaField[]): string {\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n }\n}\n\n/**\n * Create an EAS client instance\n *\n * @param options - Configuration options for the EAS client\n * @returns EAS client instance\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Use the client\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * ```\n */\nexport function createEASClient(options: EASClientOptions): EASClient {\n return new EASClient(options);\n}\n\n// Re-export GraphQL operations for advanced usage\nexport { GraphQLOperations } from \"./portal/operations.js\";\n// Re-export types and constants\nexport type {\n AttestationData,\n AttestationInfo,\n AttestationRequest,\n DeploymentResult,\n EASClientOptions,\n EASFieldType,\n GetAttestationsOptions,\n GetSchemasOptions,\n RegisterSchemaOptions,\n SchemaData,\n SchemaField,\n SchemaRequest,\n TransactionResult,\n} from \"./schema.js\";\nexport { EAS_FIELD_TYPES, ZERO_ADDRESS, ZERO_BYTES32 } from \"./schema.js\";\n// Re-export validation utilities\nexport { EASClientOptionsSchema } from \"./utils/validation.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,oBAAoB;CAC/B,WAAW;EACT,uBAAuB,YACrB,QAAQ;;;;;;;;;;EAWV,YAAY,YACV,QAAQ;;;;;;EAOV,iBAAiB,YACf,QAAQ;;;;;;;;;;;EAYV,SAAS,YACP,QAAQ;;;;;;EAOV,cAAc,YACZ,QAAQ;;;;;;EAOV,SAAS,YACP,QAAQ;;;;;;;CAQZ,SAAS;EACP,YAAY,YACV,QAAQ;;;;;;;;;;;EAYV,iBAAiB,YACf,QAAQ;;;;;;;;;;;;;;;;;EAkBV,qBAAqB,YACnB,QAAQ;;;;;;EAOV,eAAe,YACb,QAAQ;;;;;;;;;;;;;;ACjGd,MAAa,eAAeA;AAC5B,MAAa,eAAe;;;;;AAM5B,MAAa,kBAAkB;CAC7B,QAAQ;CACR,SAAS;CACT,MAAM;CACN,OAAO;CACP,SAAS;CACT,SAAS;CACT,QAAQ;CACR,OAAO;CACP,MAAM;;;;;ACnBR,MAAM,mBAAmBC,MAAE,QACxB,QAAQ,OAAO,QAAQ,gCAAsB,MAC9C;;;;AAMF,MAAa,yBAAyBA,MAAE,OAAO;CAI7C,UAAUC;CAIV,aAAaC,+DAA6B;CAI1C,oBAAoB,iBAAiB;CAIrC,+BAA+B,iBAAiB;CAIhD,OAAOF,MAAE,UAAU;;;;;ACVrB,MAAM;AAEN,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;AAmB1B,IAAa,YAAb,MAAuB;CACrB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ;;;;;;CAOR,YAAY,SAA2B;AACrC,OAAK,0DAAmB,wBAAwB;EAEhD,MAAM,EAAE,QAAQ,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AA+B;AAC9C,UAAO,KAAK,QAAQ;;AAEtB,MAAI,KAAK,mBAAmB,uBAAuB;AACjD,UAAO,KAAK,kBAAkB;;AAEhC,QAAM,IAAI,MACR;;CAIJ,AAAQ,kBAAkB,QAA+B;AACvD,SAAO,OAAO,KAAK,UAAU,GAAG,MAAM,KAAK,GAAG,MAAM,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;AAuBrE,SAAgB,gBAAgB,SAAsC;AACpE,QAAO,IAAI,UAAU"}
|
|
1
|
+
{"version":3,"file":"eas.cjs","names":["zeroAddress","z","UrlSchema","ApplicationAccessTokenSchema"],"sources":["../src/portal/operations.ts","../src/schema.ts","../src/utils/validation.ts","../src/eas.ts"],"sourcesContent":["import type { PortalClient } from \"./portal-client.js\";\n\nexport const GraphQLOperations = {\n mutations: {\n deploySchemaRegistry: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEASSchemaRegistry(\n $from: String!\n $constructorArguments: DeployContractEASSchemaRegistryInput!\n $gasLimit: String!\n ) {\n DeployContractEASSchemaRegistry(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n deployEAS: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {\n DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n registerSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASSchemaRegistryRegister(\n $address: String!\n $from: String!\n $input: EASSchemaRegistryRegisterInput!\n $gasLimit: String!\n ) {\n EASSchemaRegistryRegister(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n attest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {\n EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n multiAttest: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {\n EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n\n revoke: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {\n EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {\n transactionHash\n }\n }`),\n },\n\n queries: {\n getSchema: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASSchemaRegistryGetSchema($address: String!, $uid: String!) {\n EASSchemaRegistry(address: $address) {\n getSchema(uid: $uid) {\n uid\n resolver\n revocable\n schema\n }\n }\n }`),\n\n getAttestation: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetAttestation($address: String!, $uid: String!) {\n EAS(address: $address) {\n getAttestation(uid: $uid) {\n uid\n schema\n attester\n recipient\n time\n expirationTime\n revocable\n refUID\n data\n revocationTime\n }\n }\n }`),\n\n isAttestationValid: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASIsAttestationValid($address: String!, $uid: String!) {\n EAS(address: $address) {\n isAttestationValid(uid: $uid)\n }\n }`),\n\n getTimestamp: (graphql: PortalClient[\"graphql\"]) =>\n graphql(`\n query EASGetTimestamp($address: String!, $data: String!) {\n EAS(address: $address) {\n getTimestamp(data: $data)\n }\n }`),\n },\n};\n","import { type Address, type Hex, zeroAddress } from \"viem\";\nimport type { z } from \"zod\";\nimport type { EASClientOptionsSchema } from \"./utils/validation.js\";\n\n/**\n * Common address constants\n */\nexport const ZERO_ADDRESS = zeroAddress;\nexport const ZERO_BYTES32 = \"0x0000000000000000000000000000000000000000000000000000000000000000\" as Hex;\n\n/**\n * Supported field types for EAS schema fields.\n * Maps to the Solidity types that can be used in EAS schemas.\n */\nexport const EAS_FIELD_TYPES = {\n string: \"string\",\n address: \"address\",\n bool: \"bool\",\n bytes: \"bytes\",\n bytes32: \"bytes32\",\n uint256: \"uint256\",\n int256: \"int256\",\n uint8: \"uint8\",\n int8: \"int8\",\n} as const;\n\nexport type EASFieldType = keyof typeof EAS_FIELD_TYPES;\n\n/**\n * Represents a single field in an EAS schema.\n */\nexport interface SchemaField {\n /** The name of the field */\n name: string;\n /** The Solidity type of the field */\n type: EASFieldType;\n /** Optional description of the field's purpose */\n description?: string;\n}\n\n/**\n * Configuration options for the EAS client\n */\nexport type EASClientOptions = z.infer<typeof EASClientOptionsSchema>;\n\n/**\n * Schema registration request\n */\nexport interface SchemaRequest {\n /** Schema fields (alternative to schema string) */\n fields?: SchemaField[];\n /** Raw schema string (alternative to fields) */\n schema?: string;\n /** Resolver contract address (use ZERO_ADDRESS for no resolver) */\n resolver: Address;\n /** Whether attestations using this schema can be revoked */\n revocable: boolean;\n}\n\n/**\n * Attestation data structure\n */\nexport interface AttestationData {\n /** Recipient of the attestation */\n recipient: Address;\n /** Expiration time (0 for no expiration) */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID (use ZERO_BYTES32 for no reference) */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Attestation request\n */\nexport interface AttestationRequest {\n /** Schema UID to attest against */\n schema: Hex;\n /** Attestation data */\n data: AttestationData;\n}\n\n/**\n * Transaction result\n */\nexport interface TransactionResult {\n /** Transaction hash */\n hash: Hex;\n /** Whether the transaction was successful */\n success: boolean;\n}\n\n/**\n * Schema information\n */\nexport interface SchemaData {\n /** Schema UID */\n uid: Hex;\n /** Resolver contract address */\n resolver: Address;\n /** Whether attestations can be revoked */\n revocable: boolean;\n /** Schema string */\n schema: string;\n}\n\n/**\n * Attestation information\n */\nexport interface AttestationInfo {\n /** Attestation UID */\n uid: Hex;\n /** Schema UID */\n schema: Hex;\n /** Address that created the attestation */\n attester: Address;\n /** Recipient of the attestation */\n recipient: Address;\n /** Creation timestamp */\n time: bigint;\n /** Expiration timestamp */\n expirationTime: bigint;\n /** Whether this attestation can be revoked */\n revocable: boolean;\n /** Reference UID */\n refUID: Hex;\n /** Encoded attestation data */\n data: Hex;\n /** Value sent with the attestation */\n value: bigint;\n}\n\n/**\n * Options for retrieving schemas\n */\nexport interface GetSchemasOptions {\n /** Maximum number of schemas to return */\n limit?: number;\n /** Number of schemas to skip */\n offset?: number;\n}\n\n/**\n * Options for retrieving attestations\n */\nexport interface GetAttestationsOptions {\n /** Maximum number of attestations to return */\n limit?: number;\n /** Number of attestations to skip */\n offset?: number;\n /** Filter by schema UID */\n schema?: Hex;\n /** Filter by attester address */\n attester?: Address;\n /** Filter by recipient address */\n recipient?: Address;\n}\n\n/**\n * Contract deployment result\n */\nexport interface DeploymentResult {\n /** Deployed EAS contract address */\n easAddress: Address;\n /** Deployed Schema Registry contract address */\n schemaRegistryAddress: Address;\n /** EAS deployment transaction hash (when address not immediately available) */\n easTransactionHash?: Hex;\n /** Schema Registry deployment transaction hash (when address not immediately available) */\n schemaRegistryTransactionHash?: Hex;\n}\n\n/**\n * @deprecated Use SchemaRequest instead\n * @internal\n */\nexport interface RegisterSchemaOptions extends SchemaRequest {}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { type Address, isAddress } from \"viem\";\nimport { z } from \"zod\";\n\nconst ethAddressSchema = z.custom<Address>(\n (val) => typeof val === \"string\" && isAddress(val),\n \"Invalid Ethereum address\",\n);\n\n/**\n * Zod schema for EASClientOptions.\n */\nexport const EASClientOptionsSchema = z.object({\n /**\n * The EAS instance URL\n */\n instance: UrlSchema,\n /**\n * The application access token\n */\n accessToken: ApplicationAccessTokenSchema.optional(),\n /**\n * The EAS contract address\n */\n easContractAddress: ethAddressSchema.optional(),\n /**\n * The schema registry contract address\n */\n schemaRegistryContractAddress: ethAddressSchema.optional(),\n /**\n * Whether to enable debug mode\n */\n debug: z.boolean().optional(),\n});\n","import { createPortalClient, waitForTransactionReceipt } from \"@settlemint/sdk-portal\";\nimport { createLogger, requestLogger } from \"@settlemint/sdk-utils/logging\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport type { Address, Hex } from \"viem\";\nimport { GraphQLOperations } from \"./portal/operations.js\";\nimport type { PortalClient } from \"./portal/portal-client.js\";\nimport type { introspection } from \"./portal/portal-env.d.ts\";\nimport {\n type AttestationInfo,\n type AttestationRequest,\n type DeploymentResult,\n type EASClientOptions,\n type GetAttestationsOptions,\n type GetSchemasOptions,\n type SchemaData,\n type SchemaField,\n type SchemaRequest,\n type TransactionResult,\n ZERO_ADDRESS,\n} from \"./schema.js\";\nimport { EASClientOptionsSchema } from \"./utils/validation.js\";\n\nconst LOGGER = createLogger();\n\nconst DEFAULT_GAS_LIMIT = \"0x3d0900\";\n\n/**\n * Main EAS client class for interacting with Ethereum Attestation Service via Portal\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Deploy EAS contracts\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * console.log(\"EAS deployed at:\", deployment.easAddress);\n * ```\n */\nexport class EASClient {\n private readonly options: EASClientOptions;\n private readonly portalClient: PortalClient[\"client\"];\n private readonly portalGraphql: PortalClient[\"graphql\"];\n private deployedAddresses?: DeploymentResult;\n\n /**\n * Create a new EAS client instance\n *\n * @param options - Configuration options for the EAS client\n */\n constructor(options: EASClientOptions) {\n this.options = validate(EASClientOptionsSchema, options);\n\n const { client: portalClient, graphql: portalGraphql } = createPortalClient<{\n introspection: introspection;\n disableMasking: true;\n scalars: {\n // Change unknown to the type you are using to store metadata\n JSON: unknown;\n };\n }>(\n {\n instance: this.options.instance,\n accessToken: this.options.accessToken,\n },\n {\n fetch: requestLogger(LOGGER, \"portal\", fetch) as typeof fetch,\n },\n );\n\n this.portalClient = portalClient;\n this.portalGraphql = portalGraphql;\n }\n\n /**\n * Deploy EAS contracts via Portal\n *\n * @param deployerAddress - The address that will deploy the contracts\n * @param forwarderAddress - Optional trusted forwarder address (defaults to zero address)\n * @param gasLimit - Optional gas limit for deployment transactions (defaults to \"0x7a1200\")\n * @returns Promise resolving to deployment result with contract addresses and transaction hashes\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const deployment = await easClient.deploy(\n * \"0x1234567890123456789012345678901234567890\", // deployer address\n * \"0x0000000000000000000000000000000000000000\", // forwarder (optional)\n * \"0x7a1200\" // gas limit (optional)\n * );\n *\n * console.log(\"Schema Registry:\", deployment.schemaRegistryAddress);\n * console.log(\"EAS Contract:\", deployment.easAddress);\n * ```\n */\n public async deploy(\n deployerAddress: Address,\n forwarderAddress?: Address,\n gasLimit?: string,\n ): Promise<DeploymentResult> {\n const defaultForwarder = forwarderAddress || ZERO_ADDRESS;\n const defaultGasLimit = gasLimit || \"0x7a1200\";\n\n try {\n // Deploy Schema Registry first\n const schemaRegistryResponse = await this.portalClient.request(\n GraphQLOperations.mutations.deploySchemaRegistry(this.portalGraphql),\n {\n from: deployerAddress,\n constructorArguments: {\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n },\n );\n\n if (!schemaRegistryResponse.DeployContractEASSchemaRegistry?.transactionHash) {\n throw new Error(\"Schema Registry deployment failed - no transaction hash returned\");\n }\n\n const schemaRegistryTxHash = schemaRegistryResponse.DeployContractEASSchemaRegistry.transactionHash;\n\n // Wait for Schema Registry deployment and get contract address\n const schemaRegistryTransaction = await waitForTransactionReceipt(schemaRegistryTxHash as Hex, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!schemaRegistryTransaction?.receipt?.contractAddress) {\n throw new Error(\"Schema Registry deployment failed - could not get contract address from transaction receipt.\");\n }\n\n const schemaRegistryAddress = schemaRegistryTransaction.receipt.contractAddress;\n\n // Deploy EAS contract with correct Schema Registry address\n const easResponse = await this.portalClient.request(GraphQLOperations.mutations.deployEAS(this.portalGraphql), {\n from: deployerAddress,\n constructorArguments: {\n registry: schemaRegistryAddress,\n forwarder: defaultForwarder,\n },\n gasLimit: defaultGasLimit,\n });\n if (!easResponse.DeployContractEAS?.transactionHash) {\n throw new Error(\"EAS deployment failed - no transaction hash returned\");\n }\n\n const easTxHash = easResponse.DeployContractEAS.transactionHash as Hex;\n\n // Wait for EAS deployment and get contract address\n const easTransaction = await waitForTransactionReceipt(easTxHash, {\n portalGraphqlEndpoint: this.options.instance,\n accessToken: this.options.accessToken,\n timeout: 60_000,\n });\n\n if (!easTransaction?.receipt?.contractAddress) {\n throw new Error(\"EAS deployment failed - could not get contract address from transaction receipt.\");\n }\n const easAddress = easTransaction.receipt.contractAddress;\n\n this.deployedAddresses = {\n easAddress,\n schemaRegistryAddress,\n easTransactionHash: easTxHash as Hex,\n schemaRegistryTransactionHash: schemaRegistryTxHash as Hex,\n };\n\n return this.deployedAddresses;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to deploy EAS contracts: ${error.message}`);\n }\n }\n\n /**\n * Register a new schema in the EAS Schema Registry\n *\n * @param request - Schema registration request containing schema definition\n * @param fromAddress - Address that will register the schema\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const schemaResult = await easClient.registerSchema(\n * {\n * schema: \"uint256 eventId, uint8 voteIndex\",\n * resolver: \"0x0000000000000000000000000000000000000000\",\n * revocable: true\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Schema registered:\", schemaResult.hash);\n * ```\n */\n public async registerSchema(\n request: SchemaRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n let schemaString = request.schema;\n if (request.fields && !schemaString) {\n schemaString = this.buildSchemaString(request.fields);\n }\n\n if (!schemaString) {\n throw new Error(\"Schema string is required. Provide either 'schema' or 'fields'.\");\n }\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.registerSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n from: fromAddress,\n input: {\n schema: schemaString,\n resolver: request.resolver,\n revocable: request.revocable,\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASSchemaRegistryRegister?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to register schema: ${error.message}`);\n }\n }\n\n /**\n * Create an attestation\n *\n * @param request - Attestation request containing schema and data\n * @param fromAddress - Address that will create the attestation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const attestationResult = await easClient.attest(\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0), // No expiration\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\", // ABI-encoded data\n * value: BigInt(0)\n * }\n * },\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Attestation created:\", attestationResult.hash);\n * ```\n */\n public async attest(\n request: AttestationRequest,\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.attest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n request: {\n schema: request.schema,\n data: {\n recipient: request.data.recipient,\n expirationTime: request.data.expirationTime.toString(),\n revocable: request.data.revocable,\n refUID: request.data.refUID,\n data: request.data.data,\n value: request.data.value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create attestation: ${error.message}`);\n }\n }\n\n /**\n * Create multiple attestations in a single transaction\n *\n * @param requests - Array of attestation requests\n * @param fromAddress - Address that will create the attestations\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const multiAttestResult = await easClient.multiAttest(\n * [\n * {\n * schema: \"0x1234567890123456789012345678901234567890123456789012345678901234\",\n * data: {\n * recipient: \"0x1234567890123456789012345678901234567890\",\n * expirationTime: BigInt(0),\n * revocable: true,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x1234\",\n * value: BigInt(0)\n * }\n * },\n * {\n * schema: \"0x5678901234567890123456789012345678901234567890123456789012345678\",\n * data: {\n * recipient: \"0x5678901234567890123456789012345678901234\",\n * expirationTime: BigInt(0),\n * revocable: false,\n * refUID: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n * data: \"0x5678\",\n * value: BigInt(0)\n * }\n * }\n * ],\n * \"0x1234567890123456789012345678901234567890\" // from address\n * );\n *\n * console.log(\"Multiple attestations created:\", multiAttestResult.hash);\n * ```\n */\n public async multiAttest(\n requests: AttestationRequest[],\n fromAddress: Address,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n if (requests.length === 0) {\n throw new Error(\"At least one attestation request is required\");\n }\n\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.multiAttest(this.portalGraphql), {\n address: easAddress,\n from: fromAddress,\n input: {\n multiRequests: requests.map((req) => ({\n schema: req.schema,\n data: [\n {\n recipient: req.data.recipient,\n expirationTime: req.data.expirationTime.toString(),\n revocable: req.data.revocable,\n refUID: req.data.refUID,\n data: req.data.data,\n value: req.data.value?.toString() || \"0\",\n },\n ],\n })),\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASMultiAttest?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to create multiple attestations: ${error.message}`);\n }\n }\n\n /**\n * Revoke an existing attestation\n *\n * @param schemaUID - UID of the schema used for the attestation\n * @param attestationUID - UID of the attestation to revoke\n * @param fromAddress - Address that will revoke the attestation\n * @param value - Optional ETH value to send with the revocation\n * @param gasLimit - Optional gas limit for the transaction (defaults to \"0x3d0900\")\n * @returns Promise resolving to transaction result\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * const revokeResult = await easClient.revoke(\n * \"0x1234567890123456789012345678901234567890123456789012345678901234\", // schema UID\n * \"0x5678901234567890123456789012345678901234567890123456789012345678\", // attestation UID\n * \"0x1234567890123456789012345678901234567890\", // from address\n * BigInt(0) // value (optional)\n * );\n *\n * console.log(\"Attestation revoked:\", revokeResult.hash);\n * ```\n */\n public async revoke(\n schemaUID: Hex,\n attestationUID: Hex,\n fromAddress: Address,\n value?: bigint,\n gasLimit?: string,\n ): Promise<TransactionResult> {\n try {\n const response = await this.portalClient.request(GraphQLOperations.mutations.revoke(this.portalGraphql), {\n address: this.getEASAddress(),\n from: fromAddress,\n input: {\n request: {\n schema: schemaUID,\n data: {\n uid: attestationUID,\n value: value?.toString() || \"0\",\n },\n },\n },\n gasLimit: gasLimit || DEFAULT_GAS_LIMIT,\n });\n\n const transactionHash = response.EASRevoke?.transactionHash;\n\n if (!transactionHash) {\n throw new Error(\"No transaction hash returned from Portal\");\n }\n\n return {\n hash: transactionHash as Hex,\n success: true,\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to revoke attestation: ${error.message}`);\n }\n }\n\n /**\n * Get a schema by UID\n */\n public async getSchema(uid: Hex): Promise<SchemaData> {\n const schemaRegistryAddress = this.getSchemaRegistryAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getSchema(this.portalGraphql), {\n address: schemaRegistryAddress,\n uid: uid,\n });\n\n const schemaResult = response.EASSchemaRegistry?.getSchema;\n\n if (!schemaResult) {\n throw new Error(`Schema not found: ${uid}`);\n }\n\n return {\n uid: schemaResult.uid as Hex,\n resolver: schemaResult.resolver as Address,\n revocable: Boolean(schemaResult.revocable),\n schema: schemaResult.schema || \"\",\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get schema: ${error.message}`);\n }\n }\n\n /**\n * Get all schemas with pagination\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all schemas.\n * Consider using getSchema() for individual schema lookups.\n */\n public async getSchemas(_options?: GetSchemasOptions): Promise<SchemaData[]> {\n throw new Error(\n \"Schema listing not implemented yet. Portal's direct contract queries don't support listing all schemas. Use getSchema() for individual schema lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Get an attestation by UID\n */\n public async getAttestation(uid: Hex): Promise<AttestationInfo> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getAttestation(this.portalGraphql), {\n address: easAddress,\n uid: uid,\n });\n\n const attestationResult = response.EAS?.getAttestation;\n\n if (!attestationResult) {\n throw new Error(`Attestation not found: ${uid}`);\n }\n\n return {\n uid: attestationResult.uid as Hex,\n schema: attestationResult.schema as Hex,\n attester: attestationResult.attester as Address,\n recipient: attestationResult.recipient as Address,\n time: attestationResult.time ? BigInt(attestationResult.time) : BigInt(0),\n expirationTime: attestationResult.expirationTime ? BigInt(attestationResult.expirationTime) : BigInt(0),\n revocable: Boolean(attestationResult.revocable),\n refUID: attestationResult.refUID as Hex,\n data: attestationResult.data as Hex,\n value: BigInt(0), // Note: Portal schema doesn't include value, defaulting to 0\n };\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get attestation: ${error.message}`);\n }\n }\n\n /**\n * Get attestations with pagination and filtering\n *\n * Note: This method requires The Graph subgraph or additional indexing infrastructure\n * as Portal's direct contract queries don't support listing all attestations.\n * Consider using getAttestation() for individual attestation lookups.\n */\n public async getAttestations(_options?: GetAttestationsOptions): Promise<AttestationInfo[]> {\n throw new Error(\n \"Attestation listing not implemented yet. Portal's direct contract queries don't support listing all attestations. Use getAttestation() for individual attestation lookups or implement The Graph subgraph integration for bulk queries.\",\n );\n }\n\n /**\n * Check if an attestation is valid\n */\n public async isValidAttestation(uid: Hex): Promise<boolean> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(\n GraphQLOperations.queries.isAttestationValid(this.portalGraphql),\n {\n address: easAddress,\n uid: uid,\n },\n );\n\n return response.EAS?.isAttestationValid ?? false;\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to check attestation validity: ${error.message}`);\n }\n }\n\n /**\n * Get the timestamp for specific data\n *\n * @param data - The data to get timestamp for\n * @returns The timestamp when the data was timestamped\n */\n public async getTimestamp(data: Hex): Promise<bigint> {\n const easAddress = this.getEASAddress();\n\n try {\n const response = await this.portalClient.request(GraphQLOperations.queries.getTimestamp(this.portalGraphql), {\n address: easAddress,\n data: data,\n });\n\n const timestampResult = response.EAS?.getTimestamp;\n\n if (timestampResult === undefined || timestampResult === null) {\n throw new Error(`No timestamp found for data: ${data}`);\n }\n\n return BigInt(timestampResult);\n } catch (err) {\n const error = err as Error;\n throw new Error(`Failed to get timestamp: ${error.message}`);\n }\n }\n\n /**\n * Get client configuration\n */\n public getOptions(): EASClientOptions {\n return { ...this.options };\n }\n\n /**\n * Get the Portal client instance for advanced operations\n */\n public getPortalClient(): PortalClient[\"client\"] {\n return this.portalClient;\n }\n\n /**\n * Get current contract addresses\n */\n public getContractAddresses(): { easAddress?: Address; schemaRegistryAddress?: Address } {\n return {\n easAddress: this.options.easContractAddress || this.deployedAddresses?.easAddress,\n schemaRegistryAddress:\n this.options.schemaRegistryContractAddress || this.deployedAddresses?.schemaRegistryAddress,\n };\n }\n\n private getEASAddress(): Address {\n if (this.options.easContractAddress) {\n return this.options.easContractAddress;\n }\n if (this.deployedAddresses?.easAddress) {\n return this.deployedAddresses.easAddress;\n }\n throw new Error(\"EAS contract address not available. Please provide it in options or deploy contracts first.\");\n }\n\n private getSchemaRegistryAddress(): Address {\n if (this.options.schemaRegistryContractAddress) {\n return this.options.schemaRegistryContractAddress;\n }\n if (this.deployedAddresses?.schemaRegistryAddress) {\n return this.deployedAddresses.schemaRegistryAddress;\n }\n throw new Error(\n \"Schema Registry contract address not available. Please provide it in options or deploy contracts first.\",\n );\n }\n\n private buildSchemaString(fields: SchemaField[]): string {\n return fields.map((field) => `${field.type} ${field.name}`).join(\", \");\n }\n}\n\n/**\n * Create an EAS client instance\n *\n * @param options - Configuration options for the EAS client\n * @returns EAS client instance\n *\n * @example\n * ```typescript\n * import { createEASClient } from \"@settlemint/sdk-eas\";\n *\n * const easClient = createEASClient({\n * instance: \"https://your-portal-instance.settlemint.com\",\n * accessToken: \"your-access-token\"\n * });\n *\n * // Use the client\n * const deployment = await easClient.deploy(\"0x1234...deployer-address\");\n * ```\n */\nexport function createEASClient(options: EASClientOptions): EASClient {\n return new EASClient(options);\n}\n\n// Re-export GraphQL operations for advanced usage\nexport { GraphQLOperations } from \"./portal/operations.js\";\n// Re-export types and constants\nexport type {\n AttestationData,\n AttestationInfo,\n AttestationRequest,\n DeploymentResult,\n EASClientOptions,\n EASFieldType,\n GetAttestationsOptions,\n GetSchemasOptions,\n RegisterSchemaOptions,\n SchemaData,\n SchemaField,\n SchemaRequest,\n TransactionResult,\n} from \"./schema.js\";\nexport { EAS_FIELD_TYPES, ZERO_ADDRESS, ZERO_BYTES32 } from \"./schema.js\";\n// Re-export validation utilities\nexport { EASClientOptionsSchema } from \"./utils/validation.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,oBAAoB;CAC/B,WAAW;EACT,uBAAuB,YACrB,QAAQ;;;;;;;;;WASH;EAEP,YAAY,YACV,QAAQ;;;;;WAKH;EAEP,iBAAiB,YACf,QAAQ;;;;;;;;;;WAUH;EAEP,SAAS,YACP,QAAQ;;;;;WAKH;EAEP,cAAc,YACZ,QAAQ;;;;;WAKH;EAEP,SAAS,YACP,QAAQ;;;;;WAKH;EACR;CAED,SAAS;EACP,YAAY,YACV,QAAQ;;;;;;;;;;WAUH;EAEP,iBAAiB,YACf,QAAQ;;;;;;;;;;;;;;;;WAgBH;EAEP,qBAAqB,YACnB,QAAQ;;;;;WAKH;EAEP,eAAe,YACb,QAAQ;;;;;WAKH;EACR;CACF;;;;;;;ACxGD,MAAa,eAAeA;AAC5B,MAAa,eAAe;;;;;AAM5B,MAAa,kBAAkB;CAC7B,QAAQ;CACR,SAAS;CACT,MAAM;CACN,OAAO;CACP,SAAS;CACT,SAAS;CACT,QAAQ;CACR,OAAO;CACP,MAAM;CACP;;;;ACpBD,MAAM,mBAAmBC,MAAE,QACxB,QA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