@trustvc/trustvc 1.6.0-alpha.2 → 1.6.0-alpha.3

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.
@@ -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");
@@ -2,6 +2,7 @@ import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterf
2
2
  import { v5Contracts, v5SupportInterfaceIds } from '../token-registry-v5';
3
3
  import { v4Contracts, v4SupportInterfaceIds } 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 });
@@ -20,7 +21,6 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
20
21
  if (!titleEscrowAddress) throw new Error("Title Escrow address is required");
21
22
  if (!signer.provider) throw new Error("Provider is required");
22
23
  const { remarks } = params;
23
- let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
24
24
  const encryptedRemarks = remarks && options.id ? `0x${encrypt(remarks, options.id)}` : "0x";
25
25
  let isV5TT = titleEscrowVersion === "v5";
26
26
  let isV4TT = titleEscrowVersion === "v4";
@@ -41,19 +41,31 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
41
41
  if (!isV5TT && !isV4TT) {
42
42
  throw new Error("Only Token Registry V4/V5 is supported");
43
43
  }
44
- if (isV4TT) {
45
- titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
44
+ const Contract = getEthersContractFromProvider(signer.provider);
45
+ let titleEscrowContract;
46
+ if (isV5TT) {
47
+ titleEscrowContract = new Contract(
48
+ titleEscrowAddress,
49
+ v5Contracts.TitleEscrow__factory.abi,
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
+ signer
52
+ );
53
+ } else if (isV4TT) {
54
+ titleEscrowContract = new Contract(
46
55
  titleEscrowAddress,
56
+ v4Contracts.TitleEscrow__factory.abi,
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
58
  signer
48
59
  );
49
60
  }
50
61
  try {
51
- if (isV5TT) {
52
- await titleEscrowContract.callStatic.returnToIssuer(
53
- encryptedRemarks
54
- );
55
- } else if (isV4TT) {
56
- await titleEscrowContract.callStatic.surrender();
62
+ const isV6 = isV6EthersProvider(signer.provider);
63
+ const args = isV5TT ? [encryptedRemarks] : [];
64
+ const staticCallFxn = isV5TT ? "returnToIssuer" : "surrender";
65
+ if (isV6) {
66
+ await titleEscrowContract[staticCallFxn].staticCall(...args);
67
+ } else {
68
+ await titleEscrowContract.callStatic[staticCallFxn](...args);
57
69
  }
58
70
  } catch (e) {
59
71
  console.error("callStatic failed:", e);
@@ -61,10 +73,7 @@ const returnToIssuer = /* @__PURE__ */ __name(async (contractOptions, signer, pa
61
73
  }
62
74
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
63
75
  if (isV5TT) {
64
- return await titleEscrowContract.returnToIssuer(
65
- encryptedRemarks,
66
- txOptions
67
- );
76
+ return await titleEscrowContract.returnToIssuer(encryptedRemarks, txOptions);
68
77
  } else if (isV4TT) {
69
78
  return await titleEscrowContract.surrender(txOptions);
70
79
  }
@@ -94,27 +103,31 @@ const rejectReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
94
103
  if (!isV4TT && !isV5TT) {
95
104
  throw new Error("Only Token Registry V4/V5 is supported");
96
105
  }
106
+ const Contract = getEthersContractFromProvider(signer.provider);
97
107
  let tradeTrustTokenContract;
98
108
  if (isV5TT) {
99
- tradeTrustTokenContract = v5Contracts.TradeTrustToken__factory.connect(
109
+ tradeTrustTokenContract = new Contract(
100
110
  tokenRegistryAddress,
111
+ v5Contracts.TradeTrustToken__factory.abi,
112
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
113
  signer
102
114
  );
103
115
  } else if (isV4TT) {
104
- tradeTrustTokenContract = v4Contracts.TradeTrustToken__factory.connect(
116
+ tradeTrustTokenContract = new Contract(
105
117
  tokenRegistryAddress,
118
+ v4Contracts.TradeTrustToken__factory.abi,
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
120
  signer
107
121
  );
108
122
  }
109
123
  const encryptedRemarks = remarks && isV5TT ? `0x${encrypt(remarks, options.id)}` : "0x";
110
124
  try {
111
- if (isV5TT) {
112
- await tradeTrustTokenContract.callStatic.restore(
113
- tokenId,
114
- encryptedRemarks
115
- );
116
- } else if (isV4TT) {
117
- await tradeTrustTokenContract.callStatic.restore(tokenId);
125
+ const isV6 = isV6EthersProvider(signer.provider);
126
+ const args = isV5TT ? [tokenId, encryptedRemarks] : [tokenId];
127
+ if (isV6) {
128
+ await tradeTrustTokenContract.restore.staticCall(...args);
129
+ } else {
130
+ await tradeTrustTokenContract.callStatic.restore(...args);
118
131
  }
119
132
  } catch (e) {
120
133
  console.error("callStatic failed:", e);
@@ -122,16 +135,9 @@ const rejectReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
122
135
  }
123
136
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
124
137
  if (isV5TT) {
125
- return await tradeTrustTokenContract.restore(
126
- tokenId,
127
- encryptedRemarks,
128
- txOptions
129
- );
138
+ return await tradeTrustTokenContract.restore(tokenId, encryptedRemarks, txOptions);
130
139
  } else if (isV4TT) {
131
- return await tradeTrustTokenContract.restore(
132
- tokenId,
133
- txOptions
134
- );
140
+ return await tradeTrustTokenContract.restore(tokenId, txOptions);
135
141
  }
136
142
  }, "rejectReturned");
137
143
  const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
@@ -159,27 +165,31 @@ const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
159
165
  if (!isV4TT && !isV5TT) {
160
166
  throw new Error("Only Token Registry V4/V5 is supported");
161
167
  }
168
+ const Contract = getEthersContractFromProvider(signer.provider);
162
169
  let tradeTrustTokenContract;
163
170
  if (isV5TT) {
164
- tradeTrustTokenContract = v5Contracts.TradeTrustToken__factory.connect(
171
+ tradeTrustTokenContract = new Contract(
165
172
  tokenRegistryAddress,
173
+ v5Contracts.TradeTrustToken__factory.abi,
174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
175
  signer
167
176
  );
168
177
  } else if (isV4TT) {
169
- tradeTrustTokenContract = v4Contracts.TradeTrustToken__factory.connect(
178
+ tradeTrustTokenContract = new Contract(
170
179
  tokenRegistryAddress,
180
+ v4Contracts.TradeTrustToken__factory.abi,
181
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
182
  signer
172
183
  );
173
184
  }
174
185
  const encryptedRemarks = remarks && isV5TT ? `0x${encrypt(remarks, options.id)}` : "0x";
175
186
  try {
176
- if (isV5TT) {
177
- await tradeTrustTokenContract.callStatic.burn(
178
- tokenId,
179
- encryptedRemarks
180
- );
181
- } else if (isV4TT) {
182
- await tradeTrustTokenContract.callStatic.burn(tokenId);
187
+ const isV6 = isV6EthersProvider(signer.provider);
188
+ const args = isV5TT ? [encryptedRemarks] : [];
189
+ if (isV6) {
190
+ await tradeTrustTokenContract.burn.staticCall(...args);
191
+ } else {
192
+ await tradeTrustTokenContract.callStatic.burn(...args);
183
193
  }
184
194
  } catch (e) {
185
195
  console.error("callStatic failed:", e);
@@ -187,11 +197,7 @@ const acceptReturned = /* @__PURE__ */ __name(async (contractOptions, signer, pa
187
197
  }
188
198
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
189
199
  if (isV5TT) {
190
- return await tradeTrustTokenContract.burn(
191
- tokenId,
192
- encryptedRemarks,
193
- txOptions
194
- );
200
+ return await tradeTrustTokenContract.burn(tokenId, encryptedRemarks, txOptions);
195
201
  } else if (isV4TT) {
196
202
  return await tradeTrustTokenContract.burn(tokenId, txOptions);
197
203
  }
@@ -2,6 +2,7 @@ import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterf
2
2
  import { v4Contracts } from '../token-registry-v4';
3
3
  import { v5Contracts } from '../token-registry-v5';
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 });
@@ -13,6 +14,8 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
13
14
  let isV5TT = titleEscrowVersion === "v5";
14
15
  let isV4TT = titleEscrowVersion === "v4";
15
16
  if (!titleEscrowAddress) {
17
+ if (!tokenRegistryAddress) throw new Error("Token registry address is required");
18
+ if (!tokenId) throw new Error("Token ID is required");
16
19
  titleEscrowAddress = await getTitleEscrowAddress(
17
20
  tokenRegistryAddress,
18
21
  tokenId,
@@ -23,7 +26,6 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
23
26
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
24
27
  if (!signer.provider) throw new Error("Provider is required");
25
28
  const { holderAddress, remarks } = params;
26
- let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
27
29
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
28
30
  if (titleEscrowVersion === void 0) {
29
31
  [isV4TT, isV5TT] = await Promise.all([
@@ -42,22 +44,30 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
42
44
  if (!isV4TT && !isV5TT) {
43
45
  throw new Error("Only Token Registry V4/V5 is supported");
44
46
  }
45
- if (isV4TT) {
46
- titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
47
+ const Contract = getEthersContractFromProvider(signer.provider);
48
+ let titleEscrowContract;
49
+ if (isV5TT) {
50
+ titleEscrowContract = new Contract(
51
+ titleEscrowAddress,
52
+ v5Contracts.TitleEscrow__factory.abi,
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ signer
55
+ );
56
+ } else if (isV4TT) {
57
+ titleEscrowContract = new Contract(
47
58
  titleEscrowAddress,
59
+ v4Contracts.TitleEscrow__factory.abi,
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
61
  signer
49
62
  );
50
63
  }
51
64
  try {
52
- if (isV5TT) {
53
- await titleEscrowContract.callStatic.transferHolder(
54
- holderAddress,
55
- encryptedRemarks
56
- );
57
- } else if (isV4TT) {
58
- await titleEscrowContract.callStatic.transferHolder(
59
- holderAddress
60
- );
65
+ const isV6 = isV6EthersProvider(signer.provider);
66
+ const args = isV5TT ? [holderAddress, encryptedRemarks] : [holderAddress];
67
+ if (isV6) {
68
+ await titleEscrowContract.transferHolder.staticCall(...args);
69
+ } else {
70
+ await titleEscrowContract.callStatic.transferHolder(...args);
61
71
  }
62
72
  } catch (e) {
63
73
  console.error("callStatic failed:", e);
@@ -65,16 +75,9 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
65
75
  }
66
76
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
67
77
  if (isV5TT) {
68
- return await titleEscrowContract.transferHolder(
69
- holderAddress,
70
- encryptedRemarks,
71
- txOptions
72
- );
78
+ return await titleEscrowContract.transferHolder(holderAddress, encryptedRemarks, txOptions);
73
79
  } else if (isV4TT) {
74
- return await titleEscrowContract.transferHolder(
75
- holderAddress,
76
- txOptions
77
- );
80
+ return await titleEscrowContract.transferHolder(holderAddress, txOptions);
78
81
  }
79
82
  }, "transferHolder");
80
83
  const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
@@ -95,7 +98,6 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
95
98
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
96
99
  if (!signer.provider) throw new Error("Provider is required");
97
100
  const { newBeneficiaryAddress, remarks } = params;
98
- let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
99
101
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
100
102
  if (titleEscrowVersion === void 0) {
101
103
  [isV4TT, isV5TT] = await Promise.all([
@@ -114,22 +116,30 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
114
116
  if (!isV4TT && !isV5TT) {
115
117
  throw new Error("Only Token Registry V4/V5 is supported");
116
118
  }
117
- if (!isV5TT) {
118
- titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
119
+ const Contract = getEthersContractFromProvider(signer.provider);
120
+ let titleEscrowContract;
121
+ if (isV5TT) {
122
+ titleEscrowContract = new Contract(
119
123
  titleEscrowAddress,
124
+ v5Contracts.TitleEscrow__factory.abi,
125
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
126
+ signer
127
+ );
128
+ } else if (isV4TT) {
129
+ titleEscrowContract = new Contract(
130
+ titleEscrowAddress,
131
+ v4Contracts.TitleEscrow__factory.abi,
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
133
  signer
121
134
  );
122
135
  }
123
136
  try {
124
- if (isV5TT) {
125
- await titleEscrowContract.callStatic.transferBeneficiary(
126
- newBeneficiaryAddress,
127
- encryptedRemarks
128
- );
129
- } else if (isV4TT) {
130
- await titleEscrowContract.callStatic.transferBeneficiary(
131
- newBeneficiaryAddress
132
- );
137
+ const isV6 = isV6EthersProvider(signer.provider);
138
+ const args = isV5TT ? [newBeneficiaryAddress, encryptedRemarks] : [newBeneficiaryAddress];
139
+ if (isV6) {
140
+ await titleEscrowContract.transferBeneficiary.staticCall(...args);
141
+ } else {
142
+ await titleEscrowContract.callStatic.transferBeneficiary(...args);
133
143
  }
134
144
  } catch (e) {
135
145
  console.error("callStatic failed:", e);
@@ -137,18 +147,13 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
137
147
  }
138
148
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
139
149
  if (isV5TT) {
140
- const tx = await titleEscrowContract.transferBeneficiary(
150
+ return await titleEscrowContract.transferBeneficiary(
141
151
  newBeneficiaryAddress,
142
152
  encryptedRemarks,
143
153
  txOptions
144
154
  );
145
- return tx;
146
155
  } else if (isV4TT) {
147
- const tx = await titleEscrowContract.transferBeneficiary(
148
- newBeneficiaryAddress,
149
- txOptions
150
- );
151
- return tx;
156
+ return await titleEscrowContract.transferBeneficiary(newBeneficiaryAddress, txOptions);
152
157
  }
153
158
  }, "transferBeneficiary");
154
159
  const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
@@ -169,7 +174,6 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
169
174
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
170
175
  if (!signer.provider) throw new Error("Provider is required");
171
176
  const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
172
- let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
173
177
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
174
178
  if (titleEscrowVersion === void 0) {
175
179
  [isV4TT, isV5TT] = await Promise.all([
@@ -188,24 +192,30 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
188
192
  if (!isV4TT && !isV5TT) {
189
193
  throw new Error("Only Token Registry V4/V5 is supported");
190
194
  }
191
- if (!isV5TT) {
192
- titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
195
+ const Contract = getEthersContractFromProvider(signer.provider);
196
+ let titleEscrowContract;
197
+ if (isV5TT) {
198
+ titleEscrowContract = new Contract(
199
+ titleEscrowAddress,
200
+ v5Contracts.TitleEscrow__factory.abi,
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ signer
203
+ );
204
+ } else if (isV4TT) {
205
+ titleEscrowContract = new Contract(
193
206
  titleEscrowAddress,
207
+ v4Contracts.TitleEscrow__factory.abi,
208
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
209
  signer
195
210
  );
196
211
  }
197
212
  try {
198
- if (isV5TT) {
199
- await titleEscrowContract.callStatic.transferOwners(
200
- newBeneficiaryAddress,
201
- newHolderAddress,
202
- encryptedRemarks
203
- );
204
- } else if (isV4TT) {
205
- await titleEscrowContract.callStatic.transferOwners(
206
- newBeneficiaryAddress,
207
- newHolderAddress
208
- );
213
+ const isV6 = isV6EthersProvider(signer.provider);
214
+ const args = isV5TT ? [newBeneficiaryAddress, newHolderAddress, encryptedRemarks] : [newBeneficiaryAddress, newHolderAddress];
215
+ if (isV6) {
216
+ await titleEscrowContract.transferOwners.staticCall(...args);
217
+ } else {
218
+ await titleEscrowContract.callStatic.transferOwners(...args);
209
219
  }
210
220
  } catch (e) {
211
221
  console.error("callStatic failed:", e);
@@ -245,7 +255,6 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
245
255
  if (!titleEscrowAddress) throw new Error("Token registry address is required");
246
256
  if (!signer.provider) throw new Error("Provider is required");
247
257
  const { newBeneficiaryAddress, remarks } = params;
248
- let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
249
258
  const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
250
259
  if (titleEscrowVersion === void 0) {
251
260
  [isV4TT, isV5TT] = await Promise.all([
@@ -261,22 +270,30 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
261
270
  })
262
271
  ]);
263
272
  }
264
- if (!isV5TT) {
265
- titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
273
+ const Contract = getEthersContractFromProvider(signer.provider);
274
+ let titleEscrowContract;
275
+ if (isV5TT) {
276
+ titleEscrowContract = new Contract(
266
277
  titleEscrowAddress,
278
+ v5Contracts.TitleEscrow__factory.abi,
279
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
280
+ signer
281
+ );
282
+ } else if (isV4TT) {
283
+ titleEscrowContract = new Contract(
284
+ titleEscrowAddress,
285
+ v4Contracts.TitleEscrow__factory.abi,
286
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
287
  signer
268
288
  );
269
289
  }
270
290
  try {
271
- if (isV5TT) {
272
- await titleEscrowContract.callStatic.nominate(
273
- newBeneficiaryAddress,
274
- encryptedRemarks
275
- );
276
- } else if (isV4TT) {
277
- await titleEscrowContract.callStatic.nominate(
278
- newBeneficiaryAddress
279
- );
291
+ const isV6 = isV6EthersProvider(signer.provider);
292
+ const args = isV5TT ? [newBeneficiaryAddress, encryptedRemarks] : [newBeneficiaryAddress];
293
+ if (isV6) {
294
+ await titleEscrowContract.nominate.staticCall(...args);
295
+ } else {
296
+ await titleEscrowContract.callStatic.nominate(...args);
280
297
  }
281
298
  } catch (e) {
282
299
  console.error("callStatic failed:", e);
@@ -284,16 +301,9 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
284
301
  }
285
302
  const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
286
303
  if (isV5TT) {
287
- return await titleEscrowContract.nominate(
288
- newBeneficiaryAddress,
289
- encryptedRemarks,
290
- txOptions
291
- );
304
+ return await titleEscrowContract.nominate(newBeneficiaryAddress, encryptedRemarks, txOptions);
292
305
  } else if (isV4TT) {
293
- return await titleEscrowContract.nominate(
294
- newBeneficiaryAddress,
295
- txOptions
296
- );
306
+ return await titleEscrowContract.nominate(newBeneficiaryAddress, txOptions);
297
307
  }
298
308
  }, "nominate");
299
309
 
@@ -13,7 +13,7 @@ const getTxOptions = /* @__PURE__ */ __name(async (signer, chainId, maxFeePerGas
13
13
  maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
14
14
  }
15
15
  }
16
- return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
16
+ return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : {};
17
17
  }, "getTxOptions");
18
18
  const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
19
19
  if (isV6EthersProvider(signer.provider)) {
@@ -6,6 +6,9 @@ import { Signer } from 'ethersV6';
6
6
  declare const getTxOptions: (signer: Signer | Signer$1, chainId: CHAIN_ID, maxFeePerGas: GasValue, maxPriorityFeePerGas: GasValue) => Promise<{
7
7
  maxFeePerGas: GasValue;
8
8
  maxPriorityFeePerGas: GasValue;
9
+ } | {
10
+ maxFeePerGas?: undefined;
11
+ maxPriorityFeePerGas?: undefined;
9
12
  }>;
10
13
  declare const getChainIdSafe: (signer: Signer | Signer$1) => Promise<bigint | number>;
11
14
  declare const getSignerAddressSafe: (signer: Signer | Signer$1) => Promise<string>;