@trustvc/trustvc 1.2.5-alpha.1 → 1.2.5

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 (28) hide show
  1. package/dist/cjs/core/endorsement-chain/fetchEscrowTransfer.js +44 -18
  2. package/dist/cjs/core/endorsement-chain/fetchTokenTransfer.js +16 -6
  3. package/dist/cjs/core/endorsement-chain/useEndorsementChain.js +70 -28
  4. package/dist/cjs/utils/documents/index.js +4 -4
  5. package/dist/cjs/utils/ethers/index.js +20 -0
  6. package/dist/cjs/verify/fragments/issuer-identity/w3cIssuerIdentity.js +2 -2
  7. package/dist/esm/core/endorsement-chain/fetchEscrowTransfer.js +44 -18
  8. package/dist/esm/core/endorsement-chain/fetchTokenTransfer.js +16 -6
  9. package/dist/esm/core/endorsement-chain/useEndorsementChain.js +69 -27
  10. package/dist/esm/utils/documents/index.js +4 -4
  11. package/dist/esm/utils/ethers/index.js +17 -0
  12. package/dist/esm/verify/fragments/document-status/w3cCredentialStatus.js +1 -1
  13. package/dist/esm/verify/fragments/issuer-identity/w3cIssuerIdentity.js +2 -2
  14. package/dist/esm/verify/verify.js +1 -1
  15. package/dist/types/core/endorsement-chain/fetchEscrowTransfer.d.ts +4 -3
  16. package/dist/types/core/endorsement-chain/fetchTokenTransfer.d.ts +3 -3
  17. package/dist/types/core/endorsement-chain/helpers.d.ts +3 -2
  18. package/dist/types/core/endorsement-chain/index.d.ts +1 -1
  19. package/dist/types/core/endorsement-chain/retrieveEndorsementChain.d.ts +3 -2
  20. package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +11 -3
  21. package/dist/types/core/index.d.ts +1 -1
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/open-attestation/wrap.d.ts +1 -1
  24. package/dist/types/token-registry-v5/typedContractMethod.d.ts +1 -1
  25. package/dist/types/utils/ethers/index.d.ts +7 -0
  26. package/dist/types/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.ts +1 -1
  27. package/dist/types/verify/fragments/document-status/transferableRecords/utils.d.ts +1 -1
  28. package/package.json +9 -6
@@ -2,22 +2,39 @@
2
2
 
3
3
  var contracts = require('../../token-registry-v4/contracts');
4
4
  var contracts$1 = require('../../token-registry-v5/contracts');
5
+ var ethers = require('../../utils/ethers');
5
6
 
6
7
  var __defProp = Object.defineProperty;
7
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
9
  const fetchEscrowTransfersV4 = /* @__PURE__ */ __name(async (provider, address) => {
9
- const titleEscrowContract = contracts.TitleEscrow__factory.connect(address, provider);
10
- const holderChangeLogsDeferred = await fetchHolderTransfers(titleEscrowContract, provider);
11
- const ownerChangeLogsDeferred = await fetchOwnerTransfers(titleEscrowContract, provider);
10
+ const Contract = ethers.getEthersContractFromProvider(provider);
11
+ const titleEscrowContract = new Contract(
12
+ address,
13
+ contracts.TitleEscrow__factory.abi,
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ provider
16
+ );
17
+ const holderChangeLogsDeferred = fetchHolderTransfers(titleEscrowContract);
18
+ const ownerChangeLogsDeferred = fetchOwnerTransfers(titleEscrowContract);
12
19
  const [holderChangeLogs, ownerChangeLogs] = await Promise.all([
13
20
  holderChangeLogsDeferred,
14
21
  ownerChangeLogsDeferred
15
22
  ]);
16
23
  return [...holderChangeLogs, ...ownerChangeLogs];
17
24
  }, "fetchEscrowTransfersV4");
18
- const fetchEscrowTransfersV5 = /* @__PURE__ */ __name(async (provider, address) => {
19
- const titleEscrowContract = contracts$1.TitleEscrow__factory.connect(address, provider);
20
- const holderChangeLogsDeferred = await fetchAllTransfers(titleEscrowContract);
25
+ const fetchEscrowTransfersV5 = /* @__PURE__ */ __name(async (provider, titleEscrowAddress, tokenRegistryAddress) => {
26
+ const Contract = ethers.getEthersContractFromProvider(provider);
27
+ const titleEscrowContract = new Contract(
28
+ titleEscrowAddress,
29
+ contracts$1.TitleEscrow__factory.abi,
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ provider
32
+ );
33
+ const holderChangeLogsDeferred = await fetchAllTransfers(
34
+ titleEscrowContract,
35
+ titleEscrowAddress,
36
+ tokenRegistryAddress
37
+ );
21
38
  return holderChangeLogsDeferred;
22
39
  }, "fetchEscrowTransfersV5");
23
40
  const getParsedLogs = /* @__PURE__ */ __name((logs, titleEscrow) => {
@@ -30,9 +47,9 @@ const getParsedLogs = /* @__PURE__ */ __name((logs, titleEscrow) => {
30
47
  };
31
48
  });
32
49
  }, "getParsedLogs");
33
- const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, provider) => {
50
+ const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
34
51
  const ownerChangeFilter = titleEscrowContract.filters.BeneficiaryTransfer(null, null);
35
- const ownerChangeLogs = await provider.getLogs({ ...ownerChangeFilter, fromBlock: 0 });
52
+ const ownerChangeLogs = await titleEscrowContract.queryFilter(ownerChangeFilter, 0, "latest");
36
53
  const ownerChangeLogsParsed = getParsedLogs(ownerChangeLogs, titleEscrowContract);
37
54
  return ownerChangeLogsParsed.map((event) => ({
38
55
  type: "TRANSFER_BENEFICIARY",
@@ -42,9 +59,9 @@ const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, p
42
59
  transactionIndex: event.transactionIndex
43
60
  }));
44
61
  }, "fetchOwnerTransfers");
45
- const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, provider) => {
62
+ const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
46
63
  const holderChangeFilter = titleEscrowContract.filters.HolderTransfer(null, null);
47
- const holderChangeLogs = await provider.getLogs({ ...holderChangeFilter, fromBlock: 0 });
64
+ const holderChangeLogs = await titleEscrowContract.queryFilter(holderChangeFilter, 0, "latest");
48
65
  const holderChangeLogsParsed = getParsedLogs(holderChangeLogs, titleEscrowContract);
49
66
  return holderChangeLogsParsed.map((event) => ({
50
67
  type: "TRANSFER_HOLDER",
@@ -54,7 +71,7 @@ const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract,
54
71
  transactionIndex: event.transactionIndex
55
72
  }));
56
73
  }, "fetchHolderTransfers");
57
- const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
74
+ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, titleEscrowAddress, tokenRegistryAddress) => {
58
75
  const allFilters = [
59
76
  titleEscrowContract.filters.HolderTransfer,
60
77
  titleEscrowContract.filters.BeneficiaryTransfer,
@@ -72,8 +89,16 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
72
89
  return logs;
73
90
  })
