@trustvc/trustvc 2.7.0 → 2.9.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 (47) hide show
  1. package/dist/cjs/{document-store/deploy.js → deploy/document-store.js} +18 -18
  2. package/dist/cjs/deploy/token-registry.js +97 -0
  3. package/dist/cjs/document-store/grant-role.js +67 -0
  4. package/dist/cjs/document-store/index.js +15 -12
  5. package/dist/cjs/document-store/issue.js +0 -5
  6. package/dist/cjs/document-store/revoke-role.js +67 -0
  7. package/dist/cjs/document-store/revoke.js +0 -5
  8. package/dist/cjs/document-store/transferOwnership.js +42 -0
  9. package/dist/cjs/document-store/types.js +2 -0
  10. package/dist/cjs/index.js +8 -0
  11. package/dist/cjs/token-registry-functions/index.js +7 -0
  12. package/dist/cjs/token-registry-functions/ownerOf.js +9 -7
  13. package/dist/cjs/token-registry-functions/utils.js +39 -0
  14. package/dist/cjs/token-registry-v5/index.js +4 -4
  15. package/dist/cjs/utils/ethers/index.js +6 -2
  16. package/dist/esm/{document-store/deploy.js → deploy/document-store.js} +19 -19
  17. package/dist/esm/deploy/token-registry.js +95 -0
  18. package/dist/esm/document-store/grant-role.js +65 -0
  19. package/dist/esm/document-store/index.js +6 -3
  20. package/dist/esm/document-store/issue.js +0 -5
  21. package/dist/esm/document-store/revoke-role.js +65 -0
  22. package/dist/esm/document-store/revoke.js +0 -5
  23. package/dist/esm/document-store/transferOwnership.js +40 -0
  24. package/dist/esm/document-store/types.js +1 -0
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/token-registry-functions/index.js +1 -0
  27. package/dist/esm/token-registry-functions/ownerOf.js +9 -7
  28. package/dist/esm/token-registry-functions/utils.js +38 -2
  29. package/dist/esm/token-registry-v5/index.js +1 -1
  30. package/dist/esm/utils/ethers/index.js +7 -4
  31. package/dist/types/deploy/document-store.d.ts +77 -0
  32. package/dist/types/deploy/token-registry.d.ts +82 -0
  33. package/dist/types/document-store/grant-role.d.ts +28 -0
  34. package/dist/types/document-store/index.d.ts +7 -3
  35. package/dist/types/document-store/issue.d.ts +6 -11
  36. package/dist/types/document-store/revoke-role.d.ts +28 -0
  37. package/dist/types/document-store/transferOwnership.d.ts +30 -0
  38. package/dist/types/document-store/types.d.ts +15 -0
  39. package/dist/types/index.d.ts +17 -13
  40. package/dist/types/token-registry-functions/index.d.ts +1 -0
  41. package/dist/types/token-registry-functions/ownerOf.d.ts +1 -1
  42. package/dist/types/token-registry-functions/types.d.ts +26 -1
  43. package/dist/types/token-registry-functions/utils.d.ts +7 -4
  44. package/dist/types/token-registry-v5/index.d.ts +1 -2
  45. package/dist/types/utils/ethers/index.d.ts +6 -5
  46. package/package.json +1 -1
  47. package/dist/types/document-store/deploy.d.ts +0 -29
