@trustvc/trustvc 1.4.0 → 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.
- package/dist/cjs/core/endorsement-chain/useEndorsementChain.js +40 -14
- package/dist/esm/core/endorsement-chain/useEndorsementChain.js +40 -15
- package/dist/types/core/endorsement-chain/index.d.ts +1 -1
- package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +5 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -4
|
@@ -16,9 +16,12 @@ const TitleEscrowInterface = {
|
|
|
16
16
|
V4: supportInterfaceIds$1.supportInterfaceIds.TitleEscrow,
|
|
17
17
|
V5: supportInterfaceIds.supportInterfaceIds.TitleEscrow
|
|
18
18
|
};
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
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]);
|
|
@@ -29,8 +32,17 @@ const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, cont
|
|
|
29
32
|
});
|
|
30
33
|
return ethers$1.ethers.utils.getAddress(ethers$1.ethers.utils.hexDataSlice(result, 12));
|
|
31
34
|
}, "calldata");
|
|
32
|
-
const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId) => {
|
|
35
|
+
const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId, options) => {
|
|
33
36
|
try {
|
|
37
|
+
if (options?.titleEscrowVersion === "v4") {
|
|
38
|
+
return await calldata(
|
|
39
|
+
provider,
|
|
40
|
+
"getAddress(address,uint256)",
|
|
41
|
+
titleEscrowFactoryAddress,
|
|
42
|
+
["address", "uint256"],
|
|
43
|
+
[tokenRegistryAddress, tokenId]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
34
46
|
return await calldata(
|
|
35
47
|
provider,
|
|
36
48
|
"getEscrowAddress(address,uint256)",
|
|
@@ -39,6 +51,15 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
|
|
|
39
51
|
[tokenRegistryAddress, tokenId]
|
|
40
52
|
);
|
|
41
53
|
} catch {
|
|
54
|
+
if (options?.titleEscrowVersion === "v4") {
|
|
55
|
+
return await calldata(
|
|
56
|
+
provider,
|
|
57
|
+
"getEscrowAddress(address,uint256)",
|
|
58
|
+
titleEscrowFactoryAddress,
|
|
59
|
+
["address", "uint256"],
|
|
60
|
+
[tokenRegistryAddress, tokenId]
|
|
61
|
+
);
|
|
62
|
+
}
|
|
42
63
|
return await calldata(
|
|
43
64
|
provider,
|
|
44
65
|
"getAddress(address,uint256)",
|
|
@@ -48,25 +69,29 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
|
|
|
48
69
|
);
|
|
49
70
|
}
|
|
50
71
|
}, "resolveTitleEscrowAddress");
|
|
51
|
-
const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
|
|
52
|
-
const
|
|
53
|
-
const tokenRegistryAbi = [
|
|
54
|
-
"function titleEscrowFactory() external view returns (address)",
|
|
55
|
-
"function ownerOf(uint256 tokenId) view returns (address)"
|
|
56
|
-
];
|
|
57
|
-
const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
|
|
58
|
-
const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
|
|
72
|
+
const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, options) => {
|
|
73
|
+
const titleEscrowOwner = await getDocumentOwner(tokenRegistryAddress, tokenId, provider);
|
|
59
74
|
const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
|
|
60
75
|
const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
|
|
61
76
|
if (!isInactiveEscrow) return titleEscrowOwner;
|
|
62
|
-
const titleEscrowFactoryAddress = await
|
|
77
|
+
const titleEscrowFactoryAddress = await getTitleEscrowFactoryAddress(
|
|
78
|
+
tokenRegistryAddress,
|
|
79
|
+
provider
|
|
80
|
+
);
|
|
63
81
|
return resolveTitleEscrowAddress(
|
|
64
82
|
provider,
|
|
65
83
|
titleEscrowFactoryAddress,
|
|
66
84
|
tokenRegistryAddress,
|
|
67
|
-
tokenId
|
|
85
|
+
tokenId,
|
|
86
|
+
options
|
|
68
87
|
);
|
|
69
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");
|
|
70
95
|
const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
|
|
71
96
|
try {
|
|
72
97
|
const Contract = ethers.getEthersContractFromProvider(provider);
|
|
@@ -141,5 +166,6 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
|
|
|
141
166
|
|
|
142
167
|
exports.TitleEscrowInterface = TitleEscrowInterface;
|
|
143
168
|
exports.fetchEndorsementChain = fetchEndorsementChain;
|
|
169
|
+
exports.getDocumentOwner = getDocumentOwner;
|
|
144
170
|
exports.getTitleEscrowAddress = getTitleEscrowAddress;
|
|
145
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
|
|
18
|
-
|
|
19
|
-
|
|
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]);
|
|
@@ -27,8 +30,17 @@ const calldata = /* @__PURE__ */ __name(async (provider, functionSignature, cont
|
|
|
27
30
|
});
|
|
28
31
|
return ethers.utils.getAddress(ethers.utils.hexDataSlice(result, 12));
|
|
29
32
|
}, "calldata");
|
|
30
|
-
const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId) => {
|
|
33
|
+
const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleEscrowFactoryAddress, tokenRegistryAddress, tokenId, options) => {
|
|
31
34
|
try {
|
|
35
|
+
if (options?.titleEscrowVersion === "v4") {
|
|
36
|
+
return await calldata(
|
|
37
|
+
provider,
|
|
38
|
+
"getAddress(address,uint256)",
|
|
39
|
+
titleEscrowFactoryAddress,
|
|
40
|
+
["address", "uint256"],
|
|
41
|
+
[tokenRegistryAddress, tokenId]
|
|
42
|
+
);
|
|
43
|
+
}
|
|
32
44
|
return await calldata(
|
|
33
45
|
provider,
|
|
34
46
|
"getEscrowAddress(address,uint256)",
|
|
@@ -37,6 +49,15 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
|
|
|
37
49
|
[tokenRegistryAddress, tokenId]
|
|
38
50
|
);
|
|
39
51
|
} catch {
|
|
52
|
+
if (options?.titleEscrowVersion === "v4") {
|
|
53
|
+
return await calldata(
|
|
54
|
+
provider,
|
|
55
|
+
"getEscrowAddress(address,uint256)",
|
|
56
|
+
titleEscrowFactoryAddress,
|
|
57
|
+
["address", "uint256"],
|
|
58
|
+
[tokenRegistryAddress, tokenId]
|
|
59
|
+
);
|
|
60
|
+
}
|
|
40
61
|
return await calldata(
|
|
41
62
|
provider,
|
|
42
63
|
"getAddress(address,uint256)",
|
|
@@ -46,25 +67,29 @@ const resolveTitleEscrowAddress = /* @__PURE__ */ __name(async (provider, titleE
|
|
|
46
67
|
);
|
|
47
68
|
}
|
|
48
69
|
}, "resolveTitleEscrowAddress");
|
|
49
|
-
const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider) => {
|
|
50
|
-
const
|
|
51
|
-
const tokenRegistryAbi = [
|
|
52
|
-
"function titleEscrowFactory() external view returns (address)",
|
|
53
|
-
"function ownerOf(uint256 tokenId) view returns (address)"
|
|
54
|
-
];
|
|
55
|
-
const tokenRegistry = new Contract(tokenRegistryAddress, tokenRegistryAbi, provider);
|
|
56
|
-
const titleEscrowOwner = await tokenRegistry.ownerOf(tokenId);
|
|
70
|
+
const getTitleEscrowAddress = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, options) => {
|
|
71
|
+
const titleEscrowOwner = await getDocumentOwner(tokenRegistryAddress, tokenId, provider);
|
|
57
72
|
const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
|
|
58
73
|
const isInactiveEscrow = [BURN_ADDRESS, tokenRegistryAddress].map((address) => address.toLowerCase()).includes(titleEscrowOwner.toLowerCase());
|
|
59
74
|
if (!isInactiveEscrow) return titleEscrowOwner;
|
|
60
|
-
const titleEscrowFactoryAddress = await
|
|
75
|
+
const titleEscrowFactoryAddress = await getTitleEscrowFactoryAddress(
|
|
76
|
+
tokenRegistryAddress,
|
|
77
|
+
provider
|
|
78
|
+
);
|
|
61
79
|
return resolveTitleEscrowAddress(
|
|
62
80
|
provider,
|
|
63
81
|
titleEscrowFactoryAddress,
|
|
64
82
|
tokenRegistryAddress,
|
|
65
|
-
tokenId
|
|
83
|
+
tokenId,
|
|
84
|
+
options
|
|
66
85
|
);
|
|
67
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");
|
|
68
93
|
const checkSupportsInterface = /* @__PURE__ */ __name(async (titleEscrowAddress, interfaceId, provider) => {
|
|
69
94
|
try {
|
|
70
95
|
const Contract = getEthersContractFromProvider(provider);
|
|
@@ -137,4 +162,4 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
|
|
|
137
162
|
}));
|
|
138
163
|
}, "fetchEndorsementChain");
|
|
139
164
|
|
|
140
|
-
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';
|
|
@@ -8,7 +8,10 @@ declare const TitleEscrowInterface: {
|
|
|
8
8
|
V4: string;
|
|
9
9
|
V5: string;
|
|
10
10
|
};
|
|
11
|
-
declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider
|
|
11
|
+
declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, options?: {
|
|
12
|
+
titleEscrowVersion?: "v4" | "v5";
|
|
13
|
+
}) => Promise<string>;
|
|
14
|
+
declare const getDocumentOwner: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider) => Promise<string>;
|
|
12
15
|
interface TitleEscrowVersionParams {
|
|
13
16
|
tokenRegistryAddress?: string;
|
|
14
17
|
tokenId?: string;
|
|
@@ -19,4 +22,4 @@ interface TitleEscrowVersionParams {
|
|
|
19
22
|
declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
|
|
20
23
|
declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string) => Promise<EndorsementChain>;
|
|
21
24
|
|
|
22
|
-
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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "TrustVC library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -116,10 +116,10 @@
|
|
|
116
116
|
"@tradetrust-tt/tradetrust": "^6.10.1",
|
|
117
117
|
"@tradetrust-tt/tradetrust-utils": "^2.2.1",
|
|
118
118
|
"@tradetrust-tt/tt-verify": "^9.3.1",
|
|
119
|
-
"@trustvc/w3c-context": "^1.2.
|
|
120
|
-
"@trustvc/w3c-credential-status": "^1.2.
|
|
119
|
+
"@trustvc/w3c-context": "^1.2.2",
|
|
120
|
+
"@trustvc/w3c-credential-status": "^1.2.2",
|
|
121
121
|
"@trustvc/w3c-issuer": "^1.2.1",
|
|
122
|
-
"@trustvc/w3c-vc": "^1.2.
|
|
122
|
+
"@trustvc/w3c-vc": "^1.2.4",
|
|
123
123
|
"did-resolver": "^4.1.0",
|
|
124
124
|
"ethers": "^5.7.2",
|
|
125
125
|
"ethersV6": "npm:ethers@^6.13.5",
|