@trustvc/trustvc 1.6.0-alpha.2 → 1.6.0-alpha.4
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 +6 -6
- package/dist/cjs/token-registry-functions/mint.js +21 -17
- package/dist/cjs/token-registry-functions/rejectTransfers.js +52 -9
- package/dist/cjs/token-registry-functions/returnToken.js +51 -45
- package/dist/cjs/token-registry-functions/transfer.js +85 -75
- package/dist/cjs/token-registry-functions/utils.js +1 -1
- package/dist/esm/core/endorsement-chain/useEndorsementChain.js +6 -6
- package/dist/esm/token-registry-functions/mint.js +21 -17
- package/dist/esm/token-registry-functions/rejectTransfers.js +52 -9
- package/dist/esm/token-registry-functions/returnToken.js +51 -45
- package/dist/esm/token-registry-functions/transfer.js +85 -75
- package/dist/esm/token-registry-functions/utils.js +1 -1
- package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +1 -1
- package/dist/types/token-registry-functions/utils.d.ts +3 -0
- package/package.json +14 -2
|
@@ -120,19 +120,19 @@ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
|
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
122
|
}, "isTitleEscrowVersion");
|
|
123
|
-
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
|
|
123
|
+
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId, titleEscrowAddress) => {
|
|
124
124
|
if (!tokenRegistryAddress || !tokenId || !provider) {
|
|
125
125
|
throw new Error("Missing required dependencies");
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const resolvedTitleEscrowAddress = titleEscrowAddress ?? await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
|
|
128
128
|
const [isV4, isV5] = await Promise.all([
|
|
129
129
|
isTitleEscrowVersion({
|
|
130
|
-
titleEscrowAddress,
|
|
130
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
131
131
|
versionInterface: TitleEscrowInterface.V4,
|
|
132
132
|
provider
|
|
133
133
|
}),
|
|
134
134
|
isTitleEscrowVersion({
|
|
135
|
-
titleEscrowAddress,
|
|
135
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
136
136
|
versionInterface: TitleEscrowInterface.V5,
|
|
137
137
|
provider
|
|
138
138
|
})
|
|
@@ -144,13 +144,13 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
|
|
|
144
144
|
if (isV4) {
|
|
145
145
|
const [tokenLogs, titleEscrowLogs] = await Promise.all([
|
|
146
146
|
fetchTokenTransfer.fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
|
|
147
|
-
fetchEscrowTransfer.fetchEscrowTransfersV4(provider,
|
|
147
|
+
fetchEscrowTransfer.fetchEscrowTransfersV4(provider, resolvedTitleEscrowAddress)
|
|
148
148
|
]);
|
|
149
149
|
transferEvents = helpers.mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
|
|
150
150
|
} else if (isV5) {
|
|
151
151
|
const titleEscrowLogs = await fetchEscrowTransfer.fetchEscrowTransfersV5(
|
|
152
152
|
provider,
|
|
153
|
-
|
|
153
|
+
resolvedTitleEscrowAddress,
|
|
154
154
|
tokenRegistryAddress
|
|
155
155
|
);
|
|
156
156
|
transferEvents = helpers.mergeTransfersV5(titleEscrowLogs);
|
|
@@ -4,6 +4,7 @@ var core = require('../core');
|
|
|
4
4
|
var tokenRegistryV5 = require('../token-registry-v5');
|
|
5
5
|
var tokenRegistryV4 = require('../token-registry-v4');
|
|
6
6
|
var utils = require('./utils');
|
|
7
|
+
var ethers = require('../utils/ethers');
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -32,39 +33,42 @@ const mint = /* @__PURE__ */ __name(async (contractOptions, signer, params, opti
|
|
|
32
33
|
if (!isV4TT && !isV5TT) {
|
|
33
34
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
34
35
|
}
|
|
36
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
35
37
|
let tradeTrustTokenContract;
|
|
36
38
|
if (isV5TT) {
|
|
37
|
-
tradeTrustTokenContract =
|
|
39
|
+
tradeTrustTokenContract = new Contract(
|
|
38
40
|
tokenRegistryAddress,
|
|
41
|
+
tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
43
|
signer
|
|
40
44
|
);
|
|
41
45
|
} else if (isV4TT) {
|
|
42
|
-
tradeTrustTokenContract =
|
|
46
|
+
tradeTrustTokenContract = new Contract(
|
|
43
47
|
tokenRegistryAddress,
|
|
48
|
+
tokenRegistryV4.v4Contracts.TradeTrustToken__factory.abi,
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
50
|
signer
|
|
45
51
|
);
|
|
46
52
|
}
|
|
47
|
-
const encryptedRemarks = remarks && isV5TT ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
53
|
+
const encryptedRemarks = remarks && isV5TT ? `0x${core.encrypt(remarks, options.id ?? "")}` : "0x";
|
|
48
54
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
} else if (isV4TT) {
|
|
57
|
-
await tradeTrustTokenContract.callStatic.mint(
|
|
58
|
-
beneficiaryAddress,
|
|
59
|
-
holderAddress,
|
|
60
|
-
tokenId
|
|
61
|
-
);
|
|
55
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
56
|
+
const args = isV5TT ? [beneficiaryAddress, holderAddress, tokenId, encryptedRemarks] : [beneficiaryAddress, holderAddress, tokenId];
|
|
57
|
+
if (isV6) {
|
|
58
|
+
await tradeTrustTokenContract.mint.staticCall(...args);
|
|
59
|
+
} else {
|
|
60
|
+
await tradeTrustTokenContract.callStatic.mint(...args);
|
|
62
61
|
}
|
|
63
62
|
} catch (e) {
|
|
64
63
|
console.error("callStatic failed:", e);
|
|
65
64
|
throw new Error("Pre-check (callStatic) for mint failed");
|
|
66
65
|
}
|
|
67
|
-
const txOptions = await utils.getTxOptions(
|
|
66
|
+
const txOptions = await utils.getTxOptions(
|
|
67
|
+
signer,
|
|
68
|
+
chainId,
|
|
69
|
+
maxFeePerGas,
|
|
70
|
+
maxPriorityFeePerGas
|
|
71
|
+
);
|
|
68
72
|
if (isV5TT) {
|
|
69
73
|
return await tradeTrustTokenContract.mint(
|
|
70
74
|
beneficiaryAddress,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var core = require('
|
|
4
|
-
var tokenRegistryV5 = require('
|
|
3
|
+
var core = require('./../core');
|
|
4
|
+
var tokenRegistryV5 = require('./../token-registry-v5');
|
|
5
5
|
var utils = require('./utils');
|
|
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 });
|
|
@@ -11,6 +12,8 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
11
12
|
let { titleEscrowAddress } = contractOptions;
|
|
12
13
|
const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
|
|
13
14
|
if (!titleEscrowAddress) {
|
|
15
|
+
if (!tokenRegistryAddress) throw new Error("Token registry address is required");
|
|
16
|
+
if (!tokenId) throw new Error("Token ID is required");
|
|
14
17
|
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
15
18
|
tokenRegistryAddress,
|
|
16
19
|
tokenId,
|
|
@@ -18,10 +21,16 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
18
21
|
{}
|
|
19
22
|
);
|
|
20
23
|
}
|
|
21
|
-
if (!titleEscrowAddress) throw new Error("
|
|
24
|
+
if (!titleEscrowAddress) throw new Error("Title escrow address is required");
|
|
22
25
|
if (!signer.provider) throw new Error("Provider is required");
|
|
23
26
|
const { remarks } = params;
|
|
24
|
-
const
|
|
27
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
28
|
+
const titleEscrowContract = new Contract(
|
|
29
|
+
titleEscrowAddress,
|
|
30
|
+
tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
signer
|
|
33
|
+
);
|
|
25
34
|
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
26
35
|
let isV5TT = titleEscrowVersion === "v5";
|
|
27
36
|
if (titleEscrowVersion === void 0) {
|
|
@@ -35,7 +44,13 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
35
44
|
throw new Error("Only Token Registry V5 is supported");
|
|
36
45
|
}
|
|
37
46
|
try {
|
|
38
|
-
|
|
47
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
48
|
+
const args = isV5TT ? [encryptedRemarks] : [];
|
|
49
|
+
if (isV6) {
|
|
50
|
+
await titleEscrowContract.rejectTransferHolder.staticCall(...args);
|
|
51
|
+
} else {
|
|
52
|
+
await titleEscrowContract.callStatic.rejectTransferHolder(...args);
|
|
53
|
+
}
|
|
39
54
|
} catch (e) {
|
|
40
55
|
console.error("callStatic failed:", e);
|
|
41
56
|
throw new Error("Pre-check (callStatic) for rejectTransferHolder failed");
|
|
@@ -48,6 +63,8 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
|
|
|
48
63
|
let { titleEscrowAddress } = contractOptions;
|
|
49
64
|
const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
|
|
50
65
|
if (!titleEscrowAddress) {
|
|
66
|
+
if (!tokenRegistryAddress) throw new Error("Token registry address is required");
|
|
67
|
+
if (!tokenId) throw new Error("Token ID is required");
|
|
51
68
|
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
52
69
|
tokenRegistryAddress,
|
|
53
70
|
tokenId,
|
|
@@ -58,7 +75,13 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
|
|
|
58
75
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
59
76
|
if (!signer.provider) throw new Error("Provider is required");
|
|
60
77
|
const { remarks } = params;
|
|
61
|
-
const
|
|
78
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
79
|
+
const titleEscrowContract = new Contract(
|
|
80
|
+
titleEscrowAddress,
|
|
81
|
+
tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
signer
|
|
84
|
+
);
|
|
62
85
|
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
63
86
|
let isV5TT = titleEscrowVersion === "v5";
|
|
64
87
|
if (titleEscrowVersion === void 0) {
|
|
@@ -72,7 +95,13 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
|
|
|
72
95
|
throw new Error("Only Token Registry V5 is supported");
|
|
73
96
|
}
|
|
74
97
|
try {
|
|
75
|
-
|
|
98
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
99
|
+
const args = isV5TT ? [encryptedRemarks] : [];
|
|
100
|
+
if (isV6) {
|
|
101
|
+
await titleEscrowContract.rejectTransferBeneficiary.staticCall(...args);
|
|
102
|
+
} else {
|
|
103
|
+
await titleEscrowContract.callStatic.rejectTransferBeneficiary(...args);
|
|
104
|
+
}
|
|
76
105
|
} catch (e) {
|
|
77
106
|
console.error("callStatic failed:", e);
|
|
78
107
|
throw new Error("Pre-check (callStatic) for rejectTransferBeneficiary failed");
|
|
@@ -85,6 +114,8 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
85
114
|
let { titleEscrowAddress } = contractOptions;
|
|
86
115
|
const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
|
|
87
116
|
if (!titleEscrowAddress) {
|
|
117
|
+
if (!tokenRegistryAddress) throw new Error("Token registry address is required");
|
|
118
|
+
if (!tokenId) throw new Error("Token ID is required");
|
|
88
119
|
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
89
120
|
tokenRegistryAddress,
|
|
90
121
|
tokenId,
|
|
@@ -95,7 +126,13 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
95
126
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
96
127
|
if (!signer.provider) throw new Error("Provider is required");
|
|
97
128
|
const { remarks } = params;
|
|
98
|
-
const
|
|
129
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
130
|
+
const titleEscrowContract = new Contract(
|
|
131
|
+
titleEscrowAddress,
|
|
132
|
+
tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
signer
|
|
135
|
+
);
|
|
99
136
|
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
100
137
|
let isV5TT = titleEscrowVersion === "v5";
|
|
101
138
|
if (titleEscrowVersion === void 0) {
|
|
@@ -109,7 +146,13 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
|
|
|
109
146
|
throw new Error("Only Token Registry V5 is supported");
|
|
110
147
|
}
|
|
111
148
|
try {
|
|
112
|
-
|
|
149
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
150
|
+
const args = isV5TT ? [encryptedRemarks] : [];
|
|
151
|
+
if (isV6) {
|
|
152
|
+
await titleEscrowContract.rejectTransferOwners.staticCall(...args);
|
|
153
|
+
} else {
|
|
154
|
+
await titleEscrowContract.callStatic.rejectTransferOwners(...args);
|
|
155
|
+
}
|
|
113
156
|
} catch (e) {
|
|
114
157
|
console.error("callStatic failed:", e);
|
|
115
158
|
throw new Error("Pre-check (callStatic) for rejectTransferOwners failed");
|
|
@@ -4,6 +4,7 @@ var core = require('../core');
|
|
|
4
4
|
var tokenRegistryV5 = require('../token-registry-v5');
|
|
5
5
|
var tokenRegistryV4 = require('../token-registry-v4');
|
|
6
6
|
var utils = require('./utils');
|
|
7
|
+
var ethers = require('../utils/ethers');
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -22,7 +23,6 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
22
23
|
if (!titleEscrowAddress) throw new Error("Title Escrow address is required");
|
|
23
24
|
if (!signer.provider) throw new Error("Provider is required");
|
|
24
25
|
const { remarks } = params;
|
|
25
|
-
let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
26
26
|
const encryptedRemarks = remarks && options.id ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
27
27
|
let isV5TT = titleEscrowVersion === "v5";
|
|
28
28
|
let isV4TT = titleEscrowVersion === "v4";
|
|
@@ -43,19 +43,31 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
43
43
|
if (!isV5TT && !isV4TT) {
|
|
44
44
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
47
|
+
let titleEscrowContract;
|
|
48
|
+
if (isV5TT) {
|
|
49
|
+
titleEscrowContract = new Contract(
|
|
50
|
+
titleEscrowAddress,
|
|
51
|
+
tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
signer
|
|
54
|
+
);
|
|
55
|
+
} else if (isV4TT) {
|
|
56
|
+
titleEscrowContract = new Contract(
|
|
48
57
|
titleEscrowAddress,
|
|
58
|
+
tokenRegistryV4.v4Contracts.TitleEscrow__factory.abi,
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
60
|
signer
|
|
50
61
|
);
|
|
51
62
|
}
|
|
52
63
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
65
|
+
const args = isV5TT ? [encryptedRemarks] : [];
|
|
66
|
+
const staticCallFxn = isV5TT ? "returnToIssuer" : "surrender";
|
|
67
|
+
if (isV6) {
|
|
68
|
+
await titleEscrowContract[staticCallFxn].staticCall(...args);
|
|
69
|
+
} else {
|
|
70
|
+
await titleEscrowContract.callStatic[staticCallFxn](...args);
|
|
59
71
|
}
|
|
60
72
|
} catch (e) {
|
|
61
73
|
console.error("callStatic failed:", e);
|
|
@@ -63,10 +75,7 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
63
75
|
}
|
|
64
76
|
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
65
77
|
if (isV5TT) {
|
|
66
|
-
return await titleEscrowContract.returnToIssuer(
|
|
67
|
-
encryptedRemarks,
|
|
68
|
-
txOptions
|
|
69
|
-
);
|
|
78
|
+
return await titleEscrowContract.returnToIssuer(encryptedRemarks, txOptions);
|
|
70
79
|
} else if (isV4TT) {
|
|
71
80
|
return await titleEscrowContract.surrender(txOptions);
|
|
72
81
|
}
|
|
@@ -96,27 +105,31 @@ const rejectReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
96
105
|
if (!isV4TT && !isV5TT) {
|
|
97
106
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
98
107
|
}
|
|
108
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
99
109
|
let tradeTrustTokenContract;
|
|
100
110
|
if (isV5TT) {
|
|
101
|
-
tradeTrustTokenContract =
|
|
111
|
+
tradeTrustTokenContract = new Contract(
|
|
102
112
|
tokenRegistryAddress,
|
|
113
|
+
tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
115
|
signer
|
|
104
116
|
);
|
|
105
117
|
} else if (isV4TT) {
|
|
106
|
-
tradeTrustTokenContract =
|
|
118
|
+
tradeTrustTokenContract = new Contract(
|
|
107
119
|
tokenRegistryAddress,
|
|
120
|
+
tokenRegistryV4.v4Contracts.TradeTrustToken__factory.abi,
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
122
|
signer
|
|
109
123
|
);
|
|
110
124
|
}
|
|
111
125
|
const encryptedRemarks = remarks && isV5TT ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
112
126
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
await tradeTrustTokenContract.callStatic.restore(tokenId);
|
|
127
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
128
|
+
const args = isV5TT ? [tokenId, encryptedRemarks] : [tokenId];
|
|
129
|
+
if (isV6) {
|
|
130
|
+
await tradeTrustTokenContract.restore.staticCall(...args);
|
|
131
|
+
} else {
|
|
132
|
+
await tradeTrustTokenContract.callStatic.restore(...args);
|
|
120
133
|
}
|
|
121
134
|
} catch (e) {
|
|
122
135
|
console.error("callStatic failed:", e);
|
|
@@ -124,16 +137,9 @@ const rejectReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
124
137
|
}
|
|
125
138
|
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
126
139
|
if (isV5TT) {
|
|
127
|
-
return await tradeTrustTokenContract.restore(
|
|
128
|
-
tokenId,
|
|
129
|
-
encryptedRemarks,
|
|
130
|
-
txOptions
|
|
131
|
-
);
|
|
140
|
+
return await tradeTrustTokenContract.restore(tokenId, encryptedRemarks, txOptions);
|
|
132
141
|
} else if (isV4TT) {
|
|
133
|
-
return await tradeTrustTokenContract.restore(
|
|
134
|
-
tokenId,
|
|
135
|
-
txOptions
|
|
136
|
-
);
|
|
142
|
+
return await tradeTrustTokenContract.restore(tokenId, txOptions);
|
|
137
143
|
}
|
|
138
144
|
}, "rejectReturned");
|
|
139
145
|
const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
@@ -161,27 +167,31 @@ const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
161
167
|
if (!isV4TT && !isV5TT) {
|
|
162
168
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
163
169
|
}
|
|
170
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
164
171
|
let tradeTrustTokenContract;
|
|
165
172
|
if (isV5TT) {
|
|
166
|
-
tradeTrustTokenContract =
|
|
173
|
+
tradeTrustTokenContract = new Contract(
|
|
167
174
|
tokenRegistryAddress,
|
|
175
|
+
tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
177
|
signer
|
|
169
178
|
);
|
|
170
179
|
} else if (isV4TT) {
|
|
171
|
-
tradeTrustTokenContract =
|
|
180
|
+
tradeTrustTokenContract = new Contract(
|
|
172
181
|
tokenRegistryAddress,
|
|
182
|
+
tokenRegistryV4.v4Contracts.TradeTrustToken__factory.abi,
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
184
|
signer
|
|
174
185
|
);
|
|
175
186
|
}
|
|
176
187
|
const encryptedRemarks = remarks && isV5TT ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
177
188
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
await tradeTrustTokenContract.callStatic.burn(tokenId);
|
|
189
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
190
|
+
const args = isV5TT ? [encryptedRemarks] : [];
|
|
191
|
+
if (isV6) {
|
|
192
|
+
await tradeTrustTokenContract.burn.staticCall(...args);
|
|
193
|
+
} else {
|
|
194
|
+
await tradeTrustTokenContract.callStatic.burn(...args);
|
|
185
195
|
}
|
|
186
196
|
} catch (e) {
|
|
187
197
|
console.error("callStatic failed:", e);
|
|
@@ -189,11 +199,7 @@ const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
189
199
|
}
|
|
190
200
|
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
191
201
|
if (isV5TT) {
|
|
192
|
-
return await tradeTrustTokenContract.burn(
|
|
193
|
-
tokenId,
|
|
194
|
-
encryptedRemarks,
|
|
195
|
-
txOptions
|
|
196
|
-
);
|
|
202
|
+
return await tradeTrustTokenContract.burn(tokenId, encryptedRemarks, txOptions);
|
|
197
203
|
} else if (isV4TT) {
|
|
198
204
|
return await tradeTrustTokenContract.burn(tokenId, txOptions);
|
|
199
205
|
}
|