74
91
  );
75
- const holderChangeLogsParsed = getParsedLogs(allLogs.flat(), titleEscrowContract);
76
- const tokenRegistryAddress = await titleEscrowContract.registry();
92
+ const holderChangeLogsParsed = getParsedLogs(
93
+ allLogs.flat(),
94
+ titleEscrowContract
95
+ );
96
+ if (!tokenRegistryAddress) {
97
+ tokenRegistryAddress = await titleEscrowContract.registry();
98
+ }
99
+ if (!titleEscrowAddress) {
100
+ titleEscrowAddress = titleEscrowContract?.address ?? await titleEscrowContract.getAddress();
101
+ }
77
102
  return holderChangeLogsParsed.map((event) => {
78
103
  if (event?.name === "HolderTransfer") {
79
104
  return {
@@ -98,7 +123,7 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
98
123
  return {
99
124
  type,
100
125
  from: type === "INITIAL" ? "0x0000000000000000000000000000000000000000" : tokenRegistryAddress,
101
- to: titleEscrowContract.address,
126
+ to: titleEscrowAddress,
102
127
  blockNumber: event.blockNumber,
103
128
  transactionHash: event.transactionHash,
104
129
  transactionIndex: event.transactionIndex,
@@ -108,14 +133,15 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
108
133
  return {
109
134
  type: "RETURNED_TO_ISSUER",
110
135
  blockNumber: event.blockNumber,
111
- from: titleEscrowContract.address,
136
+ // Handle ethers v5 and v6 differently
137
+ from: titleEscrowAddress,
112
138
  to: tokenRegistryAddress,
113
139
  transactionHash: event.transactionHash,
114
140
  transactionIndex: event.transactionIndex,
115
141
  remark: event.args?.remark
116
142
  };
117
143
  } else if (event?.name === "Nomination") {
118
- return void 0;
144
+ return undefined;
119
145
  } else if (event?.name === "RejectTransferOwners") {
120
146
  return {
121
147
  type: "REJECT_TRANSFER_OWNERS",
@@ -151,8 +177,8 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
151
177
  remark: event.args?.remark
152
178
  };
153
179
  }
154
- return void 0;
155
- }).filter((event) => event !== void 0);
180
+ return undefined;
181
+ }).filter((event) => event !== undefined);
156
182
  }, "fetchAllTransfers");
157
183
  function identifyTokenReceivedType(event) {
158
184
  if (event.args.isMinting) {
@@ -1,27 +1,36 @@
1
1
  'use strict';
2
2
 
3
+ var contracts = require('../../token-registry-v4/contracts');
4
+ var ethers = require('../../utils/ethers');
3
5
  var helpers = require('../endorsement-chain/helpers');
4
6
 
5
7
  var __defProp = Object.defineProperty;
6
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const fetchTokenTransfers = /* @__PURE__ */ __name(async (tokenRegistry, tokenId) => {
8
- const logs = await fetchLogs(tokenRegistry, tokenId);
9
- const parsedLogs = parseLogs(logs, tokenRegistry);
10
- const tokenRegistryAddress = tokenRegistry.address;
9
+ const fetchTokenTransfers = /* @__PURE__ */ __name(async (provider, tokenRegistryAddress, tokenId) => {
10
+ const Contract = ethers.getEthersContractFromProvider(provider);
11
+ const tokenRegistryContract = new Contract(
12
+ tokenRegistryAddress,
13
+ contracts.TradeTrustToken__factory.abi,
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ provider
16
+ );
17
+ const logs = await fetchLogs(tokenRegistryContract, tokenId);
18
+ const parsedLogs = parseLogs(logs, tokenRegistryContract);
11
19
  const reformattedLogs = parsedLogs.map(
12
20
  (event) => formatTokenTransferEvent(event, tokenRegistryAddress)
13
21
  );
14
22
  helpers.sortLogChain(reformattedLogs);
15
23
  return reformattedLogs;
16
24
  }, "fetchTokenTransfers");
17
- const fetchLogs = /* @__PURE__ */ __name(async (tokenRegistry, tokenId) => {
25
+ async function fetchLogs(tokenRegistry, tokenId) {
18
26
  const transferLogFilter = tokenRegistry.filters.Transfer(null, null, tokenId);
19
27
  const logs = await tokenRegistry.queryFilter(transferLogFilter, 0);
20
28
  if (logs.length === 0) {
21
29
  throw new Error("Unminted Title Escrow");
22
30
  }
23
31
  return logs;
24
- }, "fetchLogs");
32
+ }
33
+ __name(fetchLogs, "fetchLogs");
25
34
  const parseLogs = /* @__PURE__ */ __name((logs, tokenRegistry) => {
26
35
  return logs.map((log) => {
27
36
  if (!log.args) throw new Error(`Transfer log malformed: ${log}`);
@@ -29,6 +38,7 @@ const parseLogs = /* @__PURE__ */ __name((logs, tokenRegistry) => {
29
38
  if (!log.transactionHash) throw new Error("Transaction hash not present");
30
39
  return {
31
40
  ...log,
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
42
  ...tokenRegistry.interface.parseLog(log)
33
43
  };
34
44
  });
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var ethers = require('ethers');
4
- var contracts = require('../../token-registry-v4/contracts');
5
- var supportInterfaceIds = require('../../token-registry-v4/supportInterfaceIds');
6
- var supportInterfaceIds$1 = require('../../token-registry-v5/supportInterfaceIds');
3
+ var ethers$1 = require('ethers');
4
+ var supportInterfaceIds$1 = require('../../token-registry-v4/supportInterfaceIds');
5
+ var supportInterfaceIds = require('../../token-registry-v5/supportInterfaceIds');
6
+ var ethers = require('../../utils/ethers');
7
7
  var decrypt = require('../decrypt');
8
8
  var fetchEscrowTransfer = require('../endorsement-chain/fetchEscrowTransfer');
9
9
  var fetchTokenTransfer = require('../endorsement-chain/fetchTokenTransfer');
@@ -13,81 +13,123 @@ var retrieveEndorsementChain = require('../endorsement-chain/retrieveEndorsement
13
13
  var __defProp = Object.defineProperty;
14
14
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
15
  const TitleEscrowInterface = {
16
- V4: supportInterfaceIds.supportInterfaceIds.TitleEscrow,
17
- V5: supportInterfaceIds$1.supportInterfaceIds.TitleEscrow
16
+ V4: supportInterfaceIds$1.supportInterfaceIds.TitleEscrow,
17
+ V5: supportInterfaceIds.supportInterfaceIds.TitleEscrow
18
18
  };
19
19
  const fetchTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistry) => {
20
20
  return tokenRegistry.titleEscrowFactory();
21
21
  }, "fetchTitleEscrowFactoryAddress");
22
- const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (titleEscrowFactoryContract, tokenRegistryAddress, tokenId) => {
22
+ const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, contractAddress, functionTypes, params) => {
23
+ const functionSelector = ethers$1.ethers.utils.id(functionSignature).slice(0, 10);
24
+ const encodedParams = ethers$1.ethers.utils.defaultAbiCoder.encode(functionTypes, [...params]);
25
+ const calldata2 = functionSelector + encodedParams.slice(2);
26
+ const result = await provider.call({
27
+ to: contractAddress,
28
+ data: calldata2
29
+ });
30
+ return ethers$1.ethers.utils.getAddress(ethers$1.ethers.utils.hexDataSlice(result, 12));
31
+ }, "calldata");
32
+ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId) => {
23
33
  try {
24
- return await titleEscrowFactoryContract.getEscrowAddress(tokenRegistryAddress, tokenId);
34
+ return await calldata(
35
+ provider,
36
+ "getEscrowAddress(address,uint256)",
37
+ titleEscrowFactoryAddress,
38
+ ["address", "uint256"],
39
+ [tokenRegistryAddress, tokenId]
40
+ );
25
41
  } catch {
26
- return titleEscrowFactoryContract.getAddress(tokenRegistryAddress, tokenId);
42
+ return await calldata(
43
+ provider,
44
+ "getAddress(address,uint256)",
45
+ titleEscrowFactoryAddress,
46
+ ["address", "uint256"],
47
+ [tokenRegistryAddress, tokenId]
48
+ );
27
49
  }
28
50
  }, "resolveTitleEscrowAddress");
29
51
  const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
52
+ const Contract = ethers.getEthersContractFromProvider(provider);
30
53
  const tokenRegistryAbi = [
31
54
  "function titleEscrowFactory() external view returns (address)",
32
55
  "function ownerOf(uint256 tokenId) view returns (address)"
33
56
  ];
34
- const tokenRegistry = new ethers.ethers.Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
57
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
35
58
  const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
36
59
  const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
37
60
  const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
38
61
  if (!isInactiveEscrow) return titleEscrowOwner;
39
62
  const titleEscrowFactoryAddress = await fetchTitleEscrowFactoryAddress(tokenRegistry);
40
- const titleEscrowFactoryContract = new ethers.ethers.Contract(
63
+ return resolveTitleEscrowAddress(
64
+ provider,
41
65
  titleEscrowFactoryAddress,
42
- [
43
- "function getAddress(address, uint256) view returns (address)",
44
- "function getEscrowAddress(address, uint256) view returns (address)"
45
- ],
46
- provider
66
+ tokenRegistryAddress,
67
+ tokenId
47
68
  );
48
- return resolveTitleEscrowAddress(titleEscrowFactoryContract, tokenRegistryAddress, tokenId);
49
69
  }, "getTitleEscrowAddress");
50
70
  const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
51
71
  try {
72
+ const Contract = ethers.getEthersContractFromProvider(provider);
52
73
  const titleEscrowAbi = [
53
74
  "function supportsInterface(bytes4 interfaceId) external view returns (bool)"
54
75
  ];
55
- const titleEscrowContract = new ethers.ethers.Contract(titleEscrowAddress, titleEscrowAbi, provider);
76
+ const titleEscrowContract = new Contract(titleEscrowAddress, titleEscrowAbi, provider);
56
77
  return await titleEscrowContract.supportsInterface(interfaceId);
57
78
  } catch {
58
79
  return false;
59
80
  }
60
81
  }, "checkSupportsInterface");
61
- const isTitleEscrowVersion = /* @__PURE__ */ __name(async (versionInterface, tokenRegistryAddress, tokenId, provider) => {
82
+ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
83
+ tokenRegistryAddress,
84
+ tokenId,
85
+ titleEscrowAddress,
86
+ versionInterface,
87
+ provider
88
+ }) => {
62
89
  try {
63
- const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
90
+ if (!titleEscrowAddress && (!tokenRegistryAddress || !tokenId)) {
91
+ throw new Error("Missing required dependencies");
92
+ } else if (!titleEscrowAddress) {
93
+ titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
94
+ }
64
95
  return await checkSupportsInterface(titleEscrowAddress, versionInterface, provider);
65
96
  } catch {
66
97
  return false;
67
98
  }
68
99
  }, "isTitleEscrowVersion");
