@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.
@@ -4,6 +4,7 @@ var core = require('../core');
4
4
  var tokenRegistryV4 = require('../token-registry-v4');
5
5
  var tokenRegistryV5 = require('../token-registry-v5');
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 });
@@ -15,6 +16,8 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
15
16
  let isV5TT = titleEscrowVersion === "v5";
16
17
  let isV4TT = titleEscrowVersion === "v4";
17
18
  if (!titleEscrowAddress) {
19
+ if (!tokenRegistryAddress) throw new Error("Token registry address is required");
20
+ if (!tokenId) throw new Error("Token ID is required");
18
21
  titleEscrowAddress = await core.getTitleEscrowAddress(
19
22
  tokenRegistryAddress,
20
23
  tokenId,
@@ -25,7 +28,6 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
25
28
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
26
29
  if (!signer.provider) throw new Error("Provider is required");
27
30
  const { holderAddress, remarks } = params;
28
- let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
29
31
  const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
30
32
  if (titleEscrowVersion === void 0) {
31
33
  [isV4TT, isV5TT] = await Promise.all([
@@ -44,22 +46,30 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
44
46
  if (!isV4TT && !isV5TT) {
45
47
  throw new Error("Only Token Registry V4/V5 is supported");
46
48
  }
47
- if (isV4TT) {
48
- titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
49
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
50
+ let titleEscrowContract;
51
+ if (isV5TT) {
52
+ titleEscrowContract = new Contract(
53
+ titleEscrowAddress,
54
+ tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ signer
57
+ );
58
+ } else if (isV4TT) {
59
+ titleEscrowContract = new Contract(
49
60
  titleEscrowAddress,
61
+ tokenRegistryV4.v4Contracts.TitleEscrow__factory.abi,
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
63
  signer
51
64
  );
52
65
  }
53
66
  try {
54
- if (isV5TT) {
55
- await titleEscrowContract.callStatic.transferHolder(
56
- holderAddress,
57
- encryptedRemarks
58
- );
59
- } else if (isV4TT) {
60
- await titleEscrowContract.callStatic.transferHolder(
61
- holderAddress
62
- );
67
+ const isV6 = ethers.isV6EthersProvider(signer.provider);
68
+ const args = isV5TT ? [holderAddress, encryptedRemarks] : [holderAddress];
69
+ if (isV6) {
70
+ await titleEscrowContract.transferHolder.staticCall(...args);
71
+ } else {
72
+ await titleEscrowContract.callStatic.transferHolder(...args);
63
73
  }
64
74
  } catch (e) {
65
75
  console.error("callStatic failed:", e);
@@ -67,16 +77,9 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
67
77
  }
68
78
  const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
69
79
  if (isV5TT) {
70
- return await titleEscrowContract.transferHolder(
71
- holderAddress,
72
- encryptedRemarks,
73
- txOptions
74
- );
80
+ return await titleEscrowContract.transferHolder(holderAddress, encryptedRemarks, txOptions);
75
81
  } else if (isV4TT) {
76
- return await titleEscrowContract.transferHolder(
77
- holderAddress,
78
- txOptions
79
- );
82
+ return await titleEscrowContract.transferHolder(holderAddress, txOptions);
80
83
  }
81
84
  }, "transferHolder");
82
85
  const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
@@ -97,7 +100,6 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
97
100
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
98
101
  if (!signer.provider) throw new Error("Provider is required");
99
102
  const { newBeneficiaryAddress, remarks } = params;
100
- let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
101
103
  const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
102
104
  if (titleEscrowVersion === void 0) {
103
105
  [isV4TT, isV5TT] = await Promise.all([
@@ -116,22 +118,30 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
116
118
  if (!isV4TT && !isV5TT) {
117
119
  throw new Error("Only Token Registry V4/V5 is supported");
118
120
  }
119
- if (!isV5TT) {
120
- titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
121
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
122
+ let titleEscrowContract;
123
+ if (isV5TT) {
124
+ titleEscrowContract = new Contract(
121
125
  titleEscrowAddress,
126
+ tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ signer
129
+ );
130
+ } else if (isV4TT) {
131
+ titleEscrowContract = new Contract(
132
+ titleEscrowAddress,
133
+ tokenRegistryV4.v4Contracts.TitleEscrow__factory.abi,
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
135
  signer
123
136
  );
124
137
  }
125
138
  try {
126
- if (isV5TT) {
127
- await titleEscrowContract.callStatic.transferBeneficiary(
128
- newBeneficiaryAddress,
129
- encryptedRemarks
130
- );
131
- } else if (isV4TT) {
132
- await titleEscrowContract.callStatic.transferBeneficiary(
133
- newBeneficiaryAddress
134
- );
139
+ const isV6 = ethers.isV6EthersProvider(signer.provider);
140
+ const args = isV5TT ? [newBeneficiaryAddress, encryptedRemarks] : [newBeneficiaryAddress];
141
+ if (isV6) {
142
+ await titleEscrowContract.transferBeneficiary.staticCall(...args);
143
+ } else {
144
+ await titleEscrowContract.callStatic.transferBeneficiary(...args);
135
145
  }
136
146
  } catch (e) {
137
147
  console.error("callStatic failed:", e);
@@ -139,18 +149,13 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
139
149
  }
140
150
  const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
141
151
  if (isV5TT) {
142
- const tx = await titleEscrowContract.transferBeneficiary(
152
+ return await titleEscrowContract.transferBeneficiary(
143
153
  newBeneficiaryAddress,
144
154
  encryptedRemarks,
145
155
  txOptions
146
156
  );
147
- return tx;
148
157
  } else if (isV4TT) {
149
- const tx = await titleEscrowContract.transferBeneficiary(
150
- newBeneficiaryAddress,
151
- txOptions
152
- );
153
- return tx;
158
+ return await titleEscrowContract.transferBeneficiary(newBeneficiaryAddress, txOptions);
154
159
  }
155
160
  }, "transferBeneficiary");
156
161
  const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
@@ -171,7 +176,6 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
171
176
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
172
177
  if (!signer.provider) throw new Error("Provider is required");
173
178
  const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
174
- let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
175
179
  const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
176
180
  if (titleEscrowVersion === void 0) {
177
181
  [isV4TT, isV5TT] = await Promise.all([
@@ -190,24 +194,30 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
190
194
  if (!isV4TT && !isV5TT) {
191
195
  throw new Error("Only Token Registry V4/V5 is supported");
192
196
  }
193
- if (!isV5TT) {
194
- titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
197
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
198
+ let titleEscrowContract;
199
+ if (isV5TT) {
200
+ titleEscrowContract = new Contract(
201
+ titleEscrowAddress,
202
+ tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
203
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
204
+ signer
205
+ );
206
+ } else if (isV4TT) {
207
+ titleEscrowContract = new Contract(
195
208
  titleEscrowAddress,
209
+ tokenRegistryV4.v4Contracts.TitleEscrow__factory.abi,
210
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
211
  signer
197
212
  );
198
213
  }
199
214
  try {
200
- if (isV5TT) {
201
- await titleEscrowContract.callStatic.transferOwners(
202
- newBeneficiaryAddress,
203
- newHolderAddress,
204
- encryptedRemarks
205
- );
206
- } else if (isV4TT) {
207
- await titleEscrowContract.callStatic.transferOwners(
208
- newBeneficiaryAddress,
209
- newHolderAddress
210
- );
215
+ const isV6 = ethers.isV6EthersProvider(signer.provider);
216
+ const args = isV5TT ? [newBeneficiaryAddress, newHolderAddress, encryptedRemarks] : [newBeneficiaryAddress, newHolderAddress];
217
+ if (isV6) {
218
+ await titleEscrowContract.transferOwners.staticCall(...args);
219
+ } else {
220
+ await titleEscrowContract.callStatic.transferOwners(...args);
211
221
  }
212
222
  } catch (e) {
213
223
  console.error("callStatic failed:", e);
@@ -247,7 +257,6 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
247
257
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
248
258
  if (!signer.provider) throw new Error("Provider is required");
249
259
  const { newBeneficiaryAddress, remarks } = params;
250
- let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
251
260
  const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
252
261
  if (titleEscrowVersion === void 0) {
253
262
  [isV4TT, isV5TT] = await Promise.all([
@@ -263,22 +272,30 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
263
272
  })
264
273
  ]);
265
274
  }
266
- if (!isV5TT) {
267
- titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
275
+ const Contract = ethers.getEthersContractFromProvider(signer.provider);
276
+ let titleEscrowContract;
277
+ if (isV5TT) {
278
+ titleEscrowContract = new Contract(
268
279
  titleEscrowAddress,
280
+ tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
281
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
282
+ signer
283
+ );
284
+ } else if (isV4TT) {
285
+ titleEscrowContract = new Contract(
286
+ titleEscrowAddress,
287
+ tokenRegistryV4.v4Contracts.TitleEscrow__factory.abi,
288
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
289
  signer
270
290
  );
271
291
  }
272
292
  try {
273
- if (isV5TT) {
274
- await titleEscrowContract.callStatic.nominate(
275
- newBeneficiaryAddress,
276
- encryptedRemarks
277
- );
278
- } else if (isV4TT) {
279
- await titleEscrowContract.callStatic.nominate(
280
- newBeneficiaryAddress
281
- );
293
+ const isV6 = ethers.isV6EthersProvider(signer.provider);
294
+ const args = isV5TT ? [newBeneficiaryAddress, encryptedRemarks] : [newBeneficiaryAddress];
295
+ if (isV6) {
296
+ await titleEscrowContract.nominate.staticCall(...args);
297
+ } else {
298
+ await titleEscrowContract.callStatic.nominate(...args);
282
299
  }
283
300
  } catch (e) {
284
301
  console.error("callStatic failed:", e);
@@ -286,16 +303,9 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
286
303
  }
287
304
  const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
288
305
  if (isV5TT) {
289
- return await titleEscrowContract.nominate(
290
- newBeneficiaryAddress,
291
- encryptedRemarks,
292
- txOptions
293
- );
306
+ return await titleEscrowContract.nominate(newBeneficiaryAddress, encryptedRemarks, txOptions);
294
307
  } else if (isV4TT) {
295
- return await titleEscrowContract.nominate(
296
- newBeneficiaryAddress,
297
- txOptions
298
- );
308
+ return await titleEscrowContract.nominate(newBeneficiaryAddress, txOptions);
299
309
  }
300
310
  }, "nominate");
301
311
 
@@ -15,7 +15,7 @@ const getTxOptions = /* @__PURE__ */ __name(async (signer, chainId, maxFeePerGas
15
15
  maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
16
16
  }
17
17
  }
18
- return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
18
+ return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : {};
19
19
  }, "getTxOptions");
20
20
  const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
21
21
  if (ethers.isV6EthersProvider(signer.provider)) {
@@ -118,19 +118,19 @@ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
118
118
  return false;
119
119
  }
120
120
  }, "isTitleEscrowVersion");
121
- const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
121
+ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId, titleEscrowAddress) => {
122
122
  if (!tokenRegistryAddress || !tokenId || !provider) {
123
123
  throw new Error("Missing required dependencies");
124
124
  }
125
- const titleEscrowAddress = await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
125
+ const resolvedTitleEscrowAddress = titleEscrowAddress ?? await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
126
126
  const [isV4, isV5] = await Promise.all([
127
127
  isTitleEscrowVersion({
128
- titleEscrowAddress,
128
+ titleEscrowAddress: resolvedTitleEscrowAddress,
129
129
  versionInterface: TitleEscrowInterface.V4,
130
130
  provider
131
131
  }),
132
132
  isTitleEscrowVersion({
133
- titleEscrowAddress,
133
+ titleEscrowAddress: resolvedTitleEscrowAddress,
134
134
  versionInterface: TitleEscrowInterface.V5,
135
135
  provider
136
136
  })
@@ -142,13 +142,13 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
142
142
  if (isV4) {
143
143
  const [tokenLogs, titleEscrowLogs] = await Promise.all([
144
144
  fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
145
- fetchEscrowTransfersV4(provider, titleEscrowAddress)
145
+ fetchEscrowTransfersV4(provider, resolvedTitleEscrowAddress)
146
146
  ]);
147
147
  transferEvents = mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
148
148
  } else if (isV5) {
149
149
  const titleEscrowLogs = await fetchEscrowTransfersV5(
150
150
  provider,
151
- titleEscrowAddress,
151
+ resolvedTitleEscrowAddress,
152
152
  tokenRegistryAddress
153
153
  );
154
154
  transferEvents = mergeTransfersV5(titleEscrowLogs);
@@ -2,6 +2,7 @@ import { checkSupportsInterface, encrypt } from '../core';
2
2
  import { v5SupportInterfaceIds, v5Contracts } from '../token-registry-v5';
3
3
  import { v4SupportInterfaceIds, v4Contracts } from '../token-registry-v4';
4
4
  import { getTxOptions } from './utils';
5
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
5
6
 
6
7
  var __defProp = Object.defineProperty;
7
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -30,39 +31,42 @@ const mint = /* @__PURE__ */ __name(async (contractOptions, signer, params, opti
30
31
  if (!isV4TT && !isV5TT) {
31
32
  throw new Error("Only Token Registry V4/V5 is supported");
32
33
  }
34
+ const Contract = getEthersContractFromProvider(signer.provider);
33
35
  let tradeTrustTokenContract;
34
36
  if (isV5TT) {
35
- tradeTrustTokenContract = v5Contracts.TradeTrustToken__factory.connect(
37
+ tradeTrustTokenContract = new Contract(
36
38
  tokenRegistryAddress,
39
+ v5Contracts.TradeTrustToken__factory.abi,
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
41
  signer
38
42
  );
39
43
  } else if (isV4TT) {
40
- tradeTrustTokenContract = v4Contracts.TradeTrustToken__factory.connect(
44
+ tradeTrustTokenContract = new Contract(
41
45
  tokenRegistryAddress,
46
+ v4Contracts.TradeTrustToken__factory.abi,
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
48
  signer
43
49
  );
44
50
  }
45
- const encryptedRemarks = remarks && isV5TT ? `0x${encrypt(remarks, options.id)}` : "0x";
51
+ const encryptedRemarks = remarks && isV5TT ? `0x${encrypt(remarks, options.id ?? "")}` : "0x";
46
52
  try {
47
- if (isV5TT) {
48
- await tradeTrustTokenContract.callStatic.mint(
49
- beneficiaryAddress,
50
- holderAddress,
51
- tokenId,
52
- encryptedRemarks
53
- );
54
- } else if (isV4TT) {
55
- await tradeTrustTokenContract.callStatic.mint(
56
- beneficiaryAddress,
57
- holderAddress,
58
- tokenId
59
- );
53
+ const isV6 = isV6EthersProvider(signer.provider);
54
+ const args = isV5TT ? [beneficiaryAddress, holderAddress, tokenId, encryptedRemarks] : [beneficiaryAddress, holderAddress, tokenId];
55
+ if (isV6) {
56
+ await tradeTrustTokenContract.mint.staticCall(...args);
57
+ } else {
58
+ await tradeTrustTokenContract.callStatic.mint(...args);
60
59
  }
61
60
  } catch (e) {
62
61
  console.error("callStatic failed:", e);
63
62
  throw new Error("Pre-check (callStatic) for mint failed");
64
63
  }
65
- const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
64
+ const txOptions = await getTxOptions(
65
+ signer,
66
+ chainId,
67
+ maxFeePerGas,
68
+ maxPriorityFeePerGas
69
+ );
66
70
  if (isV5TT) {
67
71
  return await tradeTrustTokenContract.mint(
68
72
  beneficiaryAddress,
@@ -1,6 +1,7 @@
1
- import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterface } from '../core';
2
- import { v5Contracts } from '../token-registry-v5';
1
+ import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterface } from './../core';
2
+ import { v5Contracts } from './../token-registry-v5';
3
3
  import { getTxOptions } from './utils';
4
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -9,6 +10,8 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
9
10
  let { titleEscrowAddress } = contractOptions;
10
11
  const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
11
12
  if (!titleEscrowAddress) {
13
+ if (!tokenRegistryAddress) throw new Error("Token registry address is required");
14
+ if (!tokenId) throw new Error("Token ID is required");
12
15
  titleEscrowAddress = await getTitleEscrowAddress(
13
16
  tokenRegistryAddress,
14
17
  tokenId,
@@ -16,10 +19,16 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
16
19
  {}
17
20
  );
18
21
  }
19
- if (!titleEscrowAddress) throw new Error("Token registry address is required");
22
+ if (!titleEscrowAddress) throw new Error("Title escrow address is required");
20
23
  if (!signer.provider) throw new Error("Provider is required");
21
24
  const { remarks } = params;
22
- const titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
25
+ const Contract = getEthersContractFromProvider(signer.provider);
26
+ const titleEscrowContract = new Contract(
27
+ titleEscrowAddress,
28
+ v5Contracts.TitleEscrow__factory.abi,
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ signer
31
+ );
23
32
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
24
33
  let isV5TT = titleEscrowVersion === "v5";
25
34
  if (titleEscrowVersion === void 0) {
@@ -33,7 +42,13 @@ const rejectTransferHolder = /* @__PURE__ */ __name(async (contractOptions, sign
33
42
  throw new Error("Only Token Registry V5 is supported");
34
43
  }
35
44
  try {
36
- await titleEscrowContract.callStatic.rejectTransferHolder(encryptedRemarks);
45
+ const isV6 = isV6EthersProvider(signer.provider);
46
+ const args = isV5TT ? [encryptedRemarks] : [];
47
+ if (isV6) {
48
+ await titleEscrowContract.rejectTransferHolder.staticCall(...args);
49
+ } else {
50
+ await titleEscrowContract.callStatic.rejectTransferHolder(...args);
51
+ }
37
52
  } catch (e) {
38
53
  console.error("callStatic failed:", e);
39
54
  throw new Error("Pre-check (callStatic) for rejectTransferHolder failed");
@@ -46,6 +61,8 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
46
61
  let { titleEscrowAddress } = contractOptions;
47
62
  const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
48
63
  if (!titleEscrowAddress) {
64
+ if (!tokenRegistryAddress) throw new Error("Token registry address is required");
65
+ if (!tokenId) throw new Error("Token ID is required");
49
66
  titleEscrowAddress = await getTitleEscrowAddress(
50
67
  tokenRegistryAddress,
51
68
  tokenId,
@@ -56,7 +73,13 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
56
73
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
57
74
  if (!signer.provider) throw new Error("Provider is required");
58
75
  const { remarks } = params;
59
- const titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
76
+ const Contract = getEthersContractFromProvider(signer.provider);
77
+ const titleEscrowContract = new Contract(
78
+ titleEscrowAddress,
79
+ v5Contracts.TitleEscrow__factory.abi,
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ signer
82
+ );
60
83
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
61
84
  let isV5TT = titleEscrowVersion === "v5";
62
85
  if (titleEscrowVersion === void 0) {
@@ -70,7 +93,13 @@ const rejectTransferBeneficiary = /* @__PURE__ */ __name(async (contractOptions,
70
93
  throw new Error("Only Token Registry V5 is supported");
71
94
  }
72
95
  try {
73
- await titleEscrowContract.callStatic.rejectTransferBeneficiary(encryptedRemarks);
96
+ const isV6 = isV6EthersProvider(signer.provider);
97
+ const args = isV5TT ? [encryptedRemarks] : [];
98
+ if (isV6) {
99
+ await titleEscrowContract.rejectTransferBeneficiary.staticCall(...args);
100
+ } else {
101
+ await titleEscrowContract.callStatic.rejectTransferBeneficiary(...args);
102
+ }
74
103
  } catch (e) {
75
104
  console.error("callStatic failed:", e);
76
105
  throw new Error("Pre-check (callStatic) for rejectTransferBeneficiary failed");
@@ -83,6 +112,8 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
83
112
  let { titleEscrowAddress } = contractOptions;
84
113
  const { chainId, maxFeePerGas, maxPriorityFeePerGas, titleEscrowVersion } = options;
85
114
  if (!titleEscrowAddress) {
115
+ if (!tokenRegistryAddress) throw new Error("Token registry address is required");
116
+ if (!tokenId) throw new Error("Token ID is required");
86
117
  titleEscrowAddress = await getTitleEscrowAddress(
87
118
  tokenRegistryAddress,
88
119
  tokenId,
@@ -93,7 +124,13 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
93
124
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
94
125
  if (!signer.provider) throw new Error("Provider is required");
95
126
  const { remarks } = params;
96
- const titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
127
+ const Contract = getEthersContractFromProvider(signer.provider);
128
+ const titleEscrowContract = new Contract(
129
+ titleEscrowAddress,
130
+ v5Contracts.TitleEscrow__factory.abi,
131
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
+ signer
133
+ );
97
134
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
98
135
  let isV5TT = titleEscrowVersion === "v5";
99
136
  if (titleEscrowVersion === void 0) {
@@ -107,7 +144,13 @@ const rejectTransferOwners = /* @__PURE__ */ __name(async (contractOptions, sign
107
144
  throw new Error("Only Token Registry V5 is supported");
108
145
  }
109
146
  try {
110
- await titleEscrowContract.callStatic.rejectTransferOwners(encryptedRemarks);
147
+ const isV6 = isV6EthersProvider(signer.provider);
148
+ const args = isV5TT ? [encryptedRemarks] : [];
149
+ if (isV6) {
150
+ await titleEscrowContract.rejectTransferOwners.staticCall(...args);
151
+ } else {
152
+ await titleEscrowContract.callStatic.rejectTransferOwners(...args);
153
+ }
111
154
  } catch (e) {
112
155
  console.error("callStatic failed:", e);
113
156
  throw new Error("Pre-check (callStatic) for rejectTransferOwners failed");