@@ -0,0 +1,95 @@
1
+ import { TDocDeployer__factory, TradeTrustToken__factory } from '@tradetrust-tt/token-registry/contracts';
2
+ import { getChainIdSafe, getDefaultContractAddress, isValidAddress, getTxOptions, isSupportedTitleEscrowFactory } from '../token-registry-functions/utils';
3
+ import { encodeInitParams } from '../token-registry-v5/utils';
4
+ import { getEthersContractFromProvider, getEthersContractFactoryFromProvider, isV6EthersProvider } from '../utils/ethers';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ const deployTokenRegistry = /* @__PURE__ */ __name(async (registryName, registrySymbol, signer, options = {}) => {
9
+ const { maxFeePerGas, maxPriorityFeePerGas } = options;
10
+ let { chainId, standalone, factoryAddress, tokenRegistryImplAddress, deployerContractAddress } = options;
11
+ const deployerAddress = await signer.getAddress();
12
+ if (!chainId) {
13
+ chainId = await getChainIdSafe(signer);
14
+ }
15
+ const {
16
+ TitleEscrowFactory: defaultTitleEscrowFactoryAddress,
17
+ TokenImplementation: defaultTokenImplementationContractAddress,
18
+ Deployer: defaultDeployerContractAddress
19
+ } = getDefaultContractAddress(chainId);
20
+ if (!isValidAddress(deployerContractAddress)) {
21
+ deployerContractAddress = defaultDeployerContractAddress;
22
+ }
23
+ if (!isValidAddress(tokenRegistryImplAddress)) {
24
+ tokenRegistryImplAddress = defaultTokenImplementationContractAddress;
25
+ }
26
+ if (standalone !== false && (!deployerContractAddress || !tokenRegistryImplAddress)) {
27
+ console.error(
28
+ `Network ${chainId} does not support "quick-start" mode. Defaulting to standalone mode.`
29
+ );
30
+ standalone = true;
31
+ }
32
+ if (!standalone) {
33
+ if (!deployerContractAddress || !tokenRegistryImplAddress) {
34
+ throw new Error(`Network ${chainId} currently is not supported. Use --standalone instead.`);
35
+ }
36
+ const Contract = getEthersContractFromProvider(signer.provider);
37
+ const deployerContract = new Contract(
38
+ deployerContractAddress,
39
+ TDocDeployer__factory.abi,
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ signer
42
+ // Type assertion needed for v5/v6 compatibility
43
+ );
44
+ const initParam = encodeInitParams({
45
+ name: registryName,
46
+ symbol: registrySymbol,
47
+ deployer: deployerAddress
48
+ });
49
+ const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
50
+ return await deployerContract.deploy(tokenRegistryImplAddress, initParam, txOptions);
51
+ } else {
52
+ if (!factoryAddress || !isValidAddress(factoryAddress)) {
53
+ factoryAddress = defaultTitleEscrowFactoryAddress;
54
+ if (!factoryAddress) {
55
+ throw new Error(`Network ${chainId} currently is not supported. Supply a factory address.`);
56
+ }
57
+ }
58
+ const supportedTitleEscrowFactory = await isSupportedTitleEscrowFactory(
59
+ factoryAddress,
60
+ signer.provider
61
+ );
62
+ if (!supportedTitleEscrowFactory) {
63
+ throw new Error(`Title Escrow Factory ${factoryAddress} is not supported.`);
64
+ }
65
+ const Contract = getEthersContractFactoryFromProvider(signer.provider);
66
+ const tokenFactory = new Contract(
67
+ TradeTrustToken__factory.abi,
68
+ TradeTrustToken__factory.bytecode,
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ signer
71
+ // Type assertion needed for v5/v6 compatibility
72
+ );
73
+ const isV6 = isV6EthersProvider(signer.provider);
74
+ const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
75
+ if (isV6) {
76
+ const contract = await tokenFactory.deploy(
77
+ registryName,
78
+ registrySymbol,
79
+ factoryAddress,
80
+ txOptions
81
+ );
82
+ return await contract.deploymentTransaction().wait();
83
+ } else {
84
+ const contract = await tokenFactory.deploy(
85
+ registryName,
86
+ registrySymbol,
87
+ factoryAddress,
88
+ txOptions
89
+ );
90
+ return await contract.deployTransaction.wait();
91
+ }
92
+ }
93
+ }, "deployTokenRegistry");
94
+
95
+ export { deployTokenRegistry };
@@ -0,0 +1,65 @@
1
+ import { checkSupportsInterface } from '../core';
2
+ import { supportInterfaceIds } from './supportInterfaceIds';
3
+ import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
4
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
5
+ import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
6
+ import { getTxOptions } from '../token-registry-functions/utils';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ const documentStoreGrantRole = /* @__PURE__ */ __name(async (documentStoreAddress, role, account, 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 (!role) throw new Error("Role is required");
14
+ if (!account) throw new Error("Account is required");
15
+ const { chainId, maxFeePerGas, maxPriorityFeePerGas, isTransferable } = options;
16
+ let isDocumentStore = !isTransferable;
17
+ let isTransferableDocumentStore = isTransferable;
18
+ let isTTDocumentStore = false;
19
+ if (isTransferable === void 0) {
20
+ [isDocumentStore, isTransferableDocumentStore] = await Promise.all([
21
+ checkSupportsInterface(
22
+ documentStoreAddress,
23
+ supportInterfaceIds.IDocumentStore,
24
+ signer.provider
25
+ ),
26
+ checkSupportsInterface(
27
+ documentStoreAddress,
28
+ supportInterfaceIds.ITransferableDocumentStore,
29
+ signer.provider
30
+ )
31
+ ]);
32
+ if (!isDocumentStore && !isTransferableDocumentStore) {
33
+ isTTDocumentStore = true;
34
+ }
35
+ }
36
+ const Contract = getEthersContractFromProvider(signer.provider);
37
+ let documentStoreAbi;
38
+ if (isTTDocumentStore) {
39
+ documentStoreAbi = TT_DOCUMENT_STORE_ABI;
40
+ } else {
41
+ const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
42
+ documentStoreAbi = DocumentStoreFactory.abi;
43
+ }
44
+ const documentStoreContract = new Contract(
45
+ documentStoreAddress,
46
+ documentStoreAbi,
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ signer
49
+ );
50
+ try {
51
+ const isV6 = isV6EthersProvider(signer.provider);
52
+ if (isV6) {
53
+ await documentStoreContract.grantRole.staticCall(role, account);
54
+ } else {
55
+ await documentStoreContract.callStatic.grantRole(role, account);
56
+ }
57
+ } catch (e) {
58
+ console.error("callStatic failed:", e);
59
+ throw new Error("Pre-check (callStatic) for grant-role failed");
60
+ }
61
+ const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
62
+ return await documentStoreContract.grantRole(role, account, txOptions);
63
+ }, "documentStoreGrantRole");
64
+
65
+ export { documentStoreGrantRole };
@@ -1,5 +1,8 @@
1
- export { IssueOptions, documentStoreIssue } from './issue';
2
- export { RevokeOptions, documentStoreRevoke } from './revoke';
3
- export { DeployOptions, deployDocumentStore } from './deploy';
1
+ export { documentStoreIssue } from './issue';
2
+ export { documentStoreRevoke } from './revoke';
3
+ export { documentStoreRevokeRole } from './revoke-role';
4
+ export { documentStoreGrantRole } from './grant-role';
5
+ export { documentStoreTransferOwnership } from './transferOwnership';
6
+ export { deployDocumentStore } from '../deploy/document-store';
4
7
  export { supportInterfaceIds } from './supportInterfaceIds';
