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