@trustvc/trustvc 2.6.0 → 2.7.0

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.
Files changed (32) hide show
  1. package/README.md +217 -0
  2. package/dist/cjs/document-store/contract-interfaces.js +24 -0
  3. package/dist/cjs/document-store/deploy.js +49 -0
  4. package/dist/cjs/document-store/document-store-roles.js +38 -0
  5. package/dist/cjs/document-store/index.js +46 -0
  6. package/dist/cjs/document-store/issue.js +71 -0
  7. package/dist/cjs/document-store/revoke.js +71 -0
  8. package/dist/cjs/document-store/supportInterfaceIds.js +22 -0
  9. package/dist/cjs/document-store/tt-document-store-abi.js +231 -0
  10. package/dist/cjs/index.js +21 -0
  11. package/dist/cjs/open-cert/verify.js +4 -6
  12. package/dist/esm/document-store/contract-interfaces.js +22 -0
  13. package/dist/esm/document-store/deploy.js +47 -0
  14. package/dist/esm/document-store/document-store-roles.js +35 -0
  15. package/dist/esm/document-store/index.js +5 -0
  16. package/dist/esm/document-store/issue.js +69 -0
  17. package/dist/esm/document-store/revoke.js +69 -0
  18. package/dist/esm/document-store/supportInterfaceIds.js +20 -0
  19. package/dist/esm/document-store/tt-document-store-abi.js +229 -0
  20. package/dist/esm/index.js +1 -0
  21. package/dist/esm/open-cert/verify.js +4 -6
  22. package/dist/types/document-store/contract-interfaces.d.ts +14 -0
  23. package/dist/types/document-store/deploy.d.ts +29 -0
  24. package/dist/types/document-store/document-store-roles.d.ts +14 -0
  25. package/dist/types/document-store/index.d.ts +11 -0
  26. package/dist/types/document-store/issue.d.ts +32 -0
  27. package/dist/types/document-store/revoke.d.ts +32 -0
  28. package/dist/types/document-store/supportInterfaceIds.d.ts +16 -0
  29. package/dist/types/document-store/tt-document-store-abi.d.ts +388 -0
  30. package/dist/types/index.d.ts +4 -0
  31. package/dist/types/open-cert/verify.d.ts +6 -6
  32. package/package.json +2 -1
