@trustvc/trustvc 1.4.1 → 1.4.2

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.
@@ -16,9 +16,12 @@ const TitleEscrowInterface = {
16
16
  V4: supportInterfaceIds$1.supportInterfaceIds.TitleEscrow,
17
17
  V5: supportInterfaceIds.supportInterfaceIds.TitleEscrow
18
18
  };
19
- const fetchTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistry) => {
20
- return tokenRegistry.titleEscrowFactory();
21
- }, "fetchTitleEscrowFactoryAddress");
19
+ const getTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, provider) => {
20
+ const Contract = ethers.getEthersContractFromProvider(provider);
21
+ const tokenRegistryAbi = ["function titleEscrowFactory() external view returns (address)"];
22
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
23
+ return await tokenRegistry.titleEscrowFactory();
24
+ }, "getTitleEscrowFactoryAddress");
22
25
  const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, contractAddress, functionTypes, params) => {
23
26
  const functionSelector = ethers$1.ethers.utils.id(functionSignature).slice(0, 10);
24
27
  const encodedParams = ethers$1.ethers.utils.defaultAbiCoder.encode(functionTypes, [...params]);
@@ -67,17 +70,14 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
67
70
  }
68
71
  }, "resolveTitleEscrowAddress");
69
72
  const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, options) => {
70
- const Contract = ethers.getEthersContractFromProvider(provider);
71
- const tokenRegistryAbi = [
72
- "function titleEscrowFactory() external view returns (address)",
73
- "function ownerOf(uint256 tokenId) view returns (address)"
74
- ];
75
- const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
76
- const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
73
+ const titleEscrowOwner = await getDocumentOwner(tokenRegistryAddress, tokenId, provider);
77
74
  const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
78
75
  const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
79
76
  if (!isInactiveEscrow) return titleEscrowOwner;
80
- const titleEscrowFactoryAddress = await fetchTitleEscrowFactoryAddress(tokenRegistry);
77
+ const titleEscrowFactoryAddress = await getTitleEscrowFactoryAddress(
78
+ tokenRegistryAddress,
79
+ provider
80
+ );
81
81
  return resolveTitleEscrowAddress(
82
82
  provider,
83
83
  titleEscrowFactoryAddress,
@@ -86,6 +86,12 @@ const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress
86
86
  options
87
87
  );
88
88
  }, "getTitleEscrowAddress");
89
+ const getDocumentOwner = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
90
+ const Contract = ethers.getEthersContractFromProvider(provider);
91
+ const tokenRegistryAbi = ["function ownerOf(uint256 tokenId) view returns (address)"];
92
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
93
+ return await tokenRegistry.ownerOf(tokenId);
94
+ }, "getDocumentOwner");
89
95
  const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
90
96
  try {
91
97
  const Contract = ethers.getEthersContractFromProvider(provider);
@@ -160,5 +166,6 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
160
166
 
161
167
  exports.TitleEscrowInterface = TitleEscrowInterface;
162
168
  exports.fetchEndorsementChain = fetchEndorsementChain;
169
+ exports.getDocumentOwner = getDocumentOwner;
163
170
  exports.getTitleEscrowAddress = getTitleEscrowAddress;
164
171
  exports.isTitleEscrowVersion = isTitleEscrowVersion;
@@ -14,9 +14,12 @@ const TitleEscrowInterface = {
14
14
  V4: supportInterfaceIds$1.TitleEscrow,
15
15
  V5: supportInterfaceIds.TitleEscrow
16
16
  };
17
- const fetchTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistry) => {
18
- return tokenRegistry.titleEscrowFactory();
19
- }, "fetchTitleEscrowFactoryAddress");
17
+ const getTitleEscrowFactoryAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, provider) => {
18
+ const Contract = getEthersContractFromProvider(provider);
19
+ const tokenRegistryAbi = ["function titleEscrowFactory() external view returns (address)"];
20
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
21
+ return await tokenRegistry.titleEscrowFactory();
22
+ }, "getTitleEscrowFactoryAddress");
20
23
  const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, contractAddress, functionTypes, params) => {
21
24
  const functionSelector = ethers.utils.id(functionSignature).slice(0, 10);
22
25
  const encodedParams = ethers.utils.defaultAbiCoder.encode(functionTypes, [...params]);
@@ -65,17 +68,14 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
65
68
  }
