@trustvc/trustvc 1.6.0-alpha.1 → 1.6.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core/endorsement-chain/useEndorsementChain.js +5 -6
- package/dist/cjs/token-registry-functions/index.js +28 -0
- package/dist/cjs/token-registry-functions/mint.js +90 -0
- package/dist/cjs/token-registry-functions/ownerOf.js +45 -0
- package/dist/cjs/token-registry-functions/rejectTransfers.js +166 -0
- package/dist/cjs/token-registry-functions/returnToken.js +210 -0
- package/dist/cjs/token-registry-functions/transfer.js +96 -128
- package/dist/cjs/token-registry-functions/types.js +2 -0
- package/dist/cjs/token-registry-functions/utils.js +37 -0
- package/dist/esm/core/endorsement-chain/useEndorsementChain.js +5 -7
- package/dist/esm/token-registry-functions/index.js +4 -0
- package/dist/esm/token-registry-functions/mint.js +88 -0
- package/dist/esm/token-registry-functions/ownerOf.js +43 -0
- package/dist/esm/token-registry-functions/rejectTransfers.js +162 -0
- package/dist/esm/token-registry-functions/returnToken.js +206 -0
- package/dist/esm/token-registry-functions/transfer.js +96 -128
- package/dist/esm/token-registry-functions/types.js +1 -0
- package/dist/esm/token-registry-functions/utils.js +33 -0
- package/dist/types/core/endorsement-chain/index.d.ts +1 -1
- package/dist/types/core/endorsement-chain/useEndorsementChain.d.ts +2 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -1
- package/dist/types/token-registry-functions/index.d.ts +6 -1
- package/dist/types/token-registry-functions/mint.d.ts +20 -0
- package/dist/types/token-registry-functions/ownerOf.d.ts +19 -0
- package/dist/types/token-registry-functions/rejectTransfers.d.ts +43 -0
- package/dist/types/token-registry-functions/returnToken.d.ts +44 -0
- package/dist/types/token-registry-functions/transfer.d.ts +79 -40
- package/dist/types/token-registry-functions/types.d.ts +80 -0
- package/dist/types/token-registry-functions/utils.d.ts +16 -0
- package/package.json +14 -2
|
@@ -1,43 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Signer
|
|
3
|
-
import {
|
|
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';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
declare const
|
|
41
|
-
|
|
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>;
|
|
42
81
|
|
|
43
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.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.3",
|
|
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",
|
|
@@ -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"
|