@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,6 +1,11 @@
|
|
|
1
1
|
import { documentStoreRevokeRole } from './revoke-role';
|
|
2
2
|
import { documentStoreGrantRole } from './grant-role';
|
|
3
3
|
import { getRoleString } from './document-store-roles';
|
|
4
|
+
import { checkSupportsInterface } from '../core';
|
|
5
|
+
import { supportInterfaceIds } from './supportInterfaceIds';
|
|
6
|
+
import { TT_DOCUMENT_STORE_ABI } from './tt-document-store-abi';
|
|
7
|
+
import { getEthersContractFromProvider, isV6EthersProvider } from '../utils/ethers';
|
|
8
|
+
import { TransferableDocumentStore__factory, DocumentStore__factory } from '@trustvc/document-store';
|
|
4
9
|
|
|
5
10
|
var __defProp = Object.defineProperty;
|
|
6
11
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -9,29 +14,72 @@ const documentStoreTransferOwnership = /* @__PURE__ */ __name(async (documentSto
|
|
|
9
14
|
if (!signer.provider) throw new Error("Provider is required");
|
|
10
15
|
if (!account) throw new Error("Account is required");
|
|
11
16
|
const ownerAddress = await signer.getAddress();
|
|
12
|
-
const roleString = await getRoleString(documentStoreAddress, "
|
|
17
|
+
const roleString = await getRoleString(documentStoreAddress, "DEFAULT_ADMIN_ROLE", {
|
|
13
18
|
provider: signer.provider
|
|
14
19
|
});
|
|
15
|
-
const
|
|
20
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
21
|
+
const isDocumentStore = await checkSupportsInterface(
|
|
22
|
+
documentStoreAddress,
|
|
23
|
+
supportInterfaceIds.IDocumentStore,
|
|
24
|
+
signer.provider
|
|
25
|
+
);
|
|
26
|
+
const isTransferableDocumentStore = await checkSupportsInterface(
|
|
27
|
+
documentStoreAddress,
|
|
28
|
+
supportInterfaceIds.ITransferableDocumentStore,
|
|
29
|
+
signer.provider
|
|
30
|
+
);
|
|
31
|
+
let documentStoreAbi;
|
|
32
|
+
if (isDocumentStore || isTransferableDocumentStore) {
|
|
33
|
+
const DocumentStoreFactory = isTransferableDocumentStore ? TransferableDocumentStore__factory : DocumentStore__factory;
|
|
34
|
+
documentStoreAbi = DocumentStoreFactory.abi;
|
|
35
|
+
} else {
|
|
36
|
+
documentStoreAbi = TT_DOCUMENT_STORE_ABI;
|
|
37
|
+
}
|
|
38
|
+
const documentStoreContract = new Contract(
|
|
39
|
+
documentStoreAddress,
|
|
40
|
+
documentStoreAbi,
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
signer
|
|
43
|
+
);
|
|
44
|
+
const isV6 = isV6EthersProvider(signer.provider);
|
|
45
|
+
try {
|
|
46
|
+
if (isV6) {
|
|
47
|
+
await documentStoreContract.grantRole.staticCall(roleString, account);
|
|
48
|
+
} else {
|
|
49
|
+
await documentStoreContract.callStatic.grantRole(roleString, account);
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error("callStatic failed:", e);
|
|
53
|
+
throw new Error("Pre-check (callStatic) for grant-role failed");
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
if (isV6) {
|
|
57
|
+
await documentStoreContract.revokeRole.staticCall(roleString, ownerAddress);
|
|
58
|
+
} else {
|
|
59
|
+
await documentStoreContract.callStatic.revokeRole(roleString, ownerAddress);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("callStatic failed:", e);
|
|
63
|
+
throw new Error("Pre-check (callStatic) for revoke-role failed");
|
|
64
|
+
}
|
|
65
|
+
const grantTransaction = await documentStoreGrantRole(
|
|
16
66
|
documentStoreAddress,
|
|
17
67
|
roleString,
|
|
18
68
|
account,
|
|
19
69
|
signer,
|
|
20
70
|
options
|
|
21
71
|
);
|
|
22
|
-
|
|
23
|
-
if (!grantTransactionResult) {
|
|
72
|
+
if (!grantTransaction) {
|
|
24
73
|
throw new Error("Grant transaction failed, not proceeding with revoke transaction");
|
|
25
74
|
}
|
|
26
|
-
const revokeTransaction = documentStoreRevokeRole(
|
|
75
|
+
const revokeTransaction = await documentStoreRevokeRole(
|
|
27
76
|
documentStoreAddress,
|
|
28
77
|
roleString,
|
|
29
78
|
ownerAddress,
|
|
30
79
|
signer,
|
|
31
80
|
options
|
|
32
81
|
);
|
|
33
|
-
|
|
34
|
-
if (!revokeTransactionResult) {
|
|
82
|
+
if (!revokeTransaction) {
|
|
35
83
|
throw new Error("Revoke transaction failed");
|
|
36
84
|
}
|
|
37
85
|
return { grantTransaction, revokeTransaction };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { DocumentStore__factory, TransferableDocumentStore__factory, deployDocumentStore, documentStoreGrantRole, documentStoreIssue, documentStoreRevoke, documentStoreRevokeRole } from './document-store';
|
|
3
|
+
export { DocumentStore__factory, TransferableDocumentStore__factory, deployDocumentStore, documentStoreGrantRole, documentStoreIssue, documentStoreRevoke, documentStoreRevokeRole, documentStoreTransferOwnership, getRoleString } from './document-store';
|
|
4
4
|
export * from './token-registry-functions';
|
|
5
5
|
export * from './core';
|
|
6
6
|
export * from './open-attestation';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { checkSupportsInterface } from '../core';
|
|
2
2
|
import { v5SupportInterfaceIds, v5Contracts } from '../token-registry-v5';
|
|
3
3
|
import { v4SupportInterfaceIds, v4Contracts } from '../token-registry-v4';
|
|
4
|
+
import { getEthersContractFromProvider } from '../utils/ethers';
|
|
4
5
|
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
6
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -21,23 +22,24 @@ const ownerOf = /* @__PURE__ */ __name(async (contractOptions, signer, params, o
|
|
|
21
22
|
if (!isV4TT && !isV5TT) {
|
|
22
23
|
throw new Error("Only Token Registry V4/V5 is supported");
|
|
23
24
|
}
|
|
25
|
+
const Contract = getEthersContractFromProvider(signer.provider);
|
|
24
26
|
let tradeTrustTokenContract;
|
|
25
27
|
if (isV5TT) {
|
|
26
|
-
tradeTrustTokenContract =
|
|
28
|
+
tradeTrustTokenContract = new Contract(
|
|
27
29
|
tokenRegistryAddress,
|
|
30
|
+
v5Contracts.TradeTrustToken__factory.abi,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
32
|
signer
|
|
29
33
|
);
|
|
30
34
|
} else if (isV4TT) {
|
|
31
|
-
tradeTrustTokenContract =
|
|
35
|
+
tradeTrustTokenContract = new Contract(
|
|
32
36
|
tokenRegistryAddress,
|
|
37
|
+
v4Contracts.TradeTrustToken__factory.abi,
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
39
|
signer
|
|
34
40
|
);
|
|
35
41
|
}
|
|
36
|
-
|
|
37
|
-
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
38
|
-
} else if (isV4TT) {
|
|
39
|
-
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
40
|
-
}
|
|
42
|
+
return await tradeTrustTokenContract.ownerOf(tokenId);
|
|
41
43
|
}, "ownerOf");
|
|
42
44
|
|
|
43
45
|
export { ownerOf };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { isV6EthersProvider } from '../utils/ethers';
|
|
1
|
+
import { isV6EthersProvider, getEthersContractFromProvider } from '../utils/ethers';
|
|
2
2
|
import { SUPPORTED_CHAINS } from '../utils';
|
|
3
|
+
import { isAddress } from 'ethersV6';
|
|
4
|
+
import { constants } from '../token-registry-v5';
|
|
3
5
|
|
|
4
6
|
var __defProp = Object.defineProperty;
|
|
5
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -29,5 +31,39 @@ const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
|
|
|
29
31
|
}
|
|
30
32
|
return await signer.getAddress();
|
|
31
33
|
}, "getSignerAddressSafe");
|
|
34
|
+
const { contractInterfaceId: CONTRACT_INTERFACE_ID, contractAddress: CONTRACT_ADDRESS } = constants;
|
|
35
|
+
const getDefaultContractAddress = /* @__PURE__ */ __name((chainId) => {
|
|
36
|
+
const { TitleEscrowFactory, TokenImplementation, Deployer } = CONTRACT_ADDRESS;
|
|
37
|
+
const chainTitleEscrowFactory = TitleEscrowFactory[chainId];
|
|
38
|
+
const chainTokenImplementation = TokenImplementation[chainId];
|
|
39
|
+
const chainDeployer = Deployer[chainId];
|
|
40
|
+
return {
|
|
41
|
+
TitleEscrowFactory: chainTitleEscrowFactory,
|
|
42
|
+
TokenImplementation: chainTokenImplementation,
|
|
43
|
+
Deployer: chainDeployer
|
|
44
|
+
};
|
|
45
|
+
}, "getDefaultContractAddress");
|
|
46
|
+
const isValidAddress = /* @__PURE__ */ __name((address) => {
|
|
47
|
+
if (!address) return false;
|
|
48
|
+
return isAddress(address);
|
|
49
|
+
}, "isValidAddress");
|
|
50
|
+
const isSupportedTitleEscrowFactory = /* @__PURE__ */ __name(async (factoryAddress, provider) => {
|
|
51
|
+
const Contract = getEthersContractFromProvider(provider);
|
|
52
|
+
const titleEscrowFactoryContract = new Contract(
|
|
53
|
+
factoryAddress,
|
|
54
|
+
["function implementation() view returns (address)"],
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
provider
|
|
57
|
+
);
|
|
58
|
+
const implAddr = await titleEscrowFactoryContract.implementation();
|
|
59
|
+
const implContract = new Contract(
|
|
60
|
+
implAddr,
|
|
61
|
+
["function supportsInterface(bytes4 interfaceId) view returns (bool)"],
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
provider
|
|
64
|
+
);
|
|
65
|
+
const { TitleEscrow: titleEscrowInterfaceId } = CONTRACT_INTERFACE_ID;
|
|
66
|
+
return implContract.supportsInterface(titleEscrowInterfaceId);
|
|
67
|
+
}, "isSupportedTitleEscrowFactory");
|
|
32
68
|
|
|
33
|
-
export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
|
|
69
|
+
export { getChainIdSafe, getDefaultContractAddress, getSignerAddressSafe, getTxOptions, isSupportedTitleEscrowFactory, isValidAddress };
|
|
@@ -4,4 +4,4 @@ export { supportInterfaceIds as v5SupportInterfaceIds } from './supportInterface
|
|
|
4
4
|
import * as contracts from './contracts';
|
|
5
5
|
export { contracts as v5Contracts };
|
|
6
6
|
export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './utils';
|
|
7
|
-
export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-
|
|
7
|
+
export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Contract, ContractFactory } from 'ethersV6';
|
|
2
|
+
import { Contract as Contract$1, ContractFactory as ContractFactory$1 } from 'ethers';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -14,7 +14,10 @@ const isV6EthersProvider = /* @__PURE__ */ __name((provider) => {
|
|
|
14
14
|
throw new Error("Unknown provider type");
|
|
15
15
|
}, "isV6EthersProvider");
|
|
16
16
|
const getEthersContractFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
17
|
-
return isV6EthersProvider(provider) ?
|
|
17
|
+
return isV6EthersProvider(provider) ? Contract : Contract$1;
|
|
18
18
|
}, "getEthersContractFromProvider");
|
|
19
|
+
const getEthersContractFactoryFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
20
|
+
return isV6EthersProvider(provider) ? ContractFactory : ContractFactory$1;
|
|
21
|
+
}, "getEthersContractFactoryFromProvider");
|
|
19
22
|
|
|
20
|
-
export { getEthersContractFromProvider, isV6EthersProvider };
|
|
23
|
+
export { getEthersContractFactoryFromProvider, getEthersContractFromProvider, isV6EthersProvider };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Signer as Signer$1, ContractTransactionReceipt } from 'ethersV6';
|
|
2
|
+
import { Signer, ContractReceipt } from 'ethers';
|
|
3
|
+
import { CHAIN_ID } from '../utils/supportedChains/index.js';
|
|
4
|
+
import { GasValue } from '../token-registry-functions/types.js';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Document Store Deployment Module
|
|
10
|
+
*
|
|
11
|
+
* This module provides functionality to deploy TrustVC Document Store contracts
|
|
12
|
+
* with support for both ethers v5 and v6 signers. It supports two types of stores:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Standard Document Store**: For issuing and revoking verifiable documents
|
|
15
|
+
* - Immutable ownership (documents cannot be transferred)
|
|
16
|
+
* - Suitable for most credential use cases
|
|
17
|
+
*
|
|
18
|
+
* 2. **Transferable Document Store**: For documents that can change ownership
|
|
19
|
+
* - Supports ownership transfers between addresses
|
|
20
|
+
* - Useful for transferable credentials or certificates
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configuration options for Document Store deployment
|
|
25
|
+
*/
|
|
26
|
+
interface DeployOptions {
|
|
27
|
+
chainId?: CHAIN_ID;
|
|
28
|
+
maxFeePerGas?: GasValue;
|
|
29
|
+
maxPriorityFeePerGas?: GasValue;
|
|
30
|
+
isTransferable?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Union type for transaction receipts from both ethers v5 and v6
|
|
34
|
+
*/
|
|
35
|
+
type TransactionReceipt = ContractReceipt | ContractTransactionReceipt;
|
|
36
|
+
/**
|
|
37
|
+
* Deploys a new Document Store contract with automatic type selection.
|
|
38
|
+
* **Store Types:**
|
|
39
|
+
* - **Standard** (default): Documents are immutable and cannot be transferred
|
|
40
|
+
* - **Transferable**: Documents can be transferred to different owners
|
|
41
|
+
* **Ethers Compatibility:**
|
|
42
|
+
* - Automatically detects and handles both ethers v5 and v6 signers
|
|
43
|
+
* - Returns appropriate receipt type based on signer version
|
|
44
|
+
* @param {string} storeName - The name of the document store (e.g., "My University Credentials")
|
|
45
|
+
* @param {string} owner - The owner address that will control the document store
|
|
46
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance that authorizes the deployment
|
|
47
|
+
* @param {DeployOptions} options - Configuration options for deployment
|
|
48
|
+
* @returns {Promise<TransactionReceipt>} Transaction receipt with deployed contract address
|
|
49
|
+
* @throws {Error} If store name is not provided
|
|
50
|
+
* @throws {Error} If owner address is not provided
|
|
51
|
+
* @throws {Error} If signer provider is not available
|
|
52
|
+
* @throws {Error} If deployment transaction fails
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* Deploy standard document store
|
|
56
|
+
* const receipt = await deployDocumentStore(
|
|
57
|
+
* "My Document Store",
|
|
58
|
+
* "0x1234...",
|
|
59
|
+
* signer,
|
|
60
|
+
* { chainId: CHAIN_ID.SEPOLIA }
|
|
61
|
+
* );
|
|
62
|
+
*
|
|
63
|
+
* Deploy transferable document store
|
|
64
|
+
* const receipt = await deployDocumentStore(
|
|
65
|
+
* "My Transferable Store",
|
|
66
|
+
* "0x1234...",
|
|
67
|
+
* signer,
|
|
68
|
+
* {
|
|
69
|
+
* isTransferable: true,
|
|
70
|
+
* maxFeePerGas: 50000000000n
|
|
71
|
+
* }
|
|
72
|
+
* );
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare const deployDocumentStore: (storeName: string, owner: string, signer: Signer | Signer$1, options?: DeployOptions) => Promise<TransactionReceipt>;
|
|
76
|
+
|
|
77
|
+
export { type DeployOptions, type TransactionReceipt, deployDocumentStore };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { GasValue } from '../token-registry-functions/types.js';
|
|
2
|
+
import { CHAIN_ID } from '../utils/supportedChains/index.js';
|
|
3
|
+
import { ContractReceipt, ContractTransaction as ContractTransaction$1, Signer } from 'ethers';
|
|
4
|
+
import { ContractTransactionReceipt, ContractTransactionResponse, Signer as Signer$1 } from 'ethersV6';
|
|
5
|
+
import '../utils/gasStation/index.js';
|
|
6
|
+
import '../utils/network/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Token Registry Deployment Module
|
|
10
|
+
*
|
|
11
|
+
* This module provides functionality to deploy TradeTrust Token Registry contracts
|
|
12
|
+
* with support for both ethers v5 and v6 signers. It handles two deployment modes:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Quick-start mode** (default): Uses a pre-deployed deployer contract and implementation
|
|
15
|
+
* - Faster deployment with lower gas costs
|
|
16
|
+
* - Requires network to have deployer and implementation contracts
|
|
17
|
+
*
|
|
18
|
+
* 2. **Standalone mode**: Deploys a fresh Token Registry contract from scratch
|
|
19
|
+
* - Works on any network with a supported Title Escrow Factory
|
|
20
|
+
* - Higher gas costs but more flexible
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Union type for transaction receipts from both ethers v5 and v6
|
|
25
|
+
*/
|
|
26
|
+
type ContractTransaction = ContractTransaction$1 | ContractTransactionResponse;
|
|
27
|
+
type TransactionReceipt = ContractReceipt | ContractTransactionReceipt | ContractTransaction;
|
|
28
|
+
/**
|
|
29
|
+
* Configuration options for Token Registry deployment
|
|
30
|
+
*/
|
|
31
|
+
interface DeployOptions {
|
|
32
|
+
chainId?: CHAIN_ID;
|
|
33
|
+
maxFeePerGas?: GasValue;
|
|
34
|
+
maxPriorityFeePerGas?: GasValue;
|
|
35
|
+
standalone?: boolean;
|
|
36
|
+
factoryAddress?: string;
|
|
37
|
+
tokenRegistryImplAddress?: string;
|
|
38
|
+
deployerContractAddress?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Deploys a new Token Registry contract with automatic mode selection.
|
|
42
|
+
*
|
|
43
|
+
* **Deployment Modes:**
|
|
44
|
+
* - **Quick-start** (default): Uses pre-deployed contracts for faster, cheaper deployment
|
|
45
|
+
* - **Standalone**: Deploys fresh contract when quick-start is unavailable
|
|
46
|
+
*
|
|
47
|
+
* **Ethers Compatibility:**
|
|
48
|
+
* - Automatically detects and handles both ethers v5 and v6 signers
|
|
49
|
+
* - Returns appropriate receipt type based on signer version
|
|
50
|
+
* @param {string} registryName - The name of the token registry (e.g., "My Token Registry")
|
|
51
|
+
* @param {string} registrySymbol - The symbol of the token registry (e.g., "MTR")
|
|
52
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance that authorizes the deployment
|
|
53
|
+
* @param {DeployOptions} options - Configuration options for deployment
|
|
54
|
+
* @returns {Promise<TransactionReceipt>} Transaction receipt with deployed contract address
|
|
55
|
+
* @throws {Error} If network is not supported and no custom addresses provided
|
|
56
|
+
* @throws {Error} If Title Escrow Factory is not supported (standalone mode)
|
|
57
|
+
* @throws {Error} If deployment transaction fails
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Quick-start deployment
|
|
61
|
+
* const receipt = await deployTokenRegistry(
|
|
62
|
+
* "My Registry",
|
|
63
|
+
* "MTR",
|
|
64
|
+
* signer,
|
|
65
|
+
* { chainId: CHAIN_ID.SEPOLIA }
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* // Standalone deployment with custom factory
|
|
69
|
+
* const receipt = await deployTokenRegistry(
|
|
70
|
+
* "My Registry",
|
|
71
|
+
* "MYR",
|
|
72
|
+
* signer,
|
|
73
|
+
* {
|
|
74
|
+
* standalone: true,
|
|
75
|
+
* factoryAddress: "0x..."
|
|
76
|
+
* }
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare const deployTokenRegistry: (registryName: string, registrySymbol: string, signer: Signer | Signer$1, options?: DeployOptions) => Promise<TransactionReceipt>;
|
|
81
|
+
|
|
82
|
+
export { type DeployOptions, type TransactionReceipt, deployTokenRegistry };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer as Signer$1,
|
|
1
|
+
import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
|
|
2
2
|
import { Signer, ContractTransaction } from 'ethers';
|
|
3
3
|
import { CommandOptions } from './types.js';
|
|
4
4
|
import '../utils/supportedChains/index.js';
|
|
@@ -23,6 +23,6 @@ import '../token-registry-functions/types.js';
|
|
|
23
23
|
* @throws {Error} If the role is invalid.
|
|
24
24
|
* @throws {Error} If the `callStatic.grantRole` fails as a pre-check.
|
|
25
25
|
*/
|
|
26
|
-
declare const documentStoreGrantRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction |
|
|
26
|
+
declare const documentStoreGrantRole: (documentStoreAddress: string, role: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<ContractTransaction | ContractTransactionResponse>;
|
|
27
27
|
|
|
28
28
|
export { documentStoreGrantRole };
|
|
@@ -3,7 +3,8 @@ export { documentStoreRevoke } from './revoke.js';
|
|
|
3
3
|
export { documentStoreRevokeRole } from './revoke-role.js';
|
|
4
4
|
export { documentStoreGrantRole } from './grant-role.js';
|
|
5
5
|
export { documentStoreTransferOwnership } from './transferOwnership.js';
|
|
6
|
-
export { deployDocumentStore } from '
|
|
6
|
+
export { deployDocumentStore } from '../deploy/document-store.js';
|
|
7
|
+
export { getRoleString } from './document-store-roles.js';
|
|
7
8
|
export { supportInterfaceIds } from './supportInterfaceIds.js';
|
|
8
9
|
export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
|
|
9
10
|
import 'ethersV6';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer as Signer$1,
|
|
1
|
+
import { Signer as Signer$1, ContractTransactionResponse } from 'ethersV6';
|
|
2
2
|
import { Signer, ContractTransaction } from 'ethers';
|
|
3
3
|
import { CommandOptions } from './types.js';
|
|
4
4
|
import '../utils/supportedChains/index.js';
|
|
@@ -17,14 +17,14 @@ import '../token-registry-functions/types.js';
|
|
|
17
17
|
* @param {string} account - The account to transfer ownership to.
|
|
18
18
|
* @param {SignerV5 | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the transfer ownership transaction.
|
|
19
19
|
* @param {CommandOptions} options - Optional transaction metadata including gas values and chain ID.
|
|
20
|
-
* @returns {Promise<{grantTransaction:
|
|
20
|
+
* @returns {Promise<{grantTransaction: ContractTransactionV5 | ContractTransactionV6; revokeTransaction: ContractTransactionV5 | ContractTransactionV6}>} A promise resolving to the transaction result from the grant and revoke role calls.
|
|
21
21
|
* @throws {Error} If the document store address or signer provider is not provided.
|
|
22
22
|
* @throws {Error} If the role is invalid.
|
|
23
|
-
* @throws {Error} If the `callStatic.
|
|
23
|
+
* @throws {Error} If either the `callStatic.grantRole` or `callStatic.revokeRole` pre-check fails.
|
|
24
24
|
*/
|
|
25
25
|
declare const documentStoreTransferOwnership: (documentStoreAddress: string, account: string, signer: Signer | Signer$1, options?: CommandOptions) => Promise<{
|
|
26
|
-
grantTransaction:
|
|
27
|
-
revokeTransaction:
|
|
26
|
+
grantTransaction: ContractTransaction | ContractTransactionResponse;
|
|
27
|
+
revokeTransaction: ContractTransaction | ContractTransactionResponse;
|
|
28
28
|
}>;
|
|
29
29
|
|
|
30
30
|
export { documentStoreTransferOwnership };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,33 +3,28 @@ export { contractAddress as v4ContractAddress } from './token-registry-v4/contra
|
|
|
3
3
|
export { supportInterfaceIds as v4SupportInterfaceIds } from './token-registry-v4/supportInterfaceIds.js';
|
|
4
4
|
export { c as v4Contracts } from './contracts-BEtjrEPE.js';
|
|
5
5
|
export { computeInterfaceId as v4ComputeInterfaceId, computeTitleEscrowAddress as v4ComputeTitleEscrowAddress, encodeInitParams as v4EncodeInitParams, getEventFromReceipt as v4GetEventFromReceipt } from './token-registry-v4/utils.js';
|
|
6
|
-
export { utils as v4Utils
|
|
6
|
+
export { utils as v4Utils } from '@tradetrust-tt/token-registry-v4';
|
|
7
7
|
export { contractAddress as v5ContractAddress } from './token-registry-v5/contractAddress.js';
|
|
8
8
|
export { roleHash as v5RoleHash } from './token-registry-v5/roleHash.js';
|
|
9
9
|
export { supportInterfaceIds as v5SupportInterfaceIds } from './token-registry-v5/supportInterfaceIds.js';
|
|
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
|
+
export { utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
|
|
12
13
|
export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
|
|
13
14
|
export { documentStoreIssue } from './document-store/issue.js';
|
|
14
15
|
export { documentStoreRevoke } from './document-store/revoke.js';
|
|
15
16
|
export { documentStoreRevokeRole } from './document-store/revoke-role.js';
|
|
16
17
|
export { documentStoreGrantRole } from './document-store/grant-role.js';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export { CHAIN_ID, SUPPORTED_CHAINS, chainInfo } from './utils/supportedChains/index.js';
|
|
21
|
-
export { errorMessages } from './utils/errorMessages/index.js';
|
|
22
|
-
export { WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord } from './utils/documents/index.js';
|
|
23
|
-
export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, scaleBigNumber } from './utils/gasStation/index.js';
|
|
24
|
-
export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
|
|
25
|
-
export { gaEvent, gaPageView, validateGaEvent, validateGtag, validatePageViewEvent } from './utils/analytics/analytics.js';
|
|
26
|
-
export { deployDocumentStore } from './document-store/deploy.js';
|
|
18
|
+
export { documentStoreTransferOwnership } from './document-store/transferOwnership.js';
|
|
19
|
+
export { deployDocumentStore } from './deploy/document-store.js';
|
|
20
|
+
export { getRoleString } from './document-store/document-store-roles.js';
|
|
27
21
|
export { DocumentStore__factory, TransferableDocumentStore__factory } from '@trustvc/document-store';
|
|
28
22
|
export { nominate, transferBeneficiary, transferHolder, transferOwners } from './token-registry-functions/transfer.js';
|
|
29
23
|
export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './token-registry-functions/rejectTransfers.js';
|
|
30
24
|
export { acceptReturned, rejectReturned, returnToIssuer } from './token-registry-functions/returnToken.js';
|
|
31
25
|
export { mint } from './token-registry-functions/mint.js';
|
|
32
26
|
export { ownerOf } from './token-registry-functions/ownerOf.js';
|
|
27
|
+
export { DeployOptions, TransactionReceipt, deployTokenRegistry } from './deploy/token-registry.js';
|
|
33
28
|
export { decrypt } from './core/decrypt.js';
|
|
34
29
|
export { encrypt } from './core/encrypt.js';
|
|
35
30
|
export { verifyDocument } from './core/verify.js';
|
|
@@ -57,6 +52,15 @@ export { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
|
57
52
|
export { i as vc } from './index-1ws_BWZW.js';
|
|
58
53
|
export { verifyW3CSignature } from './w3c/verify.js';
|
|
59
54
|
export { deriveW3C } from './w3c/derive.js';
|
|
55
|
+
export { OAErrorMessageHandling, errorMessageHandling, interpretFragments, w3cCredentialStatusRevoked, w3cCredentialStatusSuspended } from './utils/fragment/index.js';
|
|
56
|
+
export { networkCurrency, networkName, networkType, networks } from './utils/network/index.js';
|
|
57
|
+
export { generate12ByteNonce, generate32ByteKey, stringToUint8Array } from './utils/stringUtils/index.js';
|
|
58
|
+
export { CHAIN_ID, SUPPORTED_CHAINS, chainInfo } from './utils/supportedChains/index.js';
|
|
59
|
+
export { errorMessages } from './utils/errorMessages/index.js';
|
|
60
|
+
export { WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord } from './utils/documents/index.js';
|
|
61
|
+
export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, scaleBigNumber } from './utils/gasStation/index.js';
|
|
62
|
+
export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
|
|
63
|
+
export { gaEvent, gaPageView, validateGaEvent, validateGtag, validatePageViewEvent } from './utils/analytics/analytics.js';
|
|
60
64
|
export { CustomDnsResolver, IDNSQueryResponse, IDNSRecord, OpenAttestationDNSTextRecord, OpenAttestationDnsDidRecord, defaultDnsResolvers, getDnsDidRecords, getDocumentStoreRecords, parseDnsDidResults, parseDocumentStoreResults, parseOpenAttestationRecord, queryDns } from '@tradetrust-tt/dnsprove';
|
|
61
65
|
export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
|
|
62
66
|
export { DiagnoseError } from '@tradetrust-tt/tradetrust/dist/types/shared/utils';
|
|
@@ -67,11 +71,9 @@ import '@tradetrust-tt/token-registry-v4/contracts';
|
|
|
67
71
|
import 'ethers';
|
|
68
72
|
import '@typechain/ethers-v5/static/common';
|
|
69
73
|
import '@tradetrust-tt/token-registry-v5/contracts';
|
|
70
|
-
import '@tradetrust-tt/token-registry-v5';
|
|
71
74
|
import 'ethersV6';
|
|
72
75
|
import './document-store/types.js';
|
|
73
76
|
import './token-registry-functions/types.js';
|
|
74
|
-
import '@trustvc/w3c-credential-status';
|
|
75
77
|
import '@ethersproject/abstract-provider';
|
|
76
78
|
import 'ethers/lib/utils';
|
|
77
79
|
import '@ethersproject/abstract-signer';
|
|
@@ -89,3 +91,4 @@ import './verify/fragments/issuer-identity/w3cIssuerIdentity.js';
|
|
|
89
91
|
import './verify/fragments/document-status/w3cEmptyCredentialStatus/index.js';
|
|
90
92
|
import 'runtypes';
|
|
91
93
|
import '@trustvc/w3c-context';
|
|
94
|
+
import '@trustvc/w3c-credential-status';
|
|
@@ -3,6 +3,7 @@ export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners }
|
|
|
3
3
|
export { acceptReturned, rejectReturned, returnToIssuer } from './returnToken.js';
|
|
4
4
|
export { mint } from './mint.js';
|
|
5
5
|
export { ownerOf } from './ownerOf.js';
|
|
6
|
+
export { DeployOptions, TransactionReceipt, deployTokenRegistry } from '../deploy/token-registry.js';
|
|
6
7
|
import 'ethersV6';
|
|
7
8
|
import 'ethers';
|
|
8
9
|
import './types.js';
|
|
@@ -9,7 +9,7 @@ import '../utils/network/index.js';
|
|
|
9
9
|
* Retrieves the owner of a given token from the TradeTrustToken contract.
|
|
10
10
|
* Supports both Token Registry V4 and V5 implementations.
|
|
11
11
|
* @param {OwnerOfTokenOptions} contractOptions - Options containing the token registry address.
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {SignerV5 | SignerV6} signer - Signer instance (v5 or v6) used to query the blockchain.
|
|
13
13
|
* @param {OwnerOfTokenParams} params - Contains the `tokenId` of the token to query ownership for.
|
|
14
14
|
* @param {TransactionOptions} options - Includes the `titleEscrowVersion` and other optional metadata for interface detection.
|
|
15
15
|
* @returns {Promise<string>} A promise that resolves to the owner address of the specified token.
|
|
@@ -4,6 +4,12 @@ import { BigNumberish, Provider } from 'ethersV6';
|
|
|
4
4
|
import '../utils/gasStation/index.js';
|
|
5
5
|
import '../utils/network/index.js';
|
|
6
6
|
|
|
7
|
+
interface GasPriceScale {
|
|
8
|
+
maxPriorityFeePerGasScale: number;
|
|
9
|
+
}
|
|
10
|
+
interface GasOption extends GasPriceScale {
|
|
11
|
+
dryRun: boolean;
|
|
12
|
+
}
|
|
7
13
|
type GasValue = BigNumber | BigNumberish | string | number;
|
|
8
14
|
interface RejectTransferParams {
|
|
9
15
|
remarks?: string;
|
|
@@ -78,5 +84,24 @@ interface ProviderInfo {
|
|
|
78
84
|
ethersVersion: 'v5' | 'v6';
|
|
79
85
|
titleEscrowVersion: 'v4' | 'v5';
|
|
80
86
|
}
|
|
87
|
+
interface NetworkOption {
|
|
88
|
+
network: string;
|
|
89
|
+
}
|
|
90
|
+
type WalletOption = {
|
|
91
|
+
encryptedWalletPath: string;
|
|
92
|
+
};
|
|
93
|
+
type PrivateKeyOption = {
|
|
94
|
+
key?: string;
|
|
95
|
+
keyFile?: never;
|
|
96
|
+
} | {
|
|
97
|
+
key?: never;
|
|
98
|
+
keyFile?: string;
|
|
99
|
+
};
|
|
100
|
+
type NetworkAndWalletSignerOption = NetworkOption & (Partial<WalletOption> | Partial<PrivateKeyOption>);
|
|
101
|
+
interface DeployContractAddress {
|
|
102
|
+
TitleEscrowFactory?: string;
|
|
103
|
+
TokenImplementation?: string;
|
|
104
|
+
Deployer?: string;
|
|
105
|
+
}
|
|
81
106
|
|
|
82
|
-
export type { AcceptReturnedOptions, AcceptReturnedParams, ContractOptions, GasValue, MintTokenOptions, MintTokenParams, NominateParams, OwnerOfTokenOptions, OwnerOfTokenParams, ProviderInfo, RejectReturnedOptions, RejectReturnedParams, RejectTransferParams, ReturnToIssuerParams, TransactionOptions, TransferBeneficiaryParams, TransferHolderParams, TransferOwnersParams };
|
|
107
|
+
export type { AcceptReturnedOptions, AcceptReturnedParams, ContractOptions, DeployContractAddress, GasOption, GasPriceScale, GasValue, MintTokenOptions, MintTokenParams, NetworkAndWalletSignerOption, NetworkOption, NominateParams, OwnerOfTokenOptions, OwnerOfTokenParams, PrivateKeyOption, ProviderInfo, RejectReturnedOptions, RejectReturnedParams, RejectTransferParams, ReturnToIssuerParams, TransactionOptions, TransferBeneficiaryParams, TransferHolderParams, TransferOwnersParams, WalletOption };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GasValue } from './types.js';
|
|
1
|
+
import { GasValue, DeployContractAddress } from './types.js';
|
|
2
2
|
import { CHAIN_ID } from '../utils/supportedChains/index.js';
|
|
3
|
-
import { Signer as Signer$1 } from 'ethers';
|
|
4
|
-
import { Signer } from 'ethersV6';
|
|
3
|
+
import { Signer as Signer$1, providers } from 'ethers';
|
|
4
|
+
import { Signer, Provider } from 'ethersV6';
|
|
5
5
|
import '../utils/gasStation/index.js';
|
|
6
6
|
import '../utils/network/index.js';
|
|
7
7
|
|
|
@@ -14,5 +14,8 @@ declare const getTxOptions: (signer: Signer | Signer$1, chainId: CHAIN_ID, maxFe
|
|
|
14
14
|
}>;
|
|
15
15
|
declare const getChainIdSafe: (signer: Signer | Signer$1) => Promise<bigint | number>;
|
|
16
16
|
declare const getSignerAddressSafe: (signer: Signer | Signer$1) => Promise<string>;
|
|
17
|
+
declare const getDefaultContractAddress: (chainId: CHAIN_ID) => DeployContractAddress;
|
|
18
|
+
declare const isValidAddress: (address?: string) => boolean;
|
|
19
|
+
declare const isSupportedTitleEscrowFactory: (factoryAddress: string, provider: providers.Provider | Provider) => Promise<boolean>;
|
|
17
20
|
|
|
18
|
-
export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
|
|
21
|
+
export { getChainIdSafe, getDefaultContractAddress, getSignerAddressSafe, getTxOptions, isSupportedTitleEscrowFactory, isValidAddress };
|
|
@@ -3,7 +3,6 @@ export { roleHash as v5RoleHash } from './roleHash.js';
|
|
|
3
3
|
export { supportInterfaceIds as v5SupportInterfaceIds } from './supportInterfaceIds.js';
|
|
4
4
|
export { c as v5Contracts } from '../contracts-BaIGKzNt.js';
|
|
5
5
|
export { computeInterfaceId as v5ComputeInterfaceId, encodeInitParams as v5EncodeInitParams, getEventFromReceipt as v5GetEventFromReceipt } from './utils.js';
|
|
6
|
-
export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-
|
|
6
|
+
export { constants, utils, utils as v5Utils } from '@tradetrust-tt/token-registry-v5';
|
|
7
7
|
export { TypedContractMethod } from '@tradetrust-tt/token-registry-v5/contracts/common';
|
|
8
8
|
import '@tradetrust-tt/token-registry-v5/contracts';
|
|
9
|
-
import '@tradetrust-tt/token-registry-v5';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Provider } from '@ethersproject/abstract-provider';
|
|
1
|
+
import { Provider, Contract as Contract$1, ContractFactory as ContractFactory$1 } from 'ethersV6';
|
|
2
|
+
import { providers, Contract, ContractFactory } from 'ethers';
|
|
4
3
|
|
|
4
|
+
type ProviderV5 = providers.Provider;
|
|
5
5
|
declare const isV6EthersProvider: (provider: any) => boolean;
|
|
6
|
-
declare const getEthersContractFromProvider: (provider:
|
|
6
|
+
declare const getEthersContractFromProvider: (provider: ProviderV5 | Provider) => typeof Contract | typeof Contract$1;
|
|
7
|
+
declare const getEthersContractFactoryFromProvider: (provider: ProviderV5 | Provider) => typeof ContractFactory | typeof ContractFactory$1;
|
|
7
8
|
|
|
8
|
-
export { getEthersContractFromProvider, isV6EthersProvider };
|
|
9
|
+
export { getEthersContractFactoryFromProvider, getEthersContractFromProvider, isV6EthersProvider };
|