Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.2 #208

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from
Draft

v4.2 #208

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
bdc453a
Remove _compliance parameter from setSupplyLimit function of the Supp…
aliarbak Jan 3, 2024
fced25a
:sparkles: () add permissioning
Joachim-Lebrun Feb 9, 2024
feff21f
Add unit tests for token permissioning
aliarbak Feb 12, 2024
22dc570
Update natspec
aliarbak Feb 14, 2024
56938c9
Fix natspec issue
aliarbak Feb 14, 2024
0c853b3
Update version as 4.2.0-beta1
aliarbak Feb 21, 2024
b9a1e75
Implement upgradeable proxies to compliance modules
aliarbak Mar 8, 2024
b8d9e4b
Add module proxy
aliarbak Mar 11, 2024
cd90523
Fix lint issue
aliarbak Mar 11, 2024
db8daec
Add initializer tests
aliarbak Mar 11, 2024
f8087f2
Merge pull request #194 from TokenySolutions/compliance-modules-erc-1822
Joachim-Lebrun Mar 13, 2024
a67c2a8
Update changelog and package version
aliarbak Mar 15, 2024
0ebd8eb
Merge pull request #196 from TokenySolutions/4-1-4-change-log
Joachim-Lebrun Mar 20, 2024
3fa8596
Add token listing restrictions module
aliarbak Apr 4, 2024
72a7324
Remove unused variable
aliarbak Apr 4, 2024
f8cd846
Ignore transfer restrict checks when sender or recipient is null address
aliarbak Apr 8, 2024
37ec6e8
:bookmark:() update license
Joachim-Lebrun May 6, 2024
ca7deb4
♻(dependencies) upgrade ethers 6 and other dependencies
anonkey May 26, 2024
0fb608a
Proxify DvA manager and implement token freeze logic (#204)
aliarbak Jun 20, 2024
5a2f80c
Merge branch 'v4.2.0-beta1' into upgrade-ethers-6-and-others
Joachim-Lebrun Jun 20, 2024
9611cd1
Merge pull request #202 from anonkey/upgrade-ethers-6-and-others
Joachim-Lebrun Jun 20, 2024
87cf5c1
Merge branch 'develop' into v4.2.0-beta1
aliarbak Jun 26, 2024
ab2ba79
🐛() Fix lint issues
aliarbak Jun 26, 2024
70d94ac
Merge pull request #206 from TokenySolutions/v4.2.0-beta1
Joachim-Lebrun Jun 27, 2024
da546f5
Merge pull request #201 from TokenySolutions/update-license
Joachim-Lebrun Jun 27, 2024
95e141c
Merge pull request #198 from TokenySolutions/transfer-restrict-module…
Joachim-Lebrun Jun 27, 2024
5ee976f
🔧() TREX-122 Update compiler version
pgonday Jun 27, 2024
258b531
✅() TREX-122 Update tests
pgonday Jun 28, 2024
fdec489
Lint issues
pgonday Jun 28, 2024
30819b4
✅(test) update dva test
Joachim-Lebrun Jul 1, 2024
7cb0597
Merge pull request #209 from TokenySolutions/TREX-122-update-compiler…
Joachim-Lebrun Jul 3, 2024
b5ace5e
♻() TREX-132 Custom Errors for zero address and roles
pgonday Jun 28, 2024
0a47bb7
♻() TREX-132 Custom Errors contd
pgonday Jul 3, 2024
e6bf7a6
♻() TREX-132 Custom Errors contd
pgonday Jul 3, 2024
e5eef3f
♻() TREX-132 Update after review 1 + rebase on develop
pgonday Jul 4, 2024
ba2c853
♻() TREX-132 Missing some reverts
pgonday Jul 5, 2024
b0d18ce
✨() Change the token transfer strategy in the DvA contract
aliarbak Jul 5, 2024
a42cbed
Merge pull request #212 from TokenySolutions/dva-updates
Joachim-Lebrun Jul 5, 2024
917e421
♻() TREX-133 Events at file level
pgonday Jul 5, 2024
93d8483
Merge pull request #211 from TokenySolutions/TREX-132-cutom-errors
Joachim-Lebrun Jul 30, 2024
c11603a
Merge pull request #213 from TokenySolutions/TREX-133-events
Joachim-Lebrun Jul 30, 2024
0395ed8
TREX-129 default allowance from develop (#215)
pgonday Aug 16, 2024
e2cb9c7
TREX-161 : Add erc 165 (#219)
Joachim-Lebrun Aug 19, 2024
0e4c3dd
TREX-121 : recovery function update (#220)
Joachim-Lebrun Aug 20, 2024
da86c44
TREX-84 optional eligibility checks (#221)
Joachim-Lebrun Aug 20, 2024
7dbc59d
TREX-162 : bind and set module (#222)
Joachim-Lebrun Aug 21, 2024
23f34e0
ERC-3643 interfaces management (#223)
Joachim-Lebrun Aug 23, 2024
f0b2d47
📝(changelog) update changelog
Joachim-Lebrun Sep 9, 2024
8c5fa14
Solidity 0.8.27 (#224)
Joachim-Lebrun Sep 9, 2024
6f65f78
Ownership2steps (#226)
pgonday Oct 7, 2024
022ddc7
Merge branch 'develop' into token-listing-restrictions
pgonday Oct 15, 2024
68269bd
🔧() BT-7 Update solidity and ethers versions
pgonday Oct 15, 2024
fb7f47c
🔀() BT-7 Fix changelog merge issue
pgonday Oct 15, 2024
222e308
♻() Deduplication of batches code
pgonday Oct 16, 2024
badb68e
✨() Eligibility and compliance checker
pgonday Oct 18, 2024
36d1555
📝() Update changelog
pgonday Oct 18, 2024
0b848b1
Merge pull request #229 from TokenySolutions/BT-47-utility-checker
Joachim-Lebrun Oct 18, 2024
8f979ae
Merge pull request #197 from TokenySolutions/token-listing-restrictions
Joachim-Lebrun Oct 18, 2024
c9c7710
✨() Investor country cap module
pgonday Nov 20, 2024
8139b0c
♻() Initialize function
pgonday Nov 20, 2024
09776e9
♻() Update after review
pgonday Nov 22, 2024
a42e138
✅(test) BT-360 tests
pgonday Nov 25, 2024
c0bda14
✨() Minimum transfer by country module
pgonday Dec 1, 2024
dc035b6
♻() Add limit for batchInitialize
pgonday Dec 1, 2024
c3cf7c5
Merge pull request #231 from TokenySolutions/BT-360-investor-country-…
Joachim-Lebrun Dec 2, 2024
409b91a
✅() Update tests bt-359
pgonday Dec 11, 2024
aad3e65
Merge branch 'develop' into BT-360-min-spend-country
pgonday Dec 12, 2024
83b6ff0
✅() Update after review
pgonday Dec 16, 2024
07b45bf
Merge pull request #232 from TokenySolutions/BT-360-min-spend-country
Joachim-Lebrun Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
build:
if: 'github.event.release.prerelease'
if: "github.event.release.prerelease"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm run build
- name: Run test coverage
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
Expand All @@ -47,9 +47,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://npm.pkg.github.com/
scope: '@tokenysolutions'
scope: "@tokenysolutions"
- run: npm ci
- run: npm run build
- run: npm publish --tag beta
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
build:
if: '!github.event.release.prerelease'
if: "!github.event.release.prerelease"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm run build
- name: Run test coverage
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
Expand All @@ -47,9 +47,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://npm.pkg.github.com/
scope: '@tokenysolutions'
scope: "@tokenysolutions"
- run: npm ci
- run: npm run build
- run: npm publish
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/push_checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- name: Checkout
uses: 'actions/checkout@master'
uses: "actions/checkout@master"

- name: Set Node.js
uses: actions/setup-node@v3
Expand All @@ -20,6 +20,8 @@ jobs:
run: npm ci
- name: Lint Solidity sources
run: npm run lint:sol
- name: Build contracts
run: npm run build
- name: Lint TypeScript sources
run: npm run lint:ts

Expand All @@ -28,11 +30,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- name: Checkout
uses: 'actions/checkout@master'
uses: "actions/checkout@master"

- name: Set Node.js
uses: actions/setup-node@v3
Expand Down
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node ./scripts/commit-msg.js $1 && npx --no-install commitlint --edit $1
4 changes: 0 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
"_testContracts",
"roles/permissioning/owner/",
"roles/permissioning/agent/",
"utils",
],
};
7 changes: 4 additions & 3 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.17"],
"compiler-version": ["error", "^0.8.26"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"reentrancy": "error",
"state-visibility": "error",
Expand All @@ -21,14 +21,15 @@
"code-complexity": ["error", 7],
"function-max-lines": ["error", 50],
"max-line-length": ["error", 130],
"max-states-count": ["error", 15],
"max-states-count": ["warn", 15],
"no-empty-blocks": "error",
"no-unused-vars": "error",
"payable-fallback": "error",
"constructor-syntax": "error",
"not-rely-on-time": "off",
"reason-string": "off",
"no-global-import": "off"
"no-global-import": "off",
"gas-custom-errors": "off"
},
"plugins": ["prettier"]
}
101 changes: 100 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,105 @@
# Change Log
All notable changes to this project will be documented in this file.

## [4.2.0]

### Added

- Introduced **Token Listing Restrictions Module**: Investors can determine which tokens they can receive by whitelisting or blacklisting them
Token issuers can choose the listing type they prefer for their tokens:
WHITELISTING: investors must whitelist/allow the token address in order to receive it.
BLACKLISTING: investors can receive the token by default. If they do not want to receive it, they need to blacklist/disallow it.

- Introduced **Investor Country Cap Module**: to limit the number of identities per country.
- The module allows the token owner to set a maximum number of identities per country.

- **Default Allowance Mechanism**:
- Introduced a new feature allowing the contract owner to set certain addresses as trusted external smart contracts, enabling them to use `transferFrom` without requiring an explicit allowance from users. By default, users are opted in, allowing these contracts to have an "infinite allowance". Users can opt-out if they prefer to control allowances manually.
- Added custom errors and events to provide better feedback and traceability:
- Custom errors: `DefaultAllowanceAlreadyEnabled`, `DefaultAllowanceAlreadyDisabled`, `DefaultAllowanceAlreadySet`.
- Events: `DefaultAllowance`, `DefaultAllowanceDisabled`, `DefaultAllowanceEnabled`.
- Enhanced the `allowance` function to return `type(uint256).max` for addresses with default allowance enabled, unless the user has opted out.

- **Eligibility Checks Toggle**:
- Added the ability for the token owner to enable or disable eligibility checks on the `IdentityRegistry` contract.
- **`disableEligibilityChecks`**: Allows the token owner to disable eligibility checks, making all addresses automatically verified by the `isVerified` function.
- **`enableEligibilityChecks`**: Allows the token owner to re-enable eligibility checks, restoring the full verification process.
- Introduced custom errors and events:
- Custom errors: `EligibilityChecksDisabledAlready`, `EligibilityChecksEnabledAlready`.
- Events: `EligibilityChecksDisabled`, `EligibilityChecksEnabled`.
- This feature provides flexibility for issuers to launch tokens with or without eligibility checks, based on their needs.

- **ERC-165 Interface Implementation**:
- Implemented ERC-165 support across all major contracts in the suite, allowing them to explicitly declare the interfaces they support. This enhancement improves interoperability and makes it easier for external contracts and tools to interact with T-REX contracts.
- Each contract now implements the `supportsInterface` function to identify the supported interfaces, ensuring compliance with ERC-165 standards.
- In addition to implementing ERC-165, the ERC-3643 interfaces were organized into a new directory, with each interface inheriting from the original ERC-3643 standard interface. This setup allows for future expansion and maintains uniformity across the suite:
- `IERC3643`, `IERC3643IdentityRegistry`, `IERC3643Compliance`, `IERC3643ClaimTopicsRegistry`, `IERC3643TrustedIssuersRegistry`, `IERC3643IdentityRegistryStorage`
- For contracts that extend the ERC-3643 standard with new functions, `supportsInterface` now checks for both the new interface ID and the original ERC-3643 interface ID.
- For interfaces that did not change, `supportsInterface` checks for the ERC-3643 interface ID directly, omitting the empty version-specific interface to avoid redundancy.

- **Add and Set Module in a Single Transaction**:
- Introduced the `addAndSetModule` function in the `ModularCompliance` contract, allowing the contract owner to add a new compliance module and interact with it in a single transaction.
- This function supports adding a module and performing up to 5 interactions with the module in one call, streamlining the setup process for compliance modules.

- **Granular Agent Permissioning**:
- Introduced a new system to provide more granular control over agent roles on the token contract.
- **Default Behavior**: By default, agents can perform all actions (mint, burn, freeze tokens, freeze wallets, recover tokens, pause, unpause).
- **Restricting Permissions**: Token owners can now restrict specific roles for agents using the `setAgentRestrictions` function.
- Permissions can be restricted on actions like minting, burning, freezing, recovering, etc.
- Custom restrictions are stored in the `TokenRoles` struct.
- The `AgentRestrictionsSet` event is emitted whenever restrictions are updated for an agent.
- All agent-scoped functions (e.g., mint, burn) now check the agent’s permissions before executing the transaction, ensuring proper enforcement of these restrictions.

- **Ethers.js Version Upgrade**:
- The project was upgraded from **Ethers v5** to **Ethers v6**, introducing several changes to the API and syntax.
- **Key Changes**:
- Adjusted syntax for contract deployments, interactions, and function calls to comply with Ethers v6.
- Replaced deprecated features from v5 with the new Ethers v6 equivalents, ensuring compatibility and future-proofing the project.
- Updated test suites and helper functions to use the Ethers v6 `Interface` and `Contract` classes, ensuring smooth testing of the updated code.
- This upgrade ensures better performance, enhanced security, and improved developer experience moving forward.

- **Solidity Version Upgrade to 0.8.27**:
- Upgraded Solidity version from **0.8.17** to **0.8.27** across all contracts, bringing in multiple new features and improvements:
- **File-Level Event Declaration**: Events are now declared at the file level, simplifying code structure and improving readability.
- **Custom Errors for Require Statements**: All `require` clauses that previously returned a string reason for failure have been updated to use **custom errors**, making debugging easier and more efficient.
- This upgrade provides a cleaner, more efficient error handling process and improves overall code structure without affecting backward compatibility.

- **Utility checker**:
- Add a new utility contract to check for freeze status, eligibility and compliance of an address for a token:
- Test if the transfer of tokens will fail
- Test the eligibility of an address for a token
- Test the compliance of an address for a token
- Test the freeze status of an address for a token

### Updated

- **Token Recovery Function**:
- The `recoveryAddress` function was significantly improved to handle more complex scenarios and prevent potential bugs:
- Removed the requirement for the `newWallet` to be a key on the `onchainID`, simplifying the process and reducing potential errors.
- Enhanced compatibility with shared identity registry storage, ensuring the function works correctly even when multiple tokens share the same identity registry storage.
- Added logic to handle recovery to an existing wallet that is already linked to the investor's identity, addressing scenarios where the `newWallet` is an existing wallet.
- The function now accurately updates the identity registry, preventing errors related to attempting to add or remove identities that are already present or absent.
- Improved overall logic to ensure smooth and error-free recovery operations, with events (`RecoverySuccess`, `TokensFrozen`, `TokensUnfrozen`, etc.) emitted to provide detailed feedback.

- **Ownership Transfer**:
- Implemented a two-step ownership transfer process across all relevant contracts in the suite, using OpenZeppelin's implementation `Ownable2StepUpgradeable`.
- This change enhances security by requiring the new owner to accept ownership explicitly, preventing accidental transfers to incorrect or inaccessible addresses.
- Added new functions:
- `transferOwnership(address newOwner)`: Initiates the ownership transfer process.
- `acceptOwnership()`: Allows the pending owner to accept and finalize the ownership transfer.
- Introduced a `_pendingOwner` state variable to track the address of the pending new owner.
- Updated relevant events to reflect the two-step process:
- `OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)`
- `OwnershipTransferred(address indexed previousOwner, address indexed newOwner)`
- This change affects all contracts that previously used a single-step ownership transfer, ensuring consistent and secure ownership management across the entire suite.

## [4.1.5]

### Update
- DvA Transfer Manager contract proxified
- The DvA manager contract freezes the tokens to be transferred instead of being a vault (so it must be a token agent)
- Only the token owner (rather than agents) can call setApprovalCriteria, as it is part of the main token settings.

## [4.1.4]

### Added
Expand Down Expand Up @@ -210,4 +309,4 @@ Version 4.0.0 of TREX has been successfully audited by Hacken [more details here
- changed required key for roles on AgentManager contract (MANAGEMENT key -> EXECUTION key)
- changed required key for roles on OwnerManager contract (MANAGEMENT key -> EXECUTION key)
- import interfaces from openzeppelin instead of local copy
- contract name : **Storage** -> **TokenStorage**
- contract name : **Storage** -> **TokenStorage**
Loading