66
69
  }, "resolveTitleEscrowAddress");
67
70
  const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, options) => {
68
- const Contract = getEthersContractFromProvider(provider);
69
- const tokenRegistryAbi = [
70
- "function titleEscrowFactory() external view returns (address)",
71
- "function ownerOf(uint256 tokenId) view returns (address)"
72
- ];
73
- const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
74
- const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
71
+ const titleEscrowOwner = await getDocumentOwner(tokenRegistryAddress, tokenId, provider);
75
72
  const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
76
73
  const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
77
74
  if (!isInactiveEscrow) return titleEscrowOwner;
78
- const titleEscrowFactoryAddress = await fetchTitleEscrowFactoryAddress(tokenRegistry);
75
+ const titleEscrowFactoryAddress = await getTitleEscrowFactoryAddress(
76
+ tokenRegistryAddress,
77
+ provider
78
+ );
79
79
  return resolveTitleEscrowAddress(
80
80
  provider,
81
81
  titleEscrowFactoryAddress,
@@ -84,6 +84,12 @@ const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress
84
84
  options
85
85
  );
86
86
  }, "getTitleEscrowAddress");
87
+ const getDocumentOwner = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
88
+ const Contract = getEthersContractFromProvider(provider);
89
+ const tokenRegistryAbi = ["function ownerOf(uint256 tokenId) view returns (address)"];
90
+ const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
91
+ return await tokenRegistry.ownerOf(tokenId);
92
+ }, "getDocumentOwner");
87
93
  const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
88
94
  try {
89
95
  const Contract = getEthersContractFromProvider(provider);
@@ -156,4 +162,4 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
156
162
  }));
157
163
  }, "fetchEndorsementChain");
158
164
 
159
- export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion };
165
+ export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
@@ -3,7 +3,7 @@ export { fetchTokenTransfers } from './fetchTokenTransfer.js';
3
3
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './helpers.js';
4
4
  export { getEndorsementChain } from './retrieveEndorsementChain.js';
5
5
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './types.js';
6
- export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
6
+ export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
7
7
  import 'ethersV6';
8
8
  import '@ethersproject/abstract-provider';
9
9
  import 'ethers';
@@ -11,6 +11,7 @@ declare const TitleEscrowInterface: {
11
11
  declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, options?: {
12
12
  titleEscrowVersion?: "v4" | "v5";
13
13
  }) => Promise<string>;
14
+ declare const getDocumentOwner: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider) => Promise<string>;
14
15
  interface TitleEscrowVersionParams {
15
16
  tokenRegistryAddress?: string;
16
17
  tokenId?: string;
@@ -21,4 +22,4 @@ interface TitleEscrowVersionParams {
21
22
  declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
22
23
  declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string) => Promise<EndorsementChain>;
23
24
 
24
- export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion };
25
+ export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
@@ -6,7 +6,7 @@ export { fetchTokenTransfers } from './endorsement-chain/fetchTokenTransfer.js';
6
6
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './endorsement-chain/helpers.js';
7
7
  export { getEndorsementChain } from './endorsement-chain/retrieveEndorsementChain.js';
8
8
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './endorsement-chain/types.js';
9
- export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
9
+ export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
10
10
  export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig } from './documentBuilder.js';
11
11
  import '@trustvc/w3c-vc';
12
12
  import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
@@ -18,7 +18,7 @@ export { fetchTokenTransfers } from './core/endorsement-chain/fetchTokenTransfer
18
18
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './core/endorsement-chain/helpers.js';
19
19
  export { getEndorsementChain } from './core/endorsement-chain/retrieveEndorsementChain.js';
20
20
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './core/endorsement-chain/types.js';
21
- export { TitleEscrowInterface, fetchEndorsementChain, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
21
+ export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
22
22
  export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig } from './core/documentBuilder.js';
23
23
  export { signOA } from './open-attestation/sign.js';
24
24
  export { KeyPair } from './open-attestation/types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",