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