@trustvc/trustvc 2.6.1 → 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.
- package/README.md +217 -0
- package/dist/cjs/document-store/contract-interfaces.js +24 -0
- package/dist/cjs/document-store/deploy.js +49 -0
- package/dist/cjs/document-store/document-store-roles.js +38 -0
- package/dist/cjs/document-store/index.js +46 -0
- package/dist/cjs/document-store/issue.js +71 -0
- package/dist/cjs/document-store/revoke.js +71 -0
- package/dist/cjs/document-store/supportInterfaceIds.js +22 -0
- package/dist/cjs/document-store/tt-document-store-abi.js +231 -0
- package/dist/cjs/index.js +21 -0
- package/dist/esm/document-store/contract-interfaces.js +22 -0
- package/dist/esm/document-store/deploy.js +47 -0
- package/dist/esm/document-store/document-store-roles.js +35 -0
- package/dist/esm/document-store/index.js +5 -0
- package/dist/esm/document-store/issue.js +69 -0
- package/dist/esm/document-store/revoke.js +69 -0
- package/dist/esm/document-store/supportInterfaceIds.js +20 -0
- package/dist/esm/document-store/tt-document-store-abi.js +229 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/document-store/contract-interfaces.d.ts +14 -0
- package/dist/types/document-store/deploy.d.ts +29 -0
- package/dist/types/document-store/document-store-roles.d.ts +14 -0
- package/dist/types/document-store/index.d.ts +11 -0
- package/dist/types/document-store/issue.d.ts +32 -0
- package/dist/types/document-store/revoke.d.ts +32 -0
- package/dist/types/document-store/supportInterfaceIds.d.ts +16 -0
- package/dist/types/document-store/tt-document-store-abi.d.ts +388 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const TT_DOCUMENT_STORE_ABI = [
|
|
4
|
+
// TODO: Replace with the actual full ABI
|
|
5
|
+
// Minimal ABI for issue function (0x0f75e81f)
|
|
6
|
+
{
|
|
7
|
+
inputs: [
|
|
8
|
+
{ internalType: "string", name: "_name", type: "string" },
|
|
9
|
+
{ internalType: "address", name: "owner", type: "address" }
|
|
10
|
+
],
|
|
11
|
+
stateMutability: "nonpayable",
|
|
12
|
+
type: "constructor"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
anonymous: false,
|
|
16
|
+
inputs: [{ indexed: true, internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
17
|
+
name: "DocumentIssued",
|
|
18
|
+
type: "event"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
anonymous: false,
|
|
22
|
+
inputs: [{ indexed: true, internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
23
|
+
name: "DocumentRevoked",
|
|
24
|
+
type: "event"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
anonymous: false,
|
|
28
|
+
inputs: [
|
|
29
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
30
|
+
{ indexed: true, internalType: "bytes32", name: "previousAdminRole", type: "bytes32" },
|
|
31
|
+
{ indexed: true, internalType: "bytes32", name: "newAdminRole", type: "bytes32" }
|
|
32
|
+
],
|
|
33
|
+
name: "RoleAdminChanged",
|
|
34
|
+
type: "event"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
anonymous: false,
|
|
38
|
+
inputs: [
|
|
39
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
40
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
41
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
42
|
+
],
|
|
43
|
+
name: "RoleGranted",
|
|
44
|
+
type: "event"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
anonymous: false,
|
|
48
|
+
inputs: [
|
|
49
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
50
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
51
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
52
|
+
],
|
|
53
|
+
name: "RoleRevoked",
|
|
54
|
+
type: "event"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
inputs: [],
|
|
58
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
59
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
60
|
+
stateMutability: "view",
|
|
61
|
+
type: "function"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
inputs: [],
|
|
65
|
+
name: "ISSUER_ROLE",
|
|
66
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
67
|
+
stateMutability: "view",
|
|
68
|
+
type: "function"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
inputs: [],
|
|
72
|
+
name: "REVOKER_ROLE",
|
|
73
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
74
|
+
stateMutability: "view",
|
|
75
|
+
type: "function"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
inputs: [{ internalType: "bytes32[]", name: "documents", type: "bytes32[]" }],
|
|
79
|
+
name: "bulkIssue",
|
|
80
|
+
outputs: [],
|
|
81
|
+
stateMutability: "nonpayable",
|
|
82
|
+
type: "function"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
inputs: [{ internalType: "bytes32[]", name: "documents", type: "bytes32[]" }],
|
|
86
|
+
name: "bulkRevoke",
|
|
87
|
+
outputs: [],
|
|
88
|
+
stateMutability: "nonpayable",
|
|
89
|
+
type: "function"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
93
|
+
name: "documentIssued",
|
|
94
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
95
|
+
stateMutability: "view",
|
|
96
|
+
type: "function"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
100
|
+
name: "documentRevoked",
|
|
101
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
102
|
+
stateMutability: "view",
|
|
103
|
+
type: "function"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
107
|
+
name: "getIssuedBlock",
|
|
108
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
109
|
+
stateMutability: "view",
|
|
110
|
+
type: "function"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
|
|
114
|
+
name: "getRoleAdmin",
|
|
115
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
116
|
+
stateMutability: "view",
|
|
117
|
+
type: "function"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
inputs: [
|
|
121
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
122
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
123
|
+
],
|
|
124
|
+
name: "grantRole",
|
|
125
|
+
outputs: [],
|
|
126
|
+
stateMutability: "nonpayable",
|
|
127
|
+
type: "function"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
inputs: [
|
|
131
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
132
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
133
|
+
],
|
|
134
|
+
name: "hasRole",
|
|
135
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
136
|
+
stateMutability: "view",
|
|
137
|
+
type: "function"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
141
|
+
name: "isIssued",
|
|
142
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
143
|
+
stateMutability: "view",
|
|
144
|
+
type: "function"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
inputs: [
|
|
148
|
+
{ internalType: "bytes32", name: "document", type: "bytes32" },
|
|
149
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" }
|
|
150
|
+
],
|
|
151
|
+
name: "isIssuedBefore",
|
|
152
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
153
|
+
stateMutability: "view",
|
|
154
|
+
type: "function"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
158
|
+
name: "isRevoked",
|
|
159
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
160
|
+
stateMutability: "view",
|
|
161
|
+
type: "function"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
inputs: [
|
|
165
|
+
{ internalType: "bytes32", name: "document", type: "bytes32" },
|
|
166
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" }
|
|
167
|
+
],
|
|
168
|
+
name: "isRevokedBefore",
|
|
169
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
170
|
+
stateMutability: "view",
|
|
171
|
+
type: "function"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
175
|
+
name: "issue",
|
|
176
|
+
outputs: [],
|
|
177
|
+
stateMutability: "nonpayable",
|
|
178
|
+
type: "function"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
inputs: [],
|
|
182
|
+
name: "name",
|
|
183
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
184
|
+
stateMutability: "view",
|
|
185
|
+
type: "function"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
inputs: [
|
|
189
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
190
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
191
|
+
],
|
|
192
|
+
name: "renounceRole",
|
|
193
|
+
outputs: [],
|
|
194
|
+
stateMutability: "nonpayable",
|
|
195
|
+
type: "function"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
inputs: [{ internalType: "bytes32", name: "document", type: "bytes32" }],
|
|
199
|
+
name: "revoke",
|
|
200
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
201
|
+
stateMutability: "nonpayable",
|
|
202
|
+
type: "function"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
inputs: [
|
|
206
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
207
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
208
|
+
],
|
|
209
|
+
name: "revokeRole",
|
|
210
|
+
outputs: [],
|
|
211
|
+
stateMutability: "nonpayable",
|
|
212
|
+
type: "function"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
216
|
+
name: "supportsInterface",
|
|
217
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
218
|
+
stateMutability: "view",
|
|
219
|
+
type: "function"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
inputs: [],
|
|
223
|
+
name: "version",
|
|
224
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
225
|
+
stateMutability: "view",
|
|
226
|
+
type: "function"
|
|
227
|
+
}
|
|
228
|
+
// Add other functions from the ABI here (name, isIssued, isRevoked, etc.)
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
exports.TT_DOCUMENT_STORE_ABI = TT_DOCUMENT_STORE_ABI;
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tokenRegistryV4 = require('./token-registry-v4');
|
|
4
4
|
var tokenRegistryV5 = require('./token-registry-v5');
|
|
5
|
+
var documentStore = require('./document-store');
|
|
5
6
|
var tokenRegistryFunctions = require('./token-registry-functions');
|
|
6
7
|
var core = require('./core');
|
|
7
8
|
var openAttestation = require('./open-attestation');
|
|
@@ -81,6 +82,26 @@ Object.defineProperty(exports, "v5Utils", {
|
|
|
81
82
|
enumerable: true,
|
|
82
83
|
get: function () { return tokenRegistryV5.v5Utils; }
|
|
83
84
|
});
|
|
85
|
+
Object.defineProperty(exports, "DocumentStore__factory", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () { return documentStore.DocumentStore__factory; }
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "TransferableDocumentStore__factory", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () { return documentStore.TransferableDocumentStore__factory; }
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "deployDocumentStore", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return documentStore.deployDocumentStore; }
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "documentStoreIssue", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () { return documentStore.documentStoreIssue; }
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "documentStoreRevoke", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () { return documentStore.documentStoreRevoke; }
|
|
104
|
+
});
|
|
84
105
|
Object.keys(tokenRegistryFunctions).forEach(function (k) {
|
|
85
106
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
86
107
|
enumerable: true,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDocumentStore__factory, ITransferableDocumentStore__factory } from '@trustvc/document-store';
|
|
2
|
+
|
|
3
|
+
const IDocumentStoreInterface = IDocumentStore__factory.createInterface();
|
|
4
|
+
const ITransferableDocumentStoreInterface = ITransferableDocumentStore__factory.createInterface();
|
|
5
|
+
const IDocumentStoreFunctions = Object.values(IDocumentStoreInterface.fragments).filter((f) => f.type === "function").map((f) => f.format("sighash"));
|
|
6
|
+
const ITransferableDocumentStoreFunctions = Object.values(
|
|
7
|
+
ITransferableDocumentStoreInterface.fragments
|
|
8
|
+
).filter((f) => f.type === "function").map((f) => f.format("sighash"));
|
|
9
|
+
const contractInterfaces = {
|
|
10
|
+
/**
|
|
11
|
+
* IDocumentStore interface functions
|
|
12
|
+
* Functions: isActive, isIssued, isRevoked, name, revoke
|
|
13
|
+
*/
|
|
14
|
+
DocumentStore: IDocumentStoreFunctions,
|
|
15
|
+
/**
|
|
16
|
+
* ITransferableDocumentStore interface functions
|
|
17
|
+
* Functions: isActive, isIssued, isRevoked, issue, name, revoke
|
|
18
|
+
*/
|
|
19
|
+
TransferableDocumentStore: ITransferableDocumentStoreFunctions
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { contractInterfaces };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
|
|
2
|
+
import { ContractFactory } from 'ethersV6';
|
|
3
|
+
import { ContractFactory as ContractFactory$1 } from 'ethers';
|
|
4
|
+
import { isV6EthersProvider } from '../utils/ethers';
|
|
5
|
+
import { getTxOptions } from '../token-registry-functions/utils';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
const deployDocumentStore = /* @__PURE__ */ __name(async (storeName, owner, signer, options = {}) => {
|
|
10
|
+
if (!storeName) throw new Error("Store name is required");
|
|
11
|
+
if (!owner) throw new Error("Owner address is required");
|
|
12
|
+
if (!signer.provider) throw new Error("Provider is required");
|
|
13
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
14
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
15
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
16
|
+
const DocumentStoreFactory = options.isTransferable ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
17
|
+
try {
|
|
18
|
+
if (isV6) {
|
|
19
|
+
const ContractFactory$1 = new ContractFactory(
|
|
20
|
+
DocumentStoreFactory.abi,
|
|
21
|
+
DocumentStoreFactory.bytecode,
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
signer
|
|
24
|
+
);
|
|
25
|
+
const contract = await ContractFactory$1.deploy(storeName, owner, txOptions);
|
|
26
|
+
const receipt = await contract.deploymentTransaction()?.wait();
|
|
27
|
+
return receipt;
|
|
28
|
+
} else {
|
|
29
|
+
const ContractFactory = new ContractFactory$1(
|
|
30
|
+
DocumentStoreFactory.abi,
|
|
31
|
+
DocumentStoreFactory.bytecode,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
signer
|
|
34
|
+
);
|
|
35
|
+
const contract = await ContractFactory.deploy(storeName, owner, txOptions);
|
|
36
|
+
const receipt = await contract.deployTransaction.wait();
|
|
37
|
+
return receipt;
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error("Deployment failed:", e);
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Failed to deploy DocumentStore: ${e instanceof Error ? e.message : String(e)}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}, "deployDocumentStore");
|
|
46
|
+
|
|
47
|
+
export { deployDocumentStore };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { utils } from '@tradetrust-tt/tt-verify';
|
|
2
|
+
import { SUPPORTED_CHAINS } from '../utils';
|
|
3
|
+
import { getEthersContractFromProvider } from '../utils/ethers';
|
|
4
|
+
import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
const getRoleString = /* @__PURE__ */ __name(async (documentStoreAddress, role, options) => {
|
|
9
|
+
const { chainId } = options || {};
|
|
10
|
+
let provider = options?.provider;
|
|
11
|
+
if (!provider) {
|
|
12
|
+
if (!chainId) throw new Error("Either provider or chainId must be provided");
|
|
13
|
+
provider = utils.getProvider({ network: SUPPORTED_CHAINS[chainId].name });
|
|
14
|
+
}
|
|
15
|
+
const Contract = getEthersContractFromProvider(provider);
|
|
16
|
+
const documentStore = new Contract(
|
|
17
|
+
documentStoreAddress,
|
|
18
|
+
TT_DOCUMENT_STORE_ABI,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
provider
|
|
21
|
+
);
|
|
22
|
+
switch (role) {
|
|
23
|
+
case "admin":
|
|
24
|
+
return await documentStore.DEFAULT_ADMIN_ROLE();
|
|
25
|
+
case "issuer":
|
|
26
|
+
return await documentStore.ISSUER_ROLE();
|
|
27
|
+
case "revoker":
|
|
28
|
+
return await documentStore.REVOKER_ROLE();
|
|
29
|
+
default:
|
|
30
|
+
throw new Error("Invalid role");
|
|
31
|
+
}
|
|
32
|
+
}, "getRoleString");
|
|
33
|
+
const rolesList = ["admin", "issuer", "revoker"];
|
|
34
|
+
|
|
35
|
+
export { getRoleString, rolesList };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { IssueOptions, documentStoreIssue } from './issue';
|
|
2
|
+
export { RevokeOptions, documentStoreRevoke } from './revoke';
|
|
3
|
+
export { DeployOptions, deployDocumentStore } from './deploy';
|
|
4
|
+
export { supportInterfaceIds } from './supportInterfaceIds';
|
|
5
|
+
export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
|
|
2
|
+
import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
|
|
3
|
+
import { getTxOptions } from '../token-registry-functions/utils';
|
|
4
|
+
import { checkSupportsInterface } from '../core';
|
|
5
|
+
import { supportInterfaceIds } from './supportInterfaceIds';
|
|
6
|
+
import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const documentStoreIssue = /* @__PURE__ */ __name(async (documentStoreAddress, documentHash, signer, options = {}) => {
|
|
11
|
+
if (!documentStoreAddress) throw new Error("Document store address is required");
|
|
12
|
+
if (!signer.provider) throw new Error("Provider is required");
|
|
13
|
+
if (!documentHash) throw new Error("Document hash is required");
|
|
14
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas, isTransferable } = options;
|
|
15
|
+
let isDocumentStore = !isTransferable;
|
|
16
|
+
let isTransferableDocumentStore = isTransferable;
|
|
17
|
+
let isTTDocumentStore = false;
|
|
18
|
+
if (isTransferable === void 0) {
|
|
19
|
+
[isDocumentStore, isTransferableDocumentStore] = await Promise.all([
|
|
20
|
+
checkSupportsInterface(
|
|
21
|
+
documentStoreAddress,
|
|
22
|
+
supportInterfaceIds.IDocumentStore,
|
|
23
|
+
signer.provider
|
|
24
|
+
),
|
|
25
|
+
checkSupportsInterface(
|
|
26
|
+
documentStoreAddress,
|
|
27
|
+
supportInterfaceIds.ITransferableDocumentStore,
|
|
28
|
+
signer.provider
|
|
29
|
+
)
|
|
30
|
+
]);
|
|
31
|
+
if (!isDocumentStore && !isTransferableDocumentStore) {
|
|
32
|
+
isTTDocumentStore = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!isDocumentStore && !isTransferableDocumentStore && !isTTDocumentStore) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"Contract does not support DocumentStore, TransferableDocumentStore, or TT Document Store interface"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
41
|
+
let documentStoreAbi;
|
|
42
|
+
if (isTTDocumentStore) {
|
|
43
|
+
documentStoreAbi = TT_DOCUMENT_STORE_ABI;
|
|
44
|
+
} else {
|
|
45
|
+
const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
46
|
+
documentStoreAbi = DocumentStoreFactory.abi;
|
|
47
|
+
}
|
|
48
|
+
const documentStoreContract = new Contract(
|
|
49
|
+
documentStoreAddress,
|
|
50
|
+
documentStoreAbi,
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
signer
|
|
53
|
+
);
|
|
54
|
+
try {
|
|
55
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
56
|
+
if (isV6) {
|
|
57
|
+
await documentStoreContract.issue.staticCall(documentHash);
|
|
58
|
+
} else {
|
|
59
|
+
await documentStoreContract.callStatic.issue(documentHash);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("callStatic failed:", e);
|
|
63
|
+
throw new Error("Pre-check (callStatic) for issue failed");
|
|
64
|
+
}
|
|
65
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
66
|
+
return await documentStoreContract.issue(documentHash, txOptions);
|
|
67
|
+
}, "documentStoreIssue");
|
|
68
|
+
|
|
69
|
+
export { documentStoreIssue };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
|
|
2
|
+
import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
|
|
3
|
+
import { getTxOptions } from '../token-registry-functions/utils';
|
|
4
|
+
import { checkSupportsInterface } from '../core';
|
|
5
|
+
import { supportInterfaceIds } from './supportInterfaceIds';
|
|
6
|
+
import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const documentStoreRevoke = /* @__PURE__ */ __name(async (documentStoreAddress, documentHash, signer, options = {}) => {
|
|
11
|
+
if (!documentStoreAddress) throw new Error("Document store address is required");
|
|
12
|
+
if (!signer.provider) throw new Error("Provider is required");
|
|
13
|
+
if (!documentHash) throw new Error("Document hash is required");
|
|
14
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas, isTransferable } = options;
|
|
15
|
+
let isDocumentStore = !isTransferable;
|
|
16
|
+
let isTransferableDocumentStore = isTransferable;
|
|
17
|
+
let isTTDocumentStore = false;
|
|
18
|
+
if (isTransferable === void 0) {
|
|
19
|
+
[isDocumentStore, isTransferableDocumentStore] = await Promise.all([
|
|
20
|
+
checkSupportsInterface(
|
|
21
|
+
documentStoreAddress,
|
|
22
|
+
supportInterfaceIds.IDocumentStore,
|
|
23
|
+
signer.provider
|
|
24
|
+
),
|
|
25
|
+
checkSupportsInterface(
|
|
26
|
+
documentStoreAddress,
|
|
27
|
+
supportInterfaceIds.ITransferableDocumentStore,
|
|
28
|
+
signer.provider
|
|
29
|
+
)
|
|
30
|
+
]);
|
|
31
|
+
if (!isDocumentStore && !isTransferableDocumentStore) {
|
|
32
|
+
isTTDocumentStore = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!isDocumentStore && !isTransferableDocumentStore && !isTTDocumentStore) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"Contract does not support DocumentStore, TransferableDocumentStore, or TT Document Store interface"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
41
|
+
let documentStoreAbi;
|
|
42
|
+
if (isTTDocumentStore) {
|
|
43
|
+
documentStoreAbi = TT_DOCUMENT_STORE_ABI;
|
|
44
|
+
} else {
|
|
45
|
+
const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
46
|
+
documentStoreAbi = DocumentStoreFactory.abi;
|
|
47
|
+
}
|
|
48
|
+
const documentStoreContract = new Contract(
|
|
49
|
+
documentStoreAddress,
|
|
50
|
+
documentStoreAbi,
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
signer
|
|
53
|
+
);
|
|
54
|
+
try {
|
|
55
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
56
|
+
if (isV6) {
|
|
57
|
+
await documentStoreContract.revoke.staticCall(documentHash);
|
|
58
|
+
} else {
|
|
59
|
+
await documentStoreContract.callStatic.revoke(documentHash);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("callStatic failed:", e);
|
|
63
|
+
throw new Error("Pre-check (callStatic) for revoke failed");
|
|
64
|
+
}
|
|
65
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
66
|
+
return await documentStoreContract.revoke(documentHash, txOptions);
|
|
67
|
+
}, "documentStoreRevoke");
|
|
68
|
+
|
|
69
|
+
export { documentStoreRevoke };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { utils } from '@tradetrust-tt/token-registry-v5';
|
|
2
|
+
import { contractInterfaces } from './contract-interfaces';
|
|
3
|
+
|
|
4
|
+
const { computeInterfaceId } = utils;
|
|
5
|
+
const supportInterfaceIds = {
|
|
6
|
+
/**
|
|
7
|
+
* IDocumentStore interface ID
|
|
8
|
+
* Functions: isActive, isIssued, isRevoked, name, revoke
|
|
9
|
+
* Computed: 0xb9391097
|
|
10
|
+
*/
|
|
11
|
+
IDocumentStore: computeInterfaceId(contractInterfaces.DocumentStore),
|
|
12
|
+
/**
|
|
13
|
+
* ITransferableDocumentStore interface ID
|
|
14
|
+
* Functions: isActive, isIssued, isRevoked, issue, name, revoke
|
|
15
|
+
* Computed: 0xc2cb4227
|
|
16
|
+
*/
|
|
17
|
+
ITransferableDocumentStore: computeInterfaceId(contractInterfaces.TransferableDocumentStore)
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { supportInterfaceIds };
|