@trustvc/trustvc 2.8.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 (30) 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/index.js +2 -2
  4. package/dist/cjs/token-registry-functions/index.js +7 -0
  5. package/dist/cjs/token-registry-functions/ownerOf.js +9 -7
  6. package/dist/cjs/token-registry-functions/utils.js +39 -0
  7. package/dist/cjs/token-registry-v5/index.js +4 -4
  8. package/dist/cjs/utils/ethers/index.js +6 -2
  9. package/dist/esm/{document-store/deploy.js → deploy/document-store.js} +19 -19
  10. package/dist/esm/deploy/token-registry.js +95 -0
  11. package/dist/esm/document-store/index.js +1 -1
  12. package/dist/esm/token-registry-functions/index.js +1 -0
  13. package/dist/esm/token-registry-functions/ownerOf.js +9 -7
  14. package/dist/esm/token-registry-functions/utils.js +38 -2
  15. package/dist/esm/token-registry-v5/index.js +1 -1
  16. package/dist/esm/utils/ethers/index.js +7 -4
  17. package/dist/types/deploy/document-store.d.ts +77 -0
  18. package/dist/types/deploy/token-registry.d.ts +82 -0
  19. package/dist/types/document-store/grant-role.d.ts +2 -2
  20. package/dist/types/document-store/index.d.ts +1 -1
  21. package/dist/types/document-store/transferOwnership.d.ts +3 -3
  22. package/dist/types/index.d.ts +4 -3
  23. package/dist/types/token-registry-functions/index.d.ts +1 -0
  24. package/dist/types/token-registry-functions/ownerOf.d.ts +1 -1
  25. package/dist/types/token-registry-functions/types.d.ts +26 -1
  26. package/dist/types/token-registry-functions/utils.d.ts +7 -4
  27. package/dist/types/token-registry-v5/index.d.ts +1 -2
  28. package/dist/types/utils/ethers/index.d.ts +6 -5
  29. package/package.json +1 -1
  30. package/dist/types/document-store/deploy.d.ts +0 -29
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var documentStore = require('@trustvc/document-store');
4
- var ethersV6 = require('ethersV6');
5
- var ethers$1 = require('ethers');
6
4
  var ethers = require('../utils/ethers');
7
5
  var utils = require('../token-registry-functions/utils');
8
6
 