@@ -0,0 +1,229 @@
1
+ const TT_DOCUMENT_STORE_ABI = [
2
+ // TODO: Replace with the actual full ABI
3
+ // Minimal ABI for issue function (0x0f75e81f)
4
+ {
5
+ inputs: [
6
+ { internalType: "string", name: "_name", type: "string" },
7
+ { internalType: "address", name: "owner", type: "address" }
8
+ ],
9
+ stateMutability: "nonpayable",
10
+ type: "constructor"
11
+ },
12
+ {
13
+ anonymous: false,
14
+ inputs: [{ indexed: true, internalType: "bytes32", name: "document", type: "bytes32" }],
15
+ name: "DocumentIssued",
16
+ type: "event"
17
+ },
18
+ {
19
+ anonymous: false,
20
+ inputs: [{ indexed: true, internalType: "bytes32", name: "document", type: "bytes32" }],
21
+ name: "DocumentRevoked",
22
+ type: "event"
23
+ },
24
+ {
25
+ anonymous: false,
26
+ inputs: [
27
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
28
+ { indexed: true, internalType: "bytes32", name: "previousAdminRole", type: "bytes32" },
29
+ { indexed: true, internalType: "bytes32", name: "newAdminRole", type: "bytes32" }
30
+ ],
31
+ name: "RoleAdminChanged",
32
+ type: "event"
33
+ },
34
+ {
35
+ anonymous: false,
36
+ inputs: [
37
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
38
+ { indexed: true, internalType: "address", name: "account", type: "address" },
39
+ { indexed: true, internalType: "address", name: "sender", type: "address" }
40
+ ],
41
+ name: "RoleGranted",
42
+ type: "event"
43
+ },
44
+ {
45
+ anonymous: false,
46
+ inputs: [
47
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
48
+ { indexed: true, internalType: "address", name: "account", type: "address" },
49
+ { indexed: true, internalType: "address", name: "sender", type: "address" }
50
+ ],
51
+ name: "RoleRevoked",
52
+ type: "event"
53
+ },
54
+ {
55
+ inputs: [],
56
+ name: "DEFAULT_ADMIN_ROLE",
57
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
58
+ stateMutability: "view",
59
+ type: "function"
60
+ },
61
+ {
62
+ inputs: [],
63
+ name: "ISSUER_ROLE",
64
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
65
+ stateMutability: "view",
66
+ type: "function"
67
+ },
68
+ {
69
+ inputs: [],
70
+ name: "REVOKER_ROLE",
71
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
72
+ stateMutability: "view",
73
+ type: "function"
74
+ },
75
+ {
76
+ inputs: [{ internalType: "bytes32[]", name: "documents", type: "bytes32[]" }],
77
+ name: "bulkIssue",
78
+ outputs: [],
79
+ stateMutability: "nonpayable",
80
+ type: "function"
81
+ },
82
+ {
83
+ inputs: [{ internalType: "bytes32[]", name: "documents", type: "bytes32[]" }],
84
+ name: "bulkRevoke",
85
+ outputs: [],
86
+ stateMutability: "nonpayable",
87
+ type: "function"
88
+ },
89
+ {
90
+ inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
91
+ name: "documentIssued",
92
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
93
+ stateMutability: "view",
94
+ type: "function"
95
+ },
96
+ {
97
+ inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
98
+ name: "documentRevoked",
99
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
100
+ stateMutability: "view",
101
+ type: "function"
102
+ },
103
+ {
104
+ inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
105
+ name: "getIssuedBlock",
106
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
107
+ stateMutability: "view",
108
+ type: "function"
109
+ },
110
+ {
111
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
112
+ name: "getRoleAdmin",
113
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
114
+ stateMutability: "view",
115
+ type: "function"
116
+ },
117
+ {
118
+ inputs: [
119
+ { internalType: "bytes32", name: "role", type: "bytes32" },
120
+ { internalType: "address", name: "account", type: "address" }
121
+ ],
122
+ name: "grantRole",
123
+ outputs: [],
124
+ stateMutability: "nonpayable",
125
+ type: "function"
126
+ },
127
+ {
128
+ inputs: [
129
+ { internalType: "bytes32", name: "role", type: "bytes32" },
130
+ { internalType: "address", name: "account", type: "address" }
131
+ ],
132
+ name: "hasRole",
133
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
134
+ stateMutability: "view",
135
+ type: "function"
136
+ },
137
+ {
138
+ inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
139
+ name: "isIssued",
140
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
141
+ stateMutability: "view",
142
+ type: "function"
143
+ },
144
+ {
145
+ inputs: [
146
+ { internalType: "bytes32", name: "document", type: "bytes32" },
147
+ { internalType: "uint256", name: "blockNumber", type: "uint256" }
148
+ ],
149
+ name: "isIssuedBefore",
150
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
151
+ stateMutability: "view",
152
+ type: "function"
153
+ },
154
+ {
155
+ inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
156
+ name: "isRevoked",
157
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
158
+ stateMutability: "view",
159
+ type: "function"
160
+ },
161
+ {
162
+ inputs: [
163
+ { internalType: "bytes32", name: "document", type: "bytes32" },
164
+ { internalType: "uint256", name: "blockNumber", type: "uint256" }
165
+ ],
166
+ name: "isRevokedBefore",
167
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
168
+ stateMutability: "view",
169
+ type: "function"
170
+ },
171
+ {
172
+ inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
173
+ name: "issue",
174
+ outputs: [],
175
+ stateMutability: "nonpayable",
176
+ type: "function"
177
+ },
178
+ {
179
+ inputs: [],
180
+ name: "name",
181
+ outputs: [{ internalType: "string", name: "", type: "string" }],
182
+ stateMutability: "view",
183
+ type: "function"
184
+ },
185
+ {
186
+ inputs: [
187
+ { internalType: "bytes32", name: "role", type: "bytes32" },
188
+ { internalType: "address", name: "account", type: "address" }
189
+ ],
190
+ name: "renounceRole",
191
+ outputs: [],
192
+ stateMutability: "nonpayable",
193
+ type: "function"
194
+ },
195
+ {
196
+ inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
197
+ name: "revoke",
198
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
199
+ stateMutability: "nonpayable",
200
+ type: "function"
201
+ },
202
+ {
203
+ inputs: [
204
+ { internalType: "bytes32", name: "role", type: "bytes32" },
205
+ { internalType: "address", name: "account", type: "address" }
206
+ ],
207
+ name: "revokeRole",
208
+ outputs: [],
209
+ stateMutability: "nonpayable",
210
+ type: "function"
211
+ },
212
+ {
213
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
214
+ name: "supportsInterface",
215
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
216
+ stateMutability: "view",
217
+ type: "function"
218
+ },
219
+ {
220
+ inputs: [],
221
+ name: "version",
222
+ outputs: [{ internalType: "string", name: "", type: "string" }],
223
+ stateMutability: "view",
224
+ type: "function"
225
+ }
226
+ // Add other functions from the ABI here (name, isIssued, isRevoked, etc.)
227
+ ];
228
+
229
+ export { TT_DOCUMENT_STORE_ABI };
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { v4ComputeInterfaceId, v4ComputeTitleEscrowAddress, v4ContractAddress, v4Contracts, v4EncodeInitParams, v4GetEventFromReceipt, v4RoleHash, v4SupportInterfaceIds, v4Utils } from './token-registry-v4';
2
2
  export { v5ComputeInterfaceId, v5ContractAddress, v5Contracts, v5EncodeInitParams, v5GetEventFromReceipt, v5RoleHash, v5SupportInterfaceIds, v5Utils } from './token-registry-v5';
