@trustvc/trustvc 2.6.1 → 2.8.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/grant-role.js +67 -0
- package/dist/cjs/document-store/index.js +49 -0
- package/dist/cjs/document-store/issue.js +66 -0
- package/dist/cjs/document-store/revoke-role.js +67 -0
- package/dist/cjs/document-store/revoke.js +66 -0
- package/dist/cjs/document-store/supportInterfaceIds.js +22 -0
- package/dist/cjs/document-store/transferOwnership.js +42 -0
- package/dist/cjs/document-store/tt-document-store-abi.js +231 -0
- package/dist/cjs/document-store/types.js +2 -0
- package/dist/cjs/index.js +29 -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/grant-role.js +65 -0
- package/dist/esm/document-store/index.js +8 -0
- package/dist/esm/document-store/issue.js +64 -0
- package/dist/esm/document-store/revoke-role.js +65 -0
- package/dist/esm/document-store/revoke.js +64 -0
- package/dist/esm/document-store/supportInterfaceIds.js +20 -0
- package/dist/esm/document-store/transferOwnership.js +40 -0
- package/dist/esm/document-store/tt-document-store-abi.js +229 -0
- package/dist/esm/document-store/types.js +1 -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/grant-role.d.ts +28 -0
- package/dist/types/document-store/index.d.ts +15 -0
- package/dist/types/document-store/issue.d.ts +27 -0
- package/dist/types/document-store/revoke-role.d.ts +28 -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/transferOwnership.d.ts +30 -0
- package/dist/types/document-store/tt-document-store-abi.d.ts +388 -0
- package/dist/types/document-store/types.d.ts +15 -0
- package/dist/types/index.d.ts +17 -10
- package/package.json +2 -1
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
36
|
+
let documentStoreAbi;
|
|
37
|
+
if (isTTDocumentStore) {
|
|
38
|
+
documentStoreAbi = TT_DOCUMENT_STORE_ABI;
|
|
39
|
+
} else {
|
|
40
|
+
const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
41
|
+
documentStoreAbi = DocumentStoreFactory.abi;
|
|
42
|
+
}
|
|
43
|
+
const documentStoreContract = new Contract(
|
|
44
|
+
documentStoreAddress,
|
|
45
|
+
documentStoreAbi,
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
signer
|
|
48
|
+
);
|
|
49
|
+
try {
|
|
50
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
51
|
+
if (isV6) {
|
|
52
|
+
await documentStoreContract.revoke.staticCall(documentHash);
|
|
53
|
+
} else {
|
|
54
|
+
await documentStoreContract.callStatic.revoke(documentHash);
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error("callStatic failed:", e);
|
|
58
|
+
throw new Error("Pre-check (callStatic) for revoke failed");
|
|
59
|
+
}
|
|
60
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
61
|
+
return await documentStoreContract.revoke(documentHash, txOptions);
|
|
62
|
+
}, "documentStoreRevoke");
|
|
63
|
+
|
|
64
|
+
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 };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { documentStoreRevokeRole } from './revoke-role';
|
|
2
|
+
import { documentStoreGrantRole } from './grant-role';
|
|
3
|
+
import { getRoleString } from './document-store-roles';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const documentStoreTransferOwnership = /* @__PURE__ */ __name(async (documentStoreAddress, account, signer, options = {}) => {
|
|
8
|
+
if (!documentStoreAddress) throw new Error("Document store address is required");
|
|
9
|
+
if (!signer.provider) throw new Error("Provider is required");
|
|
10
|
+
if (!account) throw new Error("Account is required");
|
|
11
|
+
const ownerAddress = await signer.getAddress();
|
|
12
|
+
const roleString = await getRoleString(documentStoreAddress, "admin", {
|
|
13
|
+
provider: signer.provider
|
|
14
|
+
});
|
|
15
|
+
const grantTransaction = documentStoreGrantRole(
|
|
16
|
+
documentStoreAddress,
|
|
17
|
+
roleString,
|
|
18
|
+
account,
|
|
19
|
+
signer,
|
|
20
|
+
options
|
|
21
|
+
);
|
|
22
|
+
const grantTransactionResult = await grantTransaction;
|
|
23
|
+
if (!grantTransactionResult) {
|
|
24
|
+
throw new Error("Grant transaction failed, not proceeding with revoke transaction");
|
|
25
|
+
}
|
|
26
|
+
const revokeTransaction = documentStoreRevokeRole(
|
|
27
|
+
documentStoreAddress,
|
|
28
|
+
roleString,
|
|
29
|
+
ownerAddress,
|
|
30
|
+
signer,
|
|
31
|
+
options
|
|
32
|
+
);
|
|
33
|
+
const revokeTransactionResult = await revokeTransaction;
|
|
34
|
+
if (!revokeTransactionResult) {
|
|
35
|
+
throw new Error("Revoke transaction failed");
|
|
36
|
+
}
|
|
37
|
+
return { grantTransaction, revokeTransaction };
|
|
38
|
+
}, "documentStoreTransferOwnership");
|
|
39
|
+
|
|
40
|
+
export { documentStoreTransferOwnership };
|
|
@@ -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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
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, documentStoreGrantRole, documentStoreIssue, documentStoreRevoke, documentStoreRevokeRole } from './document-store';
|
|
3
4
|
export * from './token-registry-functions';
|
|
4
5
|
export * from './core';
|
|
5
6
|
export * from './open-attestation';
|
|
@@ -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,28 @@
|
|
|
1
|
+
import { Signer as Signer$1, ContractTransaction as ContractTransaction$1 } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { CommandOptions } from './types.js';
|
|
4
|
+
import '../utils/supportedChains/index.js';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
import '../token-registry-functions/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Grants a role to an account on the DocumentStore contract.
|
|
11
|
+
* Supports both Ethers v5 and v6 signers.
|
|
12
|
+
* Supports three types of document stores:
|
|
13
|
+
* 1. DocumentStore (ERC-165 compliant)
|
|
14
|
+
* 2. TransferableDocumentStore (ERC-165 compliant)
|
|
15
|
+
* 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
|
|
16
|
+
* @param {string} documentStoreAddress - The address of the DocumentStore contract.
|
|
17
|
+
* @param {string} role - The role to grant (e.g., 'ISSUER', 'REVOKER', 'ADMIN').
|
|
18
|
+
* @param {string} account - The account to grant the role to.
|
|
19
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the grant role transaction.
|
|
20
|
+
* @param {CommandOptions} options - Optional transaction metadata including gas values and chain ID.
|
|
21
|
+
* @returns {Promise<ContractTransactionV5 | ContractTransactionV6>} A promise resolving to the transaction result from the grant role call.
|
|
22
|
+
* @throws {Error} If the document store address or signer provider is not provided.
|
|
23
|
+
* @throws {Error} If the role is invalid.
|
|
24
|
+
* @throws {Error} If the `callStatic.grantRole` fails as a pre-check.
|
|
25
|
+
*/
|
|
26
|
+
declare const documentStoreGrantRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransaction$1>;
|
|
27
|
+
|
|
28
|
+
export { documentStoreGrantRole };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { documentStoreIssue } from './issue.js';
|
|
2
|
+
export { documentStoreRevoke } from './revoke.js';
|
|
3
|
+
export { documentStoreRevokeRole } from './revoke-role.js';
|
|
4
|
+
export { documentStoreGrantRole } from './grant-role.js';
|
|
5
|
+
export { documentStoreTransferOwnership } from './transferOwnership.js';
|
|
6
|
+
export { deployDocumentStore } from './deploy.js';
|
|
7
|
+
export { supportInterfaceIds } from './supportInterfaceIds.js';
|
|
8
|
+
export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
|
|
9
|
+
import 'ethersV6';
|
|
10
|
+
import 'ethers';
|
|
11
|
+
import './types.js';
|
|
12
|
+
import '../utils/supportedChains/index.js';
|
|
13
|
+
import '../utils/gasStation/index.js';
|
|
14
|
+
import '../utils/network/index.js';
|
|
15
|
+
import '../token-registry-functions/types.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { CommandOptions } from './types.js';
|
|
4
|
+
import '../utils/supportedChains/index.js';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
import '../token-registry-functions/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Issues a document hash to the DocumentStore contract.
|
|
11
|
+
* Supports both Ethers v5 and v6 signers.
|
|
12
|
+
* Supports three types of document stores:
|
|
13
|
+
* 1. DocumentStore (ERC-165 compliant)
|
|
14
|
+
* 2. TransferableDocumentStore (ERC-165 compliant)
|
|
15
|
+
* 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
|
|
16
|
+
* @param {string} documentStoreAddress - The address of the DocumentStore contract.
|
|
17
|
+
* @param {string} documentHash - The hash of the document to issue (must be a valid hex string).
|
|
18
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the issue transaction.
|
|
19
|
+
* @param {CommandOptions} options - Optional transaction metadata including gas values and chain ID.
|
|
20
|
+
* @returns {Promise<ContractTransactionV5 | ContractTransactionV6>} A promise resolving to the transaction result from the issue call.
|
|
21
|
+
* @throws {Error} If the document store address or signer provider is not provided.
|
|
22
|
+
* @throws {Error} If the document hash is invalid.
|
|
23
|
+
* @throws {Error} If the `callStatic.issue` fails as a pre-check.
|
|
24
|
+
*/
|
|
25
|
+
declare const documentStoreIssue: (documentStoreAddress: string, documentHash: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
|
|
26
|
+
|
|
27
|
+
export { documentStoreIssue };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { CommandOptions } from './types.js';
|
|
4
|
+
import '../utils/supportedChains/index.js';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
import '../token-registry-functions/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Revokes a role from an account on the DocumentStore contract.
|
|
11
|
+
* Supports both Ethers v5 and v6 signers.
|
|
12
|
+
* Supports three types of document stores:
|
|
13
|
+
* 1. DocumentStore (ERC-165 compliant)
|
|
14
|
+
* 2. TransferableDocumentStore (ERC-165 compliant)
|
|
15
|
+
* 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
|
|
16
|
+
* @param {string} documentStoreAddress - The address of the DocumentStore contract.
|
|
17
|
+
* @param {string} role - The role to revoke (e.g., 'ISSUER', 'REVOKER', 'ADMIN').
|
|
18
|
+
* @param {string} account - The account to revoke the role from.
|
|
19
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the revoke role transaction.
|
|
20
|
+
* @param {CommandOptions} options - Optional transaction metadata including gas values and chain ID.
|
|
21
|
+
* @returns {Promise<ContractTransactionV5 | ContractTransactionV6>} A promise resolving to the transaction result from the revoke role call.
|
|
22
|
+
* @throws {Error} If the document store address or signer provider is not provided.
|
|
23
|
+
* @throws {Error} If the role is invalid.
|
|
24
|
+
* @throws {Error} If the `callStatic.revokeRole` fails as a pre-check.
|
|
25
|
+
*/
|
|
26
|
+
declare const documentStoreRevokeRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
|
|
27
|
+
|
|
28
|
+
export { documentStoreRevokeRole };
|
|
@@ -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 };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Signer as Signer$1, ContractTransaction as ContractTransaction$1 } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { CommandOptions } from './types.js';
|
|
4
|
+
import '../utils/supportedChains/index.js';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
import '../token-registry-functions/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Transfers ownership of a DocumentStore contract to a new owner.
|
|
11
|
+
* Supports both Ethers v5 and v6 signers.
|
|
12
|
+
* Supports three types of document stores:
|
|
13
|
+
* 1. DocumentStore (ERC-165 compliant)
|
|
14
|
+
* 2. TransferableDocumentStore (ERC-165 compliant)
|
|
15
|
+
* 3. TT Document Store (legacy, no ERC-165 support - used as fallback)
|
|
16
|
+
* @param {string} documentStoreAddress - The address of the DocumentStore contract.
|
|
17
|
+
* @param {string} account - The account to transfer ownership to.
|
|
18
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the transfer ownership transaction.
|
|
19
|
+
* @param {CommandOptions} options - Optional transaction metadata including gas values and chain ID.
|
|
20
|
+
* @returns {Promise<{grantTransaction: Promise<ContractTransactionV5 | ContractTransactionV6>; revokeTransaction: Promise<ContractTransactionV5 | ContractTransactionV6>}>} A promise resolving to the transaction result from the grant and revoke role calls.
|
|
21
|
+
* @throws {Error} If the document store address or signer provider is not provided.
|
|
22
|
+
* @throws {Error} If the role is invalid.
|
|
23
|
+
* @throws {Error} If the `callStatic.revokeRole` fails as a pre-check.
|
|
24
|
+
*/
|
|
25
|
+
declare const documentStoreTransferOwnership: (documentStoreAddress: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<{
|
|
26
|
+
grantTransaction: Promise<ContractTransaction | ContractTransaction$1>;
|
|
27
|
+
revokeTransaction: Promise<ContractTransaction | ContractTransaction$1>;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export { documentStoreTransferOwnership };
|