@@ -16,27 +14,29 @@ const deployDocumentStore = /* @__PURE__ */ __name(async (storeName, owner, sign
16
14
  const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
17
15
  const isV6 = ethers.isV6EthersProvider(signer.provider);
18
16
  const DocumentStoreFactory = options.isTransferable ? documentStore.TransferableDocumentStore__factory : documentStore.DocumentStore__factory;
17
+ const ContractFactory = ethers.getEthersContractFactoryFromProvider(signer.provider);
18
+ const contractFactory = new ContractFactory(
19
+ DocumentStoreFactory.abi,
20
+ DocumentStoreFactory.bytecode,
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ signer
23
+ // Type assertion needed for v5/v6 compatibility
24
+ );
19
25
  try {
20
26
  if (isV6) {
21
- const ContractFactory = new ethersV6.ContractFactory(
22
- DocumentStoreFactory.abi,
23
- DocumentStoreFactory.bytecode,
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- signer
27
+ const contract = await contractFactory.deploy(
28
+ storeName,
29
+ owner,
30
+ txOptions
26
31
  );
27
- const contract = await ContractFactory.deploy(storeName, owner, txOptions);
28
- const receipt = await contract.deploymentTransaction()?.wait();
29
- return receipt;
32
+ return await contract.deploymentTransaction().wait();
30
33
  } else {
31
- const ContractFactory = new ethers$1.ContractFactory(
32
- DocumentStoreFactory.abi,
33
- DocumentStoreFactory.bytecode,
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- signer
34
+ const contract = await contractFactory.deploy(
35
+ storeName,
36
+ owner,
37
+ txOptions
36
38
  );
37
- const contract = await ContractFactory.deploy(storeName, owner, txOptions);
38
- const receipt = await contract.deployTransaction.wait();
39
- return receipt;
39
+ return await contract.deployTransaction.wait();
40
40
  }
41
41
  } catch (e) {
42
42
  console.error("Deployment failed:", e);
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var contracts = require('@tradetrust-tt/token-registry/contracts');
4
+ var utils = require('../token-registry-functions/utils');
5
+ var utils$1 = require('../token-registry-v5/utils');
6
+ var ethers = require('../utils/ethers');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ const deployTokenRegistry = /* @__PURE__ */ __name(async (registryName, registrySymbol, signer, options = {}) => {
11
+ const { maxFeePerGas, maxPriorityFeePerGas } = options;
12
+ let { chainId, standalone, factoryAddress, tokenRegistryImplAddress, deployerContractAddress } = options;
13
+ const deployerAddress = await signer.getAddress();
14
+ if (!chainId) {
15
+ chainId = await utils.getChainIdSafe(signer);
16
+ }
17
+ const {
18
+ TitleEscrowFactory: defaultTitleEscrowFactoryAddress,
19
+ TokenImplementation: defaultTokenImplementationContractAddress,
20
+ Deployer: defaultDeployerContractAddress
21
+ } = utils.getDefaultContractAddress(chainId);
22
+ if (!utils.isValidAddress(deployerContractAddress)) {
23
+ deployerContractAddress = defaultDeployerContractAddress;
24
+ }
25
+ if (!utils.isValidAddress(tokenRegistryImplAddress)) {
26
+ tokenRegistryImplAddress = defaultTokenImplementationContractAddress;
27
+ }
28
+ if (standalone !== false && (!deployerContractAddress || !tokenRegistryImplAddress)) {
29
+ console.error(
30
+ `Network ${chainId} does not support "quick-start" mode. Defaulting to standalone mode.`
31
+ );
32
+ standalone = true;
33
+ }
34
+ if (!standalone) {
35
+ if (!deployerContractAddress || !tokenRegistryImplAddress) {
36
+ throw new Error(`Network ${chainId} currently is not supported. Use --standalone instead.`);
37
+ }
38
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
39
+ const deployerContract = new Contract(
40
+ deployerContractAddress,
41
+ contracts.TDocDeployer__factory.abi,
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ signer
44
+ // Type assertion needed for v5/v6 compatibility
45
+ );
46
+ const initParam = utils$1.encodeInitParams({
47
+ name: registryName,
48
+ symbol: registrySymbol,
49
+ deployer: deployerAddress
50
+ });
51
+ const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
52
+ return await deployerContract.deploy(tokenRegistryImplAddress, initParam, txOptions);
53
+ } else {
54
+ if (!factoryAddress || !utils.isValidAddress(factoryAddress)) {
55
+ factoryAddress = defaultTitleEscrowFactoryAddress;
56
+ if (!factoryAddress) {
57
+ throw new Error(`Network ${chainId} currently is not supported. Supply a factory address.`);
58
+ }
59
+ }
60
+ const supportedTitleEscrowFactory = await utils.isSupportedTitleEscrowFactory(
61
+ factoryAddress,
62
+ signer.provider
63
+ );
64
+ if (!supportedTitleEscrowFactory) {
65
+ throw new Error(`Title Escrow Factory ${factoryAddress} is not supported.`);
66
+ }
67
+ const Contract = ethers.getEthersContractFactoryFromProvider(signer.provider);
68
+ const tokenFactory = new Contract(
69
+ contracts.TradeTrustToken__factory.abi,
70
+ contracts.TradeTrustToken__factory.bytecode,
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ signer
73
+ // Type assertion needed for v5/v6 compatibility
74
+ );
75
+ const isV6 = ethers.isV6EthersProvider(signer.provider);
76
+ const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
77
+ if (isV6) {
78
+ const contract = await tokenFactory.deploy(
79
+ registryName,
80
+ registrySymbol,
81
+ factoryAddress,
82
+ txOptions
83
+ );
84
+ return await contract.deploymentTransaction().wait();
85
+ } else {
86
+ const contract = await tokenFactory.deploy(
87
+ registryName,
88
+ registrySymbol,
89
+ factoryAddress,
90
+ txOptions
91
+ );
92
+ return await contract.deployTransaction.wait();
93
+ }
94
+ }
95
+ }, "deployTokenRegistry");
96
+
97
+ exports.deployTokenRegistry = deployTokenRegistry;
@@ -5,7 +5,7 @@ var revoke = require('./revoke');
5
5
  var revokeRole = require('./revoke-role');
6
6
  var grantRole = require('./grant-role');
7
7
  var transferOwnership = require('./transferOwnership');
8
- var deploy = require('./deploy');
8
+ var documentStore$1 = require('../deploy/document-store');
9
9
  var supportInterfaceIds = require('./supportInterfaceIds');
10
10
  var documentStore = require('@trustvc/document-store');
11
11
 
@@ -33,7 +33,7 @@ Object.defineProperty(exports, "documentStoreTransferOwnership", {
33
33
  });
34
34
  Object.defineProperty(exports, "deployDocumentStore", {
35
35
  enumerable: true,
36
- get: function () { return deploy.deployDocumentStore; }
36
+ get: function () { return documentStore$1.deployDocumentStore; }
37
37
  });
38
38
  Object.defineProperty(exports, "supportInterfaceIds", {
39
39
  enumerable: true,
@@ -5,6 +5,7 @@ var rejectTransfers = require('./rejectTransfers');
5
5
  var returnToken = require('./returnToken');
6
6
  var mint = require('./mint');
7
7
  var ownerOf = require('./ownerOf');
8
+ var tokenRegistry = require('../deploy/token-registry');
8
9
 
9
10
 
10
11
 
@@ -38,3 +39,9 @@ Object.keys(ownerOf).forEach(function (k) {
38
39
  get: function () { return ownerOf[k]; }
39
40
  });
40
41
  });
42
+ Object.keys(tokenRegistry).forEach(function (k) {
43
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
44
+ enumerable: true,
45
+ get: function () { return tokenRegistry[k]; }
46
+ });
47
+ });
@@ -3,6 +3,7 @@
3
3
  var core = require('../core');
4
4
  var tokenRegistryV5 = require('../token-registry-v5');
5
5
  var tokenRegistryV4 = require('../token-registry-v4');
6
+ var ethers = require('../utils/ethers');
6
7
 
7
8
  var __defProp = Object.defineProperty;
8
9
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -23,23 +24,24 @@ const ownerOf = /* @__PURE__ */ __name(async (contractOptions, signer, params, o
23
24
  if (!isV4TT && !isV5TT) {
24
25
  throw new Error("Only Token Registry V4/V5 is supported");
25
26
  }
27
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
26
28
  let tradeTrustTokenContract;
27
29
  if (isV5TT) {
28
- tradeTrustTokenContract = tokenRegistryV5.v5Contracts.TradeTrustToken__factory.connect(
30
+ tradeTrustTokenContract = new Contract(
29
31
  tokenRegistryAddress,
32
+ tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
34
  signer
31
35
  );
32
36
  } else if (isV4TT) {
33
- tradeTrustTokenContract = tokenRegistryV4.v4Contracts.TradeTrustToken__factory.connect(
37
+ tradeTrustTokenContract = new Contract(
34
38
  tokenRegistryAddress,
39
+ tokenRegistryV4.v4Contracts.TradeTrustToken__factory.abi,
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
41
  signer
36
42
  );
37
43
  }
38
- if (isV5TT) {
39
- return await tradeTrustTokenContract.ownerOf(tokenId);
40
- } else if (isV4TT) {
41
- return await tradeTrustTokenContract.ownerOf(tokenId);
42
- }
44
+ return await tradeTrustTokenContract.ownerOf(tokenId);
43
45
  }, "ownerOf");
44
46
 
45
47
  exports.ownerOf = ownerOf;
@@ -2,6 +2,8 @@
2
2
 
3
3
  var ethers = require('../utils/ethers');
4
4
  var utils = require('../utils');
5
+ var ethersV6 = require('ethersV6');
6
+ var tokenRegistryV5 = require('../token-registry-v5');
5
7
 
6
8
  var __defProp = Object.defineProperty;
7
9
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -31,7 +33,44 @@ const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
31
33
  }
32
34
  return await signer.getAddress();
33
35
  }, "getSignerAddressSafe");
36
+ const { contractInterfaceId: CONTRACT_INTERFACE_ID, contractAddress: CONTRACT_ADDRESS } = tokenRegistryV5.constants;
37
+ const getDefaultContractAddress = /* @__PURE__ */ __name((chainId) => {
38
+ const { TitleEscrowFactory, TokenImplementation, Deployer } = CONTRACT_ADDRESS;
39
+ const chainTitleEscrowFactory = TitleEscrowFactory[chainId];
40
+ const chainTokenImplementation = TokenImplementation[chainId];
41
+ const chainDeployer = Deployer[chainId];
42
+ return {
43
+ TitleEscrowFactory: chainTitleEscrowFactory,
44
+ TokenImplementation: chainTokenImplementation,
45
+ Deployer: chainDeployer
46
+ };
47
+ }, "getDefaultContractAddress");
48
+ const isValidAddress = /* @__PURE__ */ __name((address) => {
49
+ if (!address) return false;
50
+ return ethersV6.isAddress(address);
51
+ }, "isValidAddress");
52
+ const isSupportedTitleEscrowFactory = /* @__PURE__ */ __name(async (factoryAddress, provider) => {
53
+ const Contract = ethers.getEthersContractFromProvider(provider);
54
+ const titleEscrowFactoryContract = new Contract(
55
+ factoryAddress,
56
+ ["function implementation() view returns (address)"],
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ provider
59
+ );
60
+ const implAddr = await titleEscrowFactoryContract.implementation();
61
+ const implContract = new Contract(
62
+ implAddr,
63
+ ["function supportsInterface(bytes4 interfaceId) view returns (bool)"],
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ provider
66
+ );
67
+ const { TitleEscrow: titleEscrowInterfaceId } = CONTRACT_INTERFACE_ID;
68
+ return implContract.supportsInterface(titleEscrowInterfaceId);
69
+ }, "isSupportedTitleEscrowFactory");
34
70
 
35
71
  exports.getChainIdSafe = getChainIdSafe;
72
+ exports.getDefaultContractAddress = getDefaultContractAddress;
36
73
  exports.getSignerAddressSafe = getSignerAddressSafe;
37
74
  exports.getTxOptions = getTxOptions;
75
+ exports.isSupportedTitleEscrowFactory = isSupportedTitleEscrowFactory;
76
+ exports.isValidAddress = isValidAddress;
@@ -5,7 +5,7 @@ var roleHash = require('./roleHash');
5
5
  var supportInterfaceIds = require('./supportInterfaceIds');
6
6
  var contracts = require('./contracts');
7
7
  var utils = require('./utils');
8
- var tokenRegistryV4 = require('@tradetrust-tt/token-registry-v4');
8
+ var tokenRegistryV5 = require('@tradetrust-tt/token-registry-v5');
9
9
 
10
10
  function _interopNamespace(e) {
11
11
  if (e && e.__esModule) return e;
@@ -56,13 +56,13 @@ Object.defineProperty(exports, "v5GetEventFromReceipt", {
56
56
  });
57
57
  Object.defineProperty(exports, "constants", {
58
58
  enumerable: true,
59
- get: function () { return tokenRegistryV4.constants; }
59
+ get: function () { return tokenRegistryV5.constants; }
60
60
  });
61
61
  Object.defineProperty(exports, "utils", {
62
62
  enumerable: true,
63
- get: function () { return tokenRegistryV4.utils; }
63
+ get: function () { return tokenRegistryV5.utils; }
64
64
  });
65
65
  Object.defineProperty(exports, "v5Utils", {
66
66
  enumerable: true,
67
- get: function () { return tokenRegistryV4.utils; }
67
+ get: function () { return tokenRegistryV5.utils; }
68
68
  });
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var ethers = require('ethers');
4
3
  var ethersV6 = require('ethersV6');
4
+ var ethers = require('ethers');
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -16,8 +16,12 @@ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
16
16
  throw new Error("Unknown provider type");
17
17
  }, "isV6EthersProvider");
18
18
  const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
19
- return isV6EthersProvider(provider) ? ethersV6.ethers.Contract : ethers.ethers.Contract;
19
+ return isV6EthersProvider(provider) ? ethersV6.Contract : ethers.Contract;
20
20
  }, "getEthersContractFromProvider");