69
- const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistry, tokenId, provider, keyId) => {
70
- if (!tokenRegistry || !tokenId || !provider) {
100
+ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
101
+ if (!tokenRegistryAddress || !tokenId || !provider) {
71
102
  throw new Error("Missing required dependencies");
72
103
  }
104
+ const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
73
105
  const [isV4, isV5] = await Promise.all([
74
- isTitleEscrowVersion(TitleEscrowInterface.V4, tokenRegistry, tokenId, provider),
75
- isTitleEscrowVersion(TitleEscrowInterface.V5, tokenRegistry, tokenId, provider)
106
+ isTitleEscrowVersion({
107
+ titleEscrowAddress,
108
+ versionInterface: TitleEscrowInterface.V4,
109
+ provider
110
+ }),
111
+ isTitleEscrowVersion({
112
+ titleEscrowAddress,
113
+ versionInterface: TitleEscrowInterface.V5,
114
+ provider
115
+ })
76
116
  ]);
77
117
  if (!isV4 && !isV5) {
78
118
  throw new Error("Only Token Registry V4/V5 is supported");
79
119
  }
80
- const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistry, tokenId, provider);
81
120
  let transferEvents = [];
82
121
  if (isV4) {
83
- const tokenRegistryContract = contracts.TradeTrustToken__factory.connect(tokenRegistry, provider);
84
122
  const [tokenLogs, titleEscrowLogs] = await Promise.all([
85
- fetchTokenTransfer.fetchTokenTransfers(tokenRegistryContract, tokenId),
123
+ fetchTokenTransfer.fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
86
124
  fetchEscrowTransfer.fetchEscrowTransfersV4(provider, titleEscrowAddress)
87
125
  ]);
88
126
  transferEvents = helpers.mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
89
127
  } else if (isV5) {
90
- const titleEscrowLogs = await fetchEscrowTransfer.fetchEscrowTransfersV5(provider, titleEscrowAddress);
128
+ const titleEscrowLogs = await fetchEscrowTransfer.fetchEscrowTransfersV5(
129
+ provider,
130
+ titleEscrowAddress,
131
+ tokenRegistryAddress
132
+ );
91
133
  transferEvents = helpers.mergeTransfersV5(titleEscrowLogs);
92
134
  }
93
135
  const endorsementChain = await retrieveEndorsementChain.getEndorsementChain(provider, transferEvents);
@@ -53,7 +53,7 @@ function processOAChainId(document) {
53
53
  console.warn(
54
54
  "You are using an older version of Open-Attestation Document, to use the auto network feature, please use an updated version. Otherwise, please make sure that you select the correct network."
55
55
  );
56
- return void 0;
56
+ return undefined;
57
57
  }
58
58
  __name(processOAChainId, "processOAChainId");
59
59
  const getChainId = /* @__PURE__ */ __name((document) => {
@@ -63,14 +63,14 @@ const getChainId = /* @__PURE__ */ __name((document) => {
63
63
  } else if (openAttestation.isWrappedV2Document(document)) {
64
64
  const documentData = openAttestation.getDataV2(document);
65
65
  const identityProofType = documentData?.issuers?.[0]?.identityProof?.type;
66
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
66
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
67
67
  return processOAChainId(documentData);
68
68
  } else if (openAttestation.isWrappedV3Document(document)) {
69
69
  const identityProofType = document?.openAttestationMetadata?.identityProof?.type;
70
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
70
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
71
71
  return processOAChainId(document);
72
72
  } else {
73
- return void 0;
73
+ return undefined;
74
74
  }
75
75
  }, "getChainId");
76
76
 
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var ethers = require('ethers');
4
+ var ethersV6 = require('ethersV6');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
9
+ return !!provider?.provider;
10
+ }, "isV6EthersProvider");
11
+ const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
12
+ if (isV6EthersProvider(provider)) {
13
+ return ethersV6.ethers.Contract;
14
+ } else {
15
+ return ethers.ethers.Contract;
16
+ }
17
+ }, "getEthersContractFromProvider");
18
+
19
+ exports.getEthersContractFromProvider = getEthersContractFromProvider;
20
+ exports.isV6EthersProvider = isV6EthersProvider;
@@ -2,10 +2,10 @@
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const { Resolver } = require("did-resolver");
6
- const { getResolver: getWebDidResolver } = require("web-did-resolver");
7
5
  const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
