@trustvc/trustvc 2.8.0 → 2.9.1
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/{document-store/deploy.js → deploy/document-store.js} +18 -18
- package/dist/cjs/deploy/token-registry.js +97 -0
- package/dist/cjs/document-store/document-store-roles.js +4 -10
- package/dist/cjs/document-store/index.js +7 -2
- package/dist/cjs/document-store/transferOwnership.js +55 -7
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/token-registry-functions/index.js +7 -0
- package/dist/cjs/token-registry-functions/ownerOf.js +9 -7
- package/dist/cjs/token-registry-functions/utils.js +39 -0
- package/dist/cjs/token-registry-v5/index.js +4 -4
- package/dist/cjs/utils/ethers/index.js +6 -2
- package/dist/esm/{document-store/deploy.js → deploy/document-store.js} +19 -19
- package/dist/esm/deploy/token-registry.js +95 -0
- package/dist/esm/document-store/document-store-roles.js +4 -10
- package/dist/esm/document-store/index.js +2 -1
- package/dist/esm/document-store/transferOwnership.js +55 -7
- package/dist/esm/index.js +1 -1
- package/dist/esm/token-registry-functions/index.js +1 -0
- package/dist/esm/token-registry-functions/ownerOf.js +9 -7
- package/dist/esm/token-registry-functions/utils.js +38 -2
- package/dist/esm/token-registry-v5/index.js +1 -1
- package/dist/esm/utils/ethers/index.js +7 -4
- package/dist/types/deploy/document-store.d.ts +77 -0
- package/dist/types/deploy/token-registry.d.ts +82 -0
- package/dist/types/document-store/grant-role.d.ts +2 -2
- package/dist/types/document-store/index.d.ts +2 -1
- package/dist/types/document-store/transferOwnership.d.ts +5 -5
- package/dist/types/index.d.ts +16 -13
- package/dist/types/token-registry-functions/index.d.ts +1 -0
- package/dist/types/token-registry-functions/ownerOf.d.ts +1 -1
- package/dist/types/token-registry-functions/types.d.ts +26 -1
- package/dist/types/token-registry-functions/utils.d.ts +7 -4
- package/dist/types/token-registry-v5/index.d.ts +1 -2
- package/dist/types/utils/ethers/index.d.ts +6 -5
- package/package.json +1 -1
- package/dist/types/document-store/deploy.d.ts +0 -29
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var documentStore = require('@trustvc/document-store');
|
|
4
|
-
var ethersV6 = require('ethersV6');
|
|
5
|
-
var ethers$1 = require('ethers');
|
|
6
4
|
var ethers = require('../utils/ethers');
|
|
7
5
|
var utils = require('../token-registry-functions/utils');
|
|
8
6
|
|
|
@@ -16,27 +14,29 @@ const deployDocumentStore = /* @__PURE__ */ __name(async (storeName, owner, sign
|
|
|
16
14
|
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
17
15
|
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
18
16
|
const DocumentStoreFactory = options.isTransferable ? documentStore.TransferableDocumentStore__factory : documentStore.DocumentStore__factory;
|
|
17
|
+
const ContractFactory = ethers.getEthersContractFactoryFromProvider(signer.provider);
|
|
18
|
+
const contractFactory = new ContractFactory(
|
|
19
|
+
DocumentStoreFactory.abi,
|
|
20
|
+
DocumentStoreFactory.bytecode,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
signer
|
|
23
|
+
// Type assertion needed for v5/v6 compatibility
|
|
24
|
+
);
|
|
19
25
|
try {
|
|
20
26
|
if (isV6) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
signer
|
|
27
|
+
const contract = await contractFactory.deploy(
|
|
28
|
+
storeName,
|
|
29
|
+
owner,
|
|
30
|
+
txOptions
|
|
26
31
|
);
|
|
27
|
-
|
|
28
|
-
const receipt = await contract.deploymentTransaction()?.wait();
|
|
29
|
-
return receipt;
|
|
32
|
+
return await contract.deploymentTransaction().wait();
|
|
30
33
|
} else {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
signer
|
|
34
|
+
const contract = await contractFactory.deploy(
|
|
35
|
+
storeName,
|
|
36
|
+
owner,
|
|
37
|
+
txOptions
|
|
36
38
|
);
|
|
37
|
-
|
|
38
|
-
const receipt = await contract.deployTransaction.wait();
|
|
39
|
-
return receipt;
|
|
39
|
+
return await contract.deployTransaction.wait();
|
|
40
40
|
}
|
|
41
41
|
} catch (e) {
|
|
42
42
|
console.error("Deployment failed:", e);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contracts = require('@tradetrust-tt/token-registry/contracts');
|
|
4
|
+
var utils = require('../token-registry-functions/utils');
|
|
5
|
+
var utils$1 = require('../token-registry-v5/utils');
|
|
6
|
+
var ethers = require('../utils/ethers');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const deployTokenRegistry = /* @__PURE__ */ __name(async (registryName, registrySymbol, signer, options = {}) => {
|
|
11
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
12
|
+
let { chainId, standalone, factoryAddress, tokenRegistryImplAddress, deployerContractAddress } = options;
|
|
13
|
+
const deployerAddress = await signer.getAddress();
|
|
14
|
+
if (!chainId) {
|
|
15
|
+
chainId = await utils.getChainIdSafe(signer);
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
TitleEscrowFactory: defaultTitleEscrowFactoryAddress,
|
|
19
|
+
TokenImplementation: defaultTokenImplementationContractAddress,
|
|
20
|
+
Deployer: defaultDeployerContractAddress
|
|
21
|
+
} = utils.getDefaultContractAddress(chainId);
|
|
22
|
+
if (!utils.isValidAddress(deployerContractAddress)) {
|
|
23
|
+
deployerContractAddress = defaultDeployerContractAddress;
|
|
24
|
+
}
|
|
25
|
+
if (!utils.isValidAddress(tokenRegistryImplAddress)) {
|
|
26
|
+
tokenRegistryImplAddress = defaultTokenImplementationContractAddress;
|
|
27
|
+
}
|
|
28
|
+
if (standalone !== false && (!deployerContractAddress || !tokenRegistryImplAddress)) {
|
|
29
|
+
console.error(
|
|
30
|
+
`Network ${chainId} does not support "quick-start" mode. Defaulting to standalone mode.`
|
|
31
|
+
);
|
|
32
|
+
standalone = true;
|
|
33
|
+
}
|
|
34
|
+
if (!standalone) {
|
|
35
|
+
if (!deployerContractAddress || !tokenRegistryImplAddress) {
|
|
36
|
+
throw new Error(`Network ${chainId} currently is not supported. Use --standalone instead.`);
|
|
37
|
+
}
|
|
38
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
39
|
+
const deployerContract = new Contract(
|
|
40
|
+
deployerContractAddress,
|
|
41
|
+
contracts.TDocDeployer__factory.abi,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
signer
|
|
44
|
+
// Type assertion needed for v5/v6 compatibility
|
|
45
|
+
);
|
|
46
|
+
const initParam = utils$1.encodeInitParams({
|
|
47
|
+
name: registryName,
|
|
48
|
+
symbol: registrySymbol,
|
|
49
|
+
deployer: deployerAddress
|
|
50
|
+
});
|
|
51
|
+
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
52
|
+
return await deployerContract.deploy(tokenRegistryImplAddress, initParam, txOptions);
|
|
53
|
+
} else {
|
|
54
|
+
if (!factoryAddress || !utils.isValidAddress(factoryAddress)) {
|
|
55
|
+
factoryAddress = defaultTitleEscrowFactoryAddress;
|
|
56
|
+
if (!factoryAddress) {
|
|
57
|
+
throw new Error(`Network ${chainId} currently is not supported. Supply a factory address.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const supportedTitleEscrowFactory = await utils.isSupportedTitleEscrowFactory(
|
|
61
|
+
factoryAddress,
|
|
62
|
+
signer.provider
|
|
63
|
+
);
|
|
64
|
+
if (!supportedTitleEscrowFactory) {
|
|
65
|
+
throw new Error(`Title Escrow Factory ${factoryAddress} is not supported.`);
|
|
66
|
+
}
|
|
67
|
+
const Contract = ethers.getEthersContractFactoryFromProvider(signer.provider);
|
|
68
|
+
const tokenFactory = new Contract(
|
|
69
|
+
contracts.TradeTrustToken__factory.abi,
|
|
70
|
+
contracts.TradeTrustToken__factory.bytecode,
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
signer
|
|
73
|
+
// Type assertion needed for v5/v6 compatibility
|
|
74
|
+
);
|
|
75
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
76
|
+
const txOptions = await utils.getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
77
|
+
if (isV6) {
|
|
78
|
+
const contract = await tokenFactory.deploy(
|
|
79
|
+
registryName,
|
|
80
|
+
registrySymbol,
|
|
81
|
+
factoryAddress,
|
|
82
|
+
txOptions
|
|
83
|
+
);
|
|
84
|
+
return await contract.deploymentTransaction().wait();
|
|
85
|
+
} else {
|
|
86
|
+
const contract = await tokenFactory.deploy(
|
|
87
|
+
registryName,
|
|
88
|
+
registrySymbol,
|
|
89
|
+
factoryAddress,
|
|
90
|
+
txOptions
|
|
91
|
+
);
|
|
92
|
+
return await contract.deployTransaction.wait();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, "deployTokenRegistry");
|
|
96
|
+
|
|
97
|
+
exports.deployTokenRegistry = deployTokenRegistry;
|
|
@@ -21,18 +21,12 @@ const getRoleString = /* @__PURE__ */ __name(async (documentStoreAddress, role,
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
provider
|
|
23
23
|
);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return await documentStore.DEFAULT_ADMIN_ROLE();
|
|
27
|
-
case "issuer":
|
|
28
|
-
return await documentStore.ISSUER_ROLE();
|
|
29
|
-
case "revoker":
|
|
30
|
-
return await documentStore.REVOKER_ROLE();
|
|
31
|
-
default:
|
|
32
|
-
throw new Error("Invalid role");
|
|
24
|
+
if (typeof documentStore[role] !== "function") {
|
|
25
|
+
throw new Error(`Invalid role: ${role}`);
|
|
33
26
|
}
|
|
27
|
+
return await documentStore[role]();
|
|
34
28
|
}, "getRoleString");
|
|
35
|
-
const rolesList = ["
|
|
29
|
+
const rolesList = ["DEFAULT_ADMIN_ROLE", "ISSUER_ROLE", "REVOKER_ROLE"];
|
|
36
30
|
|
|
37
31
|
exports.getRoleString = getRoleString;
|
|
38
32
|
exports.rolesList = rolesList;
|
|
@@ -5,7 +5,8 @@ var revoke = require('./revoke');
|
|
|
5
5
|
var revokeRole = require('./revoke-role');
|
|
6
6
|
var grantRole = require('./grant-role');
|
|
7
7
|
var transferOwnership = require('./transferOwnership');
|
|
8
|
-
var
|
|
8
|
+
var documentStore$1 = require('../deploy/document-store');
|
|
9
|
+
var documentStoreRoles = require('./document-store-roles');
|
|
9
10
|
var supportInterfaceIds = require('./supportInterfaceIds');
|
|
10
11
|
var documentStore = require('@trustvc/document-store');
|
|
11
12
|
|
|
@@ -33,7 +34,11 @@ Object.defineProperty(exports, "documentStoreTransferOwnership", {
|
|
|
33
34
|
});
|
|
34
35
|
Object.defineProperty(exports, "deployDocumentStore", {
|
|
35
36
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
37
|
+
get: function () { return documentStore$1.deployDocumentStore; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "getRoleString", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return documentStoreRoles.getRoleString; }
|
|
37
42
|
});
|
|
38
43
|
Object.defineProperty(exports, "supportInterfaceIds", {
|
|
39
44
|
enumerable: true,
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
var revokeRole = require('./revoke-role');
|
|
4
4
|
var grantRole = require('./grant-role');
|
|
5
5
|
var documentStoreRoles = require('./document-store-roles');
|
|
6
|
+
var core = require('../core');
|
|
7
|
+
var supportInterfaceIds = require('./supportInterfaceIds');
|
|
8
|
+
var ttDocumentStoreAbi = require('./tt-document-store-abi');
|
|
9
|
+
var ethers = require('../utils/ethers');
|
|
10
|
+
var documentStore = require('@trustvc/document-store');
|
|
6
11
|
|
|
7
12
|
var __defProp = Object.defineProperty;
|
|
8
13
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -11,29 +16,72 @@ const documentStoreTransferOwnership = /* @__PURE__ */ __name(async (documentSto
|
|
|
11
16
|
if (!signer.provider) throw new Error("Provider is required");
|
|
12
17
|
if (!account) throw new Error("Account is required");
|
|
13
18
|
const ownerAddress = await signer.getAddress();
|
|
14
|
-
const roleString = await documentStoreRoles.getRoleString(documentStoreAddress, "
|
|
19
|
+
const roleString = await documentStoreRoles.getRoleString(documentStoreAddress, "DEFAULT_ADMIN_ROLE", {
|
|
15
20
|
provider: signer.provider
|
|
16
21
|
});
|
|
17
|
-
const
|
|
22
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
23
|
+
const isDocumentStore = await core.checkSupportsInterface(
|
|
24
|
+
documentStoreAddress,
|
|
25
|
+
supportInterfaceIds.supportInterfaceIds.IDocumentStore,
|
|
26
|
+
signer.provider
|
|
27
|
+
);
|
|
28
|
+
const isTransferableDocumentStore = await core.checkSupportsInterface(
|
|
29
|
+
documentStoreAddress,
|
|
30
|
+
supportInterfaceIds.supportInterfaceIds.ITransferableDocumentStore,
|
|
31
|
+
signer.provider
|
|
32
|
+
);
|
|
33
|
+
let documentStoreAbi;
|
|
34
|
+
if (isDocumentStore || isTransferableDocumentStore) {
|
|
35
|
+
const DocumentStoreFactory = isTransferableDocumentStore ? documentStore.TransferableDocumentStore__factory : documentStore.DocumentStore__factory;
|
|
36
|
+
documentStoreAbi = DocumentStoreFactory.abi;
|
|
37
|
+
} else {
|
|
38
|
+
documentStoreAbi = ttDocumentStoreAbi.TT_DOCUMENT_STORE_ABI;
|
|
39
|
+
}
|
|
40
|
+
const documentStoreContract = new Contract(
|
|
41
|
+
documentStoreAddress,
|
|
42
|
+
documentStoreAbi,
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
signer
|
|
45
|
+
);
|
|
46
|
+
const isV6 = ethers.isV6EthersProvider(signer.provider);
|
|
47
|
+
try {
|
|
48
|
+
if (isV6) {
|
|
49
|
+
await documentStoreContract.grantRole.staticCall(roleString, account);
|
|
50
|
+
} else {
|
|
51
|
+
await documentStoreContract.callStatic.grantRole(roleString, account);
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("callStatic failed:", e);
|
|
55
|
+
throw new Error("Pre-check (callStatic) for grant-role failed");
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
if (isV6) {
|
|
59
|
+
await documentStoreContract.revokeRole.staticCall(roleString, ownerAddress);
|
|
60
|
+
} else {
|
|
61
|
+
await documentStoreContract.callStatic.revokeRole(roleString, ownerAddress);
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error("callStatic failed:", e);
|
|
65
|
+
throw new Error("Pre-check (callStatic) for revoke-role failed");
|
|
66
|
+
}
|
|
67
|
+
const grantTransaction = await grantRole.documentStoreGrantRole(
|
|
18
68
|
documentStoreAddress,
|
|
19
69
|
roleString,
|
|
20
70
|
account,
|
|
21
71
|
signer,
|
|
22
72
|
options
|
|
23
73
|
);
|
|
24
|
-
|
|
25
|
-
if (!grantTransactionResult) {
|
|
74
|
+
if (!grantTransaction) {
|
|
26
75
|
throw new Error("Grant transaction failed, not proceeding with revoke transaction");
|
|
27
76
|
}
|
|
28
|
-
const revokeTransaction = revokeRole.documentStoreRevokeRole(
|
|
77
|
+
const revokeTransaction = await revokeRole.documentStoreRevokeRole(
|
|
29
78
|
documentStoreAddress,
|
|
30
79
|
roleString,
|
|
31
80
|
ownerAddress,
|
|
32
81
|
signer,
|
|
33
82
|
options
|
|
34
83
|
);
|
|
35
|
-
|
|
36
|
-
if (!revokeTransactionResult) {
|
|
84
|
+
if (!revokeTransaction) {
|
|
37
85
|
throw new Error("Revoke transaction failed");
|
|
38
86
|
}
|
|
39
87
|
return { grantTransaction, revokeTransaction };
|
package/dist/cjs/index.js
CHANGED
|
@@ -110,6 +110,14 @@ Object.defineProperty(exports, "documentStoreRevokeRole", {
|
|
|
110
110
|
enumerable: true,
|
|
111
111
|
get: function () { return documentStore.documentStoreRevokeRole; }
|
|
112
112
|
});
|
|
113
|
+
Object.defineProperty(exports, "documentStoreTransferOwnership", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () { return documentStore.documentStoreTransferOwnership; }
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "getRoleString", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () { return documentStore.getRoleString; }
|
|
120
|
+
});
|
|
113
121
|
Object.keys(tokenRegistryFunctions).forEach(function (k) {
|
|
114
122
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
115
123
|
enumerable: true,
|
|
@@ -5,6 +5,7 @@ var rejectTransfers = require('./rejectTransfers');
|
|
|
5
5
|
var returnToken = require('./returnToken');
|
|
6
6
|
var mint = require('./mint');
|
|
7
7
|
var ownerOf = require('./ownerOf');
|
|
8
|
+
var tokenRegistry = require('../deploy/token-registry');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -38,3 +39,9 @@ Object.keys(ownerOf).forEach(function (k) {
|
|
|
38
39
|
get: function () { return ownerOf[k]; }
|
|
39
40
|
});
|
|
40
41
|
});
|
|
42
|
+
Object.keys(tokenRegistry).forEach(function (k) {
|
|
43
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return tokenRegistry[k]; }
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var core = require('../core');
|
|
4
4
|
var tokenRegistryV5 = require('../token-registry-v5');
|
|
5
5
|
var tokenRegistryV4 = require('../token-registry-v4');
|
|
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 });
|
|
@@ -23,23 +24,24 @@ const ownerOf = /* @__PURE__ */ __name(async (contractOptions, signer, params, o
|
|
|
23
24
|
if (!isV4TT && !isV5TT) {
|
|
24
25
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
25
26
|
}
|
|
27
|
+
const Contract = ethers.getEthersContractFromProvider(signer.provider);
|
|
26
28
|
let tradeTrustTokenContract;
|
|
27
29
|
if (isV5TT) {
|
|
28
|
-
tradeTrustTokenContract =
|
|
30
|
+
tradeTrustTokenContract = new Contract(
|
|
29
31
|
tokenRegistryAddress,
|
|
32
|
+
tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
34
|
signer
|
|
31
35
|
);
|
|
32
36
|
} else if (isV4TT) {
|
|
33
|
-
tradeTrustTokenContract =
|
|
37
|
+
tradeTrustTokenContract = new Contract(
|
|
34
38
|
tokenRegistryAddress,
|
|
39
|
+
tokenRegistryV4.v4Contracts.TradeTrustToken__factory.abi,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
41
|
signer
|
|
36
42
|
);
|
|
37
43
|
}
|
|
38
|
-
|
|
39
|
-
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
40
|
-
} else if (isV4TT) {
|
|
41
|
-
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
42
|
-
}
|
|
44
|
+
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
43
45
|
}, "ownerOf");
|
|
44
46
|
|
|
45
47
|
exports.ownerOf = ownerOf;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var ethers = require('../utils/ethers');
|
|
4
4
|
var utils = require('../utils');
|
|
5
|
+
var ethersV6 = require('ethersV6');
|
|
6
|
+
var tokenRegistryV5 = require('../token-registry-v5');
|
|
5
7
|
|
|
6
8
|
var __defProp = Object.defineProperty;
|
|
7
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -31,7 +33,44 @@ const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
|
31
33
|
}
|
|
32
34
|
return await signer.getAddress();
|
|
33
35
|
}, "getSignerAddressSafe");
|
|
36
|
+
const { contractInterfaceId: CONTRACT_INTERFACE_ID, contractAddress: CONTRACT_ADDRESS } = tokenRegistryV5.constants;
|
|
37
|
+
const getDefaultContractAddress = /* @__PURE__ */ __name((chainId) => {
|
|
38
|
+
const { TitleEscrowFactory, TokenImplementation, Deployer } = CONTRACT_ADDRESS;
|
|
39
|
+
const chainTitleEscrowFactory = TitleEscrowFactory[chainId];
|
|
40
|
+
const chainTokenImplementation = TokenImplementation[chainId];
|
|
41
|
+
const chainDeployer = Deployer[chainId];
|
|
42
|
+
return {
|
|
43
|
+
TitleEscrowFactory: chainTitleEscrowFactory,
|
|
44
|
+
TokenImplementation: chainTokenImplementation,
|
|
45
|
+
Deployer: chainDeployer
|
|
46
|
+
};
|
|
47
|
+
}, "getDefaultContractAddress");
|
|
48
|
+
const isValidAddress = /* @__PURE__ */ __name((address) => {
|
|
49
|
+
if (!address) return false;
|
|
50
|
+
return ethersV6.isAddress(address);
|
|
51
|
+
}, "isValidAddress");
|
|
52
|
+
const isSupportedTitleEscrowFactory = /* @__PURE__ */ __name(async (factoryAddress, provider) => {
|
|
53
|
+
const Contract = ethers.getEthersContractFromProvider(provider);
|
|
54
|
+
const titleEscrowFactoryContract = new Contract(
|
|
55
|
+
factoryAddress,
|
|
56
|
+
["function implementation() view returns (address)"],
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
provider
|
|
59
|
+
);
|
|
60
|
+
const implAddr = await titleEscrowFactoryContract.implementation();
|
|
61
|
+
const implContract = new Contract(
|
|
62
|
+
implAddr,
|
|
63
|
+
["function supportsInterface(bytes4 interfaceId) view returns (bool)"],
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
provider
|
|
66
|
+
);
|
|
67
|
+
const { TitleEscrow: titleEscrowInterfaceId } = CONTRACT_INTERFACE_ID;
|
|
68
|
+
return implContract.supportsInterface(titleEscrowInterfaceId);
|
|
69
|
+
}, "isSupportedTitleEscrowFactory");
|
|
34
70
|
|
|
35
71
|
exports.getChainIdSafe = getChainIdSafe;
|
|
72
|
+
exports.getDefaultContractAddress = getDefaultContractAddress;
|
|
36
73
|
exports.getSignerAddressSafe = getSignerAddressSafe;
|
|
37
74
|
exports.getTxOptions = getTxOptions;
|
|
75
|
+
exports.isSupportedTitleEscrowFactory = isSupportedTitleEscrowFactory;
|
|
76
|
+
exports.isValidAddress = isValidAddress;
|
|
@@ -5,7 +5,7 @@ var roleHash = require('./roleHash');
|
|
|
5
5
|
var supportInterfaceIds = require('./supportInterfaceIds');
|
|
6
6
|
var contracts = require('./contracts');
|
|
7
7
|
var utils = require('./utils');
|
|
8
|
-
var
|
|
8
|
+
var tokenRegistryV5 = require('@tradetrust-tt/token-registry-v5');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
11
11
|
if (e && e.__esModule) return e;
|
|
@@ -56,13 +56,13 @@ Object.defineProperty(exports, "v5GetEventFromReceipt", {
|
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "constants", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return tokenRegistryV5.constants; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "utils", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return tokenRegistryV5.utils; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, "v5Utils", {
|
|
66
66
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
67
|
+
get: function () { return tokenRegistryV5.utils; }
|
|
68
68
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var ethers = require('ethers');
|
|
4
3
|
var ethersV6 = require('ethersV6');
|
|
4
|
+
var ethers = require('ethers');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -16,8 +16,12 @@ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
|
|
|
16
16
|
throw new Error("Unknown provider type");
|
|
17
17
|
}, "isV6EthersProvider");
|
|
18
18
|
const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
19
|
-
return isV6EthersProvider(provider) ? ethersV6.
|
|
19
|
+
return isV6EthersProvider(provider) ? ethersV6.Contract : ethers.Contract;
|
|
20
20
|
}, "getEthersContractFromProvider");
|
|
21
|
+
const getEthersContractFactoryFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
22
|
+
return isV6EthersProvider(provider) ? ethersV6.ContractFactory : ethers.ContractFactory;
|
|
23
|
+
}, "getEthersContractFactoryFromProvider");
|
|
21
24
|
|
|
25
|
+
exports.getEthersContractFactoryFromProvider = getEthersContractFactoryFromProvider;
|
|
22
26
|
exports.getEthersContractFromProvider = getEthersContractFromProvider;
|
|
23
27
|
exports.isV6EthersProvider = isV6EthersProvider;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
|
|
2
|
-
import {
|
|
3
|
-
import { ContractFactory as ContractFactory$1 } from 'ethers';
|
|
4
|
-
import { isV6EthersProvider } from '../utils/ethers';
|
|
2
|
+
import { isV6EthersProvider, getEthersContractFactoryFromProvider } from '../utils/ethers';
|
|
5
3
|
import { getTxOptions } from '../token-registry-functions/utils';
|
|
6
4
|
|
|
7
5
|
var __defProp = Object.defineProperty;
|
|
@@ -14,27 +12,29 @@ const deployDocumentStore = /* @__PURE__ */ __name(async (storeName, owner, sign
|
|
|
14
12
|
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
15
13
|
const isV6 = isV6EthersProvider(signer.provider);
|
|
16
14
|
const DocumentStoreFactory = options.isTransferable ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
15
|
+
const ContractFactory = getEthersContractFactoryFromProvider(signer.provider);
|
|
16
|
+
const contractFactory = new ContractFactory(
|
|
17
|
+
DocumentStoreFactory.abi,
|
|
18
|
+
DocumentStoreFactory.bytecode,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
signer
|
|
21
|
+
// Type assertion needed for v5/v6 compatibility
|
|
22
|
+
);
|
|
17
23
|
try {
|
|
18
24
|
if (isV6) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
signer
|
|
25
|
+
const contract = await contractFactory.deploy(
|
|
26
|
+
storeName,
|
|
27
|
+
owner,
|
|
28
|
+
txOptions
|
|
24
29
|
);
|
|
25
|
-
|
|
26
|
-
const receipt = await contract.deploymentTransaction()?.wait();
|
|
27
|
-
return receipt;
|
|
30
|
+
return await contract.deploymentTransaction().wait();
|
|
28
31
|
} else {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
signer
|
|
32
|
+
const contract = await contractFactory.deploy(
|
|
33
|
+
storeName,
|
|
34
|
+
owner,
|
|
35
|
+
txOptions
|
|
34
36
|
);
|
|
35
|
-
|
|
36
|
-
const receipt = await contract.deployTransaction.wait();
|
|
37
|
-
return receipt;
|
|
37
|
+
return await contract.deployTransaction.wait();
|
|
38
38
|
}
|
|
39
39
|
} catch (e) {
|
|
40
40
|
console.error("Deployment failed:", e);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { TDocDeployer__factory, TradeTrustToken__factory } from '@tradetrust-tt/token-registry/contracts';
|
|
2
|
+
import { getChainIdSafe, getDefaultContractAddress, isValidAddress, getTxOptions, isSupportedTitleEscrowFactory } from '../token-registry-functions/utils';
|
|
3
|
+
import { encodeInitParams } from '../token-registry-v5/utils';
|
|
4
|
+
import { getEthersContractFromProvider, getEthersContractFactoryFromProvider, isV6EthersProvider } from '../utils/ethers';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
const deployTokenRegistry = /* @__PURE__ */ __name(async (registryName, registrySymbol, signer, options = {}) => {
|
|
9
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = options;
|
|
10
|
+
let { chainId, standalone, factoryAddress, tokenRegistryImplAddress, deployerContractAddress } = options;
|
|
11
|
+
const deployerAddress = await signer.getAddress();
|
|
12
|
+
if (!chainId) {
|
|
13
|
+
chainId = await getChainIdSafe(signer);
|
|
14
|
+
}
|
|
15
|
+
const {
|
|
16
|
+
TitleEscrowFactory: defaultTitleEscrowFactoryAddress,
|
|
17
|
+
TokenImplementation: defaultTokenImplementationContractAddress,
|
|
18
|
+
Deployer: defaultDeployerContractAddress
|
|
19
|
+
} = getDefaultContractAddress(chainId);
|
|
20
|
+
if (!isValidAddress(deployerContractAddress)) {
|
|
21
|
+
deployerContractAddress = defaultDeployerContractAddress;
|
|
22
|
+
}
|
|
23
|
+
if (!isValidAddress(tokenRegistryImplAddress)) {
|
|
24
|
+
tokenRegistryImplAddress = defaultTokenImplementationContractAddress;
|
|
25
|
+
}
|
|
26
|
+
if (standalone !== false && (!deployerContractAddress || !tokenRegistryImplAddress)) {
|
|
27
|
+
console.error(
|
|
28
|
+
`Network ${chainId} does not support "quick-start" mode. Defaulting to standalone mode.`
|
|
29
|
+
);
|
|
30
|
+
standalone = true;
|
|
31
|
+
}
|
|
32
|
+
if (!standalone) {
|
|
33
|
+
if (!deployerContractAddress || !tokenRegistryImplAddress) {
|
|
34
|
+
throw new Error(`Network ${chainId} currently is not supported. Use --standalone instead.`);
|
|
35
|
+
}
|
|
36
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
37
|
+
const deployerContract = new Contract(
|
|
38
|
+
deployerContractAddress,
|
|
39
|
+
TDocDeployer__factory.abi,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
signer
|
|
42
|
+
// Type assertion needed for v5/v6 compatibility
|
|
43
|
+
);
|
|
44
|
+
const initParam = encodeInitParams({
|
|
45
|
+
name: registryName,
|
|
46
|
+
symbol: registrySymbol,
|
|
47
|
+
deployer: deployerAddress
|
|
48
|
+
});
|
|
49
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
50
|
+
return await deployerContract.deploy(tokenRegistryImplAddress, initParam, txOptions);
|
|
51
|
+
} else {
|
|
52
|
+
if (!factoryAddress || !isValidAddress(factoryAddress)) {
|
|
53
|
+
factoryAddress = defaultTitleEscrowFactoryAddress;
|
|
54
|
+
if (!factoryAddress) {
|
|
55
|
+
throw new Error(`Network ${chainId} currently is not supported. Supply a factory address.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const supportedTitleEscrowFactory = await isSupportedTitleEscrowFactory(
|
|
59
|
+
factoryAddress,
|
|
60
|
+
signer.provider
|
|
61
|
+
);
|
|
62
|
+
if (!supportedTitleEscrowFactory) {
|
|
63
|
+
throw new Error(`Title Escrow Factory ${factoryAddress} is not supported.`);
|
|
64
|
+
}
|
|
65
|
+
const Contract = getEthersContractFactoryFromProvider(signer.provider);
|
|
66
|
+
const tokenFactory = new Contract(
|
|
67
|
+
TradeTrustToken__factory.abi,
|
|
68
|
+
TradeTrustToken__factory.bytecode,
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
signer
|
|
71
|
+
// Type assertion needed for v5/v6 compatibility
|
|
72
|
+
);
|
|
73
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
74
|
+
const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas);
|
|
75
|
+
if (isV6) {
|
|
76
|
+
const contract = await tokenFactory.deploy(
|
|
77
|
+
registryName,
|
|
78
|
+
registrySymbol,
|
|
79
|
+
factoryAddress,
|
|
80
|
+
txOptions
|
|
81
|
+
);
|
|
82
|
+
return await contract.deploymentTransaction().wait();
|
|
83
|
+
} else {
|
|
84
|
+
const contract = await tokenFactory.deploy(
|
|
85
|
+
registryName,
|
|
86
|
+
registrySymbol,
|
|
87
|
+
factoryAddress,
|
|
88
|
+
txOptions
|
|
89
|
+
);
|
|
90
|
+
return await contract.deployTransaction.wait();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, "deployTokenRegistry");
|
|
94
|
+
|
|
95
|
+
export { deployTokenRegistry };
|
|
@@ -19,17 +19,11 @@ const getRoleString = /* @__PURE__ */ __name(async (documentStoreAddress, role,
|
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
provider
|
|
21
21
|
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return await documentStore.DEFAULT_ADMIN_ROLE();
|
|
25
|
-
case "issuer":
|
|
26
|
-
return await documentStore.ISSUER_ROLE();
|
|
27
|
-
case "revoker":
|
|
28
|
-
return await documentStore.REVOKER_ROLE();
|
|
29
|
-
default:
|
|
30
|
-
throw new Error("Invalid role");
|
|
22
|
+
if (typeof documentStore[role] !== "function") {
|
|
23
|
+
throw new Error(`Invalid role: ${role}`);
|
|
31
24
|
}
|
|
25
|
+
return await documentStore[role]();
|
|
32
26
|
}, "getRoleString");
|
|
33
|
-
const rolesList = ["
|
|
27
|
+
const rolesList = ["DEFAULT_ADMIN_ROLE", "ISSUER_ROLE", "REVOKER_ROLE"];
|
|
34
28
|
|
|
35
29
|
export { getRoleString, rolesList };
|
|
@@ -3,6 +3,7 @@ export { documentStoreRevoke } from './revoke';
|
|
|
3
3
|
export { documentStoreRevokeRole } from './revoke-role';
|
|
4
4
|
export { documentStoreGrantRole } from './grant-role';
|
|
5
5
|
export { documentStoreTransferOwnership } from './transferOwnership';
|
|
6
|
-
export { deployDocumentStore } from '
|
|
6
|
+
export { deployDocumentStore } from '../deploy/document-store';
|
|
7
|
+
export { getRoleString } from './document-store-roles';
|
|
7
8
|
export { supportInterfaceIds } from './supportInterfaceIds';
|
|
8
9
|
export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
|