21
+ const getEthersContractFactoryFromProvider = /* @__PURE__ */ __name((provider) => {
22
+ return isV6EthersProvider(provider) ? ethersV6.ContractFactory : ethers.ContractFactory;
23
+ }, "getEthersContractFactoryFromProvider");
21
24
 
25
+ exports.getEthersContractFactoryFromProvider = getEthersContractFactoryFromProvider;
22
26
  exports.getEthersContractFromProvider = getEthersContractFromProvider;
23
27
  exports.isV6EthersProvider = isV6EthersProvider;
@@ -1,7 +1,5 @@
1
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';
2
+ import { isV6EthersProvider, getEthersContractFactoryFromProvider } from '../utils/ethers';
5
3
  import { getTxOptions } from '../token-registry-functions/utils';
6
4
 
7
5
  var __defProp = Object.defineProperty;
@@ -14,27 +12,29 @@ const deployDocumentStore = /* @__PURE__ */ __name(async (storeName, owner, sign
14
12
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
15
13
  const isV6 = isV6EthersProvider(signer.provider);
16
14
  const DocumentStoreFactory = options.isTransferable ? TransferableDocumentStore__factory : DocumentStore__factory;
15
+ const ContractFactory = getEthersContractFactoryFromProvider(signer.provider);
16
+ const contractFactory = new ContractFactory(
17
+ DocumentStoreFactory.abi,
18
+ DocumentStoreFactory.bytecode,
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ signer
21
+ // Type assertion needed for v5/v6 compatibility
22
+ );
17
23
  try {
18
24
  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
25
+ const contract = await contractFactory.deploy(
26
+ storeName,
27
+ owner,
28
+ txOptions
24
29
  );
25
- const contract = await ContractFactory$1.deploy(storeName, owner, txOptions);
26
- const receipt = await contract.deploymentTransaction()?.wait();
27
- return receipt;
30
+ return await contract.deploymentTransaction().wait();
28
31
  } 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
32
+ const contract = await contractFactory.deploy(
33
+ storeName,
34
+ owner,
35
+ txOptions
34
36
  );
35
- const contract = await ContractFactory.deploy(storeName, owner, txOptions);
36
- const receipt = await contract.deployTransaction.wait();
37
- return receipt;
37
+ return await contract.deployTransaction.wait();
38
38
  }
39
39
  } catch (e) {
40
40
  console.error("Deployment failed:", e);
@@ -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 };
@@ -3,6 +3,6 @@ export { documentStoreRevoke } from './revoke';
3
3
  export { documentStoreRevokeRole } from './revoke-role';
