@trustvc/trustvc 1.6.0-alpha.1 → 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.
- package/dist/cjs/core/endorsement-chain/useEndorsementChain.js +5 -6
- package/dist/cjs/token-registry-functions/index.js +28 -0
- package/dist/cjs/token-registry-functions/mint.js +90 -0
- package/dist/cjs/token-registry-functions/ownerOf.js +45 -0
- package/dist/cjs/token-registry-functions/rejectTransfers.js +166 -0
- package/dist/cjs/token-registry-functions/returnToken.js +210 -0
- package/dist/cjs/token-registry-functions/transfer.js +96 -128
- package/dist/cjs/token-registry-functions/types.js +2 -0
- package/dist/cjs/token-registry-functions/utils.js +37 -0
- package/dist/esm/core/endorsement-chain/useEndorsementChain.js +5 -7
- package/dist/esm/token-registry-functions/index.js +4 -0
- package/dist/esm/token-registry-functions/mint.js +88 -0
- package/dist/esm/token-registry-functions/ownerOf.js +43 -0
- package/dist/esm/token-registry-functions/rejectTransfers.js +162 -0
- package/dist/esm/token-registry-functions/returnToken.js +206 -0
- package/dist/esm/token-registry-functions/transfer.js +96 -128
- package/dist/esm/token-registry-functions/types.js +1 -0
- package/dist/esm/token-registry-functions/utils.js +33 -0
- package/dist/types/core/endorsement-chain/index.d.ts +1 -1
- package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +2 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -1
- package/dist/types/token-registry-functions/index.d.ts +6 -1
- package/dist/types/token-registry-functions/mint.d.ts +20 -0
- package/dist/types/token-registry-functions/ownerOf.d.ts +19 -0
- package/dist/types/token-registry-functions/rejectTransfers.d.ts +43 -0
- package/dist/types/token-registry-functions/returnToken.d.ts +44 -0
- package/dist/types/token-registry-functions/transfer.d.ts +79 -40
- package/dist/types/token-registry-functions/types.d.ts +80 -0
- package/dist/types/token-registry-functions/utils.d.ts +16 -0
- package/package.json +14 -2
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { isV6EthersProvider } from '
|
|
1
|
+
import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterface } from '../core';
|
|
2
|
+
import { v4Contracts } from '../token-registry-v4';
|
|
3
|
+
import { v5Contracts } from '../token-registry-v5';
|
|
4
|
+
import { getTxOptions } from './utils';
|
|
5
|
+
import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
10
|
-
if (isV6EthersProvider(signer.provider)) {
|
|
11
|
-
const network = await signer.provider?.getNetwork();
|
|
12
|
-
if (!network?.chainId) throw new Error("Cannot determine chainId: provider is missing");
|
|
13
|
-
return network.chainId;
|
|
14
|
-
}
|
|
15
|
-
return await signer.getChainId();
|
|
16
|
-
}, "getChainIdSafe");
|
|
17
9
|
const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
18
10
|
const { tokenRegistryAddress, tokenId } = contractOptions;
|
|
19
11
|
const { titleEscrowVersion } = options;
|
|
20
12
|
let { titleEscrowAddress } = contractOptions;
|
|
21
|
-
|
|
13
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
22
14
|
let isV5TT = titleEscrowVersion === "v5";
|
|
23
15
|
let isV4TT = titleEscrowVersion === "v4";
|
|
24
16
|
if (!titleEscrowAddress) {
|
|
17
|
+
if (!tokenRegistryAddress) throw new Error("Token registry address is required");
|
|
18
|
+
if (!tokenId) throw new Error("Token ID is required");
|
|
25
19
|
titleEscrowAddress = await getTitleEscrowAddress(
|
|
26
20
|
tokenRegistryAddress,
|
|
27
21
|
tokenId,
|
|
@@ -32,7 +26,6 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
32
26
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
33
27
|
if (!signer.provider) throw new Error("Provider is required");
|
|
34
28
|
const { holderAddress, remarks } = params;
|
|
35
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
36
29
|
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
37
30
|
if (titleEscrowVersion === void 0) {
|
|
38
31
|
[isV4TT, isV5TT] = await Promise.all([
|
|
@@ -51,43 +44,38 @@ const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
51
44
|
if (!isV4TT && !isV5TT) {
|
|
52
45
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
53
46
|
}
|
|
54
|
-
|
|
55
|
-
|
|
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(
|
|
56
58
|
titleEscrowAddress,
|
|
59
|
+
v4Contracts.TitleEscrow__factory.abi,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
61
|
signer
|
|
58
62
|
);
|
|
59
63
|
}
|
|
60
64
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
await titleEscrowContract.callStatic.transferHolder(
|
|
68
|
-
holderAddress
|
|
69
|
-
);
|
|
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);
|
|
70
71
|
}
|
|
71
72
|
} catch (e) {
|
|
72
73
|
console.error("callStatic failed:", e);
|
|
73
74
|
throw new Error("Pre-check (callStatic) for transferHolder failed");
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
77
|
-
const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
78
|
-
if (gasStation) {
|
|
79
|
-
const gasFees = await gasStation();
|
|
80
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
81
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
76
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
85
77
|
if (isV5TT) {
|
|
86
|
-
return await titleEscrowContract.transferHolder(
|
|
87
|
-
holderAddress,
|
|
88
|
-
encryptedRemarks,
|
|
89
|
-
txOptions
|
|
90
|
-
);
|
|
78
|
+
return await titleEscrowContract.transferHolder(holderAddress, encryptedRemarks, txOptions);
|
|
91
79
|
} else if (isV4TT) {
|
|
92
80
|
return await titleEscrowContract.transferHolder(holderAddress, txOptions);
|
|
93
81
|
}
|
|
@@ -96,7 +84,7 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
|
|
|
96
84
|
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
97
85
|
const { titleEscrowVersion } = options;
|
|
98
86
|
let { titleEscrowAddress } = contractOptions;
|
|
99
|
-
|
|
87
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
100
88
|
let isV5TT = titleEscrowVersion === "v5";
|
|
101
89
|
let isV4TT = titleEscrowVersion === "v4";
|
|
102
90
|
if (!titleEscrowAddress) {
|
|
@@ -110,7 +98,6 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
|
|
|
110
98
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
111
99
|
if (!signer.provider) throw new Error("Provider is required");
|
|
112
100
|
const { newBeneficiaryAddress, remarks } = params;
|
|
113
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
114
101
|
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
115
102
|
if (titleEscrowVersion === void 0) {
|
|
116
103
|
[isV4TT, isV5TT] = await Promise.all([
|
|
@@ -129,57 +116,51 @@ const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signe
|
|
|
129
116
|
if (!isV4TT && !isV5TT) {
|
|
130
117
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
131
118
|
}
|
|
132
|
-
|
|
133
|
-
|
|
119
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
120
|
+
let titleEscrowContract;
|
|
121
|
+
if (isV5TT) {
|
|
122
|
+
titleEscrowContract = new Contract(
|
|
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(
|
|
134
130
|
titleEscrowAddress,
|
|
131
|
+
v4Contracts.TitleEscrow__factory.abi,
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
133
|
signer
|
|
136
134
|
);
|
|
137
135
|
}
|
|
138
136
|
try {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
await titleEscrowContract.callStatic.transferBeneficiary(
|
|
146
|
-
newBeneficiaryAddress
|
|
147
|
-
);
|
|
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);
|
|
148
143
|
}
|
|
149
144
|
} catch (e) {
|
|
150
145
|
console.error("callStatic failed:", e);
|
|
151
146
|
throw new Error("Pre-check (callStatic) for transferBeneficiary failed");
|
|
152
147
|
}
|
|
153
|
-
|
|
154
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
155
|
-
const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
156
|
-
if (gasStation) {
|
|
157
|
-
const gasFees = await gasStation();
|
|
158
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
159
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
148
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
163
149
|
if (isV5TT) {
|
|
164
|
-
|
|
150
|
+
return await titleEscrowContract.transferBeneficiary(
|
|
165
151
|
newBeneficiaryAddress,
|
|
166
152
|
encryptedRemarks,
|
|
167
153
|
txOptions
|
|
168
154
|
);
|
|
169
|
-
return tx;
|
|
170
155
|
} else if (isV4TT) {
|
|
171
|
-
|
|
172
|
-
newBeneficiaryAddress,
|
|
173
|
-
txOptions
|
|
174
|
-
);
|
|
175
|
-
return tx;
|
|
156
|
+
return await titleEscrowContract.transferBeneficiary(newBeneficiaryAddress, txOptions);
|
|
176
157
|
}
|
|
177
158
|
}, "transferBeneficiary");
|
|
178
159
|
const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
179
160
|
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
180
161
|
const { titleEscrowVersion } = options;
|
|
181
162
|
let { titleEscrowAddress } = contractOptions;
|
|
182
|
-
|
|
163
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
183
164
|
let isV5TT = titleEscrowVersion === "v5";
|
|
184
165
|
let isV4TT = titleEscrowVersion === "v4";
|
|
185
166
|
if (!titleEscrowAddress) {
|
|
@@ -193,7 +174,6 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
193
174
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
194
175
|
if (!signer.provider) throw new Error("Provider is required");
|
|
195
176
|
const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
|
|
196
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
197
177
|
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
198
178
|
if (titleEscrowVersion === void 0) {
|
|
199
179
|
[isV4TT, isV5TT] = await Promise.all([
|
|
@@ -212,39 +192,36 @@ const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, pa
|
|
|
212
192
|
if (!isV4TT && !isV5TT) {
|
|
213
193
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
214
194
|
}
|
|
215
|
-
|
|
216
|
-
|
|
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(
|
|
217
206
|
titleEscrowAddress,
|
|
207
|
+
v4Contracts.TitleEscrow__factory.abi,
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
209
|
signer
|
|
219
210
|
);
|
|
220
211
|
}
|
|
221
212
|
try {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
);
|
|
228
|
-
} else if (isV4TT) {
|
|
229
|
-
await titleEscrowContract.callStatic.transferOwners(
|
|
230
|
-
newBeneficiaryAddress,
|
|
231
|
-
newHolderAddress
|
|
232
|
-
);
|
|
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);
|
|
233
219
|
}
|
|
234
220
|
} catch (e) {
|
|
235
221
|
console.error("callStatic failed:", e);
|
|
236
222
|
throw new Error("Pre-check (callStatic) for transferOwners failed");
|
|
237
223
|
}
|
|
238
|
-
|
|
239
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
240
|
-
const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
241
|
-
if (gasStation) {
|
|
242
|
-
const gasFees = await gasStation();
|
|
243
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
244
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
224
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
248
225
|
if (isV5TT) {
|
|
249
226
|
return await titleEscrowContract.transferOwners(
|
|
250
227
|
newBeneficiaryAddress,
|
|
@@ -264,7 +241,7 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
|
|
|
264
241
|
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
265
242
|
const { titleEscrowVersion } = options;
|
|
266
243
|
let { titleEscrowAddress } = contractOptions;
|
|
267
|
-
|
|
244
|
+
const { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
268
245
|
let isV5TT = titleEscrowVersion === "v5";
|
|
269
246
|
let isV4TT = titleEscrowVersion === "v4";
|
|
270
247
|
if (!titleEscrowAddress) {
|
|
@@ -278,7 +255,6 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
|
|
|
278
255
|
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
279
256
|
if (!signer.provider) throw new Error("Provider is required");
|
|
280
257
|
const { newBeneficiaryAddress, remarks } = params;
|
|
281
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
282
258
|
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
283
259
|
if (titleEscrowVersion === void 0) {
|
|
284
260
|
[isV4TT, isV5TT] = await Promise.all([
|
|
@@ -294,48 +270,40 @@ const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params,
|
|
|
294
270
|
})
|
|
295
271
|
]);
|
|
296
272
|
}
|
|
297
|
-
|
|
298
|
-
|
|
273
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
274
|
+
let titleEscrowContract;
|
|
275
|
+
if (isV5TT) {
|
|
276
|
+
titleEscrowContract = new Contract(
|
|
299
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
|
|
300
287
|
signer
|
|
301
288
|
);
|
|
302
289
|
}
|
|
303
290
|
try {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
await titleEscrowContract.callStatic.nominate(
|
|
311
|
-
newBeneficiaryAddress
|
|
312
|
-
);
|
|
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);
|
|
313
297
|
}
|
|
314
298
|
} catch (e) {
|
|
315
299
|
console.error("callStatic failed:", e);
|
|
316
300
|
throw new Error("Pre-check (callStatic) for nominate failed");
|
|
317
301
|
}
|
|
318
|
-
|
|
319
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
320
|
-
const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
321
|
-
if (gasStation) {
|
|
322
|
-
const gasFees = await gasStation();
|
|
323
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
324
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
302
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
328
303
|
if (isV5TT) {
|
|
329
|
-
return await titleEscrowContract.nominate(
|
|
330
|
-
newBeneficiaryAddress,
|
|
331
|
-
encryptedRemarks,
|
|
332
|
-
txOptions
|
|
333
|
-
);
|
|
304
|
+
return await titleEscrowContract.nominate(newBeneficiaryAddress, encryptedRemarks, txOptions);
|
|
334
305
|
} else if (isV4TT) {
|
|
335
|
-
return await titleEscrowContract.nominate(
|
|
336
|
-
newBeneficiaryAddress,
|
|
337
|
-
txOptions
|
|
338
|
-
);
|
|
306
|
+
return await titleEscrowContract.nominate(newBeneficiaryAddress, txOptions);
|
|
339
307
|
}
|
|
340
308
|
}, "nominate");
|
|
341
309
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isV6EthersProvider } from '../utils/ethers';
|
|
2
|
+
import { SUPPORTED_CHAINS } from '@tradetrust-tt/tradetrust-utils';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
const getTxOptions = /* @__PURE__ */ __name(async (signer, chainId, maxFeePerGas, maxPriorityFeePerGas) => {
|
|
7
|
+
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
8
|
+
chainId = chainId ?? await getChainIdSafe(signer);
|
|
9
|
+
const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
10
|
+
if (gasStation) {
|
|
11
|
+
const gasFees = await gasStation();
|
|
12
|
+
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
13
|
+
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : {};
|
|
17
|
+
}, "getTxOptions");
|
|
18
|
+
const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
19
|
+
if (isV6EthersProvider(signer.provider)) {
|
|
20
|
+
const network = await signer.provider?.getNetwork();
|
|
21
|
+
if (!network?.chainId) throw new Error("Cannot determine chainId: provider is missing");
|
|
22
|
+
return network.chainId;
|
|
23
|
+
}
|
|
24
|
+
return await signer.getChainId();
|
|
25
|
+
}, "getChainIdSafe");
|
|
26
|
+
const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
27
|
+
if (isV6EthersProvider(signer.provider)) {
|
|
28
|
+
return await signer.getAddress();
|
|
29
|
+
}
|
|
30
|
+
return await signer.getAddress();
|
|
31
|
+
}, "getSignerAddressSafe");
|
|
32
|
+
|
|
33
|
+
export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
|
|
@@ -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, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
|
|
6
|
+
export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
|
|
7
7
|
import 'ethersV6';
|
|
8
8
|
import '@ethersproject/abstract-provider';
|
|
9
9
|
import 'ethers';
|
|
@@ -12,6 +12,7 @@ declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: str
|
|
|
12
12
|
titleEscrowVersion?: "v4" | "v5";
|
|
13
13
|
}) => Promise<string>;
|
|
14
14
|
declare const getDocumentOwner: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider) => Promise<string>;
|
|
15
|
+
declare const checkSupportsInterface: (contractAddress: string, interfaceId: string, provider: Provider | ethers.Provider) => Promise<boolean>;
|
|
15
16
|
interface TitleEscrowVersionParams {
|
|
16
17
|
tokenRegistryAddress?: string;
|
|
17
18
|
tokenId?: string;
|
|
@@ -27,4 +28,4 @@ interface TitleEscrowVersionParams {
|
|
|
27
28
|
declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
|
|
28
29
|
declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string) => Promise<EndorsementChain>;
|
|
29
30
|
|
|
30
|
-
export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
|
|
31
|
+
export { TitleEscrowInterface, checkSupportsInterface, 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, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
|
|
9
|
+
export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
|
|
10
10
|
export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './documentBuilder.js';
|
|
11
11
|
import '@trustvc/w3c-vc';
|
|
12
12
|
import 'ethers';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export { c as v5Contracts } from './contracts-BaIGKzNt.js';
|
|
|
11
11
|
export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './token-registry-v5/utils.js';
|
|
12
12
|
export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
|
|
13
13
|
export { nominate, transferBeneficiary, transferHolder, transferOwners } from './token-registry-functions/transfer.js';
|
|
14
|
+
export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './token-registry-functions/rejectTransfers.js';
|
|
15
|
+
export { acceptReturned, rejectReturned, returnToIssuer } from './token-registry-functions/returnToken.js';
|
|
16
|
+
export { mint } from './token-registry-functions/mint.js';
|
|
17
|
+
export { ownerOf } from './token-registry-functions/ownerOf.js';
|
|
14
18
|
export { decrypt } from './core/decrypt.js';
|
|
15
19
|
export { encrypt } from './core/encrypt.js';
|
|
16
20
|
export { verifyDocument } from './core/verify.js';
|
|
@@ -19,7 +23,7 @@ export { fetchTokenTransfers } from './core/endorsement-chain/fetchTokenTransfer
|
|
|
19
23
|
export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './core/endorsement-chain/helpers.js';
|
|
20
24
|
export { getEndorsementChain } from './core/endorsement-chain/retrieveEndorsementChain.js';
|
|
21
25
|
export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './core/endorsement-chain/types.js';
|
|
22
|
-
export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
|
|
26
|
+
export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
|
|
23
27
|
export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './core/documentBuilder.js';
|
|
24
28
|
export { signOA } from './open-attestation/sign.js';
|
|
25
29
|
export { KeyPair } from './open-attestation/types.js';
|
|
@@ -54,6 +58,7 @@ import '@typechain/ethers-v5/static/common';
|
|
|
54
58
|
import '@tradetrust-tt/token-registry-v5/contracts';
|
|
55
59
|
import '@tradetrust-tt/token-registry-v5';
|
|
56
60
|
import 'ethersV6';
|
|
61
|
+
import './token-registry-functions/types.js';
|
|
57
62
|
import '@ethersproject/abstract-provider';
|
|
58
63
|
import 'ethers/lib/utils';
|
|
59
64
|
import '@ethersproject/abstract-signer';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export { nominate, transferBeneficiary, transferHolder, transferOwners } from './transfer.js';
|
|
2
|
-
|
|
2
|
+
export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './rejectTransfers.js';
|
|
3
|
+
export { acceptReturned, rejectReturned, returnToIssuer } from './returnToken.js';
|
|
4
|
+
export { mint } from './mint.js';
|
|
5
|
+
export { ownerOf } from './ownerOf.js';
|
|
3
6
|
import 'ethersV6';
|
|
4
7
|
import 'ethers';
|
|
8
|
+
import './types.js';
|
|
9
|
+
import '@tradetrust-tt/tradetrust-utils';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Signer as Signer$1 } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { MintTokenOptions, MintTokenParams, TransactionOptions } from './types.js';
|
|
4
|
+
import '@tradetrust-tt/tradetrust-utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Mints a new token into the TradeTrustToken registry with the specified beneficiary and holder.
|
|
8
|
+
* Supports both Token Registry V4 and V5 contracts.
|
|
9
|
+
* @param {MintTokenOptions} contractOptions - Contains the `tokenRegistryAddress` for the minting contract.
|
|
10
|
+
* @param {Signer | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the mint transaction.
|
|
11
|
+
* @param {MintTokenParams} params - Parameters for minting, including `beneficiaryAddress`, `holderAddress`, `tokenId`, and optional `remarks`.
|
|
12
|
+
* @param {TransactionOptions} options - Transaction metadata including gas values, version detection, chain ID, and optional encryption ID.
|
|
13
|
+
* @returns {Promise<ContractTransaction>} A promise resolving to the transaction result from the mint call.
|
|
14
|
+
* @throws {Error} If the token registry address or signer provider is not provided.
|
|
15
|
+
* @throws {Error} If neither V4 nor V5 interfaces are supported.
|
|
16
|
+
* @throws {Error} If the `callStatic.mint` fails as a pre-check.
|
|
17
|
+
*/
|
|
18
|
+
declare const mint: (contractOptions: MintTokenOptions, signer: Signer | Signer$1, params: MintTokenParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
19
|
+
|
|
20
|
+
export { mint };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Signer as Signer$1 } from 'ethersV6';
|
|
2
|
+
import { Signer } from 'ethers';
|
|
3
|
+
import { OwnerOfTokenOptions, OwnerOfTokenParams, TransactionOptions } from './types.js';
|
|
4
|
+
import '@tradetrust-tt/tradetrust-utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the owner of a given token from the TradeTrustToken contract.
|
|
8
|
+
* Supports both Token Registry V4 and V5 implementations.
|
|
9
|
+
* @param {OwnerOfTokenOptions} contractOptions - Options containing the token registry address.
|
|
10
|
+
* @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to query the blockchain.
|
|
11
|
+
* @param {OwnerOfTokenParams} params - Contains the `tokenId` of the token to query ownership for.
|
|
12
|
+
* @param {TransactionOptions} options - Includes the `titleEscrowVersion` and other optional metadata for interface detection.
|
|
13
|
+
* @returns {Promise<string>} A promise that resolves to the owner address of the specified token.
|
|
14
|
+
* @throws {Error} If token registry address or signer provider is not provided.
|
|
15
|
+
* @throws {Error} If the token registry does not support V4 or V5 interfaces.
|
|
16
|
+
*/
|
|
17
|
+
declare const ownerOf: (contractOptions: OwnerOfTokenOptions, signer: Signer | Signer$1, params: OwnerOfTokenParams, options: TransactionOptions) => Promise<string>;
|
|
18
|
+
|
|
19
|
+
export { ownerOf };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Signer as Signer$1 } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { ContractOptions, RejectTransferParams, TransactionOptions } from './types.js';
|
|
4
|
+
import '@tradetrust-tt/tradetrust-utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Rejects the transfer of holder for a title escrow contract.
|
|
8
|
+
* @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
|
|
9
|
+
* @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
|
|
10
|
+
* @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
|
|
11
|
+
* @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
|
|
12
|
+
* @throws error if the title escrow address or signer provider is missing.
|
|
13
|
+
* @throws if the version is not V5 compatible.
|
|
14
|
+
* @throws if the dry-run (`callStatic`) fails.
|
|
15
|
+
* @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferHolder call.
|
|
16
|
+
*/
|
|
17
|
+
declare const rejectTransferHolder: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
18
|
+
/**
|
|
19
|
+
* Rejects the transfer of beneficiary for a title escrow contract.
|
|
20
|
+
* @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
|
|
21
|
+
* @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
|
|
22
|
+
* @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
|
|
23
|
+
* @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
|
|
24
|
+
* @throws error if the title escrow address or signer provider is missing.
|
|
25
|
+
* @throws error if the version is not V5 compatible.
|
|
26
|
+
* @throws error if the dry-run (`callStatic`) fails.
|
|
27
|
+
* @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferBeneficiary call.
|
|
28
|
+
*/
|
|
29
|
+
declare const rejectTransferBeneficiary: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
30
|
+
/**
|
|
31
|
+
* Rejects the transfer of ownership for a title escrow contract.
|
|
32
|
+
* @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
|
|
33
|
+
* @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
|
|
34
|
+
* @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
|
|
35
|
+
* @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
|
|
36
|
+
* @throws error if the title escrow address or signer provider is missing.
|
|
37
|
+
* @throws an error if the version is not V5 compatible.
|
|
38
|
+
* @throws an error if the dry-run (`callStatic`) fails.
|
|
39
|
+
* @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferOwners call.
|
|
40
|
+
*/
|
|
41
|
+
declare const rejectTransferOwners: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
42
|
+
|
|
43
|
+
export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Signer as Signer$1 } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractTransaction } from 'ethers';
|
|
3
|
+
import { ContractOptions, ReturnToIssuerParams, TransactionOptions, RejectReturnedOptions, AcceptReturnedParams, AcceptReturnedOptions, RejectReturnedParams } from './types.js';
|
|
4
|
+
import '@tradetrust-tt/tradetrust-utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the token to the original issuer from the Title Escrow contract.
|
|
8
|
+
* @param {ContractOptions} contractOptions - Options including token ID, registry address, and optionally title escrow address.
|
|
9
|
+
* @param {Signer | SignerV6} signer - Signer instance (Ethers v5 or v6) that will execute the transaction.
|
|
10
|
+
* @param {ReturnToIssuerParams} params - Contains optional remarks to be encrypted and attached to the transaction.
|
|
11
|
+
* @param {TransactionOptions} options - Transaction settings including gas fees, escrow version, chain ID, and optional encryption ID.
|
|
12
|
+
* @returns {Promise<ContractTransaction>} Promise that resolves to the transaction response from the `returnToIssuer` function.
|
|
13
|
+
* @throws {Error} If title escrow address or provider is not provided or if version is unsupported.
|
|
14
|
+
* @throws {Error} If the `callStatic.returnToIssuer` fails as a pre-check.
|
|
15
|
+
*/
|
|
16
|
+
declare const returnToIssuer: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: ReturnToIssuerParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
17
|
+
/**
|
|
18
|
+
* Rejects a previously returned token by restoring it back to the token registry.
|
|
19
|
+
* This is only supported on Token Registry V5 contracts with the `restore` functionality.
|
|
20
|
+
* @param {AcceptReturnedOptions} contractOptions - Contains the `tokenRegistryAddress` used to locate the TradeTrustToken contract.
|
|
21
|
+
* @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to authorize the transaction.
|
|
22
|
+
* @param {AcceptReturnedParams} params - Includes the `tokenId` to restore and optional `remarks` to encrypt.
|
|
23
|
+
* @param {TransactionOptions} options - Configuration for the transaction including version, gas fees, and optional `id` used for encryption.
|
|
24
|
+
* @returns {Promise<ContractTransaction>} A promise that resolves to the transaction result of the `restore` call.
|
|
25
|
+
* @throws {Error} If the token registry address or provider is missing.
|
|
26
|
+
* @throws {Error} If the token registry version is unsupported.
|
|
27
|
+
* @throws {Error} If the callStatic pre-check fails.
|
|
28
|
+
*/
|
|
29
|
+
declare const rejectReturned: (contractOptions: AcceptReturnedOptions, signer: Signer | Signer$1, params: RejectReturnedParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
30
|
+
/**
|
|
31
|
+
* Accepts the returned token by burning it from the TradeTrustToken contract.
|
|
32
|
+
* Only supported on Token Registry V5 contracts that implement the burnable interface.
|
|
33
|
+
* @param {RejectReturnedOptions} contractOptions - Contains the `tokenRegistryAddress` from which the token will be burned.
|
|
34
|
+
* @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to authorize and send the burn transaction.
|
|
35
|
+
* @param {AcceptReturnedParams} params - Includes the `tokenId` to burn and optional `remarks` for audit trail.
|
|
36
|
+
* @param {TransactionOptions} options - Transaction settings including chain ID, gas fee values, escrow version, and encryption ID for remarks.
|
|
37
|
+
* @returns {Promise<ContractTransaction>} A promise resolving to the transaction result of the burn call.
|
|
38
|
+
* @throws {Error} If token registry address or signer provider is not provided.
|
|
39
|
+
* @throws {Error} If the contract does not support Token Registry V5.
|
|
40
|
+
* @throws {Error} If `callStatic.burn` fails as a pre-check.
|
|
41
|
+
*/
|
|
42
|
+
declare const acceptReturned: (contractOptions: RejectReturnedOptions, signer: Signer | Signer$1, params: AcceptReturnedParams, options: TransactionOptions) => Promise<ContractTransaction>;
|
|
43
|
+
|
|
44
|
+
export { acceptReturned, rejectReturned, returnToIssuer };
|