8
6
  try {
7
+ const { Resolver } = await import('did-resolver');
8
+ const { getResolver: getWebDidResolver } = await import('web-did-resolver');
9
9
  const resolver = new Resolver({
10
10
  ...getWebDidResolver()
11
11
  });
@@ -1,21 +1,38 @@
1
1
  import { TitleEscrow__factory } from '../../token-registry-v4/contracts';
2
2
  import { TitleEscrow__factory as TitleEscrow__factory$1 } from '../../token-registry-v5/contracts';
3
+ import { getEthersContractFromProvider } from '../../utils/ethers';
3
4
 
4
5
  var __defProp = Object.defineProperty;
5
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  const fetchEscrowTransfersV4 = /* @__PURE__ */ __name(async (provider, address) => {
7
- const titleEscrowContract = TitleEscrow__factory.connect(address, provider);
8
- const holderChangeLogsDeferred = await fetchHolderTransfers(titleEscrowContract, provider);
9
- const ownerChangeLogsDeferred = await fetchOwnerTransfers(titleEscrowContract, provider);
8
+ const Contract = getEthersContractFromProvider(provider);
9
+ const titleEscrowContract = new Contract(
10
+ address,
11
+ TitleEscrow__factory.abi,
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ provider
14
+ );
15
+ const holderChangeLogsDeferred = fetchHolderTransfers(titleEscrowContract);
16
+ const ownerChangeLogsDeferred = fetchOwnerTransfers(titleEscrowContract);
10
17
  const [holderChangeLogs, ownerChangeLogs] = await Promise.all([
11
18
  holderChangeLogsDeferred,
12
19
  ownerChangeLogsDeferred
13
20
  ]);
14
21
  return [...holderChangeLogs, ...ownerChangeLogs];
15
22
  }, "fetchEscrowTransfersV4");
16
- const fetchEscrowTransfersV5 = /* @__PURE__ */ __name(async (provider, address) => {
17
- const titleEscrowContract = TitleEscrow__factory$1.connect(address, provider);
18
- const holderChangeLogsDeferred = await fetchAllTransfers(titleEscrowContract);
23
+ const fetchEscrowTransfersV5 = /* @__PURE__ */ __name(async (provider, titleEscrowAddress, tokenRegistryAddress) => {
24
+ const Contract = getEthersContractFromProvider(provider);
25
+ const titleEscrowContract = new Contract(
26
+ titleEscrowAddress,
27
+ TitleEscrow__factory$1.abi,
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ provider
30
+ );
31
+ const holderChangeLogsDeferred = await fetchAllTransfers(
32
+ titleEscrowContract,
33
+ titleEscrowAddress,
34
+ tokenRegistryAddress
35
+ );
19
36
  return holderChangeLogsDeferred;
20
37
  }, "fetchEscrowTransfersV5");
21
38
  const getParsedLogs = /* @__PURE__ */ __name((logs, titleEscrow) => {
@@ -28,9 +45,9 @@ const getParsedLogs = /* @__PURE__ */ __name((logs, titleEscrow) => {
28
45
  };
29
46
  });
30
47
  }, "getParsedLogs");
31
- const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, provider) => {
48
+ const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
32
49
  const ownerChangeFilter = titleEscrowContract.filters.BeneficiaryTransfer(null, null);
33
- const ownerChangeLogs = await provider.getLogs({ ...ownerChangeFilter, fromBlock: 0 });
50
+ const ownerChangeLogs = await titleEscrowContract.queryFilter(ownerChangeFilter, 0, "latest");
34
51
  const ownerChangeLogsParsed = getParsedLogs(ownerChangeLogs, titleEscrowContract);
35
52
  return ownerChangeLogsParsed.map((event) => ({
36
53
  type: "TRANSFER_BENEFICIARY",
@@ -40,9 +57,9 @@ const fetchOwnerTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, p
40
57
  transactionIndex: event.transactionIndex
41
58
  }));
42
59
  }, "fetchOwnerTransfers");
43
- const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, provider) => {
60
+ const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
44
61
  const holderChangeFilter = titleEscrowContract.filters.HolderTransfer(null, null);
45
- const holderChangeLogs = await provider.getLogs({ ...holderChangeFilter, fromBlock: 0 });
62
+ const holderChangeLogs = await titleEscrowContract.queryFilter(holderChangeFilter, 0, "latest");
46
63
  const holderChangeLogsParsed = getParsedLogs(holderChangeLogs, titleEscrowContract);
47
64
  return holderChangeLogsParsed.map((event) => ({
48
65
  type: "TRANSFER_HOLDER",
@@ -52,7 +69,7 @@ const fetchHolderTransfers = /* @__PURE__ */ __name(async (titleEscrowContract,
52
69
  transactionIndex: event.transactionIndex
53
70
  }));
54
71
  }, "fetchHolderTransfers");
55
- const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) => {
72
+ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, titleEscrowAddress, tokenRegistryAddress) => {
56
73
  const allFilters = [
57
74
  titleEscrowContract.filters.HolderTransfer,
58
75
  titleEscrowContract.filters.BeneficiaryTransfer,
@@ -70,8 +87,16 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
70
87
  return logs;
71
88
  })
72
89
  );