4
4
  export { documentStoreGrantRole } from './grant-role';
5
5
  export { documentStoreTransferOwnership } from './transferOwnership';
6
- export { deployDocumentStore } from './deploy';
6
+ export { deployDocumentStore } from '../deploy/document-store';
7
7
  export { supportInterfaceIds } from './supportInterfaceIds';
8
8
  export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { Signer as Signer$1, ContractTransaction as ContractTransaction$1 } from 'ethersV6';
1
+ import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
2
2
  import { Signer, ContractTransaction } from 'ethers';
3
3
  import { CommandOptions } from './types.js';
4
4
  import '../utils/supportedChains/index.js';
@@ -23,6 +23,6 @@ import '../token-registry-functions/types.js';
23
23
  * @throws {Error} If the role is invalid.
24
24
  * @throws {Error} If the `callStatic.grantRole` fails as a pre-check.
25
25
  */
26
- declare const documentStoreGrantRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransaction$1>;
26
+ declare const documentStoreGrantRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
27
27
 
28
28
  export { documentStoreGrantRole };
@@ -3,7 +3,7 @@ export { documentStoreRevoke } from './revoke.js';
3
3
  export { documentStoreRevokeRole } from './revoke-role.js';
4
4
  export { documentStoreGrantRole } from './grant-role.js';
