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