73
- const holderChangeLogsParsed = getParsedLogs(allLogs.flat(), titleEscrowContract);
74
- const tokenRegistryAddress = await titleEscrowContract.registry();
90
+ const holderChangeLogsParsed = getParsedLogs(
91
+ allLogs.flat(),
92
+ titleEscrowContract
93
+ );
94
+ if (!tokenRegistryAddress) {
95
+ tokenRegistryAddress = await titleEscrowContract.registry();
96
+ }
97
+ if (!titleEscrowAddress) {
98
+ titleEscrowAddress = titleEscrowContract?.address ?? await titleEscrowContract.getAddress();
99
+ }
75
100
  return holderChangeLogsParsed.map((event) => {
76
101
  if (event?.name === "HolderTransfer") {
77
102
  return {
@@ -96,7 +121,7 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
96
121
  return {
97
122
  type,
98
123
  from: type === "INITIAL" ? "0x0000000000000000000000000000000000000000" : tokenRegistryAddress,
99
- to: titleEscrowContract.address,
124
+ to: titleEscrowAddress,
100
125
  blockNumber: event.blockNumber,
101
126
  transactionHash: event.transactionHash,
102
127
  transactionIndex: event.transactionIndex,
@@ -106,14 +131,15 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
106
131
  return {
107
132
  type: "RETURNED_TO_ISSUER",
108
133
  blockNumber: event.blockNumber,
109
- from: titleEscrowContract.address,
134
+ // Handle ethers v5 and v6 differently
135
+ from: titleEscrowAddress,
110
136
  to: tokenRegistryAddress,
111
137
  transactionHash: event.transactionHash,
112
138
  transactionIndex: event.transactionIndex,
113
139
  remark: event.args?.remark
114
140
  };
115
141
  } else if (event?.name === "Nomination") {
116
- return void 0;
142
+ return undefined;
117
143
  } else if (event?.name === "RejectTransferOwners") {
118
144
  return {
119
145
  type: "REJECT_TRANSFER_OWNERS",
@@ -149,8 +175,8 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract) =>
149
175
  remark: event.args?.remark
150
176
  };
151
177
  }
152
- return void 0;
153
- }).filter((event) => event !== void 0);
178
+ return undefined;
179
+ }).filter((event) => event !== undefined);
154
180
  }, "fetchAllTransfers");
155
181
  function identifyTokenReceivedType(event) {
156
182
  if (event.args.isMinting) {
@@ -1,25 +1,34 @@
1
+ import { TradeTrustToken__factory } from '../../token-registry-v4/contracts';
2
+ import { getEthersContractFromProvider } from '../../utils/ethers';
1
3
  import { sortLogChain } from '../endorsement-chain/helpers';
2
4
 
3
5
  var __defProp = Object.defineProperty;
4
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const fetchTokenTransfers = /* @__PURE__ */ __name(async (tokenRegistry, tokenId) => {
6
- const logs = await fetchLogs(tokenRegistry, tokenId);
7
- const parsedLogs = parseLogs(logs, tokenRegistry);
8
- const tokenRegistryAddress = tokenRegistry.address;
7
+ const fetchTokenTransfers = /* @__PURE__ */ __name(async (provider, tokenRegistryAddress, tokenId) => {
8
+ const Contract = getEthersContractFromProvider(provider);
9
+ const tokenRegistryContract = new Contract(
10
+ tokenRegistryAddress,
11
+ TradeTrustToken__factory.abi,
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ provider
14
+ );
15
+ const logs = await fetchLogs(tokenRegistryContract, tokenId);
16
+ const parsedLogs = parseLogs(logs, tokenRegistryContract);
9
17
  const reformattedLogs = parsedLogs.map(
10
18
  (event) => formatTokenTransferEvent(event, tokenRegistryAddress)
11
19
  );
12
20
  sortLogChain(reformattedLogs);
13
21
  return reformattedLogs;
14
22
  }, "fetchTokenTransfers");
15
- const fetchLogs = /* @__PURE__ */ __name(async (tokenRegistry, tokenId) => {
23
+ async function fetchLogs(tokenRegistry, tokenId) {
16
24
  const transferLogFilter = tokenRegistry.filters.Transfer(null, null, tokenId);
17
25
  const logs = await tokenRegistry.queryFilter(transferLogFilter, 0);
18
26
  if (logs.length === 0) {
19
27
  throw new Error("Unminted Title Escrow");
20
28
  }
21
29
  return logs;
22
- }, "fetchLogs");
30
+ }
31
+ __name(fetchLogs, "fetchLogs");
23
32
  const parseLogs = /* @__PURE__ */ __name((logs, tokenRegistry) => {
24
33
  return logs.map((log) => {
25
34
  if (!log.args) throw new Error(`Transfer log malformed: ${log}`);
@@ -27,6 +36,7 @@ const parseLogs = /* @__PURE__ */ __name((logs, tokenRegistry) => {
27
36
  if (!log.transactionHash) throw new Error("Transaction hash not present");
28
37
  return {
29
38
  ...log,
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
40
  ...tokenRegistry.interface.parseLog(log)
31
41
  };
32
42
  });
@@ -1,7 +1,7 @@
1
1
  import { ethers } from 'ethers';
2
- import { TradeTrustToken__factory } from '../../token-registry-v4/contracts';
3
- import { supportInterfaceIds } from '../../token-registry-v4/supportInterfaceIds';
4
- import { supportInterfaceIds as supportInterfaceIds$1 } from '../../token-registry-v5/supportInterfaceIds';
2
+ import { supportInterfaceIds as supportInterfaceIds$1 } from '../../token-registry-v4/supportInterfaceIds';
3
+ import { supportInterfaceIds } from '../../token-registry-v5/supportInterfaceIds';
4
+ import { getEthersContractFromProvider } from '../../utils/ethers';
5
5
  import { decrypt } from '../decrypt';
6
6
  import { fetchEscrowTransfersV4, fetchEscrowTransfersV5 } from '../endorsement-chain/fetchEscrowTransfer';
7
7
  import { fetchTokenTransfers } from '../endorsement-chain/fetchTokenTransfer';
@@ -11,81 +11,123 @@ import { getEndorsementChain } from '../endorsement-chain/retrieveEndorsementCha
11
11
  var __defProp = Object.defineProperty;
12
12
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
13
  const TitleEscrowInterface = {
14
- V4: supportInterfaceIds.TitleEscrow,
15
- V5: supportInterfaceIds$1.TitleEscrow
14
+ V4: supportInterfaceIds$1.TitleEscrow,
15
+ V5: supportInterfaceIds.TitleEscrow
16
16
  };
17
17
  const fetchTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistry) => {
18
18
  return tokenRegistry.titleEscrowFactory();
19
19
  }, "fetchTitleEscrowFactoryAddress");
20
- const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (titleEscrowFactoryContract, tokenRegistryAddress, tokenId) => {
20
+ const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, contractAddress, functionTypes, params) => {
21
+ const functionSelector = ethers.utils.id(functionSignature).slice(0, 10);
22
+ const encodedParams = ethers.utils.defaultAbiCoder.encode(functionTypes, [...params]);
23
+ const calldata2 = functionSelector + encodedParams.slice(2);
24
+ const result = await provider.call({
25
+ to: contractAddress,
26
+ data: calldata2
27
+ });
28
+ return ethers.utils.getAddress(ethers.utils.hexDataSlice(result, 12));
29
+ }, "calldata");
30
+ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId) => {
21
31
  try {
22
- return await titleEscrowFactoryContract.getEscrowAddress(tokenRegistryAddress, tokenId);
32
+ return await calldata(
33
+ provider,
34
+ "getEscrowAddress(address,uint256)",
35
+ titleEscrowFactoryAddress,
36
+ ["address", "uint256"],
37
+ [tokenRegistryAddress, tokenId]
38
+ );
23
39
  } catch {
24
- return titleEscrowFactoryContract.getAddress(tokenRegistryAddress, tokenId);
40
+ return await calldata(
41
+ provider,
42
+ "getAddress(address,uint256)",
43
+ titleEscrowFactoryAddress,
44
+ ["address", "uint256"],
45
+ [tokenRegistryAddress, tokenId]
46
+ );
25
47
  }
26
48
  }, "resolveTitleEscrowAddress");
27
49
  const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
50
+ const Contract = getEthersContractFromProvider(provider);
28
51
  const tokenRegistryAbi = [
29
52
  "function titleEscrowFactory() external view returns (address)",
30
53
  "function ownerOf(uint256 tokenId) view returns (address)"
31
54
  ];
32
- const tokenRegistry = new ethers.Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
55
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
33
56
  const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
34
57
  const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
35
58
  const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
36
59
  if (!isInactiveEscrow) return titleEscrowOwner;
37
60
  const titleEscrowFactoryAddress = await fetchTitleEscrowFactoryAddress(tokenRegistry);
38
- const titleEscrowFactoryContract = new ethers.Contract(
61
+ return resolveTitleEscrowAddress(
62
+ provider,
39
63
  titleEscrowFactoryAddress,
40
- [
41
- "function getAddress(address, uint256) view returns (address)",
42
- "function getEscrowAddress(address, uint256) view returns (address)"
43
- ],
44
- provider
64
+ tokenRegistryAddress,
65
+ tokenId
45
66
  );
46
- return resolveTitleEscrowAddress(titleEscrowFactoryContract, tokenRegistryAddress, tokenId);
47
67
  }, "getTitleEscrowAddress");
48
68
  const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
49
69
  try {
70
+ const Contract = getEthersContractFromProvider(provider);
50
71
  const titleEscrowAbi = [
51
72
  "function supportsInterface(bytes4 interfaceId) external view returns (bool)"
52
73
  ];
53
- const titleEscrowContract = new ethers.Contract(titleEscrowAddress, titleEscrowAbi, provider);
74
+ const titleEscrowContract = new Contract(titleEscrowAddress, titleEscrowAbi, provider);
54
75
  return await titleEscrowContract.supportsInterface(interfaceId);
55
76
  } catch {
56
77
  return false;
57
78
  }
58
79
  }, "checkSupportsInterface");