5
8
  export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
@@ -32,11 +32,6 @@ const documentStoreIssue = /* @__PURE__ */ __name(async (documentStoreAddress, d
32
32
  isTTDocumentStore = true;
33
33
  }
34
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
35
  const Contract = getEthersContractFromProvider(signer.provider);
41
36
  let documentStoreAbi;
42
37
  if (isTTDocumentStore) {
@@ -0,0 +1,65 @@
1
+ import { checkSupportsInterface } from '../core';
2
+ import { supportInterfaceIds } from './supportInterfaceIds';
3
+ import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
4
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
5
+ import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
6
+ import { getTxOptions } from '../token-registry-functions/utils';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ const documentStoreRevokeRole = /* @__PURE__ */ __name(async (documentStoreAddress, role, account, 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 (!role) throw new Error("Role is required");
14
+ if (!account) throw new Error("Account is required");
15
+ const { chainId, maxFeePerGas, maxPriorityFeePerGas, isTransferable } = options;
16
+ let isDocumentStore = !isTransferable;
17
+ let isTransferableDocumentStore = isTransferable;
18
+ let isTTDocumentStore = false;
19
+ if (isTransferable === void 0) {
20
+ [isDocumentStore, isTransferableDocumentStore] = await Promise.all([
21
+ checkSupportsInterface(
22
+ documentStoreAddress,
23
+ supportInterfaceIds.IDocumentStore,
24
+ signer.provider
25
+ ),
26
+ checkSupportsInterface(
27
+ documentStoreAddress,
28
+ supportInterfaceIds.ITransferableDocumentStore,
29
+ signer.provider
30
+ )
31
+ ]);
32
+ if (!isDocumentStore && !isTransferableDocumentStore) {
33
+ isTTDocumentStore = true;
34
+ }
35
+ }
36
+ const Contract = getEthersContractFromProvider(signer.provider);
37
+ let documentStoreAbi;
38
+ if (isTTDocumentStore) {
39
+ documentStoreAbi = TT_DOCUMENT_STORE_ABI;
40
+ } else {
41
+ const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
42
+ documentStoreAbi = DocumentStoreFactory.abi;
43
+ }
44
+ const documentStoreContract = new Contract(
45
+ documentStoreAddress,
46
+ documentStoreAbi,
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ signer
49
+ );
50
+ try {
51
+ const isV6 = isV6EthersProvider(signer.provider);
52
+ if (isV6) {
53
+ await documentStoreContract.revokeRole.staticCall(role, account);
54
+ } else {
55
+ await documentStoreContract.callStatic.revokeRole(role, account);
56
+ }
57
+ } catch (e) {
58
+ console.error("callStatic failed:", e);
59
+ throw new Error("Pre-check (callStatic) for revoke-role failed");
60
+ }
61
+ const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
62
+ return await documentStoreContract.revokeRole(role, account, txOptions);
63
+ }, "documentStoreRevokeRole");
64
+
65
+ export { documentStoreRevokeRole };
@@ -32,11 +32,6 @@ const documentStoreRevoke = /* @__PURE__ */ __name(async (documentStoreAddress,
32
32
  isTTDocumentStore = true;
33
33
  }
34
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
35
  const Contract = getEthersContractFromProvider(signer.provider);
41
36
  let documentStoreAbi;
42
37
  if (isTTDocumentStore) {
@@ -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 @@
1
+
package/dist/esm/index.js CHANGED
@@ -1,6 +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
+ export { DocumentStore__factory, TransferableDocumentStore__factory, deployDocumentStore, documentStoreGrantRole, documentStoreIssue, documentStoreRevoke, documentStoreRevokeRole } from './document-store';
4
4
  export * from './token-registry-functions';
5
5
  export * from './core';
6
6
  export * from './open-attestation';
@@ -3,3 +3,4 @@ export * from './rejectTransfers';
3
3
  export * from './returnToken';
4
4
  export * from './mint';
5
5
  export * from './ownerOf';
6
+ export * from '../deploy/token-registry';
@@ -1,6 +1,7 @@
1
1
  import { checkSupportsInterface } from '../core';
2
2
  import { v5SupportInterfaceIds, v5Contracts } from '../token-registry-v5';
3
3
  import { v4SupportInterfaceIds, v4Contracts } from '../token-registry-v4';
4
+ import { getEthersContractFromProvider } from '../utils/ethers';
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -21,23 +22,24 @@ const ownerOf = /* @__PURE__ */ __name(async (contractOptions, signer, params, o
21
22
  if (!isV4TT && !isV5TT) {
22
23
  throw new Error("Only Token Registry V4/V5 is supported");
23
24
  }
25
+ const Contract = getEthersContractFromProvider(signer.provider);
24
26
  let tradeTrustTokenContract;
25
27
  if (isV5TT) {
26
- tradeTrustTokenContract = v5Contracts.TradeTrustToken__factory.connect(
28
+ tradeTrustTokenContract = new Contract(
27
29
  tokenRegistryAddress,
30
+ v5Contracts.TradeTrustToken__factory.abi,
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
32
  signer
29
33
  );
30
34
  } else if (isV4TT) {
31
- tradeTrustTokenContract = v4Contracts.TradeTrustToken__factory.connect(
35
+ tradeTrustTokenContract = new Contract(
32
36
  tokenRegistryAddress,
37
+ v4Contracts.TradeTrustToken__factory.abi,
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
39
  signer
34
40
  );
35
41
  }
36
- if (isV5TT) {
37
- return await tradeTrustTokenContract.ownerOf(tokenId);
38
- } else if (isV4TT) {
39
- return await tradeTrustTokenContract.ownerOf(tokenId);
40
- }
42
+ return await tradeTrustTokenContract.ownerOf(tokenId);
41
43
  }, "ownerOf");
42
44
 
43
45
  export { ownerOf };
@@ -1,5 +1,7 @@
1
- import { isV6EthersProvider } from '../utils/ethers';
1
+ import { isV6EthersProvider, getEthersContractFromProvider } from '../utils/ethers';
2
2
  import { SUPPORTED_CHAINS } from '../utils';
3
+ import { isAddress } from 'ethersV6';
4
+ import { constants } from '../token-registry-v5';
3
5
 
4
6
  var __defProp = Object.defineProperty;
5
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -29,5 +31,39 @@ const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
29
31
  }
30
32
  return await signer.getAddress();
31
33
  }, "getSignerAddressSafe");
34
+ const { contractInterfaceId: CONTRACT_INTERFACE_ID, contractAddress: CONTRACT_ADDRESS } = constants;
35
+ const getDefaultContractAddress = /* @__PURE__ */ __name((chainId) => {
36
+ const { TitleEscrowFactory, TokenImplementation, Deployer } = CONTRACT_ADDRESS;
37
+ const chainTitleEscrowFactory = TitleEscrowFactory[chainId];
38
+ const chainTokenImplementation = TokenImplementation[chainId];
39
+ const chainDeployer = Deployer[chainId];
40
+ return {
41
+ TitleEscrowFactory: chainTitleEscrowFactory,
42
+ TokenImplementation: chainTokenImplementation,
43
+ Deployer: chainDeployer
44
+ };
45
+ }, "getDefaultContractAddress");
46
+ const isValidAddress = /* @__PURE__ */ __name((address) => {
47
+ if (!address) return false;
48
+ return isAddress(address);
49
+ }, "isValidAddress");
50
+ const isSupportedTitleEscrowFactory = /* @__PURE__ */ __name(async (factoryAddress, provider) => {
51
+ const Contract = getEthersContractFromProvider(provider);
52
+ const titleEscrowFactoryContract = new Contract(
53
+ factoryAddress,
54
+ ["function implementation() view returns (address)"],
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ provider
57
+ );
58
+ const implAddr = await titleEscrowFactoryContract.implementation();
59
+ const implContract = new Contract(
60
+ implAddr,
61
+ ["function supportsInterface(bytes4 interfaceId) view returns (bool)"],
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+ provider
64
+ );
65
+ const { TitleEscrow: titleEscrowInterfaceId } = CONTRACT_INTERFACE_ID;
66
+ return implContract.supportsInterface(titleEscrowInterfaceId);
67
+ }, "isSupportedTitleEscrowFactory");
32
68
 
33
- export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
69
+ export { getChainIdSafe, getDefaultContractAddress, getSignerAddressSafe, getTxOptions, isSupportedTitleEscrowFactory, isValidAddress };
@@ -4,4 +4,4 @@ export { supportInterfaceIds as v5SupportInterfaceIds } from './supportInterface
4
4
  import * as contracts from './contracts';
5
5
  export { contracts as v5Contracts };
6
6
  export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './utils';
7
- export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v4';
7
+ export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
@@ -1,5 +1,5 @@
1
- import { ethers as ethers$1 } from 'ethers';
2
- import { ethers } from 'ethersV6';
1
+ import { Contract, ContractFactory } from 'ethersV6';
2
+ import { Contract as Contract$1, ContractFactory as ContractFactory$1 } from 'ethers';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -14,7 +14,10 @@ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
14
14
  throw new Error("Unknown provider type");
15
15
  }, "isV6EthersProvider");
16
16
  const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
17
- return isV6EthersProvider(provider) ? ethers.Contract : ethers$1.Contract;
17
+ return isV6EthersProvider(provider) ? Contract : Contract$1;
18
18
  }, "getEthersContractFromProvider");