3
+ export { DocumentStore__factory, TransferableDocumentStore__factory, deployDocumentStore, documentStoreIssue, documentStoreRevoke } from './document-store';
3
4
  export * from './token-registry-functions';
4
5
  export * from './core';
5
6
  export * from './open-attestation';
@@ -22,7 +22,7 @@ const OpencertsRegistryVerificationValidData = RegistryEntry.And(
22
22
  );
23
23
  const OpencertsRegistryVerificationInvalidData = Record({
24
24
  value: String,
25
- status: Literal("INVALID"),
25
+ status: Literal("SKIPPED"),
26
26
  reason: Reason
27
27
  });
28
28
  const OpencertsRegistryVerificationValidDataArray = Array(
@@ -50,7 +50,7 @@ const storeToData = /* @__PURE__ */ __name((registry, store) => {
50
50
  }
51
51
  return {
52
52
  value: store,
53
- status: "INVALID",
53
+ status: "SKIPPED",
54
54
  reason: {
55
55
  code: 0 /* INVALID_IDENTITY */,
56
56
  codeString: OpencertsRegistryCode[0 /* INVALID_IDENTITY */],
@@ -115,8 +115,7 @@ const registryVerifier = {
115
115
  return {
116
116
  type,
117
117
  name,
118
- status: "INVALID",
119
- data,
118
+ status: "SKIPPED",
120
119
  reason: data.reason
121
120
  };
122
121
  }
@@ -130,8 +129,7 @@ const registryVerifier = {
130
129
  return {
131
130
  type,
132
131
  name,
133
- status: "INVALID",
134
- data: issuerFragments,
132
+ status: "SKIPPED",
135
133
  reason: invalidIssuer.reason
136
134
  };
137
135
  } else if (OpencertsRegistryVerificationValidDataArray.guard(issuerFragments)) {
@@ -0,0 +1,14 @@
1
+ declare const contractInterfaces: {
2
+ /**
3
+ * IDocumentStore interface functions
4
+ * Functions: isActive, isIssued, isRevoked, name, revoke
5
+ */
6
+ DocumentStore: string[];
7
+ /**
8
+ * ITransferableDocumentStore interface functions
9
+ * Functions: isActive, isIssued, isRevoked, issue, name, revoke
10
+ */
11
+ TransferableDocumentStore: string[];
12
+ };
13
+
14
+ export { contractInterfaces };
@@ -0,0 +1,29 @@
1
+ import { Signer as Signer$1, ContractTransactionReceipt } from 'ethersV6';
2
+ import { Signer, ContractReceipt } from 'ethers';
3
+ import { CHAIN_ID } from '../utils/supportedChains/index.js';
4
+ import { GasValue } from '../token-registry-functions/types.js';
5
+ import '../utils/gasStation/index.js';
6
+ import '../utils/network/index.js';
7
+
8
+ /**
9
+ * Deploys a new DocumentStore contract.
10
+ * Supports both Ethers v5 and v6 signers.
11
+ * @param {string} storeName - The name of the document store.
12
+ * @param {string} owner - The owner address of the document store.
13
+ * @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the deployment.
14
+ * @param {DeployOptions} options - Optional transaction metadata including gas values and chain ID.
15
+ * @returns {Promise<TransactionReceipt>} A promise resolving to the deployed contract address and transaction hash.
16
+ * @throws {Error} If the signer provider is not provided.
17
+ * @throws {Error} If the store name or owner address is not provided.
18
+ * @throws {Error} If deployment fails.
19
+ */
20
+ interface DeployOptions {
21
+ chainId?: CHAIN_ID;
22
+ maxFeePerGas?: GasValue;
23
+ maxPriorityFeePerGas?: GasValue;
24
+ isTransferable?: boolean;
25
+ }
26
+ type TransactionReceipt = ContractReceipt | ContractTransactionReceipt;
27
+ declare const deployDocumentStore: (storeName: string, owner: string, signer: Signer | Signer$1, options?: DeployOptions) => Promise<TransactionReceipt>;
28
+
29
+ export { type DeployOptions, type TransactionReceipt, deployDocumentStore };
@@ -0,0 +1,14 @@
1
+ import { Provider } from 'ethersV6';
2
+ import { providers } from 'ethers';
3
+ import { CHAIN_ID } from '../utils/supportedChains/index.js';
4
+ import '../utils/gasStation/index.js';
5
+ import '../utils/network/index.js';
6
+
7
+ interface CallOptions {
8
+ chainId?: CHAIN_ID;
9
+ provider?: Provider | providers.Provider;
10
+ }
11
+ declare const getRoleString: (documentStoreAddress: string, role: string, options?: CallOptions) => Promise<string>;
12
+ declare const rolesList: string[];
13
+
14
+ export { getRoleString, rolesList };
@@ -0,0 +1,11 @@
1
+ export { IssueOptions, documentStoreIssue } from './issue.js';
2
+ export { RevokeOptions, documentStoreRevoke } from './revoke.js';
3
+ export { DeployOptions, deployDocumentStore } from './deploy.js';
4
+ export { supportInterfaceIds } from './supportInterfaceIds.js';
5
+ export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
6
+ import 'ethersV6';
7
+ import 'ethers';
8
+ import '../utils/supportedChains/index.js';
9
+ import '../utils/gasStation/index.js';
10
+ import '../utils/network/index.js';
11
+ import '../token-registry-functions/types.js';
@@ -0,0 +1,32 @@
1
+ import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { CHAIN_ID } from '../utils/supportedChains/index.js';
4
+ import { GasValue } from '../token-registry-functions/types.js';
5
+ import '../utils/gasStation/index.js';
6
+ import '../utils/network/index.js';
7
+
8
+ /**
9
+ * Issues a document hash to the DocumentStore contract.
10
+ * Supports both Ethers v5 and v6 signers.
11
+ * Supports three types of document stores:
12
+ * 1. DocumentStore (ERC-165 compliant)
13
+ * 2. TransferableDocumentStore (ERC-165 compliant)
14
+ * 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
15
+ * @param {string} documentStoreAddress - The address of the DocumentStore contract.
16
+ * @param {string} documentHash - The hash of the document to issue (must be a valid hex string).
17
+ * @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the issue transaction.
18
+ * @param {IssueOptions} options - Optional transaction metadata including gas values and chain ID.
19
+ * @returns {Promise<ContractTransactionV5 | ContractTransactionV6>} A promise resolving to the transaction result from the issue call.
20
+ * @throws {Error} If the document store address or signer provider is not provided.
21
+ * @throws {Error} If the document hash is invalid.
22
+ * @throws {Error} If the `callStatic.issue` fails as a pre-check.
23
+ */
24
+ interface IssueOptions {
25
+ chainId?: CHAIN_ID;
26
+ maxFeePerGas?: GasValue;
27
+ maxPriorityFeePerGas?: GasValue;
28
+ isTransferable?: boolean;
29
+ }
30
+ declare const documentStoreIssue: (documentStoreAddress: string, documentHash: string, signer: Signer | Signer$1, options?: IssueOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
31
+
32
+ export { type IssueOptions, documentStoreIssue };
@@ -0,0 +1,32 @@
1
+ import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { CHAIN_ID } from '../utils/supportedChains/index.js';
4
+ import { GasValue } from '../token-registry-functions/types.js';
5
+ import '../utils/gasStation/index.js';
6
+ import '../utils/network/index.js';
7
+
8
+ /**
9
+ * Revokes a document hash from the DocumentStore contract.
10
+ * Supports both Ethers v5 and v6 signers.
11
+ * Supports three types of document stores:
12
+ * 1. DocumentStore (ERC-165 compliant)
13
+ * 2. TransferableDocumentStore (ERC-165 compliant)
14
+ * 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
15
+ * @param {string} documentStoreAddress - The address of the DocumentStore contract.
16
+ * @param {string} documentHash - The hash of the document to revoke (must be a valid hex string).
17
+ * @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the revoke transaction.
18
+ * @param {RevokeOptions} options - Optional transaction metadata including gas values and chain ID.
19
+ * @returns {Promise<ContractTransactionV5 | ContractTransactionV6>} A promise resolving to the transaction result from the revoke call.
20
+ * @throws {Error} If the document store address or signer provider is not provided.
21
+ * @throws {Error} If the document hash is invalid.
22
+ * @throws {Error} If the `callStatic.revoke` fails as a pre-check.
23
+ */
24
+ interface RevokeOptions {
25
+ chainId?: CHAIN_ID;
26
+ maxFeePerGas?: GasValue;
27
+ maxPriorityFeePerGas?: GasValue;
28
+ isTransferable?: boolean;
29
+ }
30
+ declare const documentStoreRevoke: (documentStoreAddress: string, documentHash: string, signer: Signer | Signer$1, options?: RevokeOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
31
+
32
+ export { type RevokeOptions, documentStoreRevoke };
@@ -0,0 +1,16 @@
1
+ declare const supportInterfaceIds: {
2
+ /**
3
+ * IDocumentStore interface ID
4
+ * Functions: isActive, isIssued, isRevoked, name, revoke
5
+ * Computed: 0xb9391097
6
+ */
7
+ IDocumentStore: string;
8
+ /**
9
+ * ITransferableDocumentStore interface ID
10
+ * Functions: isActive, isIssued, isRevoked, issue, name, revoke
11
+ * Computed: 0xc2cb4227
12
+ */
13
+ ITransferableDocumentStore: string;
14
+ };
15
+
16
+ export { supportInterfaceIds };