@trustvc/trustvc 1.7.3 → 1.8.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.
Files changed (33) hide show
  1. package/dist/cjs/core/endorsement-chain/useEndorsementChain.js +5 -6
  2. package/dist/cjs/index.js +7 -0
  3. package/dist/cjs/token-registry-functions/index.js +40 -0
  4. package/dist/cjs/token-registry-functions/mint.js +90 -0
  5. package/dist/cjs/token-registry-functions/ownerOf.js +45 -0
  6. package/dist/cjs/token-registry-functions/rejectTransfers.js +166 -0
  7. package/dist/cjs/token-registry-functions/returnToken.js +210 -0
  8. package/dist/cjs/token-registry-functions/transfer.js +315 -0
  9. package/dist/cjs/token-registry-functions/types.js +2 -0
  10. package/dist/cjs/token-registry-functions/utils.js +37 -0
  11. package/dist/esm/core/endorsement-chain/useEndorsementChain.js +5 -7
  12. package/dist/esm/index.js +1 -0
  13. package/dist/esm/token-registry-functions/index.js +5 -0
  14. package/dist/esm/token-registry-functions/mint.js +88 -0
  15. package/dist/esm/token-registry-functions/ownerOf.js +43 -0
  16. package/dist/esm/token-registry-functions/rejectTransfers.js +162 -0
  17. package/dist/esm/token-registry-functions/returnToken.js +206 -0
  18. package/dist/esm/token-registry-functions/transfer.js +310 -0
  19. package/dist/esm/token-registry-functions/types.js +1 -0
  20. package/dist/esm/token-registry-functions/utils.js +33 -0
  21. package/dist/types/core/endorsement-chain/index.d.ts +1 -1
  22. package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +2 -1
  23. package/dist/types/core/index.d.ts +1 -1
  24. package/dist/types/index.d.ts +7 -1
  25. package/dist/types/token-registry-functions/index.d.ts +9 -0
  26. package/dist/types/token-registry-functions/mint.d.ts +20 -0
  27. package/dist/types/token-registry-functions/ownerOf.d.ts +19 -0
  28. package/dist/types/token-registry-functions/rejectTransfers.d.ts +43 -0
  29. package/dist/types/token-registry-functions/returnToken.d.ts +44 -0
  30. package/dist/types/token-registry-functions/transfer.d.ts +82 -0
  31. package/dist/types/token-registry-functions/types.d.ts +80 -0
  32. package/dist/types/token-registry-functions/utils.d.ts +16 -0
  33. package/package.json +15 -3
@@ -0,0 +1,33 @@
1
+ import { isV6EthersProvider } from '../utils/ethers';
2
+ import { SUPPORTED_CHAINS } from '@tradetrust-tt/tradetrust-utils';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const getTxOptions = /* @__PURE__ */ __name(async (signer, chainId, maxFeePerGas, maxPriorityFeePerGas) => {
7
+ if (!maxFeePerGas || !maxPriorityFeePerGas) {
8
+ chainId = chainId ?? await getChainIdSafe(signer);
9
+ const gasStation = SUPPORTED_CHAINS[chainId]?.gasStation;
10
+ if (gasStation) {
11
+ const gasFees = await gasStation();
12
+ maxFeePerGas = gasFees?.maxFeePerGas ?? 0;
13
+ maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0;
14
+ }
15
+ }
16
+ return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : {};
17
+ }, "getTxOptions");
18
+ const getChainIdSafe = /* @__PURE__ */ __name(async (signer) => {
19
+ if (isV6EthersProvider(signer.provider)) {
20
+ const network = await signer.provider?.getNetwork();
21
+ if (!network?.chainId) throw new Error("Cannot determine chainId: provider is missing");
22
+ return network.chainId;
23
+ }
24
+ return await signer.getChainId();
25
+ }, "getChainIdSafe");
26
+ const getSignerAddressSafe = /* @__PURE__ */ __name(async (signer) => {
27
+ if (isV6EthersProvider(signer.provider)) {
28
+ return await signer.getAddress();
29
+ }
30
+ return await signer.getAddress();
31
+ }, "getSignerAddressSafe");
32
+
33
+ export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
@@ -3,7 +3,7 @@ export { fetchTokenTransfers } from './fetchTokenTransfer.js';
3
3
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './helpers.js';
4
4
  export { getEndorsementChain } from './retrieveEndorsementChain.js';