19
+ const getEthersContractFactoryFromProvider = /* @__PURE__ */ __name((provider) => {
20
+ return isV6EthersProvider(provider) ? ContractFactory : ContractFactory$1;
21
+ }, "getEthersContractFactoryFromProvider");
19
22
 
20
- export { getEthersContractFromProvider, isV6EthersProvider };
23
+ export { getEthersContractFactoryFromProvider, getEthersContractFromProvider, isV6EthersProvider };
@@ -0,0 +1,77 @@
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
+ * Document Store Deployment Module
10
+ *
11
+ * This module provides functionality to deploy TrustVC Document Store contracts
12
+ * with support for both ethers v5 and v6 signers. It supports two types of stores:
13
+ *
14
+ * 1. **Standard Document Store**: For issuing and revoking verifiable documents
15
+ * - Immutable ownership (documents cannot be transferred)
16
+ * - Suitable for most credential use cases
17
+ *
18
+ * 2. **Transferable Document Store**: For documents that can change ownership
19
+ * - Supports ownership transfers between addresses
20
+ * - Useful for transferable credentials or certificates
21
+ */
22
+
23
+ /**
24
+ * Configuration options for Document Store deployment
25
+ */
26
+ interface DeployOptions {
27
+ chainId?: CHAIN_ID;
28
+ maxFeePerGas?: GasValue;
29
+ maxPriorityFeePerGas?: GasValue;
30
+ isTransferable?: boolean;
31
+ }
32
+ /**
33
+ * Union type for transaction receipts from both ethers v5 and v6
34
+ */
35
+ type TransactionReceipt = ContractReceipt | ContractTransactionReceipt;
36
+ /**
37
+ * Deploys a new Document Store contract with automatic type selection.
38
+ * **Store Types:**
39
+ * - **Standard** (default): Documents are immutable and cannot be transferred
40
+ * - **Transferable**: Documents can be transferred to different owners
41
+ * **Ethers Compatibility:**
42
+ * - Automatically detects and handles both ethers v5 and v6 signers
43
+ * - Returns appropriate receipt type based on signer version
44
+ * @param {string} storeName - The name of the document store (e.g., "My University Credentials")
45
+ * @param {string} owner - The owner address that will control the document store
46
+ * @param {SignerV5 | SignerV6} signer - Signer instance that authorizes the deployment
47
+ * @param {DeployOptions} options - Configuration options for deployment
48
+ * @returns {Promise<TransactionReceipt>} Transaction receipt with deployed contract address
49
+ * @throws {Error} If store name is not provided
50
+ * @throws {Error} If owner address is not provided
51
+ * @throws {Error} If signer provider is not available
52
+ * @throws {Error} If deployment transaction fails
53
+ * @example
54
+ * ```typescript
55
+ * Deploy standard document store
56
+ * const receipt = await deployDocumentStore(
57
+ * "My Document Store",
58
+ * "0x1234...",
59
+ * signer,
60
+ * { chainId: CHAIN_ID.SEPOLIA }
61
+ * );
62
+ *
63
+ * Deploy transferable document store
64
+ * const receipt = await deployDocumentStore(
65
+ * "My Transferable Store",
66
+ * "0x1234...",
67
+ * signer,
68
+ * {
69
+ * isTransferable: true,
70
+ * maxFeePerGas: 50000000000n
71
+ * }
72
+ * );
73
+ * ```
74
+ */
75
+ declare const deployDocumentStore: (storeName: string, owner: string, signer: Signer | Signer$1, options?: DeployOptions) => Promise<TransactionReceipt>;
76
+
77
+ export { type DeployOptions, type TransactionReceipt, deployDocumentStore };
@@ -0,0 +1,82 @@
1
+ import { GasValue } from '../token-registry-functions/types.js';
2
+ import { CHAIN_ID } from '../utils/supportedChains/index.js';
3
+ import { ContractReceipt, ContractTransaction as ContractTransaction$1, Signer } from 'ethers';
4
+ import { ContractTransactionReceipt, ContractTransactionResponse, Signer as Signer$1 } from 'ethersV6';
5
+ import '../utils/gasStation/index.js';
6
+ import '../utils/network/index.js';
7
+
8
+ /**
9
+ * Token Registry Deployment Module
10
+ *
11
+ * This module provides functionality to deploy TradeTrust Token Registry contracts
12
+ * with support for both ethers v5 and v6 signers. It handles two deployment modes:
13
+ *
14
+ * 1. **Quick-start mode** (default): Uses a pre-deployed deployer contract and implementation
15
+ * - Faster deployment with lower gas costs
16
+ * - Requires network to have deployer and implementation contracts
17
+ *
18
+ * 2. **Standalone mode**: Deploys a fresh Token Registry contract from scratch
19
+ * - Works on any network with a supported Title Escrow Factory
20
+ * - Higher gas costs but more flexible
21
+ */
22
+
23
+ /**
24
+ * Union type for transaction receipts from both ethers v5 and v6
25
+ */
26
+ type ContractTransaction = ContractTransaction$1 | ContractTransactionResponse;
27
+ type TransactionReceipt = ContractReceipt | ContractTransactionReceipt | ContractTransaction;
28
+ /**
29
+ * Configuration options for Token Registry deployment
30
+ */
31
+ interface DeployOptions {
32
+ chainId?: CHAIN_ID;
33
+ maxFeePerGas?: GasValue;
34
+ maxPriorityFeePerGas?: GasValue;
35
+ standalone?: boolean;
36
+ factoryAddress?: string;
37
+ tokenRegistryImplAddress?: string;
38
+ deployerContractAddress?: string;
39
+ }
40
+ /**
41
+ * Deploys a new Token Registry contract with automatic mode selection.
42
+ *
43
+ * **Deployment Modes:**
44
+ * - **Quick-start** (default): Uses pre-deployed contracts for faster, cheaper deployment
45
+ * - **Standalone**: Deploys fresh contract when quick-start is unavailable
46
+ *
47
+ * **Ethers Compatibility:**
48
+ * - Automatically detects and handles both ethers v5 and v6 signers
49
+ * - Returns appropriate receipt type based on signer version
50
+ * @param {string} registryName - The name of the token registry (e.g., "My Token Registry")
51
+ * @param {string} registrySymbol - The symbol of the token registry (e.g., "MTR")
52
+ * @param {SignerV5 | SignerV6} signer - Signer instance that authorizes the deployment
53
+ * @param {DeployOptions} options - Configuration options for deployment
54
+ * @returns {Promise<TransactionReceipt>} Transaction receipt with deployed contract address
55
+ * @throws {Error} If network is not supported and no custom addresses provided
56
+ * @throws {Error} If Title Escrow Factory is not supported (standalone mode)
57
+ * @throws {Error} If deployment transaction fails
58
+ * @example
59
+ * ```typescript
60
+ * // Quick-start deployment
61
+ * const receipt = await deployTokenRegistry(
62
+ * "My Registry",
63
+ * "MTR",
64
+ * signer,
65
+ * { chainId: CHAIN_ID.SEPOLIA }
66
+ * );
67
+ *
68
+ * // Standalone deployment with custom factory
69
+ * const receipt = await deployTokenRegistry(
70
+ * "My Registry",
71
+ * "MYR",
72
+ * signer,
73
+ * {
74
+ * standalone: true,
75
+ * factoryAddress: "0x..."
76
+ * }
77
+ * );
78
+ * ```
79
+ */
80
+ declare const deployTokenRegistry: (registryName: string, registrySymbol: string, signer: Signer | Signer$1, options?: DeployOptions) => Promise<TransactionReceipt>;
81
+
82
+ export { type DeployOptions, type TransactionReceipt, deployTokenRegistry };
@@ -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
+ * 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 | ContractTransactionResponse>;
27
+
28
+ export { documentStoreGrantRole };
@@ -1,10 +1,14 @@
1
- export { IssueOptions, documentStoreIssue } from './issue.js';
2
- export { RevokeOptions, documentStoreRevoke } from './revoke.js';
3
- export { DeployOptions, deployDocumentStore } from './deploy.js';
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/document-store.js';
4
7
  export { supportInterfaceIds } from './supportInterfaceIds.js';
5
8
  export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
6
9
  import 'ethersV6';
7
10
  import 'ethers';
11
+ import './types.js';
8
12
  import '../utils/supportedChains/index.js';
9
13
  import '../utils/gasStation/index.js';
10
14
  import '../utils/network/index.js';