5
5
  export { documentStoreTransferOwnership } from './transferOwnership.js';
6
- export { deployDocumentStore } from './deploy.js';
6
+ export { deployDocumentStore } from '../deploy/document-store.js';
7
7
  export { supportInterfaceIds } from './supportInterfaceIds.js';
8
8
  export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
9
9
  import 'ethersV6';
@@ -1,4 +1,4 @@
1
- import { Signer as Signer$1, ContractTransaction as ContractTransaction$1 } from 'ethersV6';
1
+ import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
2
2
  import { Signer, ContractTransaction } from 'ethers';
3
3
  import { CommandOptions } from './types.js';
4
4
  import '../utils/supportedChains/index.js';
@@ -23,8 +23,8 @@ import '../token-registry-functions/types.js';
23
23
  * @throws {Error} If the `callStatic.revokeRole` fails as a pre-check.
24
24
  */
25
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>;
26
+ grantTransaction: Promise<ContractTransaction | ContractTransactionResponse>;
27
+ revokeTransaction: Promise<ContractTransaction | ContractTransactionResponse>;
28
28
  }>;
29
29
 
30
30
  export { documentStoreTransferOwnership };
@@ -3,12 +3,13 @@ export { contractAddress as v4ContractAddress } from './token-registry-v4/contra
3
3
  export { supportInterfaceIds as v4SupportInterfaceIds } from './token-registry-v4/supportInterfaceIds.js';
