@trustvc/trustvc 1.6.0-alpha.1 → 1.6.0
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 +6 -6
- package/dist/cjs/index.js +0 -7
- package/dist/esm/core/endorsement-chain/useEndorsementChain.js +6 -6
- package/dist/esm/index.js +0 -1
- package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +1 -1
- package/dist/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/token-registry-functions/index.js +0 -12
- package/dist/cjs/token-registry-functions/transfer.js +0 -347
- package/dist/esm/token-registry-functions/index.js +0 -1
- package/dist/esm/token-registry-functions/transfer.js +0 -342
- package/dist/types/token-registry-functions/index.d.ts +0 -4
- package/dist/types/token-registry-functions/transfer.d.ts +0 -43
|
@@ -122,19 +122,19 @@ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
|
|
|
122
122
|
return false;
|
|
123
123
|
}
|
|
124
124
|
}, "isTitleEscrowVersion");
|
|
125
|
-
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
|
|
125
|
+
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId, titleEscrowAddress) => {
|
|
126
126
|
if (!tokenRegistryAddress || !tokenId || !provider) {
|
|
127
127
|
throw new Error("Missing required dependencies");
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const resolvedTitleEscrowAddress = titleEscrowAddress ?? await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
|
|
130
130
|
const [isV4, isV5] = await Promise.all([
|
|
131
131
|
isTitleEscrowVersion({
|
|
132
|
-
titleEscrowAddress,
|
|
132
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
133
133
|
versionInterface: TitleEscrowInterface.V4,
|
|
134
134
|
provider
|
|
135
135
|
}),
|
|
136
136
|
isTitleEscrowVersion({
|
|
137
|
-
titleEscrowAddress,
|
|
137
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
138
138
|
versionInterface: TitleEscrowInterface.V5,
|
|
139
139
|
provider
|
|
140
140
|
})
|
|
@@ -146,13 +146,13 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
|
|
|
146
146
|
if (isV4) {
|
|
147
147
|
const [tokenLogs, titleEscrowLogs] = await Promise.all([
|
|
148
148
|
fetchTokenTransfer.fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
|
|
149
|
-
fetchEscrowTransfer.fetchEscrowTransfersV4(provider,
|
|
149
|
+
fetchEscrowTransfer.fetchEscrowTransfersV4(provider, resolvedTitleEscrowAddress)
|
|
150
150
|
]);
|
|
151
151
|
transferEvents = helpers.mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
|
|
152
152
|
} else if (isV5) {
|
|
153
153
|
const titleEscrowLogs = await fetchEscrowTransfer.fetchEscrowTransfersV5(
|
|
154
154
|
provider,
|
|
155
|
-
|
|
155
|
+
resolvedTitleEscrowAddress,
|
|
156
156
|
tokenRegistryAddress
|
|
157
157
|
);
|
|
158
158
|
transferEvents = helpers.mergeTransfersV5(titleEscrowLogs);
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var tokenRegistryV4 = require('./token-registry-v4');
|
|
4
4
|
var tokenRegistryV5 = require('./token-registry-v5');
|
|
5
|
-
var tokenRegistryFunctions = require('./token-registry-functions');
|
|
6
5
|
var core = require('./core');
|
|
7
6
|
var openAttestation = require('./open-attestation');
|
|
8
7
|
var verify = require('./verify');
|
|
@@ -80,12 +79,6 @@ Object.defineProperty(exports, "v5Utils", {
|
|
|
80
79
|
enumerable: true,
|
|
81
80
|
get: function () { return tokenRegistryV5.v5Utils; }
|
|
82
81
|
});
|
|
83
|
-
Object.keys(tokenRegistryFunctions).forEach(function (k) {
|
|
84
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function () { return tokenRegistryFunctions[k]; }
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
82
|
Object.keys(core).forEach(function (k) {
|
|
90
83
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
91
84
|
enumerable: true,
|
|
@@ -120,19 +120,19 @@ const isTitleEscrowVersion = /* @__PURE__ */ __name(async ({
|
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
122
|
}, "isTitleEscrowVersion");
|
|
123
|
-
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId) => {
|
|
123
|
+
const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress, tokenId, provider, keyId, titleEscrowAddress) => {
|
|
124
124
|
if (!tokenRegistryAddress || !tokenId || !provider) {
|
|
125
125
|
throw new Error("Missing required dependencies");
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const resolvedTitleEscrowAddress = titleEscrowAddress ?? await getTitleEscrowAddress(tokenRegistryAddress, tokenId, provider);
|
|
128
128
|
const [isV4, isV5] = await Promise.all([
|
|
129
129
|
isTitleEscrowVersion({
|
|
130
|
-
titleEscrowAddress,
|
|
130
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
131
131
|
versionInterface: TitleEscrowInterface.V4,
|
|
132
132
|
provider
|
|
133
133
|
}),
|
|
134
134
|
isTitleEscrowVersion({
|
|
135
|
-
titleEscrowAddress,
|
|
135
|
+
titleEscrowAddress: resolvedTitleEscrowAddress,
|
|
136
136
|
versionInterface: TitleEscrowInterface.V5,
|
|
137
137
|
provider
|
|
138
138
|
})
|
|
@@ -144,13 +144,13 @@ const fetchEndorsementChain = /* @__PURE__ */ __name(async (tokenRegistryAddress
|
|
|
144
144
|
if (isV4) {
|
|
145
145
|
const [tokenLogs, titleEscrowLogs] = await Promise.all([
|
|
146
146
|
fetchTokenTransfers(provider, tokenRegistryAddress, tokenId),
|
|
147
|
-
fetchEscrowTransfersV4(provider,
|
|
147
|
+
fetchEscrowTransfersV4(provider, resolvedTitleEscrowAddress)
|
|
148
148
|
]);
|
|
149
149
|
transferEvents = mergeTransfersV4([...titleEscrowLogs, ...tokenLogs]);
|
|
150
150
|
} else if (isV5) {
|
|
151
151
|
const titleEscrowLogs = await fetchEscrowTransfersV5(
|
|
152
152
|
provider,
|
|
153
|
-
|
|
153
|
+
resolvedTitleEscrowAddress,
|
|
154
154
|
tokenRegistryAddress
|
|
155
155
|
);
|
|
156
156
|
transferEvents = mergeTransfersV5(titleEscrowLogs);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { v4ComputeInterfaceId, v4ComputeTitleEscrowAddress, v4ContractAddress, v4Contracts, v4EncodeInitParams, v4GetEventFromReceipt, v4RoleHash, v4SupportInterfaceIds, v4Utils } from './token-registry-v4';
|
|
2
2
|
export { v5ComputeInterfaceId, v5ContractAddress, v5Contracts, v5EncodeInitParams, v5GetEventFromReceipt, v5RoleHash, v5SupportInterfaceIds, v5Utils } from './token-registry-v5';
|
|
3
|
-
export * from './token-registry-functions';
|
|
4
3
|
export * from './core';
|
|
5
4
|
export * from './open-attestation';
|
|
6
5
|
export * from './verify';
|
|
@@ -25,6 +25,6 @@ interface TitleEscrowVersionParams {
|
|
|
25
25
|
* @returns {Promise<boolean>} - return true if titleEscrow matches supportInterface
|
|
26
26
|
*/
|
|
27
27
|
declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
|
|
28
|
-
declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string) => Promise<EndorsementChain>;
|
|
28
|
+
declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string, titleEscrowAddress?: string) => Promise<EndorsementChain>;
|
|
29
29
|
|
|
30
30
|
export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export { supportInterfaceIds as v5SupportInterfaceIds } from './token-registry-v
|
|
|
10
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
|
-
export { nominate, transferBeneficiary, transferHolder, transferOwners } from './token-registry-functions/transfer.js';
|
|
14
13
|
export { decrypt } from './core/decrypt.js';
|
|
15
14
|
export { encrypt } from './core/encrypt.js';
|
|
16
15
|
export { verifyDocument } from './core/verify.js';
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var transfer = require('./transfer');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(transfer).forEach(function (k) {
|
|
8
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return transfer[k]; }
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tradetrustUtils = require('@tradetrust-tt/tradetrust-utils');
|
|
4
|
-
var core = require('src/core');
|
|
5
|
-
var tokenRegistryV4 = require('src/token-registry-v4');
|
|
6
|
-
var tokenRegistryV5 = require('src/token-registry-v5');
|
|
7
|
-
var ethers = require('src/utils/ethers');
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
-
const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
12
|
-
if (ethers.isV6EthersProvider(signer.provider)) {
|
|
13
|
-
const network = await signer.provider?.getNetwork();
|
|
14
|
-
if (!network?.chainId) throw new Error("Cannot determine chainId: provider is missing");
|
|
15
|
-
return network.chainId;
|
|
16
|
-
}
|
|
17
|
-
return await signer.getChainId();
|
|
18
|
-
}, "getChainIdSafe");
|
|
19
|
-
const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
20
|
-
const { tokenRegistryAddress, tokenId } = contractOptions;
|
|
21
|
-
const { titleEscrowVersion } = options;
|
|
22
|
-
let { titleEscrowAddress } = contractOptions;
|
|
23
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
24
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
25
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
26
|
-
if (!titleEscrowAddress) {
|
|
27
|
-
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
28
|
-
tokenRegistryAddress,
|
|
29
|
-
tokenId,
|
|
30
|
-
signer.provider,
|
|
31
|
-
{ titleEscrowVersion }
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
35
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
36
|
-
const { holderAddress, remarks } = params;
|
|
37
|
-
let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
38
|
-
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
39
|
-
if (titleEscrowVersion === void 0) {
|
|
40
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
41
|
-
core.isTitleEscrowVersion({
|
|
42
|
-
titleEscrowAddress,
|
|
43
|
-
versionInterface: core.TitleEscrowInterface.V4,
|
|
44
|
-
provider: signer.provider
|
|
45
|
-
}),
|
|
46
|
-
core.isTitleEscrowVersion({
|
|
47
|
-
titleEscrowAddress,
|
|
48
|
-
versionInterface: core.TitleEscrowInterface.V5,
|
|
49
|
-
provider: signer.provider
|
|
50
|
-
})
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
if (!isV4TT && !isV5TT) {
|
|
54
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
55
|
-
}
|
|
56
|
-
if (isV4TT) {
|
|
57
|
-
titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
|
|
58
|
-
titleEscrowAddress,
|
|
59
|
-
signer
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
if (isV5TT) {
|
|
64
|
-
await titleEscrowContract.callStatic.transferHolder(
|
|
65
|
-
holderAddress,
|
|
66
|
-
encryptedRemarks
|
|
67
|
-
);
|
|
68
|
-
} else if (isV4TT) {
|
|
69
|
-
await titleEscrowContract.callStatic.transferHolder(
|
|
70
|
-
holderAddress
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.error("callStatic failed:", e);
|
|
75
|
-
throw new Error("Pre-check (callStatic) for transferHolder failed");
|
|
76
|
-
}
|
|
77
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
78
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
79
|
-
const gasStation = tradetrustUtils.SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
80
|
-
if (gasStation) {
|
|
81
|
-
const gasFees = await gasStation();
|
|
82
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
83
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
87
|
-
if (isV5TT) {
|
|
88
|
-
return await titleEscrowContract.transferHolder(
|
|
89
|
-
holderAddress,
|
|
90
|
-
encryptedRemarks,
|
|
91
|
-
txOptions
|
|
92
|
-
);
|
|
93
|
-
} else if (isV4TT) {
|
|
94
|
-
return await titleEscrowContract.transferHolder(holderAddress, txOptions);
|
|
95
|
-
}
|
|
96
|
-
}, "transferHolder");
|
|
97
|
-
const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
98
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
99
|
-
const { titleEscrowVersion } = options;
|
|
100
|
-
let { titleEscrowAddress } = contractOptions;
|
|
101
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
102
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
103
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
104
|
-
if (!titleEscrowAddress) {
|
|
105
|
-
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
106
|
-
tokenRegistryAddress,
|
|
107
|
-
tokenId,
|
|
108
|
-
signer.provider,
|
|
109
|
-
{ titleEscrowVersion }
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
113
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
114
|
-
const { newBeneficiaryAddress, remarks } = params;
|
|
115
|
-
let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
116
|
-
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
117
|
-
if (titleEscrowVersion === void 0) {
|
|
118
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
119
|
-
core.isTitleEscrowVersion({
|
|
120
|
-
titleEscrowAddress,
|
|
121
|
-
versionInterface: core.TitleEscrowInterface.V4,
|
|
122
|
-
provider: signer.provider
|
|
123
|
-
}),
|
|
124
|
-
core.isTitleEscrowVersion({
|
|
125
|
-
titleEscrowAddress,
|
|
126
|
-
versionInterface: core.TitleEscrowInterface.V5,
|
|
127
|
-
provider: signer.provider
|
|
128
|
-
})
|
|
129
|
-
]);
|
|
130
|
-
}
|
|
131
|
-
if (!isV4TT && !isV5TT) {
|
|
132
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
133
|
-
}
|
|
134
|
-
if (!isV5TT) {
|
|
135
|
-
titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
|
|
136
|
-
titleEscrowAddress,
|
|
137
|
-
signer
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
if (isV5TT) {
|
|
142
|
-
await titleEscrowContract.callStatic.transferBeneficiary(
|
|
143
|
-
newBeneficiaryAddress,
|
|
144
|
-
encryptedRemarks
|
|
145
|
-
);
|
|
146
|
-
} else if (isV4TT) {
|
|
147
|
-
await titleEscrowContract.callStatic.transferBeneficiary(
|
|
148
|
-
newBeneficiaryAddress
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
} catch (e) {
|
|
152
|
-
console.error("callStatic failed:", e);
|
|
153
|
-
throw new Error("Pre-check (callStatic) for transferBeneficiary failed");
|
|
154
|
-
}
|
|
155
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
156
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
157
|
-
const gasStation = tradetrustUtils.SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
158
|
-
if (gasStation) {
|
|
159
|
-
const gasFees = await gasStation();
|
|
160
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
161
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
165
|
-
if (isV5TT) {
|
|
166
|
-
const tx = await titleEscrowContract.transferBeneficiary(
|
|
167
|
-
newBeneficiaryAddress,
|
|
168
|
-
encryptedRemarks,
|
|
169
|
-
txOptions
|
|
170
|
-
);
|
|
171
|
-
return tx;
|
|
172
|
-
} else if (isV4TT) {
|
|
173
|
-
const tx = await titleEscrowContract.transferBeneficiary(
|
|
174
|
-
newBeneficiaryAddress,
|
|
175
|
-
txOptions
|
|
176
|
-
);
|
|
177
|
-
return tx;
|
|
178
|
-
}
|
|
179
|
-
}, "transferBeneficiary");
|
|
180
|
-
const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
181
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
182
|
-
const { titleEscrowVersion } = options;
|
|
183
|
-
let { titleEscrowAddress } = contractOptions;
|
|
184
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
185
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
186
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
187
|
-
if (!titleEscrowAddress) {
|
|
188
|
-
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
189
|
-
tokenRegistryAddress,
|
|
190
|
-
tokenId,
|
|
191
|
-
signer.provider,
|
|
192
|
-
{ titleEscrowVersion }
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
196
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
197
|
-
const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
|
|
198
|
-
let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
199
|
-
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
200
|
-
if (titleEscrowVersion === void 0) {
|
|
201
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
202
|
-
core.isTitleEscrowVersion({
|
|
203
|
-
titleEscrowAddress,
|
|
204
|
-
versionInterface: core.TitleEscrowInterface.V4,
|
|
205
|
-
provider: signer.provider
|
|
206
|
-
}),
|
|
207
|
-
core.isTitleEscrowVersion({
|
|
208
|
-
titleEscrowAddress,
|
|
209
|
-
versionInterface: core.TitleEscrowInterface.V5,
|
|
210
|
-
provider: signer.provider
|
|
211
|
-
})
|
|
212
|
-
]);
|
|
213
|
-
}
|
|
214
|
-
if (!isV4TT && !isV5TT) {
|
|
215
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
216
|
-
}
|
|
217
|
-
if (!isV5TT) {
|
|
218
|
-
titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
|
|
219
|
-
titleEscrowAddress,
|
|
220
|
-
signer
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
if (isV5TT) {
|
|
225
|
-
await titleEscrowContract.callStatic.transferOwners(
|
|
226
|
-
newBeneficiaryAddress,
|
|
227
|
-
newHolderAddress,
|
|
228
|
-
encryptedRemarks
|
|
229
|
-
);
|
|
230
|
-
} else if (isV4TT) {
|
|
231
|
-
await titleEscrowContract.callStatic.transferOwners(
|
|
232
|
-
newBeneficiaryAddress,
|
|
233
|
-
newHolderAddress
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
} catch (e) {
|
|
237
|
-
console.error("callStatic failed:", e);
|
|
238
|
-
throw new Error("Pre-check (callStatic) for transferOwners failed");
|
|
239
|
-
}
|
|
240
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
241
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
242
|
-
const gasStation = tradetrustUtils.SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
243
|
-
if (gasStation) {
|
|
244
|
-
const gasFees = await gasStation();
|
|
245
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
246
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
250
|
-
if (isV5TT) {
|
|
251
|
-
return await titleEscrowContract.transferOwners(
|
|
252
|
-
newBeneficiaryAddress,
|
|
253
|
-
newHolderAddress,
|
|
254
|
-
encryptedRemarks,
|
|
255
|
-
txOptions
|
|
256
|
-
);
|
|
257
|
-
} else if (isV4TT) {
|
|
258
|
-
return await titleEscrowContract.transferOwners(
|
|
259
|
-
newBeneficiaryAddress,
|
|
260
|
-
newHolderAddress,
|
|
261
|
-
txOptions
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
}, "transferOwners");
|
|
265
|
-
const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
266
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
267
|
-
const { titleEscrowVersion } = options;
|
|
268
|
-
let { titleEscrowAddress } = contractOptions;
|
|
269
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
270
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
271
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
272
|
-
if (!titleEscrowAddress) {
|
|
273
|
-
titleEscrowAddress = await core.getTitleEscrowAddress(
|
|
274
|
-
tokenRegistryAddress,
|
|
275
|
-
tokenId,
|
|
276
|
-
signer.provider,
|
|
277
|
-
{ titleEscrowVersion }
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
281
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
282
|
-
const { newBeneficiaryAddress, remarks } = params;
|
|
283
|
-
let titleEscrowContract = tokenRegistryV5.v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
284
|
-
const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
|
|
285
|
-
if (titleEscrowVersion === void 0) {
|
|
286
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
287
|
-
core.isTitleEscrowVersion({
|
|
288
|
-
titleEscrowAddress,
|
|
289
|
-
versionInterface: core.TitleEscrowInterface.V4,
|
|
290
|
-
provider: signer.provider
|
|
291
|
-
}),
|
|
292
|
-
core.isTitleEscrowVersion({
|
|
293
|
-
titleEscrowAddress,
|
|
294
|
-
versionInterface: core.TitleEscrowInterface.V5,
|
|
295
|
-
provider: signer.provider
|
|
296
|
-
})
|
|
297
|
-
]);
|
|
298
|
-
}
|
|
299
|
-
if (!isV5TT) {
|
|
300
|
-
titleEscrowContract = tokenRegistryV4.v4Contracts.TitleEscrow__factory.connect(
|
|
301
|
-
titleEscrowAddress,
|
|
302
|
-
signer
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
try {
|
|
306
|
-
if (isV5TT) {
|
|
307
|
-
await titleEscrowContract.callStatic.nominate(
|
|
308
|
-
newBeneficiaryAddress,
|
|
309
|
-
encryptedRemarks
|
|
310
|
-
);
|
|
311
|
-
} else if (isV4TT) {
|
|
312
|
-
await titleEscrowContract.callStatic.nominate(
|
|
313
|
-
newBeneficiaryAddress
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
} catch (e) {
|
|
317
|
-
console.error("callStatic failed:", e);
|
|
318
|
-
throw new Error("Pre-check (callStatic) for nominate failed");
|
|
319
|
-
}
|
|
320
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
321
|
-
chainId = chainId ?? await getChainIdSafe(signer);
|
|
322
|
-
const gasStation = tradetrustUtils.SUPPORTED_CHAINS[chainId]?.gasStation;
|
|
323
|
-
if (gasStation) {
|
|
324
|
-
const gasFees = await gasStation();
|
|
325
|
-
maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
|
|
326
|
-
maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
const txOptions = maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : void 0;
|
|
330
|
-
if (isV5TT) {
|
|
331
|
-
return await titleEscrowContract.nominate(
|
|
332
|
-
newBeneficiaryAddress,
|
|
333
|
-
encryptedRemarks,
|
|
334
|
-
txOptions
|
|
335
|
-
);
|
|
336
|
-
} else if (isV4TT) {
|
|
337
|
-
return await titleEscrowContract.nominate(
|
|
338
|
-
newBeneficiaryAddress,
|
|
339
|
-
txOptions
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
}, "nominate");
|
|
343
|
-
|
|
344
|
-
exports.nominate = nominate;
|
|
345
|
-
exports.transferBeneficiary = transferBeneficiary;
|
|
346
|
-
exports.transferHolder = transferHolder;
|
|
347
|
-
exports.transferOwners = transferOwners;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './transfer';
|
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import { SUPPORTED_CHAINS } from '@tradetrust-tt/tradetrust-utils';
|
|
2
|
-
import { getTitleEscrowAddress, encrypt, isTitleEscrowVersion, TitleEscrowInterface } from 'src/core';
|
|
3
|
-
import { v4Contracts } from 'src/token-registry-v4';
|
|
4
|
-
import { v5Contracts } from 'src/token-registry-v5';
|
|
5
|
-
import { isV6EthersProvider } from 'src/utils/ethers';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
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
|
-
const transferHolder = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
18
|
-
const { tokenRegistryAddress, tokenId } = contractOptions;
|
|
19
|
-
const { titleEscrowVersion } = options;
|
|
20
|
-
let { titleEscrowAddress } = contractOptions;
|
|
21
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
22
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
23
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
24
|
-
if (!titleEscrowAddress) {
|
|
25
|
-
titleEscrowAddress = await getTitleEscrowAddress(
|
|
26
|
-
tokenRegistryAddress,
|
|
27
|
-
tokenId,
|
|
28
|
-
signer.provider,
|
|
29
|
-
{ titleEscrowVersion }
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
33
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
34
|
-
const { holderAddress, remarks } = params;
|
|
35
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
36
|
-
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
37
|
-
if (titleEscrowVersion === void 0) {
|
|
38
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
39
|
-
isTitleEscrowVersion({
|
|
40
|
-
titleEscrowAddress,
|
|
41
|
-
versionInterface: TitleEscrowInterface.V4,
|
|
42
|
-
provider: signer.provider
|
|
43
|
-
}),
|
|
44
|
-
isTitleEscrowVersion({
|
|
45
|
-
titleEscrowAddress,
|
|
46
|
-
versionInterface: TitleEscrowInterface.V5,
|
|
47
|
-
provider: signer.provider
|
|
48
|
-
})
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
if (!isV4TT && !isV5TT) {
|
|
52
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
53
|
-
}
|
|
54
|
-
if (isV4TT) {
|
|
55
|
-
titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
|
|
56
|
-
titleEscrowAddress,
|
|
57
|
-
signer
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
if (isV5TT) {
|
|
62
|
-
await titleEscrowContract.callStatic.transferHolder(
|
|
63
|
-
holderAddress,
|
|
64
|
-
encryptedRemarks
|
|
65
|
-
);
|
|
66
|
-
} else if (isV4TT) {
|
|
67
|
-
await titleEscrowContract.callStatic.transferHolder(
|
|
68
|
-
holderAddress
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.error("callStatic failed:", e);
|
|
73
|
-
throw new Error("Pre-check (callStatic) for transferHolder failed");
|
|
74
|
-
}
|
|
75
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
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;
|
|
85
|
-
if (isV5TT) {
|
|
86
|
-
return await titleEscrowContract.transferHolder(
|
|
87
|
-
holderAddress,
|
|
88
|
-
encryptedRemarks,
|
|
89
|
-
txOptions
|
|
90
|
-
);
|
|
91
|
-
} else if (isV4TT) {
|
|
92
|
-
return await titleEscrowContract.transferHolder(holderAddress, txOptions);
|
|
93
|
-
}
|
|
94
|
-
}, "transferHolder");
|
|
95
|
-
const transferBeneficiary = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
96
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
97
|
-
const { titleEscrowVersion } = options;
|
|
98
|
-
let { titleEscrowAddress } = contractOptions;
|
|
99
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
100
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
101
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
102
|
-
if (!titleEscrowAddress) {
|
|
103
|
-
titleEscrowAddress = await getTitleEscrowAddress(
|
|
104
|
-
tokenRegistryAddress,
|
|
105
|
-
tokenId,
|
|
106
|
-
signer.provider,
|
|
107
|
-
{ titleEscrowVersion }
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
111
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
112
|
-
const { newBeneficiaryAddress, remarks } = params;
|
|
113
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
114
|
-
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
115
|
-
if (titleEscrowVersion === void 0) {
|
|
116
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
117
|
-
isTitleEscrowVersion({
|
|
118
|
-
titleEscrowAddress,
|
|
119
|
-
versionInterface: TitleEscrowInterface.V4,
|
|
120
|
-
provider: signer.provider
|
|
121
|
-
}),
|
|
122
|
-
isTitleEscrowVersion({
|
|
123
|
-
titleEscrowAddress,
|
|
124
|
-
versionInterface: TitleEscrowInterface.V5,
|
|
125
|
-
provider: signer.provider
|
|
126
|
-
})
|
|
127
|
-
]);
|
|
128
|
-
}
|
|
129
|
-
if (!isV4TT && !isV5TT) {
|
|
130
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
131
|
-
}
|
|
132
|
-
if (!isV5TT) {
|
|
133
|
-
titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
|
|
134
|
-
titleEscrowAddress,
|
|
135
|
-
signer
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
if (isV5TT) {
|
|
140
|
-
await titleEscrowContract.callStatic.transferBeneficiary(
|
|
141
|
-
newBeneficiaryAddress,
|
|
142
|
-
encryptedRemarks
|
|
143
|
-
);
|
|
144
|
-
} else if (isV4TT) {
|
|
145
|
-
await titleEscrowContract.callStatic.transferBeneficiary(
|
|
146
|
-
newBeneficiaryAddress
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
} catch (e) {
|
|
150
|
-
console.error("callStatic failed:", e);
|
|
151
|
-
throw new Error("Pre-check (callStatic) for transferBeneficiary failed");
|
|
152
|
-
}
|
|
153
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
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;
|
|
163
|
-
if (isV5TT) {
|
|
164
|
-
const tx = await titleEscrowContract.transferBeneficiary(
|
|
165
|
-
newBeneficiaryAddress,
|
|
166
|
-
encryptedRemarks,
|
|
167
|
-
txOptions
|
|
168
|
-
);
|
|
169
|
-
return tx;
|
|
170
|
-
} else if (isV4TT) {
|
|
171
|
-
const tx = await titleEscrowContract.transferBeneficiary(
|
|
172
|
-
newBeneficiaryAddress,
|
|
173
|
-
txOptions
|
|
174
|
-
);
|
|
175
|
-
return tx;
|
|
176
|
-
}
|
|
177
|
-
}, "transferBeneficiary");
|
|
178
|
-
const transferOwners = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
179
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
180
|
-
const { titleEscrowVersion } = options;
|
|
181
|
-
let { titleEscrowAddress } = contractOptions;
|
|
182
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
183
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
184
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
185
|
-
if (!titleEscrowAddress) {
|
|
186
|
-
titleEscrowAddress = await getTitleEscrowAddress(
|
|
187
|
-
tokenRegistryAddress,
|
|
188
|
-
tokenId,
|
|
189
|
-
signer.provider,
|
|
190
|
-
{ titleEscrowVersion }
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
194
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
195
|
-
const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
|
|
196
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
197
|
-
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
198
|
-
if (titleEscrowVersion === void 0) {
|
|
199
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
200
|
-
isTitleEscrowVersion({
|
|
201
|
-
titleEscrowAddress,
|
|
202
|
-
versionInterface: TitleEscrowInterface.V4,
|
|
203
|
-
provider: signer.provider
|
|
204
|
-
}),
|
|
205
|
-
isTitleEscrowVersion({
|
|
206
|
-
titleEscrowAddress,
|
|
207
|
-
versionInterface: TitleEscrowInterface.V5,
|
|
208
|
-
provider: signer.provider
|
|
209
|
-
})
|
|
210
|
-
]);
|
|
211
|
-
}
|
|
212
|
-
if (!isV4TT && !isV5TT) {
|
|
213
|
-
throw new Error("Only Token Registry V4/V5 is supported");
|
|
214
|
-
}
|
|
215
|
-
if (!isV5TT) {
|
|
216
|
-
titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
|
|
217
|
-
titleEscrowAddress,
|
|
218
|
-
signer
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
try {
|
|
222
|
-
if (isV5TT) {
|
|
223
|
-
await titleEscrowContract.callStatic.transferOwners(
|
|
224
|
-
newBeneficiaryAddress,
|
|
225
|
-
newHolderAddress,
|
|
226
|
-
encryptedRemarks
|
|
227
|
-
);
|
|
228
|
-
} else if (isV4TT) {
|
|
229
|
-
await titleEscrowContract.callStatic.transferOwners(
|
|
230
|
-
newBeneficiaryAddress,
|
|
231
|
-
newHolderAddress
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
} catch (e) {
|
|
235
|
-
console.error("callStatic failed:", e);
|
|
236
|
-
throw new Error("Pre-check (callStatic) for transferOwners failed");
|
|
237
|
-
}
|
|
238
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
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;
|
|
248
|
-
if (isV5TT) {
|
|
249
|
-
return await titleEscrowContract.transferOwners(
|
|
250
|
-
newBeneficiaryAddress,
|
|
251
|
-
newHolderAddress,
|
|
252
|
-
encryptedRemarks,
|
|
253
|
-
txOptions
|
|
254
|
-
);
|
|
255
|
-
} else if (isV4TT) {
|
|
256
|
-
return await titleEscrowContract.transferOwners(
|
|
257
|
-
newBeneficiaryAddress,
|
|
258
|
-
newHolderAddress,
|
|
259
|
-
txOptions
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}, "transferOwners");
|
|
263
|
-
const nominate = /* @__PURE__ */ __name(async (contractOptions, signer, params, options) => {
|
|
264
|
-
const { tokenId, tokenRegistryAddress } = contractOptions;
|
|
265
|
-
const { titleEscrowVersion } = options;
|
|
266
|
-
let { titleEscrowAddress } = contractOptions;
|
|
267
|
-
let { chainId, maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
268
|
-
let isV5TT = titleEscrowVersion === "v5";
|
|
269
|
-
let isV4TT = titleEscrowVersion === "v4";
|
|
270
|
-
if (!titleEscrowAddress) {
|
|
271
|
-
titleEscrowAddress = await getTitleEscrowAddress(
|
|
272
|
-
tokenRegistryAddress,
|
|
273
|
-
tokenId,
|
|
274
|
-
signer.provider,
|
|
275
|
-
{ titleEscrowVersion }
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
if (!titleEscrowAddress) throw new Error("Token registry address is required");
|
|
279
|
-
if (!signer.provider) throw new Error("Provider is required");
|
|
280
|
-
const { newBeneficiaryAddress, remarks } = params;
|
|
281
|
-
let titleEscrowContract = v5Contracts.TitleEscrow__factory.connect(titleEscrowAddress, signer);
|
|
282
|
-
const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
|
|
283
|
-
if (titleEscrowVersion === void 0) {
|
|
284
|
-
[isV4TT, isV5TT] = await Promise.all([
|
|
285
|
-
isTitleEscrowVersion({
|
|
286
|
-
titleEscrowAddress,
|
|
287
|
-
versionInterface: TitleEscrowInterface.V4,
|
|
288
|
-
provider: signer.provider
|
|
289
|
-
}),
|
|
290
|
-
isTitleEscrowVersion({
|
|
291
|
-
titleEscrowAddress,
|
|
292
|
-
versionInterface: TitleEscrowInterface.V5,
|
|
293
|
-
provider: signer.provider
|
|
294
|
-
})
|
|
295
|
-
]);
|
|
296
|
-
}
|
|
297
|
-
if (!isV5TT) {
|
|
298
|
-
titleEscrowContract = v4Contracts.TitleEscrow__factory.connect(
|
|
299
|
-
titleEscrowAddress,
|
|
300
|
-
signer
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
try {
|
|
304
|
-
if (isV5TT) {
|
|
305
|
-
await titleEscrowContract.callStatic.nominate(
|
|
306
|
-
newBeneficiaryAddress,
|
|
307
|
-
encryptedRemarks
|
|
308
|
-
);
|
|
309
|
-
} else if (isV4TT) {
|
|
310
|
-
await titleEscrowContract.callStatic.nominate(
|
|
311
|
-
newBeneficiaryAddress
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
} catch (e) {
|
|
315
|
-
console.error("callStatic failed:", e);
|
|
316
|
-
throw new Error("Pre-check (callStatic) for nominate failed");
|
|
317
|
-
}
|
|
318
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
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;
|
|
328
|
-
if (isV5TT) {
|
|
329
|
-
return await titleEscrowContract.nominate(
|
|
330
|
-
newBeneficiaryAddress,
|
|
331
|
-
encryptedRemarks,
|
|
332
|
-
txOptions
|
|
333
|
-
);
|
|
334
|
-
} else if (isV4TT) {
|
|
335
|
-
return await titleEscrowContract.nominate(
|
|
336
|
-
newBeneficiaryAddress,
|
|
337
|
-
txOptions
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
}, "nominate");
|
|
341
|
-
|
|
342
|
-
export { nominate, transferBeneficiary, transferHolder, transferOwners };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { CHAIN_ID } from '@tradetrust-tt/tradetrust-utils';
|
|
2
|
-
import { Signer as Signer$1, BigNumberish } from 'ethersV6';
|
|
3
|
-
import { Signer, BigNumber } from 'ethers';
|
|
4
|
-
|
|
5
|
-
interface TransferHolderParams {
|
|
6
|
-
holderAddress: string;
|
|
7
|
-
remarks?: string;
|
|
8
|
-
}
|
|
9
|
-
interface TransferBeneficiaryParams {
|
|
10
|
-
newBeneficiaryAddress: string;
|
|
11
|
-
remarks?: string;
|
|
12
|
-
}
|
|
13
|
-
interface NominateParams {
|
|
14
|
-
newBeneficiaryAddress: string;
|
|
15
|
-
remarks?: string;
|
|
16
|
-
}
|
|
17
|
-
interface TransferOwnersParams {
|
|
18
|
-
newHolderAddress: string;
|
|
19
|
-
newBeneficiaryAddress: string;
|
|
20
|
-
remarks?: string;
|
|
21
|
-
}
|
|
22
|
-
interface TransferOptions {
|
|
23
|
-
chainId?: CHAIN_ID;
|
|
24
|
-
titleEscrowVersion?: 'v4' | 'v5';
|
|
25
|
-
maxFeePerGas?: BigNumberish | string | number | BigNumber;
|
|
26
|
-
maxPriorityFeePerGas?: BigNumberish | string | number | BigNumber;
|
|
27
|
-
id?: string;
|
|
28
|
-
}
|
|
29
|
-
type ContractOptions = {
|
|
30
|
-
titleEscrowAddress: string;
|
|
31
|
-
tokenId?: string | number;
|
|
32
|
-
tokenRegistryAddress?: string;
|
|
33
|
-
} | {
|
|
34
|
-
titleEscrowAddress?: undefined;
|
|
35
|
-
tokenId: string | number;
|
|
36
|
-
tokenRegistryAddress: string;
|
|
37
|
-
};
|
|
38
|
-
declare const transferHolder: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferHolderParams, options: TransferOptions) => Promise<ContractTransactionResponse>;
|
|
39
|
-
declare const transferBeneficiary: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferBeneficiaryParams, options: TransferOptions) => Promise<any>;
|
|
40
|
-
declare const transferOwners: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferOwnersParams, options: TransferOptions) => Promise<any>;
|
|
41
|
-
declare const nominate: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: NominateParams, options: TransferOptions) => Promise<any>;
|
|
42
|
-
|
|
43
|
-
export { nominate, transferBeneficiary, transferHolder, transferOwners };
|