5
5
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './types.js';
6
- export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
6
+ export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './useEndorsementChain.js';
7
7
  import 'ethersV6';
8
8
  import '@ethersproject/abstract-provider';
9
9
  import 'ethers';
@@ -12,6 +12,7 @@ declare const getTitleEscrowAddress: (tokenRegistryAddress: string, tokenId: str
12
12
  titleEscrowVersion?: "v4" | "v5";
13
13
  }) => Promise<string>;
14
14
  declare const getDocumentOwner: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider) => Promise<string>;
15
+ declare const checkSupportsInterface: (contractAddress: string, interfaceId: string, provider: Provider | ethers.Provider) => Promise<boolean>;
15
16
  interface TitleEscrowVersionParams {
16
17
  tokenRegistryAddress?: string;
17
18
  tokenId?: string;
@@ -27,4 +28,4 @@ interface TitleEscrowVersionParams {
27
28
  declare const isTitleEscrowVersion: ({ tokenRegistryAddress, tokenId, titleEscrowAddress, versionInterface, provider, }: TitleEscrowVersionParams) => Promise<boolean>;
28
29
  declare const fetchEndorsementChain: (tokenRegistryAddress: string, tokenId: string, provider: Provider | ethers.Provider, keyId?: string, titleEscrowAddress?: string) => Promise<EndorsementChain>;
29
30
 
30
- export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
31
+ export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion };
@@ -6,7 +6,7 @@ export { fetchTokenTransfers } from './endorsement-chain/fetchTokenTransfer.js';
6
6
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './endorsement-chain/helpers.js';
7
7
  export { getEndorsementChain } from './endorsement-chain/retrieveEndorsementChain.js';
8
8
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './endorsement-chain/types.js';
9
- export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
9
+ export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
10
10
  export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './documentBuilder.js';
11
11
  import '@trustvc/w3c-vc';
12
12
  import 'ethers';
@@ -10,6 +10,11 @@ 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
+ export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './token-registry-functions/rejectTransfers.js';
15
+ export { acceptReturned, rejectReturned, returnToIssuer } from './token-registry-functions/returnToken.js';
16
+ export { mint } from './token-registry-functions/mint.js';
17
+ export { ownerOf } from './token-registry-functions/ownerOf.js';
13
18
  export { decrypt } from './core/decrypt.js';
14
19
  export { encrypt } from './core/encrypt.js';
15
20
  export { verifyDocument } from './core/verify.js';
@@ -18,7 +23,7 @@ export { fetchTokenTransfers } from './core/endorsement-chain/fetchTokenTransfer
18
23
  export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from './core/endorsement-chain/helpers.js';
19
24
  export { getEndorsementChain } from './core/endorsement-chain/retrieveEndorsementChain.js';
20
25
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './core/endorsement-chain/types.js';
21
- export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
26
+ export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
22
27
  export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './core/documentBuilder.js';
23
28
  export { signOA } from './open-attestation/sign.js';
24
29
  export { KeyPair } from './open-attestation/types.js';
@@ -55,6 +60,7 @@ import '@typechain/ethers-v5/static/common';
55
60
  import '@tradetrust-tt/token-registry-v5/contracts';
56
61
  import '@tradetrust-tt/token-registry-v5';
57
62
  import 'ethersV6';
63
+ import './token-registry-functions/types.js';
58
64
  import '@ethersproject/abstract-provider';
59
65
  import 'ethers/lib/utils';
60
66
  import '@ethersproject/abstract-signer';
@@ -0,0 +1,9 @@
1
+ export { nominate, transferBeneficiary, transferHolder, transferOwners } from './transfer.js';
2
+ export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners } from './rejectTransfers.js';
3
+ export { acceptReturned, rejectReturned, returnToIssuer } from './returnToken.js';
4
+ export { mint } from './mint.js';
5
+ export { ownerOf } from './ownerOf.js';
6
+ import 'ethersV6';
7
+ import 'ethers';
8
+ import './types.js';
9
+ import '@tradetrust-tt/tradetrust-utils';
@@ -0,0 +1,20 @@
1
+ import { Signer as Signer$1 } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { MintTokenOptions, MintTokenParams, TransactionOptions } from './types.js';
4
+ import '@tradetrust-tt/tradetrust-utils';
5
+
6
+ /**
7
+ * Mints a new token into the TradeTrustToken registry with the specified beneficiary and holder.
8
+ * Supports both Token Registry V4 and V5 contracts.
9
+ * @param {MintTokenOptions} contractOptions - Contains the `tokenRegistryAddress` for the minting contract.
10
+ * @param {Signer | SignerV6} signer - Signer instance (Ethers v5 or v6) that authorizes the mint transaction.
11
+ * @param {MintTokenParams} params - Parameters for minting, including `beneficiaryAddress`, `holderAddress`, `tokenId`, and optional `remarks`.
12
+ * @param {TransactionOptions} options - Transaction metadata including gas values, version detection, chain ID, and optional encryption ID.
13
+ * @returns {Promise<ContractTransaction>} A promise resolving to the transaction result from the mint call.
14
+ * @throws {Error} If the token registry address or signer provider is not provided.
15
+ * @throws {Error} If neither V4 nor V5 interfaces are supported.
16
+ * @throws {Error} If the `callStatic.mint` fails as a pre-check.
17
+ */
18
+ declare const mint: (contractOptions: MintTokenOptions, signer: Signer | Signer$1, params: MintTokenParams, options: TransactionOptions) => Promise<ContractTransaction>;
19
+
20
+ export { mint };
@@ -0,0 +1,19 @@
1
+ import { Signer as Signer$1 } from 'ethersV6';
2
+ import { Signer } from 'ethers';
3
+ import { OwnerOfTokenOptions, OwnerOfTokenParams, TransactionOptions } from './types.js';
4
+ import '@tradetrust-tt/tradetrust-utils';
5
+
6
+ /**
7
+ * Retrieves the owner of a given token from the TradeTrustToken contract.
8
+ * Supports both Token Registry V4 and V5 implementations.
9
+ * @param {OwnerOfTokenOptions} contractOptions - Options containing the token registry address.
10
+ * @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to query the blockchain.
11
+ * @param {OwnerOfTokenParams} params - Contains the `tokenId` of the token to query ownership for.
12
+ * @param {TransactionOptions} options - Includes the `titleEscrowVersion` and other optional metadata for interface detection.
13
+ * @returns {Promise<string>} A promise that resolves to the owner address of the specified token.
14
+ * @throws {Error} If token registry address or signer provider is not provided.
15
+ * @throws {Error} If the token registry does not support V4 or V5 interfaces.
16
+ */
17
+ declare const ownerOf: (contractOptions: OwnerOfTokenOptions, signer: Signer | Signer$1, params: OwnerOfTokenParams, options: TransactionOptions) => Promise<string>;
18
+
19
+ export { ownerOf };
@@ -0,0 +1,43 @@
1
+ import { Signer as Signer$1 } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { ContractOptions, RejectTransferParams, TransactionOptions } from './types.js';
4
+ import '@tradetrust-tt/tradetrust-utils';
5
+
6
+ /**
7
+ * Rejects the transfer of holder for a title escrow contract.
8
+ * @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
9
+ * @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
10
+ * @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
11
+ * @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
12
+ * @throws error if the title escrow address or signer provider is missing.
13
+ * @throws if the version is not V5 compatible.
14
+ * @throws if the dry-run (`callStatic`) fails.
15
+ * @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferHolder call.
16
+ */
17
+ declare const rejectTransferHolder: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
18
+ /**
19
+ * Rejects the transfer of beneficiary for a title escrow contract.
20
+ * @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
21
+ * @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
22
+ * @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
23
+ * @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
24
+ * @throws error if the title escrow address or signer provider is missing.
25
+ * @throws error if the version is not V5 compatible.
26
+ * @throws error if the dry-run (`callStatic`) fails.
27
+ * @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferBeneficiary call.
28
+ */
29
+ declare const rejectTransferBeneficiary: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
30
+ /**
31
+ * Rejects the transfer of ownership for a title escrow contract.
32
+ * @param {ContractOptions} contractOptions - Contract-related options including the token registry address, and optionally, token ID and the title escrow address.
33
+ * @param {Signer | SignerV6} signer - Ethers signer (V5 or V6) used to sign and send the transaction.
34
+ * @param {RejectTransferParams} params - Contains the `remarks` field which is an optional string that will be encrypted and sent with the transaction.
35
+ * @param {TransactionOptions} options - Transfer options including optional `chainId`, `titleEscrowVersion`, `maxFeePerGas`, `maxPriorityFeePerGas`, and an `id` used for encryption.
36
+ * @throws error if the title escrow address or signer provider is missing.
37
+ * @throws an error if the version is not V5 compatible.
38
+ * @throws an error if the dry-run (`callStatic`) fails.
39
+ * @returns {Promise<ContractTransaction>} The transaction response of the rejectTransferOwners call.
40
+ */
41
+ declare const rejectTransferOwners: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: RejectTransferParams, options: TransactionOptions) => Promise<ContractTransaction>;
42
+
43
+ export { rejectTransferBeneficiary, rejectTransferHolder, rejectTransferOwners };
@@ -0,0 +1,44 @@
1
+ import { Signer as Signer$1 } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { ContractOptions, ReturnToIssuerParams, TransactionOptions, RejectReturnedOptions, AcceptReturnedParams, AcceptReturnedOptions, RejectReturnedParams } from './types.js';
4
+ import '@tradetrust-tt/tradetrust-utils';
5
+
6
+ /**
7
+ * Returns the token to the original issuer from the Title Escrow contract.
8
+ * @param {ContractOptions} contractOptions - Options including token ID, registry address, and optionally title escrow address.
9
+ * @param {Signer | SignerV6} signer - Signer instance (Ethers v5 or v6) that will execute the transaction.
10
+ * @param {ReturnToIssuerParams} params - Contains optional remarks to be encrypted and attached to the transaction.
11
+ * @param {TransactionOptions} options - Transaction settings including gas fees, escrow version, chain ID, and optional encryption ID.
12
+ * @returns {Promise<ContractTransaction>} Promise that resolves to the transaction response from the `returnToIssuer` function.
13
+ * @throws {Error} If title escrow address or provider is not provided or if version is unsupported.
14
+ * @throws {Error} If the `callStatic.returnToIssuer` fails as a pre-check.
15
+ */
16
+ declare const returnToIssuer: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: ReturnToIssuerParams, options: TransactionOptions) => Promise<ContractTransaction>;
17
+ /**
18
+ * Rejects a previously returned token by restoring it back to the token registry.
19
+ * This is only supported on Token Registry V5 contracts with the `restore` functionality.
20
+ * @param {AcceptReturnedOptions} contractOptions - Contains the `tokenRegistryAddress` used to locate the TradeTrustToken contract.
21
+ * @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to authorize the transaction.
22
+ * @param {AcceptReturnedParams} params - Includes the `tokenId` to restore and optional `remarks` to encrypt.
23
+ * @param {TransactionOptions} options - Configuration for the transaction including version, gas fees, and optional `id` used for encryption.
24
+ * @returns {Promise<ContractTransaction>} A promise that resolves to the transaction result of the `restore` call.
25
+ * @throws {Error} If the token registry address or provider is missing.
26
+ * @throws {Error} If the token registry version is unsupported.
27
+ * @throws {Error} If the callStatic pre-check fails.
28
+ */
29
+ declare const rejectReturned: (contractOptions: AcceptReturnedOptions, signer: Signer | Signer$1, params: RejectReturnedParams, options: TransactionOptions) => Promise<ContractTransaction>;
30
+ /**
31
+ * Accepts the returned token by burning it from the TradeTrustToken contract.
32
+ * Only supported on Token Registry V5 contracts that implement the burnable interface.
33
+ * @param {RejectReturnedOptions} contractOptions - Contains the `tokenRegistryAddress` from which the token will be burned.
34
+ * @param {Signer | SignerV6} signer - Signer instance (v5 or v6) used to authorize and send the burn transaction.
35
+ * @param {AcceptReturnedParams} params - Includes the `tokenId` to burn and optional `remarks` for audit trail.
36
+ * @param {TransactionOptions} options - Transaction settings including chain ID, gas fee values, escrow version, and encryption ID for remarks.
37
+ * @returns {Promise<ContractTransaction>} A promise resolving to the transaction result of the burn call.
38
+ * @throws {Error} If token registry address or signer provider is not provided.
39
+ * @throws {Error} If the contract does not support Token Registry V5.
40
+ * @throws {Error} If `callStatic.burn` fails as a pre-check.
41
+ */
42
+ declare const acceptReturned: (contractOptions: RejectReturnedOptions, signer: Signer | Signer$1, params: AcceptReturnedParams, options: TransactionOptions) => Promise<ContractTransaction>;
43
+
44
+ export { acceptReturned, rejectReturned, returnToIssuer };
@@ -0,0 +1,82 @@
1
+ import { Signer as Signer$1 } from 'ethersV6';
2
+ import { Signer, ContractTransaction } from 'ethers';
3
+ import { ContractOptions, TransferHolderParams, TransactionOptions, TransferBeneficiaryParams, TransferOwnersParams, NominateParams } from './types.js';
4
+ import '@tradetrust-tt/tradetrust-utils';
5
+
6
+ /**
7
+ * Transfers holder role of a Title Escrow contract to a new address.
8
+ * The caller of this function must be the current holder.
9
+ * @param {ContractOptions} contractOptions - Contains `tokenRegistryAddress` and optionally `tokenId` and `titleEscrowAddress`.
10
+ * @param {Signer | SignerV6} signer - The signer (ethers v5 or v6) who initiates the transaction.
11
+ * @param {TransferHolderParams} params - Object containing `holderAddress` (address to transfer to) and optional `remarks`.
12
+ * @param {TransactionOptions} options - Transaction options including:
13
+ * - `titleEscrowVersion` (optional): Either "v4" or "v5"
14
+ * - `chainId` (optional): Used for gas station lookup
15
+ * - `maxFeePerGas` (optional), `maxPriorityFeePerGas` (optional): EIP-1559 gas fee configuration
16
+ * - `id` (optional): ID used for encrypting remarks
17
+ * @throws If required fields like `titleEscrowAddress` or `signer.provider` are missing.
18
+ * @throws If the version is unsupported (neither v4 nor v5).
19
+ * @throws If the dry-run via `callStatic` fails.
20
+ * @returns {Promise<ContractTransaction>} The transaction response for `transferHolder`.
21
+ */
22
+ declare const transferHolder: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferHolderParams, options: TransactionOptions) => Promise<ContractTransaction>;
23
+ /**
24
+ * Transfers the beneficiary role of a Title Escrow contract to a new beneficiary address.
25
+ * The caller of this function must be the current holder.
26
+ * @param {ContractOptions} contractOptions - Contains `tokenRegistryAddress` and optionally `tokenId` and `titleEscrowAddress`.
27
+ * @param {Signer | SignerV6} signer - The signer (ethers v5 or v6) who initiates and signs the transaction.
28
+ * @param {TransferBeneficiaryParams} params - Object containing:
29
+ * - `newBeneficiaryAddress`: Address to which the beneficiary role is being transferred.
30
+ * - `remarks` (optional): Optional encrypted message attached with the transaction.
31
+ * @param {TransactionOptions} options - Transaction configuration options:
32
+ * - `titleEscrowVersion` (optional): Token registry version, either `'v4'` or `'v5'`.
33
+ * - `chainId` (optional): Used to query gas station info if gas fee values are missing.
34
+ * - `maxFeePerGas`(optional), `maxPriorityFeePerGas`(optional): EIP-1559 gas fee parameters.
35
+ * - `id`(optional): Used for encryption of remarks.
36
+ * @throws If required values like `titleEscrowAddress` or `signer.provider` are missing.
37
+ * @throws If the version is unsupported (neither v4 nor v5).
38
+ * @throws If the dry-run `callStatic` fails for pre-checking the transaction.
39
+ * @returns {Promise<ContractTransaction>} The transaction response for the `transferBeneficiary` call.
40
+ */
41
+ declare const transferBeneficiary: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferBeneficiaryParams, options: TransactionOptions) => Promise<ContractTransaction>;
42
+ /**
43
+ * Transfers both the holder and beneficiary roles of a Title Escrow contract to new addresses.
44
+ * The caller of this function must be the current holder and beneficiary both.
45
+ * @param {ContractOptions} contractOptions - Contains `tokenRegistryAddress` and optionally `tokenId` and `titleEscrowAddress`.
46
+ * @param {Signer | SignerV6} signer - The signer (ethers v5 or v6) who initiates and signs the transaction.
47
+ * @param {TransferOwnersParams} params - Object containing:
48
+ * - `newBeneficiaryAddress`: The new beneficiary address.
49
+ * - `newHolderAddress`: The new holder address.
50
+ * - `remarks` (optional): Optional remarks that will be encrypted and included with the transaction.
51
+ * @param {TransactionOptions} options - Transaction configuration options:
52
+ * - `titleEscrowVersion` (optional): Token registry version, either `'v4'` or `'v5'`.
53
+ * - `chainId` (optional): Used for gas station lookup if gas fee values are not provided.
54
+ * - `maxFeePerGas`(optional), `maxPriorityFeePerGas`(optional): EIP-1559 gas fee parameters.
55
+ * - `id`(optional): Used for encrypting remarks.
56
+ * @throws If required fields like `titleEscrowAddress` or `signer.provider` are missing.
57
+ * @throws If the title escrow version is unsupported.
58
+ * @throws If the pre-check `callStatic.transferOwners` fails.
59
+ * @returns {Promise<ContractTransaction>} The transaction response from the `transferOwners` call.
60
+ */
61
+ declare const transferOwners: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: TransferOwnersParams, options: TransactionOptions) => Promise<ContractTransaction>;
62
+ /**
63
+ * Nominates a new beneficiary on the Title Escrow contract.
64
+ * The caller of this function must be the current beneficiary.
65
+ * @param {ContractOptions} contractOptions - Contains `tokenRegistryAddress` and optionally `tokenId` and `titleEscrowAddress`.
66
+ * @param {Signer | SignerV6} signer - The signer (ethers v5 or v6) who will sign and send the transaction.
67
+ * @param {NominateParams} params - Nomination parameters:
68
+ * - `newBeneficiaryAddress`: The Ethereum address to nominate as the new beneficiary.
69
+ * - `remarks` (optional): Remarks to include with the transaction (will be encrypted).
70
+ * @param {TransactionOptions} options - Transaction-level configuration:
71
+ * - `titleEscrowVersion` (optional): Specifies token registry version, either `'v4'` or `'v5'`.
72
+ * - `chainId` (optional): Chain ID used for querying gas stations if fees are not set.
73
+ * - `maxFeePerGas`(optional), `maxPriorityFeePerGas`(optional): EIP-1559-compatible gas fee settings.
74
+ * - `id`(optional): Used for encrypting the remarks string.
75
+ * @throws If required inputs like `titleEscrowAddress` or `signer.provider` are missing.
76
+ * @throws If token registry version is unsupported.
77
+ * @throws If the dry-run `callStatic.nominate()` fails.
78
+ * @returns {Promise<ContractTransaction>} The transaction response from the `nominate` method.
79
+ */
80
+ declare const nominate: (contractOptions: ContractOptions, signer: Signer | Signer$1, params: NominateParams, options: TransactionOptions) => Promise<ContractTransaction>;
81
+
82
+ export { nominate, transferBeneficiary, transferHolder, transferOwners };
@@ -0,0 +1,80 @@
1
+ import { CHAIN_ID } from '@tradetrust-tt/tradetrust-utils';
2
+ import { BigNumber, providers } from 'ethers';
3
+ import { BigNumberish, Provider } from 'ethersV6';
4
+
5
+ type GasValue = BigNumber | BigNumberish | string | number;
6
+ interface RejectTransferParams {
7
+ remarks?: string;
8
+ }
9
+ interface ReturnToIssuerParams {
10
+ remarks?: string;
11
+ }
12
+ interface AcceptReturnedParams {
13
+ tokenId: string | number;
14
+ remarks?: string;
15
+ }
16
+ interface RejectReturnedParams {
17
+ tokenId: string | number;
18
+ remarks?: string;
19
+ }
20
+ interface MintTokenParams {
21
+ beneficiaryAddress: string;
22
+ holderAddress: string;
23
+ tokenId: string | number;
24
+ remarks?: string;
25
+ }
26
+ interface OwnerOfTokenParams {
27
+ tokenId: string | number;
28
+ }
29
+ interface TransactionOptions {
30
+ chainId?: CHAIN_ID;
31
+ titleEscrowVersion?: 'v4' | 'v5';
32
+ maxFeePerGas?: BigNumberish | string | number | BigNumber;
33
+ maxPriorityFeePerGas?: BigNumberish | string | number | BigNumber;
34
+ id?: string;
35
+ }
36
+ type ContractOptions = {
37
+ titleEscrowAddress: string;
38
+ tokenId?: string | number;
39
+ tokenRegistryAddress?: string;
40
+ } | {
41
+ titleEscrowAddress?: undefined;
42
+ tokenId: string | number;
43
+ tokenRegistryAddress: string;
44
+ };
45
+ type AcceptReturnedOptions = {
46
+ tokenRegistryAddress: string;
47
+ };
48
+ type RejectReturnedOptions = {
49
+ tokenRegistryAddress: string;
50
+ };
51
+ type MintTokenOptions = {
52
+ tokenRegistryAddress: string;
53
+ };
54
+ type OwnerOfTokenOptions = {
55
+ tokenRegistryAddress: string;
56
+ };
57
+ interface TransferHolderParams {
58
+ holderAddress: string;
59
+ remarks?: string;
60
+ }
61
+ interface TransferBeneficiaryParams {
62
+ newBeneficiaryAddress: string;
63
+ remarks?: string;
64
+ }
65
+ interface NominateParams {
66
+ newBeneficiaryAddress: string;
67
+ remarks?: string;
68
+ }
69
+ interface TransferOwnersParams {
70
+ newHolderAddress: string;
71
+ newBeneficiaryAddress: string;
72
+ remarks?: string;
73
+ }
74
+ interface ProviderInfo {
75
+ Provider: providers.Provider | Provider;
76
+ ethersVersion: 'v5' | 'v6';
77
+ titleEscrowVersion: 'v4' | 'v5';
78
+ }
79
+
80
+ export type { AcceptReturnedOptions, AcceptReturnedParams, ContractOptions, GasValue, MintTokenOptions, MintTokenParams, NominateParams, OwnerOfTokenOptions, OwnerOfTokenParams, ProviderInfo, RejectReturnedOptions, RejectReturnedParams, RejectTransferParams, ReturnToIssuerParams, TransactionOptions, TransferBeneficiaryParams, TransferHolderParams, TransferOwnersParams };
@@ -0,0 +1,16 @@
1
+ import { GasValue } from './types.js';
2
+ import { CHAIN_ID } from '@tradetrust-tt/tradetrust-utils';
3
+ import { Signer as Signer$1 } from 'ethers';
4
+ import { Signer } from 'ethersV6';
5
+
6
+ declare const getTxOptions: (signer: Signer | Signer$1, chainId: CHAIN_ID, maxFeePerGas: GasValue, maxPriorityFeePerGas: GasValue) => Promise<{
7
+ maxFeePerGas: GasValue;
8
+ maxPriorityFeePerGas: GasValue;
9
+ } | {
10
+ maxFeePerGas?: undefined;
11
+ maxPriorityFeePerGas?: undefined;
12
+ }>;
13
+ declare const getChainIdSafe: (signer: Signer | Signer$1) => Promise<bigint | number>;
14
+ declare const getSignerAddressSafe: (signer: Signer | Signer$1) => Promise<string>;
15
+
16
+ export { getChainIdSafe, getSignerAddressSafe, getTxOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.7.3",
3
+ "version": "1.8.0",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -10,6 +10,10 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "test": "npx vitest --run --test-timeout=15000",
13
+ "test:e2e": "concurrently -k \"npm run e2e:node\" \"npm run wait-and-test\"",
14
+ "e2e:node": "npx hardhat node",
15
+ "wait-and-test": "wait-on tcp:8545 && npm run e2e:test",
16
+ "e2e:test": "npx hardhat test src/__tests__/e2e/**/*.test.ts --network hardhat",
13
17
  "type-check": "tsc --noEmit",
14
18
  "lint": "npx eslint . --color --format=table --max-warnings=0",
15
19
  "lint:fix": "npx eslint . --fix",
@@ -115,7 +119,7 @@
115
119
  "@tradetrust-tt/token-registry-v4": "npm:@tradetrust-tt/token-registry@^4.16.0",
116
120
  "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.5.0",
117
121
  "@tradetrust-tt/tradetrust": "^6.10.2",
118
- "@tradetrust-tt/tradetrust-utils": "^2.4.1",
122
+ "@tradetrust-tt/tradetrust-utils": "^2.4.2",
119
123
  "@tradetrust-tt/tt-verify": "^9.5.1",
120
124
  "@trustvc/w3c-context": "^1.2.13",
121
125
  "@trustvc/w3c-credential-status": "^1.2.13",
@@ -131,13 +135,18 @@
131
135
  "@commitlint/config-conventional": "^19.8.0",
132
136
  "@commitlint/config-nx-scopes": "^19.8.0",
133
137
  "@commitlint/prompt": "^19.8.0",
138
+ "@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
139
+ "@nomiclabs/hardhat-ethers": "^2.2.3",
140
+ "@openzeppelin/contracts": "^5.3.0",
134
141
  "@semantic-release/changelog": "^6.0.3",
135
142
  "@semantic-release/git": "^10.0.1",
136
143
  "@semantic-release/npm": "^9.0.2",
137
144
  "@types/conventional-commits-parser": "^5.0.1",
138
145
  "@types/lodash": "^4.17.16",
146
+ "@types/mocha": "^10.0.10",
139
147
  "@types/node": "^18.19.86",
140
148
  "@vitest/coverage-v8": "^1.6.1",
149
+ "concurrently": "^9.2.0",
141
150
  "cpy": "^11.1.0",
142
151
  "dotenv": "^16.5.0",
143
152
  "eslint": "^9.25.1",
@@ -149,17 +158,20 @@
149
158
  "eslint-plugin-promise": "^7.2.1",
150
159
  "eth-testing": "^1.14.0",
151
160
  "execa": "^9.5.2",
161
+ "hardhat": "^2.25.0",
152
162
  "husky": "^9.1.7",
153
163
  "lint-staged": "^15.5.1",
154
164
  "prettier": "^3.5.3",
155
165
  "rimraf": "^5.0.10",
156
166
  "semantic-release": "^20.1.3",
157
167
  "ts-node": "^10.9.2",
168
+ "tsconfig-paths": "^4.2.0",
158
169
  "tsup": "^8.4.0",
159
170
  "typescript": "^5.8.3",
160
171
  "typescript-eslint": "^8.31.0",
161
172
  "vite-plugin-dts": "^3.9.1",
162
- "vitest": "^1.6.1"
173
+ "vitest": "^1.6.1",
174
+ "wait-on": "^8.0.3"
163
175
  },
164
176
  "overrides": {
165
177
  "ethers": "^5.8.0"