59
- const isTitleEscrowVersion = /* @__PURE__ */ __name(async (versionInterface, tokenRegistryAddress, tokenId, provider) => {
80
+ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
81
+ tokenRegistryAddress,
82
+ tokenId,
83
+ titleEscrowAddress,
84
+ versionInterface,
85
+ provider
86
+ }) => {
60
87
  try {
61
- const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
88
+ if (!titleEscrowAddress && (!tokenRegistryAddress || !tokenId)) {
89
+ throw new Error("Missing required dependencies");
90
+ } else if (!titleEscrowAddress) {
91
+ titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
92
+ }
62
93
  return await checkSupportsInterface(titleEscrowAddress, versionInterface, provider);
63
94
  } catch {
64
95
  return false;
65
96
  }
66
97
  }, "isTitleEscrowVersion");
67
- const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistry, tokenId, provider, keyId) => {
68
- if (!tokenRegistry || !tokenId || !provider) {
98
+ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
99
+ if (!tokenRegistryAddress || !tokenId || !provider) {
69
100
  throw new Error("Missing required dependencies");
70
101
  }
102
+ const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
71
103
  const [isV4, isV5] = await Promise.all([
72
- isTitleEscrowVersion(TitleEscrowInterface.V4, tokenRegistry, tokenId, provider),
73
- isTitleEscrowVersion(TitleEscrowInterface.V5, tokenRegistry, tokenId, provider)
104
+ isTitleEscrowVersion({
105
+ titleEscrowAddress,
106
+ versionInterface: TitleEscrowInterface.V4,
107
+ provider
108
+ }),
109
+ isTitleEscrowVersion({
110
+ titleEscrowAddress,
111
+ versionInterface: TitleEscrowInterface.V5,
112
+ provider
113
+ })
74
114
  ]);
75
115
  if (!isV4 && !isV5) {
76
116
  throw new Error("Only Token Registry V4/V5 is supported");
77
117
  }
78
- const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistry, tokenId, provider);
79
118
  let transferEvents = [];
80
119
  if (isV4) {
81
- const tokenRegistryContract = TradeTrustToken__factory.connect(tokenRegistry, provider);
82
120
  const [tokenLogs, titleEscrowLogs] = await Promise.all([
83
- fetchTokenTransfers(tokenRegistryContract, tokenId),
121
+ fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
84
122
  fetchEscrowTransfersV4(provider, titleEscrowAddress)
85
123
  ]);
86
124
  transferEvents = mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
87
125
  } else if (isV5) {
88
- const titleEscrowLogs = await fetchEscrowTransfersV5(provider, titleEscrowAddress);
126
+ const titleEscrowLogs = await fetchEscrowTransfersV5(
127
+ provider,
128
+ titleEscrowAddress,
129
+ tokenRegistryAddress
130
+ );
89
131
  transferEvents = mergeTransfersV5(titleEscrowLogs);
90
132
  }
91
133
  const endorsementChain = await getEndorsementChain(provider, transferEvents);
@@ -51,7 +51,7 @@ function processOAChainId(document) {
51
51
  console.warn(
52
52
  "You are using an older version of Open-Attestation Document, to use the auto network feature, please use an updated version. Otherwise, please make sure that you select the correct network."
53
53
  );
54
- return void 0;
54
+ return undefined;
55
55
  }
56
56
  __name(processOAChainId, "processOAChainId");
57
57
  const getChainId = /* @__PURE__ */ __name((document) => {
@@ -61,14 +61,14 @@ const getChainId = /* @__PURE__ */ __name((document) => {
61
61
  } else if (isWrappedV2Document(document)) {
62
62
  const documentData = getDataV2(document);
63
63
  const identityProofType = documentData?.issuers?.[0]?.identityProof?.type;
64
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
64
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
65
65
  return processOAChainId(documentData);
66
66
  } else if (isWrappedV3Document(document)) {
67
67
  const identityProofType = document?.openAttestationMetadata?.identityProof?.type;
68
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
68
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
69
69
  return processOAChainId(document);
70
70
  } else {
71
- return void 0;
71
+ return undefined;
72
72
  }
73
73
  }, "getChainId");
74
74
 
@@ -0,0 +1,17 @@
1
+ import { ethers as ethers$1 } from 'ethers';
2
+ import { ethers } from 'ethersV6';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
7
+ return !!provider?.provider;
8
+ }, "isV6EthersProvider");
9
+ const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
10
+ if (isV6EthersProvider(provider)) {
11
+ return ethers.Contract;
12
+ } else {
13
+ return ethers$1.Contract;
14
+ }
15
+ }, "getEthersContractFromProvider");
16
+
17
+ export { getEthersContractFromProvider, isV6EthersProvider };
@@ -1,4 +1,4 @@
1
- import { isSignedDocument, verifyCredentialStatus } from '@trustvc/w3c-vc';
1
+ import { verifyCredentialStatus, isSignedDocument } from '@trustvc/w3c-vc';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const { Resolver } = require("did-resolver");
4
- const { getResolver: getWebDidResolver } = require("web-did-resolver");
5
3
  const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