4
4
  export { c as v4Contracts } from './contracts-BEtjrEPE.js';
5
5
  export { computeInterfaceId as v4ComputeInterfaceId, computeTitleEscrowAddress as v4ComputeTitleEscrowAddress, encodeInitParams as v4EncodeInitParams, getEventFromReceipt as v4GetEventFromReceipt } from './token-registry-v4/utils.js';
6
- export { utils as v4Utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v4';
6
+ export { utils as v4Utils } from '@tradetrust-tt/token-registry-v4';
7
7
  export { contractAddress as v5ContractAddress } from './token-registry-v5/contractAddress.js';
8
8
  export { roleHash as v5RoleHash } from './token-registry-v5/roleHash.js';
9
9
  export { supportInterfaceIds as v5SupportInterfaceIds } from './token-registry-v5/supportInterfaceIds.js';
10
10
  export { c as v5Contracts } from './contracts-BaIGKzNt.js';
11
11
  export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './token-registry-v5/utils.js';
12
+ export { utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
12
13
  export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
13
14
  export { documentStoreIssue } from './document-store/issue.js';
14
15
  export { documentStoreRevoke } from './document-store/revoke.js';
@@ -23,13 +24,14 @@ export { WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData,
23
24
  export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, scaleBigNumber } from './utils/gasStation/index.js';
24
25
  export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
25
26
  export { gaEvent, gaPageView, validateGaEvent, validateGtag, validatePageViewEvent } from './utils/analytics/analytics.js';
26
- export { deployDocumentStore } from './document-store/deploy.js';
27
+ export { deployDocumentStore } from './deploy/document-store.js';
27
28
  export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
28
29
  export { nominate, transferBeneficiary, transferHolder, transferOwners } from './token-registry-functions/transfer.js';
29
30
  export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './token-registry-functions/rejectTransfers.js';
30
31
  export { acceptReturned, rejectReturned, returnToIssuer } from './token-registry-functions/returnToken.js';
31
32
  export { mint } from './token-registry-functions/mint.js';
32
33
  export { ownerOf } from './token-registry-functions/ownerOf.js';
34
+ export { DeployOptions, TransactionReceipt, deployTokenRegistry } from './deploy/token-registry.js';
33
35
  export { decrypt } from './core/decrypt.js';
34
36
  export { encrypt } from './core/encrypt.js';
35
37
  export { verifyDocument } from './core/verify.js';
@@ -67,7 +69,6 @@ import '@tradetrust-tt/token-registry-v4/contracts';
67
69
  import 'ethers';
68
70
  import '@typechain/ethers-v5/static/common';
69
71
  import '@tradetrust-tt/token-registry-v5/contracts';
70
- import '@tradetrust-tt/token-registry-v5';
71
72
  import 'ethersV6';
72
73
  import './document-store/types.js';
73
74
  import './token-registry-functions/types.js';
@@ -3,6 +3,7 @@ export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners }
3
3
  export { acceptReturned, rejectReturned, returnToIssuer } from './returnToken.js';
4
4
  export { mint } from './mint.js';
5
5
  export { ownerOf } from './ownerOf.js';
6
+ export { DeployOptions, TransactionReceipt, deployTokenRegistry } from '../deploy/token-registry.js';
6
7
  import 'ethersV6';
7
8
  import 'ethers';
8
9
  import './types.js';
@@ -9,7 +9,7 @@ import '../utils/network/index.js';
9
9
  * Retrieves the owner of a given token from the TradeTrustToken contract.
10
10
  * Supports both Token Registry V4 and V5 implementations.
11
11
  * @param {OwnerOfTokenOptions} contractOptions - Options containing the token registry address.
12
- * @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to query the blockchain.
12
+ * @param {SignerV5 | SignerV6} signer - Signer instance (v5 or v6) used to query the blockchain.
13
13
  * @param {OwnerOfTokenParams} params - Contains the `tokenId` of the token to query ownership for.
14
14
  * @param {TransactionOptions} options - Includes the `titleEscrowVersion` and other optional metadata for interface detection.
15
15
  * @returns {Promise<string>} A promise that resolves to the owner address of the specified token.
@@ -4,6 +4,12 @@ import { BigNumberish, Provider } from 'ethersV6';
4
4
  import '../utils/gasStation/index.js';
5
5
  import '../utils/network/index.js';
6
6
 
7
+ interface GasPriceScale {
8
+ maxPriorityFeePerGasScale: number;
9
+ }
10
+ interface GasOption extends GasPriceScale {
11
+ dryRun: boolean;
12
+ }
7
13
  type GasValue = BigNumber | BigNumberish | string | number;
8
14
  interface RejectTransferParams {
9
15
  remarks?: string;
@@ -78,5 +84,24 @@ interface ProviderInfo {
78
84
  ethersVersion: 'v5' | 'v6';
79
85
  titleEscrowVersion: 'v4' | 'v5';
80
86
  }
87
+ interface NetworkOption {
88
+ network: string;
89
+ }
90
+ type WalletOption = {
91
+ encryptedWalletPath: string;
92
+ };
93
+ type PrivateKeyOption = {
94
+ key?: string;
95
+ keyFile?: never;
96
+ } | {
97
+ key?: never;
98
+ keyFile?: string;
99
+ };
100
+ type NetworkAndWalletSignerOption = NetworkOption & (Partial<WalletOption> | Partial<PrivateKeyOption>);
101
+ interface DeployContractAddress {
102
+ TitleEscrowFactory?: string;
103
+ TokenImplementation?: string;
104
+ Deployer?: string;
105
+ }
81
106
 
82
- export type { AcceptReturnedOptions, AcceptReturnedParams, ContractOptions, GasValue, MintTokenOptions, MintTokenParams, NominateParams, OwnerOfTokenOptions, OwnerOfTokenParams, ProviderInfo, RejectReturnedOptions, RejectReturnedParams, RejectTransferParams, ReturnToIssuerParams, TransactionOptions, TransferBeneficiaryParams, TransferHolderParams, TransferOwnersParams };
107
+ export type { AcceptReturnedOptions, AcceptReturnedParams, ContractOptions, DeployContractAddress, GasOption, GasPriceScale, GasValue, MintTokenOptions, MintTokenParams, NetworkAndWalletSignerOption, NetworkOption, NominateParams, OwnerOfTokenOptions, OwnerOfTokenParams, PrivateKeyOption, ProviderInfo, RejectReturnedOptions, RejectReturnedParams, RejectTransferParams, ReturnToIssuerParams, TransactionOptions, TransferBeneficiaryParams, TransferHolderParams, TransferOwnersParams, WalletOption };
@@ -1,7 +1,7 @@
1
- import { GasValue } from './types.js';
1
+ import { GasValue, DeployContractAddress } from './types.js';
2
2
  import { CHAIN_ID } from '../utils/supportedChains/index.js';
3
- import { Signer as Signer$1 } from 'ethers';
4
- import { Signer } from 'ethersV6';
3
+ import { Signer as Signer$1, providers } from 'ethers';
4
+ import { Signer, Provider } from 'ethersV6';
5
5
  import '../utils/gasStation/index.js';
6
6
  import '../utils/network/index.js';
7
7
 
@@ -14,5 +14,8 @@ declare const getTxOptions: (signer: Signer | Signer$1, chainId: CHAIN_ID, maxFe
14
14
  }>;
15
15
  declare const getChainIdSafe: (signer: Signer | Signer$1) => Promise<bigint | number>;
16
16
  declare const getSignerAddressSafe: (signer: Signer | Signer$1) => Promise<string>;
17
+ declare const getDefaultContractAddress: (chainId: CHAIN_ID) => DeployContractAddress;
18
+ declare const isValidAddress: (address?: string) => boolean;
19
+ declare const isSupportedTitleEscrowFactory: (factoryAddress: string, provider: providers.Provider | Provider) => Promise<boolean>;
17
20
 
18
- export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
21
+ export { getChainIdSafe, getDefaultContractAddress, getSignerAddressSafe, getTxOptions, isSupportedTitleEscrowFactory, isValidAddress };
@@ -3,7 +3,6 @@ export { roleHash as v5RoleHash } from './roleHash.js';
3
3
  export { supportInterfaceIds as v5SupportInterfaceIds } from './supportInterfaceIds.js';
4
4
  export { c as v5Contracts } from '../contracts-BaIGKzNt.js';
5
5
  export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './utils.js';
6
- export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v4';
6
+ export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
7
7
  export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
8
8
  import '@tradetrust-tt/token-registry-v5/contracts';
9
- import '@tradetrust-tt/token-registry-v5';
@@ -1,8 +1,9 @@
1
- import { ethers as ethers$1 } from 'ethers';
2
- import { ethers } from 'ethersV6';
3
- import { Provider } from '@ethersproject/abstract-provider';
1
+ import { Provider, Contract as Contract$1, ContractFactory as ContractFactory$1 } from 'ethersV6';
2
+ import { providers, Contract, ContractFactory } from 'ethers';
4
3
 
4
+ type ProviderV5 = providers.Provider;
5
5
  declare const isV6EthersProvider: (provider: any) => boolean;
6
- declare const getEthersContractFromProvider: (provider: Provider | ethers.Provider) => typeof ethers$1.Contract | typeof ethers.Contract;
6
+ declare const getEthersContractFromProvider: (provider: ProviderV5 | Provider) => typeof Contract | typeof Contract$1;
7
+ declare const getEthersContractFactoryFromProvider: (provider: ProviderV5 | Provider) => typeof ContractFactory | typeof ContractFactory$1;
7
8
 
8
- export { getEthersContractFromProvider, isV6EthersProvider };
9
+ export { getEthersContractFactoryFromProvider, getEthersContractFromProvider, isV6EthersProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,29 +0,0 @@
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 };