6
4
  try {
5
+ const { Resolver } = await import('did-resolver');
6
+ const { getResolver: getWebDidResolver } = await import('web-did-resolver');
7
7
  const resolver = new Resolver({
8
8
  ...getWebDidResolver()
9
9
  });
@@ -1,4 +1,4 @@
1
- import { openAttestationVerifiers as openAttestationVerifiers$1, openAttestationDidIdentityProof, openAttestationHash, openAttestationDidSignedDocumentStatus, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof } from '@tradetrust-tt/tt-verify';
1
+ import { openAttestationVerifiers as openAttestationVerifiers$1, openAttestationDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationDnsDidIdentityProof, openAttestationEthereumTokenRegistryStatus, openAttestationEthereumDocumentStoreStatus, openAttestationDidSignedDocumentStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
2
  export { createResolver, getIdentifier, isValid, openAttestationDidIdentityProof, utils, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
3
3
  import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
4
4
  import { credentialStatusTransferableRecordVerifier } from './fragments/document-status/transferableRecords/transferableRecordVerifier';
@@ -1,8 +1,9 @@
1
- import { providers } from 'ethers';
1
+ import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
2
3
  import { TitleEscrowTransferEvent, TransferBaseEvent } from './types.js';
3
4
  import 'ethers/lib/utils';
4
5
 
5
- declare const fetchEscrowTransfersV4: (provider: providers.Provider, address: string) => Promise<TitleEscrowTransferEvent[]>;
6
- declare const fetchEscrowTransfersV5: (provider: any, address: string) => Promise<TransferBaseEvent[]>;
6
+ declare const fetchEscrowTransfersV4: (provider: ethers.providers.Provider | ethers$1.Provider, address: string) => Promise<TitleEscrowTransferEvent[]>;
7
+ declare const fetchEscrowTransfersV5: (provider: ethers.providers.Provider | ethers$1.Provider, titleEscrowAddress: string, tokenRegistryAddress?: string) => Promise<TransferBaseEvent[]>;
7
8
 
8
9
  export { fetchEscrowTransfersV4, fetchEscrowTransfersV5 };
@@ -1,8 +1,8 @@
1
+ import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
1
3
  import { TokenTransferEvent } from './types.js';
2
- import { TradeTrustToken } from '@tradetrust-tt/token-registry-v4/contracts';
3
- import 'ethers';
4
4
  import 'ethers/lib/utils';
5
5
 
6
- declare const fetchTokenTransfers: (tokenRegistry: TradeTrustToken, tokenId: string) => Promise<TokenTransferEvent[]>;
6
+ declare const fetchTokenTransfers: (provider: ethers.providers.Provider | ethers$1.Provider, tokenRegistryAddress: string, tokenId: string) => Promise<TokenTransferEvent[]>;
7
7
 
8
8
  export { fetchTokenTransfers };
@@ -1,8 +1,9 @@
1
- import { TransferBaseEvent } from './types.js';
2
1
  import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
3
+ import { TransferBaseEvent } from './types.js';
3
4
  import 'ethers/lib/utils';
4
5
 
5
- declare const fetchEventTime: (blockNumber: number, provider: ethers.providers.Provider) => Promise<number>;
6
+ declare const fetchEventTime: (blockNumber: number, provider: ethers.providers.Provider | ethers$1.Provider) => Promise<number>;
6
7
  declare const mergeTransfersV4: (transferEvents: TransferBaseEvent[]) => TransferBaseEvent[];
7
8
  declare const mergeTransfersV5: (transferEvents: TransferBaseEvent[]) => TransferBaseEvent[];
8
9
  declare const sortLogChain: (logChain: TransferBaseEvent[]) => TransferBaseEvent[];
@@ -5,5 +5,5 @@ export { getEndorsementChain } from './retrieveEndorsementChain.js';
5
5
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './types.js';
6
6
  export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
7
7
  import 'ethers';
8
- import '@tradetrust-tt/token-registry-v4/contracts';
8
+ import 'ethersV6';
9
9
  import 'ethers/lib/utils';
@@ -1,7 +1,8 @@
1
- import { TransferBaseEvent, EndorsementChain } from './types.js';
2
1
  import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
3
+ import { TransferBaseEvent, EndorsementChain } from './types.js';
3
4
  import 'ethers/lib/utils';
4
5
 
5
- declare const getEndorsementChain: (provider: ethers.providers.Provider, logChain: TransferBaseEvent[]) => Promise<EndorsementChain>;
6
+ declare const getEndorsementChain: (provider: ethers.providers.Provider | ethers$1.Provider, logChain: TransferBaseEvent[]) => Promise<EndorsementChain>;
6
7
 
7
8
  export { getEndorsementChain };
@@ -1,4 +1,5 @@
1
1
  import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
2
3
  import { EndorsementChain } from './types.js';
3
4
  import 'ethers/lib/utils';
4
5
 
@@ -6,8 +7,15 @@ declare const TitleEscrowInterface: {
6
7
  V4: string;
7
8
  V5: string;
8
9
  };
9
- declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: string, provider: ethers.providers.Provider) => Promise<string>;
10
- declare const isTitleEscrowVersion: (versionInterface: string, tokenRegistryAddress: string, tokenId: string, provider: ethers.providers.Provider) => Promise<boolean>;
11
- declare const fetchEndorsementChain: (tokenRegistry: string, tokenId: string, provider: ethers.providers.Provider, keyId?: string) => Promise<EndorsementChain>;
10
+ declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: string, provider: ethers.providers.Provider | ethers$1.Provider) => Promise<string>;
11
+ interface TitleEscrowVersionParams {
12
+ tokenRegistryAddress?: string;
13
+ tokenId?: string;
14
+ titleEscrowAddress?: string;
15
+ versionInterface: string;
16
+ provider: ethers.providers.Provider | ethers$1.Provider;
17
+ }
18
+ declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
19
+ declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: ethers.providers.Provider | ethers$1.Provider, keyId?: string) => Promise<EndorsementChain>;
12
20
 
13
21
  export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion };
@@ -10,5 +10,5 @@ export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isT
10
10
  import '@trustvc/w3c-vc';
11
11
  import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
12
12
  import 'ethers';
13
- import '@tradetrust-tt/token-registry-v4/contracts';
13
+ import 'ethersV6';
14
14
  import 'ethers/lib/utils';
@@ -44,6 +44,7 @@ export { DiagnoseError } from '@tradetrust-tt/tradetrust/dist/types/shared/utils
44
44
  export { createResolver, getIdentifier, isValid, openAttestationDidIdentityProof, utils, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
45
45
  export { DocumentsToVerify, ErrorVerificationFragment, InvalidVerificationFragment, ProviderDetails, providerType as ProviderType, SkippedVerificationFragment, ValidVerificationFragment, VerificationBuilderOptions, VerificationFragment, VerificationFragmentStatus, VerificationFragmentType, VerificationFragmentWithData, Verifier, VerifierOptions } from '@tradetrust-tt/tt-verify/dist/types/src/types/core';
46
46
  import 'ethers';
47
+ import 'ethersV6';
47
48
  import 'ethers/lib/utils';
48
49
  import '@ethersproject/abstract-signer';
49
50
  import '@tradetrust-tt/tradetrust/dist/types/3.0/types';
@@ -1,4 +1,4 @@
1
- import { v2, OpenAttestationDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
1
+ import { OpenAttestationDocument, WrappedDocument, v2 } from '@tradetrust-tt/tradetrust';
2
2
  export { __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
3
3
 
4
4
  declare const wrapOADocumentV2: <T extends v2.OpenAttestationDocument>(document: T) => Promise<v2.WrappedDocument<T>>;
@@ -1,9 +1,9 @@
1
1
  export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
2
- import '@tradetrust-tt/token-registry-v4/contracts';
3
2
  import '@trustvc/w3c-vc';
4
3
  import '@trustvc/w3c-issuer';
5
4
  import '@tradetrust-tt/tradetrust-utils';
6
5
  import '@tradetrust-tt/tradetrust-utils/constants/network';
7
6
  import '@tradetrust-tt/tradetrust-utils/constants/supportedChains';
8
7
  import '@tradetrust-tt/dnsprove';
8
+ import '@tradetrust-tt/token-registry-v4/contracts';
9
9
  import '@tradetrust-tt/token-registry-v5/contracts';
@@ -0,0 +1,7 @@
1
+ import { ethers } from 'ethers';
2
+ import { ethers as ethers$1 } from 'ethersV6';
3
+
4
+ declare const isV6EthersProvider: (provider: any) => boolean;
5
+ declare const getEthersContractFromProvider: (provider: ethers.providers.Provider | ethers$1.Provider) => typeof ethers.Contract | typeof ethers$1.Contract;
6
+
7
+ export { getEthersContractFromProvider, isV6EthersProvider };
@@ -1,4 +1,4 @@
1
- import { OpenAttestationEthereumTokenRegistryStatusCode, VerificationFragment, ErrorVerificationFragment, Verifier } from '@tradetrust-tt/tt-verify';
1
+ import { Verifier, VerificationFragment, OpenAttestationEthereumTokenRegistryStatusCode, ErrorVerificationFragment } from '@tradetrust-tt/tt-verify';
2
2
 
3
3
  type TransferableRecordsErrorReason = {
4
4
  code: OpenAttestationEthereumTokenRegistryStatusCode;
@@ -1,5 +1,5 @@
1
1
  import { ValidTokenRegistryStatus, InvalidTokenRegistryStatus } from '@tradetrust-tt/tt-verify';
2
- import { providers, errors } from 'ethers';
2
+ import { errors, providers } from 'ethers';
3
3
 
4
4
  type EthersError = {
5
5
  message?: string;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.2.5-alpha.1",
3
+ "version": "1.2.5",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
8
+ "type": "commonjs",
8
9
  "files": [
9
10
  "dist"
10
11
  ],
@@ -64,8 +65,8 @@
64
65
  "require": "./dist/cjs/token-registry-v5/index.js"
65
66
  },
66
67
  "./token-registry-v5/contracts": {
67
- "import": "./dist/esm/token-registry-v5/contracts.js",
68
68
  "types": "./dist/types/token-registry-v5/contracts.d.ts",
69
+ "import": "./dist/esm/token-registry-v5/contracts.js",
69
70
  "require": "./dist/cjs/token-registry-v5/contracts.js"
70
71
  },
71
72
  "./utils": {
@@ -112,7 +113,7 @@
112
113
  "dependencies": {
113
114
  "@tradetrust-tt/dnsprove": "^2.16.0",
114
115
  "@tradetrust-tt/token-registry-v4": "npm:@tradetrust-tt/token-registry@^4.15.1",
115
- "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.1.2",
116
+ "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.1.3",
116
117
  "@tradetrust-tt/tradetrust": "^6.10.0",
117
118
  "@tradetrust-tt/tradetrust-utils": "^2.1.5",
118
119
  "@tradetrust-tt/tt-verify": "^9.3.0",
@@ -122,6 +123,7 @@
122
123
  "@trustvc/w3c-vc": "^1.2.3",
123
124
  "did-resolver": "^4.1.0",
124
125
  "ethers": "^5.7.2",
126
+ "ethersV6": "npm:ethers@^6.13.5",
125
127
  "js-sha3": "^0.9.3",
126
128
  "ts-chacha20": "^1.2.0",
127
129
  "web-did-resolver": "^2.0.27"
@@ -143,6 +145,7 @@
143
145
  "eslint": "^9.16.0",
144
146
  "eslint-config-prettier": "^9.1.0",
145
147
  "eslint-formatter-table": "^7.32.1",
148
+ "eslint-plugin-jsdoc": "^50.6.3",
146
149
  "eslint-plugin-node": "^11.1.0",
147
150
  "eslint-plugin-prettier": "^5.2.1",
148
151
  "eslint-plugin-promise": "^7.2.1",
@@ -162,12 +165,12 @@
162
165
  "overrides": {
163
166
  "ethers": "^5.7.2"
164
167
  },
165
- "optionalDependencies": {
166
- "@rollup/rollup-linux-x64-gnu": "~4.28.0"
167
- },
168
168
  "peerDependencies": {
169
169
  "ethers": "^5.7.2"
170
170
  },
171
+ "optionalDependencies": {
172
+ "@rollup/rollup-linux-x64-gnu": "~4.28.0"
173
+ },
171
174
  "lint-staged": {
172
175
  "*.{js,ts}": [
173
176
  "eslint --fix",