├── .solhintignore
├── .gitattributes
├── docs
├── img
│ ├── T-REX.png
│ ├── tokeny.png
│ ├── Xmas T-REX.png
│ └── T-REX Components.png
└── TREX-WhitePaper.pdf
├── .husky
├── pre-commit
└── commit-msg
├── .prettierrc.json
├── .solcover.js
├── tsconfig.json
├── .gitignore
├── contracts
├── _testContracts
│ ├── OIDImports.sol
│ ├── ClaimIssuerTrick.sol
│ ├── MockContract.sol
│ ├── v_3_5_2
│ │ ├── LegacyProxy.sol
│ │ └── LegacyIA.sol
│ ├── TestUpgradedCountryAllowModule.sol
│ └── TestERC20.sol
├── compliance
│ ├── modular
│ │ ├── modules
│ │ │ ├── ModuleProxy.sol
│ │ │ └── AbstractModule.sol
│ │ └── MCStorage.sol
│ └── legacy
│ │ ├── DefaultCompliance.sol
│ │ ├── test
│ │ ├── MaxBalanceTest.sol
│ │ ├── SupplyLimitTest.sol
│ │ ├── DayMonthLimitsTest.sol
│ │ ├── ApproveTransferTest.sol
│ │ ├── CountryRestrictionsTest.sol
│ │ ├── CountryWhitelistingTest.sol
│ │ └── ExchangeMonthlyLimitsTest.sol
│ │ └── features
│ │ └── SupplyLimit.sol
├── proxy
│ ├── interface
│ │ └── IProxy.sol
│ ├── authority
│ │ ├── IIAFactory.sol
│ │ └── IAFactory.sol
│ ├── ClaimTopicsRegistryProxy.sol
│ ├── ModularComplianceProxy.sol
│ ├── IdentityRegistryStorageProxy.sol
│ ├── TrustedIssuersRegistryProxy.sol
│ ├── IdentityRegistryProxy.sol
│ ├── AbstractProxy.sol
│ └── TokenProxy.sol
├── registry
│ ├── storage
│ │ ├── CTRStorage.sol
│ │ ├── IRSStorage.sol
│ │ ├── IRStorage.sol
│ │ └── TIRStorage.sol
│ ├── interface
│ │ └── IClaimTopicsRegistry.sol
│ └── implementation
│ │ └── ClaimTopicsRegistry.sol
├── roles
│ ├── AgentRole.sol
│ ├── AgentRoleUpgradeable.sol
│ └── Roles.sol
└── token
│ └── TokenStorage.sol
├── commitlint.config.js
├── test
├── fixtures
│ └── deploy-compliance.fixture.ts
├── registries
│ └── claim-topics-registry.test.ts
├── token
│ └── token-recovery.test.ts
└── agentRole.test.ts
├── hardhat.config.ts
├── .solhint.json
├── .github
└── workflows
│ ├── push_checking.yml
│ ├── publish-release.yml
│ └── publish-prerelease.yml
├── scripts
└── flatten.js
├── .eslintrc.json
├── CONTRIBUTING.md
├── package.json
├── README.md
└── index.d.ts
/.solhintignore:
--------------------------------------------------------------------------------
1 | contracts/_testContracts
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.sol linguist-language=Solidity
2 |
--------------------------------------------------------------------------------
/docs/img/T-REX.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TokenySolutions/T-REX/HEAD/docs/img/T-REX.png
--------------------------------------------------------------------------------
/docs/img/tokeny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TokenySolutions/T-REX/HEAD/docs/img/tokeny.png
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/docs/img/Xmas T-REX.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TokenySolutions/T-REX/HEAD/docs/img/Xmas T-REX.png
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 150,
3 | "singleQuote": true,
4 | "trailingComma": "all"
5 | }
--------------------------------------------------------------------------------
/docs/TREX-WhitePaper.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TokenySolutions/T-REX/HEAD/docs/TREX-WhitePaper.pdf
--------------------------------------------------------------------------------
/docs/img/T-REX Components.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TokenySolutions/T-REX/HEAD/docs/img/T-REX Components.png
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | node ./scripts/commit-msg.js $1 && npx --no-install commitlint --edit $1
5 |
--------------------------------------------------------------------------------
/.solcover.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | skipFiles: [
3 | "compliance/legacy",
4 | "_testContracts",
5 | "roles/permissioning/owner/",
6 | "roles/permissioning/agent/",
7 | ],
8 | };
9 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "module": "commonjs",
5 | "esModuleInterop": true,
6 | "forceConsistentCasingInFileNames": true,
7 | "strict": true,
8 | "skipLibCheck": true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
3 | # Artifacts
4 | build/
5 | bin/
6 | coverage/
7 | coverage.json
8 | typechain-types/
9 | artifacts/
10 | cache/
11 | docgen/
12 | flat/
13 |
14 | # IDEs
15 | .idea/
16 | .vscode/
17 |
18 | # NPM
19 | gas-report
20 | /bin/
21 |
--------------------------------------------------------------------------------
/contracts/_testContracts/OIDImports.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity 0.8.17;
3 |
4 | import "@onchain-id/solidity/contracts/ClaimIssuer.sol";
5 | import "@onchain-id/solidity/contracts/Identity.sol";
6 | import "@onchain-id/solidity/contracts/proxy/ImplementationAuthority.sol";
7 |
8 | contract OIDImports {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/contracts/_testContracts/ClaimIssuerTrick.sol:
--------------------------------------------------------------------------------
1 | contract ClaimIssuerTrick {
2 | function isClaimValid(
3 | address _identity,
4 | uint256 claimTopic,
5 | bytes calldata sig,
6 | bytes calldata data)
7 | public view returns (bool) {
8 | if (msg.sender == _identity) {
9 | return true;
10 | }
11 |
12 | revert('ERROR');
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parserPreset: {
3 | parserOpts: {
4 | headerPattern: /^(.*)\((.*)\) (.*)$/,
5 | headerCorrespondence: ['type', 'scope', 'message'],
6 | },
7 | },
8 | rules: {
9 | 'scope-empty': [1, 'never'],
10 | 'type-empty': [2, 'never'],
11 | 'type-enum': [2, 'always', ['✨', '🐛', '♻', '✅', '📝', '🔀', '✏', '🔧', '➕', '➖', '🔖', '👷', '🚨', '🚑', '🎉']],
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/test/fixtures/deploy-compliance.fixture.ts:
--------------------------------------------------------------------------------
1 | import { ethers } from 'hardhat';
2 |
3 | // eslint-disable-next-line import/prefer-default-export
4 | export async function deployComplianceFixture() {
5 | const [deployer, aliceWallet, bobWallet, anotherWallet] = await ethers.getSigners();
6 |
7 | const compliance = await ethers.deployContract('ModularCompliance');
8 | await compliance.init();
9 |
10 | return {
11 | accounts: {
12 | deployer,
13 | aliceWallet,
14 | bobWallet,
15 | anotherWallet,
16 | },
17 | suite: {
18 | compliance,
19 | },
20 | };
21 | }
22 |
--------------------------------------------------------------------------------
/contracts/_testContracts/MockContract.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.17;
2 |
3 | contract MockContract {
4 | address _irRegistry;
5 | uint16 _investorCountry;
6 |
7 | function identityRegistry() public view returns (address identityRegistry) {
8 | if (_irRegistry != address(0)) {
9 | return _irRegistry;
10 | } else {
11 | return address(this);
12 | }
13 | }
14 |
15 | function investorCountry(address investor) public view returns (uint16 country) {
16 | return _investorCountry;
17 | }
18 |
19 | function setInvestorCountry(uint16 country) public {
20 | _investorCountry = country;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/hardhat.config.ts:
--------------------------------------------------------------------------------
1 | import '@xyrusworx/hardhat-solidity-json';
2 | import '@nomicfoundation/hardhat-toolbox';
3 | import { HardhatUserConfig } from 'hardhat/config';
4 | import '@openzeppelin/hardhat-upgrades';
5 | import 'solidity-coverage';
6 | import '@nomiclabs/hardhat-solhint';
7 | import '@primitivefi/hardhat-dodoc';
8 |
9 | const config: HardhatUserConfig = {
10 | solidity: {
11 | version: '0.8.17',
12 | settings: {
13 | optimizer: {
14 | enabled: true,
15 | runs: 200,
16 | },
17 | },
18 | },
19 | gasReporter: {
20 | enabled: true,
21 | },
22 | dodoc: {
23 | runOnCompile: false,
24 | debugMode: true,
25 | outputDir: "./docgen",
26 | freshOutput: true,
27 | },
28 | };
29 |
30 | export default config;
31 |
--------------------------------------------------------------------------------
/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:recommended",
3 | "rules": {
4 | "compiler-version": ["error", "^0.8.17"],
5 | "func-visibility": ["warn", { "ignoreConstructors": true }],
6 | "reentrancy": "error",
7 | "state-visibility": "error",
8 | "quotes": ["error", "double"],
9 | "const-name-snakecase": "error",
10 | "contract-name-camelcase": "error",
11 | "event-name-camelcase": "error",
12 | "func-name-mixedcase": "error",
13 | "func-param-name-mixedcase": "error",
14 | "modifier-name-mixedcase": "error",
15 | "private-vars-leading-underscore": ["error", { "strict": false }],
16 | "use-forbidden-name": "error",
17 | "var-name-mixedcase": "error",
18 | "imports-on-top": "error",
19 | "ordering": "error",
20 | "visibility-modifier-order": "error",
21 | "code-complexity": ["error", 7],
22 | "function-max-lines": ["error", 50],
23 | "max-line-length": ["error", 130],
24 | "max-states-count": ["error", 15],
25 | "no-empty-blocks": "error",
26 | "no-unused-vars": "error",
27 | "payable-fallback": "error",
28 | "constructor-syntax": "error",
29 | "not-rely-on-time": "off",
30 | "reason-string": "off",
31 | "no-global-import": "off"
32 | },
33 | "plugins": ["prettier"]
34 | }
35 |
--------------------------------------------------------------------------------
/.github/workflows/push_checking.yml:
--------------------------------------------------------------------------------
1 | name: Test workflow
2 | on: pull_request
3 | jobs:
4 | lint:
5 | name: Lint sources
6 | runs-on: ubuntu-latest
7 | strategy:
8 | matrix:
9 | node-version: [16.x]
10 |
11 | steps:
12 | - name: Checkout
13 | uses: 'actions/checkout@v4'
14 |
15 | - name: Set Node.js
16 | uses: actions/setup-node@v3
17 | with:
18 | node-version: ${{ matrix.node-version }}
19 | - name: Install dependencies
20 | run: npm ci
21 | - name: Lint Solidity sources
22 | run: npm run lint:sol
23 | - name: Lint TypeScript sources
24 | run: npm run lint:ts
25 |
26 | unit_test:
27 | name: Unit tests
28 | runs-on: ubuntu-latest
29 | strategy:
30 | matrix:
31 | node-version: [16.x]
32 |
33 | steps:
34 | - name: Checkout
35 | uses: 'actions/checkout@master'
36 |
37 | - name: Set Node.js
38 | uses: actions/setup-node@v3
39 | with:
40 | node-version: ${{ matrix.node-version }}
41 |
42 | - name: Install dependencies
43 | run: npm ci
44 | - name: Build application
45 | run: npm run build
46 | - name: Run test coverage
47 | run: npm run coverage
48 | - name: Upload coverage to action results
49 | uses: actions/upload-artifact@v4
50 | with:
51 | path: |
52 | coverage/
53 | coverage.json
54 |
--------------------------------------------------------------------------------
/.github/workflows/publish-release.yml:
--------------------------------------------------------------------------------
1 | name: Publish Release Package
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | build:
9 | if: '!github.event.release.prerelease'
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: actions/setup-node@v3
14 | with:
15 | node-version: 16
16 | - run: npm ci
17 | - run: npm run build
18 | - name: Run test coverage
19 | run: npm run coverage
20 | - name: Zip coverage results
21 | run: zip -r coverage.zip "coverage/" "coverage.json"
22 | - name: Upload artifacts to release
23 | uses: softprops/action-gh-release@v1
24 | if: ${{startsWith(github.ref, 'refs/tags/') }}
25 | with:
26 | files: coverage.zip
27 |
28 | publish-npm:
29 | needs: build
30 | runs-on: ubuntu-latest
31 | steps:
32 | - uses: actions/checkout@v3
33 | - uses: actions/setup-node@v3
34 | with:
35 | node-version: 16
36 | registry-url: https://registry.npmjs.org/
37 | - run: npm ci
38 | - run: npm run build
39 | - run: npm publish
40 | env:
41 | NODE_AUTH_TOKEN: ${{secrets.npm_token}}
42 |
43 | publish-gpr:
44 | needs: build
45 | runs-on: ubuntu-latest
46 | steps:
47 | - uses: actions/checkout@v3
48 | - uses: actions/setup-node@v3
49 | with:
50 | node-version: 16
51 | registry-url: https://npm.pkg.github.com/
52 | scope: '@tokenysolutions'
53 | - run: npm ci
54 | - run: npm run build
55 | - run: npm publish
56 | env:
57 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
58 |
--------------------------------------------------------------------------------
/.github/workflows/publish-prerelease.yml:
--------------------------------------------------------------------------------
1 | name: Publish Beta Package
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | build:
9 | if: 'github.event.release.prerelease'
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: actions/setup-node@v3
14 | with:
15 | node-version: 16
16 | - run: npm ci
17 | - run: npm run build
18 | - name: Run test coverage
19 | run: npm run coverage
20 | - name: Zip coverage results
21 | run: zip -r coverage.zip "coverage/" "coverage.json"
22 | - name: Upload artifacts to release
23 | uses: softprops/action-gh-release@v1
24 | if: ${{startsWith(github.ref, 'refs/tags/') }}
25 | with:
26 | files: coverage.zip
27 |
28 | publish-npm:
29 | needs: build
30 | runs-on: ubuntu-latest
31 | steps:
32 | - uses: actions/checkout@v3
33 | - uses: actions/setup-node@v3
34 | with:
35 | node-version: 16
36 | registry-url: https://registry.npmjs.org/
37 | - run: npm ci
38 | - run: npm run build
39 | - run: npm publish --tag beta
40 | env:
41 | NODE_AUTH_TOKEN: ${{secrets.npm_token}}
42 |
43 | publish-gpr:
44 | needs: build
45 | runs-on: ubuntu-latest
46 | steps:
47 | - uses: actions/checkout@v3
48 | - uses: actions/setup-node@v3
49 | with:
50 | node-version: 16
51 | registry-url: https://npm.pkg.github.com/
52 | scope: '@tokenysolutions'
53 | - run: npm ci
54 | - run: npm run build
55 | - run: npm publish --tag beta
56 | env:
57 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
58 |
--------------------------------------------------------------------------------
/scripts/flatten.js:
--------------------------------------------------------------------------------
1 | const glob = require('glob');
2 | const fs = require('fs-extra');
3 | const { spawnSync } = require('child_process');
4 |
5 | // Get a list of all solidity files in the contracts directory
6 | const files = glob.sync('contracts/**/*.sol');
7 |
8 | let processedCount = 0; // to keep track of processed files
9 |
10 | files.forEach((file) => {
11 | processedCount += 1;
12 |
13 | console.log(`[${processedCount}/${files.length}] Flattening: ${file} ...`);
14 |
15 | // Generate the output file path
16 | const outputFilePath = file.replace('contracts', 'flat');
17 |
18 | // Ensure the output directory exists
19 | fs.ensureDirSync(outputFilePath.substring(0, outputFilePath.lastIndexOf('/')));
20 |
21 | // Flatten the contract and write it directly to the output file
22 | const flatten = spawnSync('npx', ['hardhat', 'flatten', file], {
23 | stdio: ['ignore', fs.openSync(outputFilePath, 'w'), 'inherit'],
24 | });
25 |
26 | if (flatten.error) {
27 | console.error(`Error flattening ${file}: ${flatten.error.message}`);
28 | } else {
29 | // Read the file back
30 | const flattenedContent = fs.readFileSync(outputFilePath, 'utf-8');
31 |
32 | // Process content
33 | let modifiedContent = flattenedContent
34 | .split('\n')
35 | .filter((line) => !line.trim().startsWith('// SPDX-License-Identifier') && !line.trim().startsWith('pragma solidity'))
36 | .join('\n')
37 | .replace(/\n{3,}/g, '\n\n');
38 |
39 | // Add the single SPDX and pragma declaration at the top
40 | modifiedContent = `// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.17;\n\n${modifiedContent}`;
41 |
42 | // Write the modified content back to the file
43 | fs.writeFileSync(outputFilePath, modifiedContent);
44 |
45 | console.log(`[${processedCount}/${files.length}] Flattened: ${file}`);
46 | }
47 | });
48 |
49 | console.log('All files processed!');
50 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "@typescript-eslint/parser",
3 | "extends": [
4 | "eslint-config-airbnb-base",
5 | "plugin:@typescript-eslint/recommended",
6 | "prettier"
7 | ],
8 | "env": {
9 | "node": true,
10 | "mocha": true
11 | },
12 | "globals": {
13 | "expect": true,
14 | "artifacts": true,
15 | "contract": true
16 | },
17 | "plugins": [
18 | "prettier",
19 | "security",
20 | "@typescript-eslint",
21 | "chai-friendly"
22 | ],
23 | "settings": {
24 | "import/resolver": {
25 | "typescript": {},
26 | "node": {
27 | "extensions": [".js", ".jsx", ".ts", ".tsx"]
28 | }
29 | }
30 | },
31 | "rules": {
32 | "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
33 | "camelcase": 0,
34 | "chai-friendly/no-unused-expressions": 2,
35 | "comma-dangle": ["error", "always-multiline"],
36 | "dot-notation": 0,
37 | "function-paren-newline": 0,
38 | "max-len": ["error", { "code": 150 }],
39 | "no-confusing-arrow": 0,
40 | "no-console": 0,
41 | "no-else-return": 0,
42 | "no-multiple-empty-lines": ["error", { "max": 3 }],
43 | "no-param-reassign": 0,
44 | "no-unused-expressions": 0,
45 | "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
46 | "no-use-before-define": 0,
47 | "object-curly-newline": ["error", { "consistent": true }],
48 | "object-shorthand": 0,
49 | "padded-blocks": 0,
50 | "prefer-destructuring": 0,
51 | "prettier/prettier": "error",
52 | "quote-props": ["error", "as-needed"],
53 | "strict": 0,
54 | "no-undef": "off",
55 | "no-await-in-loop": "off",
56 | "import/no-extraneous-dependencies": "off",
57 | "import/extensions": [
58 | "error",
59 | "ignorePackages",
60 | {
61 | "js": "never",
62 | "jsx": "never",
63 | "ts": "never",
64 | "tsx": "never"
65 | }
66 | ]
67 | }
68 | }
--------------------------------------------------------------------------------
/contracts/_testContracts/v_3_5_2/LegacyProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity 0.8.17;
4 |
5 | interface IImplementationAuthorityLegacy {
6 | function getImplementation() external view returns (address);
7 | }
8 |
9 | contract LegacyProxy {
10 | address public implementationAuthority;
11 |
12 | constructor(
13 | address _implementationAuthority,
14 | address _identityRegistry,
15 | address _compliance,
16 | string memory _name,
17 | string memory _symbol,
18 | uint8 _decimals,
19 | address _onchainID
20 | ) {
21 | implementationAuthority = _implementationAuthority;
22 |
23 | address logic = IImplementationAuthorityLegacy(implementationAuthority).getImplementation();
24 |
25 | // solhint-disable-next-line avoid-low-level-calls
26 | (bool success, ) =
27 | logic.delegatecall(
28 | abi.encodeWithSignature(
29 | 'init(address,address,string,string,uint8,address)',
30 | _identityRegistry,
31 | _compliance,
32 | _name,
33 | _symbol,
34 | _decimals,
35 | _onchainID
36 | )
37 | );
38 | require(success, 'Initialization failed.');
39 | }
40 |
41 | fallback() external payable {
42 | address logic = IImplementationAuthorityLegacy(implementationAuthority).getImplementation();
43 |
44 | assembly {
45 | // solium-disable-line
46 | calldatacopy(0x0, 0x0, calldatasize())
47 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
48 | let retSz := returndatasize()
49 | returndatacopy(0, 0, retSz)
50 | switch success
51 | case 0 {
52 | revert(0, retSz)
53 | }
54 | default {
55 | return(0, retSz)
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to T-REX Protocol
2 |
3 | We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4 |
5 | - Reporting a bug
6 | - Discussing the current state of the code
7 | - Submitting a fix
8 | - Proposing new features
9 |
10 | ## We Develop with Github
11 |
12 | We use Github to host code, to track issues and feature requests, as well as accept pull requests.
13 |
14 | ## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
15 |
16 | Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
17 |
18 | 1. Fork the repo and create your branch from `main`.
19 | 2. If you've added code that should be tested, add tests. Our test suite uses TypeScript and Hardhat.
20 | 3. Ensure the test suite passes. Tests are automated and any PR will trigger them automatically.
21 | 4. Make sure your code lints. We use [Solhint](https://github.com/protofire/solhint) for Solidity and [ESLint](https://eslint.org/) for TypeScript.
22 | 5. Issue that pull request!
23 |
24 | ## Any contributions you make will be under the GPL v3 Software License
25 |
26 | In short, when you submit code changes, your submissions are understood to be under the same [GNU General Public License v3.0](http://www.gnu.org/licenses/gpl-3.0.html) that covers the project. Feel free to contact the maintainers if that's a concern.
27 |
28 | ## Report bugs using Github's [issues](https://github.com/TokenySolutions/T-REX/issues)
29 |
30 | We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/TokenySolutions/T-REX/issues/new); it's that easy!
31 |
32 | ## Write bug reports with detail, background, and sample code
33 |
34 | Great Bug Reports tend to have:
35 |
36 | - A quick summary and/or background
37 | - Steps to reproduce
38 | - Be specific!
39 | - Give sample code if you can.
40 | - What you expected would happen
41 | - What actually happens
42 |
43 | ## Use a Consistent Coding Style
44 |
45 | We're using [Solhint](https://github.com/protofire/solhint) for Solidity and [ESLint](https://eslint.org/) for TypeScript. Make sure your code follows the style guide.
46 |
47 | ## Commit Messages
48 |
49 | We encourage the use of [Gitmoji](https://gitmoji.dev/) for commit messages. It's a fun and easy way to identify the purpose or intent of a commit with a simple emoji.
50 |
51 | ## License
52 |
53 | By contributing, you agree that your contributions will be licensed under its GPL v3 License.
54 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tokenysolutions/t-rex",
3 | "version": "4.1.6",
4 | "description": "A fully compliant environment for the issuance and use of tokenized securities.",
5 | "main": "index.js",
6 | "directories": {
7 | "doc": "docs",
8 | "test": "test"
9 | },
10 | "files": [
11 | "artifacts",
12 | "contracts",
13 | "index.js",
14 | "index.d.ts",
15 | "!contract/_testContracts",
16 | "!artifacts/contracts/_testContracts",
17 | "!contract/Migrations.sol",
18 | "!artifacts/contracts/Migrations.sol",
19 | "!artifacts/build-info"
20 | ],
21 | "scripts": {
22 | "build": "hardhat compile",
23 | "flatten": "node scripts/flatten.js",
24 | "coverage": "hardhat coverage",
25 | "test": "hardhat test",
26 | "lint:ts": "eslint \"test/**/*.ts\"",
27 | "lint:ts-fix": "eslint \"test/**/*.ts\" --fix",
28 | "lint": "npm run lint:sol",
29 | "lint:sol": "solhint \"contracts/**/*.sol\"",
30 | "docs": "hardhat dodoc",
31 | "prepare": "husky install"
32 | },
33 | "repository": {
34 | "type": "git",
35 | "url": "git+https://github.com/TokenySolutions/T-REX.git"
36 | },
37 | "author": "Tokeny Solutions",
38 | "license": "SEE LICENSE IN LICENSE.md",
39 | "bugs": {
40 | "url": "https://github.com/TokenySolutions/T-REX/issues"
41 | },
42 | "homepage": "https://github.com/TokenySolutions/T-REX#README",
43 | "devDependencies": {
44 | "@commitlint/cli": "^17.6.1",
45 | "@nomicfoundation/hardhat-toolbox": "^2.0.2",
46 | "@nomiclabs/hardhat-solhint": "^3.0.1",
47 | "@onchain-id/solidity": "^2.0.0",
48 | "@openzeppelin/contracts": "^4.8.3",
49 | "@openzeppelin/contracts-upgradeable": "^4.8.3",
50 | "@openzeppelin/hardhat-upgrades": "^1.28.0",
51 | "@primitivefi/hardhat-dodoc": "^0.2.3",
52 | "@xyrusworx/hardhat-solidity-json": "^1.0.2",
53 | "eslint": "^8.39.0",
54 | "eslint-config-airbnb-base": "^15.0.0",
55 | "eslint-config-prettier": "^8.8.0",
56 | "eslint-plugin-chai-friendly": "^0.7.2",
57 | "eslint-plugin-import": "^2.27.5",
58 | "eslint-plugin-prettier": "^4.2.1",
59 | "eslint-plugin-security": "^1.7.1",
60 | "hardhat": "^2.14.0",
61 | "husky": "^8.0.3",
62 | "lint-staged": "^13.2.2",
63 | "prettier": "^2.8.8",
64 | "prettier-plugin-solidity": "^1.1.3",
65 | "solhint": "^3.4.1",
66 | "solhint-plugin-prettier": "^0.0.5",
67 | "glob": "^10.2.6",
68 | "fs-extra": "^11.1.1",
69 | "@typescript-eslint/parser": "^6.7.4",
70 | "@typescript-eslint/eslint-plugin": "^6.7.4",
71 | "eslint-import-resolver-typescript": "^3.6.1",
72 | "eth-gas-reporter": "^0.2.27"
73 | },
74 | "lint-staged": {
75 | "*.js": [
76 | "eslint"
77 | ]
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/contracts/_testContracts/v_3_5_2/LegacyIA.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity 0.8.17;
4 |
5 | abstract contract ContextLegacy {
6 | function _msgSender() internal view virtual returns (address) {
7 | return msg.sender;
8 | }
9 |
10 | function _msgData() internal view virtual returns (bytes calldata) {
11 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
12 | return msg.data;
13 | }
14 | }
15 |
16 |
17 | abstract contract OwnableLegacy is ContextLegacy {
18 | address private _owner;
19 |
20 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
21 |
22 | /**
23 | * @dev Initializes the contract setting the deployer as the initial owner.
24 | */
25 | constructor () {
26 | address msgSender = _msgSender();
27 | _owner = msgSender;
28 | emit OwnershipTransferred(address(0), msgSender);
29 | }
30 |
31 | /**
32 | * @dev Returns the address of the current owner.
33 | */
34 | function owner() public view virtual returns (address) {
35 | return _owner;
36 | }
37 |
38 | /**
39 | * @dev Throws if called by any account other than the owner.
40 | */
41 | modifier onlyOwner() {
42 | require(owner() == _msgSender(), "OwnableLegacy: caller is not the owner");
43 | _;
44 | }
45 |
46 | /**
47 | * @dev Leaves the contract without owner. It will not be possible to call
48 | * `onlyOwner` functions anymore. Can only be called by the current owner.
49 | *
50 | * NOTE: Renouncing ownership will leave the contract without an owner,
51 | * thereby removing any functionality that is only available to the owner.
52 | */
53 | function renounceOwnership() public virtual onlyOwner {
54 | emit OwnershipTransferred(_owner, address(0));
55 | _owner = address(0);
56 | }
57 |
58 | /**
59 | * @dev Transfers ownership of the contract to a new account (`newOwner`).
60 | * Can only be called by the current owner.
61 | */
62 | function transferOwnership(address newOwner) public virtual onlyOwner {
63 | require(newOwner != address(0), "OwnableLegacy: new owner is the zero address");
64 | emit OwnershipTransferred(_owner, newOwner);
65 | _owner = newOwner;
66 | }
67 | }
68 |
69 |
70 | contract LegacyIA is OwnableLegacy {
71 | event UpdatedImplementation(address newAddress);
72 |
73 | address public implementation;
74 |
75 | constructor(address _implementation) {
76 | implementation = _implementation;
77 | emit UpdatedImplementation(_implementation);
78 | }
79 |
80 | function getImplementation() external view returns (address) {
81 | return implementation;
82 | }
83 |
84 | function updateImplementation(address _newImplementation) public onlyOwner {
85 | implementation = _newImplementation;
86 | emit UpdatedImplementation(_newImplementation);
87 | }
88 | }
--------------------------------------------------------------------------------
/test/registries/claim-topics-registry.test.ts:
--------------------------------------------------------------------------------
1 | import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2 | import { expect } from 'chai';
3 | import { deployFullSuiteFixture } from '../fixtures/deploy-full-suite.fixture';
4 |
5 | describe('ClaimTopicsRegistry', () => {
6 | describe('.init', () => {
7 | describe('when contract was already initialized', () => {
8 | it('should revert', async () => {
9 | const {
10 | suite: { claimTopicsRegistry },
11 | } = await loadFixture(deployFullSuiteFixture);
12 |
13 | await expect(claimTopicsRegistry.init()).to.be.revertedWith('Initializable: contract is already initialized');
14 | });
15 | });
16 | });
17 |
18 | describe('.addClaimTopic', () => {
19 | describe('when sender is not owner', () => {
20 | it('should revert', async () => {
21 | const {
22 | suite: { claimTopicsRegistry },
23 | accounts: { anotherWallet },
24 | } = await loadFixture(deployFullSuiteFixture);
25 |
26 | await expect(claimTopicsRegistry.connect(anotherWallet).addClaimTopic(1)).to.be.revertedWith('Ownable: caller is not the owner');
27 | });
28 | });
29 |
30 | describe('when sender is owner', () => {
31 | describe('when topic array contains more than 14 elements', () => {
32 | it('should revert', async () => {
33 | const {
34 | suite: { claimTopicsRegistry },
35 | accounts: { deployer },
36 | } = await loadFixture(deployFullSuiteFixture);
37 |
38 | await Promise.all(Array.from({ length: 14 }, (_, i) => i).map((i) => claimTopicsRegistry.addClaimTopic(i)));
39 |
40 | await expect(claimTopicsRegistry.connect(deployer).addClaimTopic(14)).to.be.revertedWith('cannot require more than 15 topics');
41 | });
42 | });
43 |
44 | describe('when adding a topic that is already added', () => {
45 | it('should revert', async () => {
46 | const {
47 | suite: { claimTopicsRegistry },
48 | accounts: { deployer },
49 | } = await loadFixture(deployFullSuiteFixture);
50 |
51 | await claimTopicsRegistry.addClaimTopic(1);
52 |
53 | await expect(claimTopicsRegistry.connect(deployer).addClaimTopic(1)).to.be.revertedWith('claimTopic already exists');
54 | });
55 | });
56 | });
57 | });
58 |
59 | describe('.removeClaimTopic', () => {
60 | describe('when sender is not owner', () => {
61 | it('should revert', async () => {
62 | const {
63 | suite: { claimTopicsRegistry },
64 | accounts: { anotherWallet },
65 | } = await loadFixture(deployFullSuiteFixture);
66 |
67 | await expect(claimTopicsRegistry.connect(anotherWallet).removeClaimTopic(1)).to.be.revertedWith('Ownable: caller is not the owner');
68 | });
69 | });
70 |
71 | describe('when sender is owner', () => {
72 | it('should remove claim topic', async () => {
73 | const {
74 | suite: { claimTopicsRegistry },
75 | accounts: { deployer },
76 | } = await loadFixture(deployFullSuiteFixture);
77 |
78 | await claimTopicsRegistry.addClaimTopic(1);
79 | await claimTopicsRegistry.addClaimTopic(2);
80 | await claimTopicsRegistry.addClaimTopic(3);
81 |
82 | const tx = await claimTopicsRegistry.connect(deployer).removeClaimTopic(2);
83 | await expect(tx).to.emit(claimTopicsRegistry, 'ClaimTopicRemoved').withArgs(2);
84 | });
85 | });
86 | });
87 | });
88 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## ⚠️ This repository is DEPRECATED and no longer maintained ⚠️
2 | Please see [https://github.com/ERC-3643/ERC-3643](https://github.com/ERC-3643/ERC-3643)
3 |
4 | # T-REX : Token for Regulated EXchanges
5 |
6 | 
7 | 
8 | 
9 | 
10 | 
11 |
12 |
13 |
14 |
15 | ----
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | ## Overview
27 |
28 | The T-REX (Token for Regulated EXchanges) protocol is a comprehensive suite of Solidity smart contracts,
29 | implementing the [ERC-3643 standard](https://eips.ethereum.org/EIPS/eip-3643) and designed to enable the issuance, management, and transfer of security
30 | tokens in
31 | compliance with regulations. It ensures secure and compliant transactions for all parties involved in the token exchange.
32 |
33 | ## Key Components
34 |
35 | The T-REX protocol consists of several key components:
36 |
37 | - **[ONCHAINID](https://github.com/onchain-id/solidity)**: A smart contract deployed by a user to interact with the security token or any other application
38 | where an on-chain identity may be relevant. It stores keys and claims related to a specific identity.
39 |
40 | - **Trusted Issuers Registry**: This contract houses the addresses of all trusted claim issuers associated with a specific token.
41 |
42 | - **Claim Topics Registry**: This contract maintains a list of all trusted claim topics related to the security token.
43 |
44 | - **Identity Registry**: This contract holds the identity contract addresses of all eligible users authorized to hold the token. It is responsible for claim verification.
45 |
46 | - **Compliance Smart Contract**: This contract independently operates to check whether a transfer is in compliance with the established rules for the token.
47 |
48 | - **Security Token Contract**: This contract interacts with the Identity Registry to check the eligibility status of investors, enabling token holding and transactions.
49 |
50 | ## Getting Started
51 |
52 | 1. Clone the repository: `git clone https://github.com/TokenySolutions/T-REX.git`
53 | 2. Install dependencies: `npm ci`
54 | 3. Compile the contracts: `hardhat compile`
55 | 4. Run tests: `hardhat test`
56 |
57 | ## Documentation
58 |
59 | For a detailed understanding of the T-REX protocol, please refer to the [whitepaper](./docs/TREX-WhitePaper.pdf).
60 | All functions of T-REX smart contracts are described in the [T-REX documentation](https://docs.tokeny.com/docs/smart-contracts)
61 |
62 | ## Contributing
63 |
64 | We welcome contributions from the community. Please refer to the [CONTRIBUTING](./CONTRIBUTING.md) guide for more details.
65 |
66 | ## License
67 |
68 | This project is licensed under the [GNU General Public License v3.0](./LICENSE.md).
69 |
70 | ----
71 |
72 |
77 |
78 | ----
79 |
--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | type ContractJSON = {
2 | _format: string;
3 | contractName: string;
4 | sourcename: string;
5 | abi: any[];
6 | bytecode: string;
7 | deployedBytecode: string;
8 | linkReferences: any;
9 | }
10 |
11 | export namespace contracts {
12 | // Token
13 | export const Token: ContractJSON;
14 | export const TokenStorage: ContractJSON;
15 | // Roles
16 | export const AgentRole: ContractJSON;
17 | export const AgentRoleUpgradeable: ContractJSON;
18 | export const Roles: ContractJSON;
19 | // Roles/permissioning/agent
20 | export const AgentManager: ContractJSON;
21 | export const AgentRoles: ContractJSON;
22 | export const AgentRolesUpgradeable: ContractJSON;
23 | // Roles/permissioning/owner
24 | export const OwnerManager: ContractJSON;
25 | export const OwnerRoles: ContractJSON;
26 | export const OwnerRolesUpgradeable: ContractJSON;
27 | // registry
28 | export const ClaimTopicsRegistry: ContractJSON;
29 | export const IdentityRegistry: ContractJSON;
30 | export const IdentityRegistryStorage: ContractJSON;
31 | export const TrustedIssuersRegistry: ContractJSON;
32 | // registry/Storage
33 | export const CTRStorage: ContractJSON;
34 | export const IRSStorage: ContractJSON;
35 | export const IRStorage: ContractJSON;
36 | export const TIRStorage: ContractJSON;
37 | // proxy
38 | export const AbstractProxy: ContractJSON;
39 | export const ClaimTopicsRegistryProxy: ContractJSON;
40 | export const IdentityRegistryProxy: ContractJSON;
41 | export const IdentityRegistryStorageProxy: ContractJSON;
42 | export const ModularComplianceProxy: ContractJSON;
43 | export const TokenProxy: ContractJSON;
44 | export const TrustedIssuersRegistryProxy: ContractJSON;
45 | // proxy/authority
46 | export const TREXImplementationAuthority: ContractJSON;
47 | // factory
48 | export const TREXFactory: ContractJSON;
49 | // gateway
50 | export const TREXGateway: ContractJSON;
51 | // DVD
52 | export const DVDTransferManager: ContractJSON;
53 | // DVA
54 | export const DVATransferManager: ContractJSON;
55 | // compliance
56 | export const MCStorage: ContractJSON;
57 | export const ModularCompliance: ContractJSON;
58 | // compliance/modular/modules
59 | export const AbstractModule: ContractJSON;
60 | export const AbstractModuleUpgradeable: ContractJSON;
61 | export const ModuleProxy: ContractJSON;
62 | export const ConditionalTransferModule: ContractJSON;
63 | export const CountryAllowModule: ContractJSON;
64 | export const CountryRestrictModule: ContractJSON;
65 | export const MaxBalanceModule: ContractJSON;
66 | export const ExchangeMonthlyLimitsModule: ContractJSON;
67 | export const TimeExchangeLimitsModule: ContractJSON;
68 | export const TimeTransfersLimitsModule: ContractJSON;
69 | export const SupplyLimitModule: ContractJSON;
70 | export const TransferFeesModule: ContractJSON;
71 | export const TransferRestrictModule: ContractJSON;
72 |
73 | export const TokenListingRestrictionsModule: ContractJSON;
74 | }
75 |
76 | export namespace interfaces {
77 | export const IToken: ContractJSON;
78 | export const IClaimTopicsRegistry: ContractJSON;
79 | export const IIdentityRegistry: ContractJSON;
80 | export const IIdentityRegistryStorage: ContractJSON;
81 | export const ITrustedIssuersRegistry: ContractJSON;
82 | export const IProxy: ContractJSON;
83 | export const IAFactory: ContractJSON;
84 | export const IIAFactory: ContractJSON;
85 | export const ITREXImplementationAuthority: ContractJSON;
86 | export const ITREXFactory: ContractJSON;
87 | export const ITREXGateway: ContractJSON;
88 | export const IModularCompliance: ContractJSON;
89 | export const IModule: ContractJSON;
90 |
91 | export const IDVATransferManager: ContractJSON;
92 | }
93 |
--------------------------------------------------------------------------------
/contracts/compliance/modular/modules/ModuleProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
66 |
67 | contract ModuleProxy is ERC1967Proxy {
68 | // solhint-disable-next-line no-empty-blocks
69 | constructor(address implementation, bytes memory _data) ERC1967Proxy(implementation, _data) { }
70 | }
--------------------------------------------------------------------------------
/contracts/proxy/interface/IProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | interface IProxy {
66 |
67 | /// events
68 |
69 | event ImplementationAuthoritySet(address indexed _implementationAuthority);
70 |
71 | /// functions
72 |
73 | function setImplementationAuthority(address _newImplementationAuthority) external;
74 |
75 | function getImplementationAuthority() external view returns(address);
76 | }
77 |
--------------------------------------------------------------------------------
/contracts/registry/storage/CTRStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | contract CTRStorage {
67 | /// @dev All required Claim Topics
68 | uint256[] internal _claimTopics;
69 |
70 | /**
71 | * @dev This empty reserved space is put in place to allow future versions to add new
72 | * variables without shifting down storage in the inheritance chain.
73 | */
74 | uint256[49] private __gap;
75 | }
--------------------------------------------------------------------------------
/contracts/_testContracts/TestUpgradedCountryAllowModule.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../compliance/modular/modules/CountryAllowModule.sol";
66 |
67 | contract TestUpgradedCountryAllowModule is CountryAllowModule {
68 | /// new field
69 | uint256 private _newField;
70 |
71 | // setter for _newField
72 | function setNewField(uint256 value) external onlyOwner {
73 | _newField = value;
74 | }
75 |
76 | // getter for _newField
77 | function getNewField() external view returns (uint256) {
78 | return _newField;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/contracts/_testContracts/TestERC20.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts developed by Tokeny to manage and transfer financial assets on the ethereum blockchain
45 | *
46 | * Copyright (C) 2022, Tokeny sàrl.
47 | *
48 | * This program is free software: you can redistribute it and/or modify
49 | * it under the terms of the GNU General Public License as published by
50 | * the Free Software Foundation, either version 3 of the License, or
51 | * (at your option) any later version.
52 | *
53 | * This program is distributed in the hope that it will be useful,
54 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
55 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 | * GNU General Public License for more details.
57 | *
58 | * You should have received a copy of the GNU General Public License
59 | * along with this program. If not, see .
60 | */
61 | pragma solidity 0.8.17;
62 |
63 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";
64 | import "@openzeppelin/contracts/access/Ownable.sol";
65 |
66 | contract TestERC20 is Ownable, ERC20Pausable {
67 |
68 | constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
69 |
70 | function pause() public onlyOwner {
71 | _pause();
72 | }
73 |
74 | function mint(address recipient, uint256 amount) public onlyOwner {
75 | _mint(recipient, amount);
76 | }
77 |
78 | function unpause() public onlyOwner {
79 | _unpause();
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/contracts/compliance/modular/MCStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | contract MCStorage {
67 | /// token linked to the compliance contract
68 | address internal _tokenBound;
69 |
70 | /// Array of modules bound to the compliance
71 | address[] internal _modules;
72 |
73 | /// Mapping of module binding status
74 | mapping(address => bool) internal _moduleBound;
75 |
76 | /**
77 | * @dev This empty reserved space is put in place to allow future versions to add new
78 | * variables without shifting down storage in the inheritance chain.
79 | */
80 | uint256[49] private __gap;
81 | }
82 |
--------------------------------------------------------------------------------
/contracts/registry/storage/IRSStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "@onchain-id/solidity/contracts/interface/IIdentity.sol";
67 |
68 | contract IRSStorage {
69 | /// @dev struct containing the identity contract and the country of the user
70 | struct Identity {
71 | IIdentity identityContract;
72 | uint16 investorCountry;
73 | }
74 | /// @dev mapping between a user address and the corresponding identity
75 | mapping(address => Identity) internal _identities;
76 |
77 | /// @dev array of Identity Registries linked to this storage
78 | address[] internal _identityRegistries;
79 |
80 | /**
81 | * @dev This empty reserved space is put in place to allow future versions to add new
82 | * variables without shifting down storage in the inheritance chain.
83 | */
84 | uint256[49] private __gap;
85 | }
--------------------------------------------------------------------------------
/contracts/registry/storage/IRStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "../interface/IClaimTopicsRegistry.sol";
67 | import "../interface/ITrustedIssuersRegistry.sol";
68 | import "../interface/IIdentityRegistryStorage.sol";
69 |
70 | contract IRStorage {
71 | /// @dev Address of the ClaimTopicsRegistry Contract
72 | IClaimTopicsRegistry internal _tokenTopicsRegistry;
73 |
74 | /// @dev Address of the TrustedIssuersRegistry Contract
75 | ITrustedIssuersRegistry internal _tokenIssuersRegistry;
76 |
77 | /// @dev Address of the IdentityRegistryStorage Contract
78 | IIdentityRegistryStorage internal _tokenIdentityStorage;
79 |
80 | /**
81 | * @dev This empty reserved space is put in place to allow future versions to add new
82 | * variables without shifting down storage in the inheritance chain.
83 | */
84 | uint256[49] private __gap;
85 | }
--------------------------------------------------------------------------------
/contracts/registry/storage/TIRStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol";
67 |
68 | contract TIRStorage {
69 | /// @dev Array containing all TrustedIssuers identity contract address.
70 | IClaimIssuer[] internal _trustedIssuers;
71 |
72 | /// @dev Mapping between a trusted issuer address and its corresponding claimTopics.
73 | mapping(address => uint256[]) internal _trustedIssuerClaimTopics;
74 |
75 | /// @dev Mapping between a claim topic and the allowed trusted issuers for it.
76 | mapping(uint256 => IClaimIssuer[]) internal _claimTopicsToTrustedIssuers;
77 |
78 | /**
79 | * @dev This empty reserved space is put in place to allow future versions to add new
80 | * variables without shifting down storage in the inheritance chain.
81 | */
82 | uint256[49] private __gap;
83 | }
84 |
--------------------------------------------------------------------------------
/test/token/token-recovery.test.ts:
--------------------------------------------------------------------------------
1 | import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2 | import { expect } from 'chai';
3 | import { ethers } from 'hardhat';
4 | import { deployFullSuiteFixture } from '../fixtures/deploy-full-suite.fixture';
5 |
6 | describe('Token - Recovery', () => {
7 | describe('.recoveryAddress()', () => {
8 | describe('when sender is not an agent', () => {
9 | it('should reverts', async () => {
10 | const {
11 | suite: { token },
12 | accounts: { bobWallet, anotherWallet },
13 | identities: { bobIdentity },
14 | } = await loadFixture(deployFullSuiteFixture);
15 |
16 | await bobIdentity
17 | .connect(bobWallet)
18 | .addKey(ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(['address'], [anotherWallet.address])), 1, 1);
19 |
20 | await expect(token.connect(anotherWallet).recoveryAddress(bobWallet.address, anotherWallet.address, bobIdentity.address)).to.be.revertedWith(
21 | 'AgentRole: caller does not have the Agent role',
22 | );
23 | });
24 | });
25 |
26 | describe('when sender is an agent', () => {
27 | describe('when wallet to recover has no balance', () => {
28 | it('should revert', async () => {
29 | const {
30 | suite: { token },
31 | accounts: { tokenAgent, aliceWallet, bobWallet, anotherWallet },
32 | identities: { bobIdentity },
33 | } = await loadFixture(deployFullSuiteFixture);
34 |
35 | await token.connect(bobWallet).transfer(aliceWallet.address, await token.balanceOf(bobWallet.address));
36 |
37 | await expect(token.connect(tokenAgent).recoveryAddress(bobWallet.address, anotherWallet.address, bobIdentity.address)).to.be.revertedWith(
38 | 'no tokens to recover',
39 | );
40 | });
41 | });
42 |
43 | describe('when new wallet is not authorized on the identity', () => {
44 | it('should revert', async () => {
45 | const {
46 | suite: { token },
47 | accounts: { tokenAgent, bobWallet, anotherWallet },
48 | identities: { bobIdentity },
49 | } = await loadFixture(deployFullSuiteFixture);
50 |
51 | await expect(token.connect(tokenAgent).recoveryAddress(bobWallet.address, anotherWallet.address, bobIdentity.address)).to.be.revertedWith(
52 | 'Recovery not possible',
53 | );
54 | });
55 | });
56 |
57 | describe('when wallet is frozen', () => {
58 | it('should recover and freeze the new wallet', async () => {
59 | const {
60 | suite: { token },
61 | accounts: { tokenAgent, bobWallet, anotherWallet },
62 | identities: { bobIdentity },
63 | } = await loadFixture(deployFullSuiteFixture);
64 |
65 | await bobIdentity
66 | .connect(bobWallet)
67 | .addKey(ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(['address'], [anotherWallet.address])), 1, 1);
68 |
69 | await token.connect(tokenAgent).setAddressFrozen(bobWallet.address, true);
70 |
71 | const tx = await token.connect(tokenAgent).recoveryAddress(bobWallet.address, anotherWallet.address, bobIdentity.address);
72 | await expect(token.isFrozen(anotherWallet.address)).to.be.eventually.true;
73 | await expect(tx).to.emit(token, 'RecoverySuccess').withArgs(bobWallet.address, anotherWallet.address, bobIdentity.address);
74 | await expect(tx).to.emit(token, 'AddressFrozen').withArgs(anotherWallet.address, true, tokenAgent.address);
75 | });
76 | });
77 |
78 | describe('when wallet has frozen token', () => {
79 | it('should recover and freeze tokens on the new wallet', async () => {
80 | const {
81 | suite: { token },
82 | accounts: { tokenAgent, bobWallet, anotherWallet },
83 | identities: { bobIdentity },
84 | } = await loadFixture(deployFullSuiteFixture);
85 |
86 | await bobIdentity
87 | .connect(bobWallet)
88 | .addKey(ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(['address'], [anotherWallet.address])), 1, 1);
89 |
90 | await token.connect(tokenAgent).freezePartialTokens(bobWallet.address, 50);
91 |
92 | const tx = await token.connect(tokenAgent).recoveryAddress(bobWallet.address, anotherWallet.address, bobIdentity.address);
93 | await expect(token.getFrozenTokens(anotherWallet.address)).to.be.eventually.eq(50);
94 | await expect(tx).to.emit(token, 'RecoverySuccess').withArgs(bobWallet.address, anotherWallet.address, bobIdentity.address);
95 | await expect(tx).to.emit(token, 'TokensFrozen').withArgs(anotherWallet.address, 50);
96 | });
97 | });
98 | });
99 | });
100 | });
101 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/DefaultCompliance.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./BasicCompliance.sol";
66 |
67 | contract DefaultCompliance is BasicCompliance {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | // solhint-disable-next-line no-empty-blocks
72 | function transferred(address _from, address _to, uint256 _value) external override {
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | // solhint-disable-next-line no-empty-blocks
79 | function created(address _to, uint256 _value) external override {
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | // solhint-disable-next-line no-empty-blocks
86 | function destroyed(address _from, uint256 _value) external override {
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address /*_from*/, address /*_to*/, uint256 /*_value*/) external view override returns (bool) {
93 | return true;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/contracts/roles/AgentRole.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "@openzeppelin/contracts/access/Ownable.sol";
67 |
68 | import "./Roles.sol";
69 |
70 | contract AgentRole is Ownable {
71 | using Roles for Roles.Role;
72 |
73 | Roles.Role private _agents;
74 |
75 | event AgentAdded(address indexed _agent);
76 | event AgentRemoved(address indexed _agent);
77 |
78 | modifier onlyAgent() {
79 | require(isAgent(msg.sender), "AgentRole: caller does not have the Agent role");
80 | _;
81 | }
82 |
83 | function addAgent(address _agent) public onlyOwner {
84 | require(_agent != address(0), "invalid argument - zero address");
85 | _agents.add(_agent);
86 | emit AgentAdded(_agent);
87 | }
88 |
89 | function removeAgent(address _agent) public onlyOwner {
90 | require(_agent != address(0), "invalid argument - zero address");
91 | _agents.remove(_agent);
92 | emit AgentRemoved(_agent);
93 | }
94 |
95 | function isAgent(address _agent) public view returns (bool) {
96 | return _agents.has(_agent);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/contracts/roles/AgentRoleUpgradeable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
67 |
68 | import "./Roles.sol";
69 |
70 | contract AgentRoleUpgradeable is OwnableUpgradeable {
71 | using Roles for Roles.Role;
72 |
73 | Roles.Role private _agents;
74 |
75 | event AgentAdded(address indexed _agent);
76 | event AgentRemoved(address indexed _agent);
77 |
78 | modifier onlyAgent() {
79 | require(isAgent(msg.sender), "AgentRole: caller does not have the Agent role");
80 | _;
81 | }
82 |
83 | function addAgent(address _agent) public onlyOwner {
84 | require(_agent != address(0), "invalid argument - zero address");
85 | _agents.add(_agent);
86 | emit AgentAdded(_agent);
87 | }
88 |
89 | function removeAgent(address _agent) public onlyOwner {
90 | require(_agent != address(0), "invalid argument - zero address");
91 | _agents.remove(_agent);
92 | emit AgentRemoved(_agent);
93 | }
94 |
95 | function isAgent(address _agent) public view returns (bool) {
96 | return _agents.has(_agent);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/contracts/roles/Roles.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | /**
67 | * @title Roles
68 | * @dev Library for managing addresses assigned to a Role.
69 | */
70 | library Roles {
71 | struct Role {
72 | mapping(address => bool) bearer;
73 | }
74 |
75 | /**
76 | * @dev Give an account access to this role.
77 | */
78 | function add(Role storage role, address account) internal {
79 | require(!has(role, account), "Roles: account already has role");
80 | role.bearer[account] = true;
81 | }
82 |
83 | /**
84 | * @dev Remove an account's access to this role.
85 | */
86 | function remove(Role storage role, address account) internal {
87 | require(has(role, account), "Roles: account does not have role");
88 | role.bearer[account] = false;
89 | }
90 |
91 | /**
92 | * @dev Check if an account has this role.
93 | * @return bool
94 | */
95 | function has(Role storage role, address account) internal view returns (bool) {
96 | require(account != address(0), "Roles: account is the zero address");
97 | return role.bearer[account];
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/MaxBalanceTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/MaxBalance.sol";
66 |
67 | contract MaxBalanceTest is MaxBalance {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnMaxBalance(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnMaxBalance(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnMaxBalance(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnMaxBalance(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/SupplyLimitTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/SupplyLimit.sol";
66 |
67 | contract SupplyLimitTest is SupplyLimit {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnSupplyLimit(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnSupplyLimit(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnSupplyLimit(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnSupplyLimit(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/proxy/authority/IIAFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 | interface IIAFactory {
65 |
66 | /// events
67 |
68 | /// event emitted when a new TREXImplementationAuthority is deployed
69 | event ImplementationAuthorityDeployed(address indexed _ia);
70 |
71 | /// functions
72 |
73 | /**
74 | * @dev deploy a new TREXImplementationAuthority smart contract
75 | * @param _token the token for which the new IA will be used
76 | * function called by the `changeImplementationAuthority` function
77 | * can be called only by the reference TREXImplementationAuthority contract
78 | * the new contract deployed will contain all the versions from reference IA
79 | * the new contract will be set on the same version as the reference IA
80 | * ownership of the new IA is transferred to the Owner of the token
81 | * emits a `ImplementationAuthorityDeployed` event
82 | * returns the address of the IA contract deployed
83 | */
84 | function deployIA(address _token) external returns (address);
85 |
86 | /**
87 | * @dev function used to know if an IA contract was deployed by the factory or not
88 | * @param _ia the address of TREXImplementationAuthority contract
89 | */
90 | function deployedByFactory(address _ia) external view returns (bool);
91 | }
92 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/DayMonthLimitsTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/DayMonthLimits.sol";
66 |
67 | contract DayMonthLimitsTest is DayMonthLimits {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnDayMonthLimits(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnDayMonthLimits(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnDayMonthLimits(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnDayMonthLimits(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/ApproveTransferTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/ApproveTransfer.sol";
66 |
67 | contract ApproveTransferTest is ApproveTransfer {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnApproveTransfer(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnApproveTransfer(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnApproveTransfer(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnApproveTransfer(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/CountryRestrictionsTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/CountryRestrictions.sol";
66 |
67 | contract CountryRestrictionsTest is CountryRestrictions {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnCountryRestrictions(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnCountryRestrictions(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnCountryRestrictions(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnCountryRestrictions(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/CountryWhitelistingTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/CountryWhitelisting.sol";
66 |
67 | contract CountryWhitelistingTest is CountryWhitelisting {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnCountryWhitelisting(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnCountryWhitelisting(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnCountryWhitelisting(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnCountryWhitelisting(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/test/ExchangeMonthlyLimitsTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../features/ExchangeMonthlyLimits.sol";
66 |
67 | contract ExchangeMonthlyLimitsTest is ExchangeMonthlyLimits {
68 | /**
69 | * @dev See {ICompliance-transferred}.
70 | */
71 | function transferred(address _from, address _to, uint256 _value) external onlyToken override {
72 | _transferActionOnExchangeMonthlyLimits(_from, _to, _value);
73 | }
74 |
75 | /**
76 | * @dev See {ICompliance-created}.
77 | */
78 | function created(address _to, uint256 _value) external onlyToken override {
79 | _creationActionOnExchangeMonthlyLimits(_to, _value);
80 | }
81 |
82 | /**
83 | * @dev See {ICompliance-destroyed}.
84 | */
85 | function destroyed(address _from, uint256 _value) external onlyToken override {
86 | _destructionActionOnExchangeMonthlyLimits(_from, _value);
87 | }
88 |
89 | /**
90 | * @dev See {ICompliance-canTransfer}.
91 | */
92 | function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
93 | if (!complianceCheckOnExchangeMonthlyLimits(_from, _to, _value))
94 | {
95 | return false;
96 | }
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/test/agentRole.test.ts:
--------------------------------------------------------------------------------
1 | import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2 | import { expect } from 'chai';
3 | import { ethers } from 'hardhat';
4 |
5 | async function deployAgentFixture() {
6 | const [ownerWallet, aliceWallet, bobWallet] = await ethers.getSigners();
7 |
8 | const agentRole = await ethers.deployContract('AgentRole');
9 |
10 | return {
11 | accounts: {
12 | ownerWallet,
13 | aliceWallet,
14 | bobWallet,
15 | },
16 | contracts: {
17 | agentRole,
18 | },
19 | };
20 | }
21 |
22 | describe('AgentRole', () => {
23 | describe('.addAgent', () => {
24 | describe('when the sender is not the owner', () => {
25 | it('should reverts', async () => {
26 | const {
27 | accounts: { aliceWallet, bobWallet },
28 | contracts: { agentRole },
29 | } = await loadFixture(deployAgentFixture);
30 |
31 | await expect(agentRole.connect(bobWallet).addAgent(aliceWallet.address)).to.be.revertedWith('Ownable: caller is not the owner');
32 | });
33 | });
34 |
35 | describe('when the sender is the owner', () => {
36 | describe('when address to add is the zero address', () => {
37 | it('should reverts', async () => {
38 | const {
39 | accounts: { ownerWallet },
40 | contracts: { agentRole },
41 | } = await loadFixture(deployAgentFixture);
42 |
43 | await expect(agentRole.connect(ownerWallet).addAgent(ethers.constants.AddressZero)).to.be.revertedWith('invalid argument - zero address');
44 | });
45 | });
46 |
47 | describe('when address to add is a valid address', () => {
48 | describe('when address to add is already an agent', () => {
49 | it('should reverts', async () => {
50 | const {
51 | accounts: { ownerWallet, aliceWallet },
52 | contracts: { agentRole },
53 | } = await loadFixture(deployAgentFixture);
54 |
55 | await agentRole.connect(ownerWallet).addAgent(aliceWallet.address);
56 | await expect(agentRole.connect(ownerWallet).addAgent(aliceWallet.address)).to.be.revertedWith('Roles: account already has role');
57 | });
58 | });
59 |
60 | describe('when address to add is not an agent address', () => {
61 | it('should add the agent', async () => {
62 | const {
63 | accounts: { ownerWallet, aliceWallet },
64 | contracts: { agentRole },
65 | } = await loadFixture(deployAgentFixture);
66 |
67 | const tx = await agentRole.connect(ownerWallet).addAgent(aliceWallet.address);
68 | await expect(tx).to.emit(agentRole, 'AgentAdded').withArgs(aliceWallet.address);
69 | expect(await agentRole.isAgent(aliceWallet.address)).to.be.true;
70 | });
71 | });
72 | });
73 | });
74 | });
75 |
76 | describe('.removeAgent', () => {
77 | describe('when the sender is not the owner', () => {
78 | it('should reverts', async () => {
79 | const {
80 | accounts: { aliceWallet, bobWallet },
81 | contracts: { agentRole },
82 | } = await loadFixture(deployAgentFixture);
83 |
84 | await expect(agentRole.connect(bobWallet).removeAgent(aliceWallet.address)).to.be.revertedWith('Ownable: caller is not the owner');
85 | });
86 | });
87 |
88 | describe('when the sender is the owner', () => {
89 | describe('when address to add is the zero address', () => {
90 | it('should reverts', async () => {
91 | const {
92 | accounts: { ownerWallet },
93 | contracts: { agentRole },
94 | } = await loadFixture(deployAgentFixture);
95 |
96 | await expect(agentRole.connect(ownerWallet).removeAgent(ethers.constants.AddressZero)).to.be.revertedWith(
97 | 'invalid argument - zero address',
98 | );
99 | });
100 | });
101 |
102 | describe('when address to add is a valid address', () => {
103 | describe('when address to add is not an agent', () => {
104 | it('should reverts', async () => {
105 | const {
106 | accounts: { ownerWallet, aliceWallet },
107 | contracts: { agentRole },
108 | } = await loadFixture(deployAgentFixture);
109 |
110 | await expect(agentRole.connect(ownerWallet).removeAgent(aliceWallet.address)).to.be.revertedWith('Roles: account does not have role');
111 | });
112 | });
113 |
114 | describe('when address to add is an agent address', () => {
115 | it('should remove the agent', async () => {
116 | const {
117 | accounts: { ownerWallet, aliceWallet },
118 | contracts: { agentRole },
119 | } = await loadFixture(deployAgentFixture);
120 |
121 | await agentRole.connect(ownerWallet).addAgent(aliceWallet.address);
122 | const tx = await agentRole.connect(ownerWallet).removeAgent(aliceWallet.address);
123 | await expect(tx).to.emit(agentRole, 'AgentRemoved').withArgs(aliceWallet.address);
124 | expect(await agentRole.isAgent(aliceWallet.address)).to.be.false;
125 | });
126 | });
127 | });
128 | });
129 | });
130 | });
131 |
--------------------------------------------------------------------------------
/contracts/token/TokenStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 | import "../compliance/modular/IModularCompliance.sol";
66 | import "../registry/interface/IIdentityRegistry.sol";
67 |
68 | contract TokenStorage {
69 | /// @dev ERC20 basic variables
70 | mapping(address => uint256) internal _balances;
71 | mapping(address => mapping(address => uint256)) internal _allowances;
72 | uint256 internal _totalSupply;
73 |
74 | /// @dev Token information
75 | string internal _tokenName;
76 | string internal _tokenSymbol;
77 | uint8 internal _tokenDecimals;
78 | address internal _tokenOnchainID;
79 | string internal constant _TOKEN_VERSION = "4.1.3";
80 |
81 | /// @dev Variables of freeze and pause functions
82 | mapping(address => bool) internal _frozen;
83 | mapping(address => uint256) internal _frozenTokens;
84 |
85 | bool internal _tokenPaused = false;
86 |
87 | /// @dev Identity Registry contract used by the onchain validator system
88 | IIdentityRegistry internal _tokenIdentityRegistry;
89 |
90 | /// @dev Compliance contract linked to the onchain validator system
91 | IModularCompliance internal _tokenCompliance;
92 |
93 | /**
94 | * @dev This empty reserved space is put in place to allow future versions to add new
95 | * variables without shifting down storage in the inheritance chain.
96 | */
97 | uint256[49] private __gap;
98 | }
99 |
--------------------------------------------------------------------------------
/contracts/proxy/ClaimTopicsRegistryProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./AbstractProxy.sol";
66 |
67 | contract ClaimTopicsRegistryProxy is AbstractProxy {
68 |
69 | constructor(address implementationAuthority) {
70 | require(implementationAuthority != address(0), "invalid argument - zero address");
71 | _storeImplementationAuthority(implementationAuthority);
72 | emit ImplementationAuthoritySet(implementationAuthority);
73 |
74 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getCTRImplementation();
75 |
76 | // solhint-disable-next-line avoid-low-level-calls
77 | (bool success, ) = logic.delegatecall(abi.encodeWithSignature("init()"));
78 | require(success, "Initialization failed.");
79 | }
80 |
81 | // solhint-disable-next-line no-complex-fallback
82 | fallback() external payable {
83 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getCTRImplementation();
84 |
85 | // solhint-disable-next-line no-inline-assembly
86 | assembly {
87 | calldatacopy(0x0, 0x0, calldatasize())
88 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
89 | let retSz := returndatasize()
90 | returndatacopy(0, 0, retSz)
91 | switch success
92 | case 0 {
93 | revert(0, retSz)
94 | }
95 | default {
96 | return(0, retSz)
97 | }
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/contracts/proxy/ModularComplianceProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./AbstractProxy.sol";
66 |
67 | contract ModularComplianceProxy is AbstractProxy {
68 |
69 | constructor(address implementationAuthority) {
70 | require(implementationAuthority != address(0), "invalid argument - zero address");
71 | _storeImplementationAuthority(implementationAuthority);
72 | emit ImplementationAuthoritySet(implementationAuthority);
73 |
74 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getMCImplementation();
75 |
76 | // solhint-disable-next-line avoid-low-level-calls
77 | (bool success, ) = logic.delegatecall(abi.encodeWithSignature("init()"));
78 | require(success, "Initialization failed.");
79 | }
80 |
81 | // solhint-disable-next-line no-complex-fallback
82 | fallback() external payable {
83 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getMCImplementation();
84 |
85 | // solhint-disable-next-line no-inline-assembly
86 | assembly {
87 | calldatacopy(0x0, 0x0, calldatasize())
88 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
89 | let retSz := returndatasize()
90 | returndatacopy(0, 0, retSz)
91 | switch success
92 | case 0 {
93 | revert(0, retSz)
94 | }
95 | default {
96 | return(0, retSz)
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/contracts/proxy/IdentityRegistryStorageProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./AbstractProxy.sol";
66 |
67 | contract IdentityRegistryStorageProxy is AbstractProxy {
68 |
69 | constructor(address implementationAuthority) {
70 | require(implementationAuthority != address(0), "invalid argument - zero address");
71 | _storeImplementationAuthority(implementationAuthority);
72 | emit ImplementationAuthoritySet(implementationAuthority);
73 |
74 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getIRSImplementation();
75 |
76 | // solhint-disable-next-line avoid-low-level-calls
77 | (bool success, ) = logic.delegatecall(abi.encodeWithSignature("init()"));
78 | require(success, "Initialization failed.");
79 | }
80 |
81 | // solhint-disable-next-line no-complex-fallback
82 | fallback() external payable {
83 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getIRSImplementation();
84 |
85 | // solhint-disable-next-line no-inline-assembly
86 | assembly {
87 | calldatacopy(0x0, 0x0, calldatasize())
88 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
89 | let retSz := returndatasize()
90 | returndatacopy(0, 0, retSz)
91 | switch success
92 | case 0 {
93 | revert(0, retSz)
94 | }
95 | default {
96 | return(0, retSz)
97 | }
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/contracts/proxy/TrustedIssuersRegistryProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | /**
41 | * NOTICE
42 | *
43 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
44 | * If you choose to receive it under the GPL v.3 license, the following applies:
45 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47 | *
48 | * Copyright (C) 2023, Tokeny sàrl.
49 | *
50 | * This program is free software: you can redistribute it and/or modify
51 | * it under the terms of the GNU General Public License as published by
52 | * the Free Software Foundation, either version 3 of the License, or
53 | * (at your option) any later version.
54 | *
55 | * This program is distributed in the hope that it will be useful,
56 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 | * GNU General Public License for more details.
59 | *
60 | * You should have received a copy of the GNU General Public License
61 | * along with this program. If not, see .
62 | */
63 |
64 | pragma solidity 0.8.17;
65 |
66 | import "./AbstractProxy.sol";
67 |
68 | contract TrustedIssuersRegistryProxy is AbstractProxy {
69 |
70 | constructor(address implementationAuthority) {
71 | require(implementationAuthority != address(0), "invalid argument - zero address");
72 | _storeImplementationAuthority(implementationAuthority);
73 | emit ImplementationAuthoritySet(implementationAuthority);
74 |
75 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getTIRImplementation();
76 |
77 | // solhint-disable-next-line avoid-low-level-calls
78 | (bool success, ) = logic.delegatecall(abi.encodeWithSignature("init()"));
79 | require(success, "Initialization failed.");
80 | }
81 |
82 | // solhint-disable-next-line no-complex-fallback
83 | fallback() external payable {
84 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getTIRImplementation();
85 |
86 | // solhint-disable-next-line no-inline-assembly
87 | assembly {
88 | calldatacopy(0x0, 0x0, calldatasize())
89 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
90 | let retSz := returndatasize()
91 | returndatacopy(0, 0, retSz)
92 | switch success
93 | case 0 {
94 | revert(0, retSz)
95 | }
96 | default {
97 | return(0, retSz)
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/contracts/proxy/authority/IAFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./TREXImplementationAuthority.sol";
66 |
67 | contract IAFactory is IIAFactory {
68 |
69 | /// variables
70 |
71 | /// address of the trex factory
72 | address private _trexFactory;
73 |
74 | /// mapping allowing to know if an IA was deployed by the factory or not
75 | mapping(address => bool) private _deployedByFactory;
76 |
77 | /// functions
78 |
79 | constructor (address trexFactory) {
80 | _trexFactory = trexFactory;
81 | }
82 |
83 | /**
84 | * @dev See {IIAFactory-deployIA}.
85 | */
86 | function deployIA(address _token) external override returns (address){
87 | if (ITREXFactory(_trexFactory).getImplementationAuthority() != msg.sender) {
88 | revert("only reference IA can deploy");}
89 | TREXImplementationAuthority _newIA =
90 | new TREXImplementationAuthority(false, ITREXImplementationAuthority(msg.sender).getTREXFactory(), address(this));
91 | _newIA.fetchVersion(ITREXImplementationAuthority(msg.sender).getCurrentVersion());
92 | _newIA.useTREXVersion(ITREXImplementationAuthority(msg.sender).getCurrentVersion());
93 | Ownable(_newIA).transferOwnership(Ownable(_token).owner());
94 | _deployedByFactory[address(_newIA)] = true;
95 | emit ImplementationAuthorityDeployed(address(_newIA));
96 | return address(_newIA);
97 | }
98 |
99 | /**
100 | * @dev See {IIAFactory-deployedByFactory}.
101 | */
102 | function deployedByFactory(address _ia) external view override returns (bool) {
103 | return _deployedByFactory[_ia];
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/contracts/registry/interface/IClaimTopicsRegistry.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | interface IClaimTopicsRegistry {
66 | /**
67 | * this event is emitted when a claim topic has been added to the ClaimTopicsRegistry
68 | * the event is emitted by the 'addClaimTopic' function
69 | * `claimTopic` is the required claim added to the Claim Topics Registry
70 | */
71 | event ClaimTopicAdded(uint256 indexed claimTopic);
72 |
73 | /**
74 | * this event is emitted when a claim topic has been removed from the ClaimTopicsRegistry
75 | * the event is emitted by the 'removeClaimTopic' function
76 | * `claimTopic` is the required claim removed from the Claim Topics Registry
77 | */
78 | event ClaimTopicRemoved(uint256 indexed claimTopic);
79 |
80 | /**
81 | * @dev Add a trusted claim topic (For example: KYC=1, AML=2).
82 | * Only owner can call.
83 | * emits `ClaimTopicAdded` event
84 | * cannot add more than 15 topics for 1 token as adding more could create gas issues
85 | * @param _claimTopic The claim topic index
86 | */
87 | function addClaimTopic(uint256 _claimTopic) external;
88 |
89 | /**
90 | * @dev Remove a trusted claim topic (For example: KYC=1, AML=2).
91 | * Only owner can call.
92 | * emits `ClaimTopicRemoved` event
93 | * @param _claimTopic The claim topic index
94 | */
95 | function removeClaimTopic(uint256 _claimTopic) external;
96 |
97 | /**
98 | * @dev Get the trusted claim topics for the security token
99 | * @return Array of trusted claim topics
100 | */
101 | function getClaimTopics() external view returns (uint256[] memory);
102 | }
103 |
--------------------------------------------------------------------------------
/contracts/registry/implementation/ClaimTopicsRegistry.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
66 | import "../storage/CTRStorage.sol";
67 | import "../interface/IClaimTopicsRegistry.sol";
68 |
69 | contract ClaimTopicsRegistry is IClaimTopicsRegistry, OwnableUpgradeable, CTRStorage {
70 |
71 | function init() external initializer {
72 | __Ownable_init();
73 | }
74 |
75 | /**
76 | * @dev See {IClaimTopicsRegistry-addClaimTopic}.
77 | */
78 | function addClaimTopic(uint256 _claimTopic) external override onlyOwner {
79 | uint256 length = _claimTopics.length;
80 | require(length < 15, "cannot require more than 15 topics");
81 | for (uint256 i = 0; i < length; i++) {
82 | require(_claimTopics[i] != _claimTopic, "claimTopic already exists");
83 | }
84 | _claimTopics.push(_claimTopic);
85 | emit ClaimTopicAdded(_claimTopic);
86 | }
87 |
88 | /**
89 | * @dev See {IClaimTopicsRegistry-removeClaimTopic}.
90 | */
91 | function removeClaimTopic(uint256 _claimTopic) external override onlyOwner {
92 | uint256 length = _claimTopics.length;
93 | for (uint256 i = 0; i < length; i++) {
94 | if (_claimTopics[i] == _claimTopic) {
95 | _claimTopics[i] = _claimTopics[length - 1];
96 | _claimTopics.pop();
97 | emit ClaimTopicRemoved(_claimTopic);
98 | break;
99 | }
100 | }
101 | }
102 |
103 | /**
104 | * @dev See {IClaimTopicsRegistry-getClaimTopics}.
105 | */
106 | function getClaimTopics() external view override returns (uint256[] memory) {
107 | return _claimTopics;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/contracts/compliance/modular/modules/AbstractModule.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./IModule.sol";
66 |
67 | abstract contract AbstractModule is IModule {
68 |
69 | /// compliance contract binding status
70 | mapping(address => bool) private _complianceBound;
71 |
72 | /**
73 | * @dev Throws if `_compliance` is not a bound compliance contract address.
74 | */
75 | modifier onlyBoundCompliance(address _compliance) {
76 | require(_complianceBound[_compliance], "compliance not bound");
77 | _;
78 | }
79 |
80 | /**
81 | * @dev Throws if called from an address that is not a bound compliance contract.
82 | */
83 | modifier onlyComplianceCall() {
84 | require(_complianceBound[msg.sender], "only bound compliance can call");
85 | _;
86 | }
87 |
88 | /**
89 | * @dev See {IModule-bindCompliance}.
90 | */
91 | function bindCompliance(address _compliance) external override {
92 | require(_compliance != address(0), "invalid argument - zero address");
93 | require(!_complianceBound[_compliance], "compliance already bound");
94 | require(msg.sender == _compliance, "only compliance contract can call");
95 | _complianceBound[_compliance] = true;
96 | emit ComplianceBound(_compliance);
97 | }
98 |
99 | /**
100 | * @dev See {IModule-unbindCompliance}.
101 | */
102 | function unbindCompliance(address _compliance) external onlyComplianceCall override {
103 | require(_compliance != address(0), "invalid argument - zero address");
104 | require(msg.sender == _compliance, "only compliance contract can call");
105 | _complianceBound[_compliance] = false;
106 | emit ComplianceUnbound(_compliance);
107 | }
108 |
109 | /**
110 | * @dev See {IModule-isComplianceBound}.
111 | */
112 | function isComplianceBound(address _compliance) external view override returns (bool) {
113 | return _complianceBound[_compliance];
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/contracts/proxy/IdentityRegistryProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./AbstractProxy.sol";
66 |
67 | contract IdentityRegistryProxy is AbstractProxy {
68 |
69 | constructor(
70 | address implementationAuthority,
71 | address _trustedIssuersRegistry,
72 | address _claimTopicsRegistry,
73 | address _identityStorage
74 | ) {
75 | require(
76 | implementationAuthority != address(0)
77 | && _trustedIssuersRegistry != address(0)
78 | && _claimTopicsRegistry != address(0)
79 | && _identityStorage != address(0)
80 | , "invalid argument - zero address");
81 | _storeImplementationAuthority(implementationAuthority);
82 | emit ImplementationAuthoritySet(implementationAuthority);
83 |
84 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getIRImplementation();
85 |
86 | // solhint-disable-next-line avoid-low-level-calls
87 | (bool success, ) = logic.delegatecall(
88 | abi.encodeWithSignature(
89 | "init(address,address,address)",
90 | _trustedIssuersRegistry,
91 | _claimTopicsRegistry,
92 | _identityStorage));
93 | require(success, "Initialization failed.");
94 | }
95 |
96 | // solhint-disable-next-line no-complex-fallback
97 | fallback() external payable {
98 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getIRImplementation();
99 |
100 | // solhint-disable-next-line no-inline-assembly
101 | assembly {
102 | calldatacopy(0x0, 0x0, calldatasize())
103 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
104 | let retSz := returndatasize()
105 | returndatacopy(0, 0, retSz)
106 | switch success
107 | case 0 {
108 | revert(0, retSz)
109 | }
110 | default {
111 | return(0, retSz)
112 | }
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/contracts/proxy/AbstractProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./interface/IProxy.sol";
66 | import "./authority/ITREXImplementationAuthority.sol";
67 | import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
68 |
69 | abstract contract AbstractProxy is IProxy, Initializable {
70 |
71 | /**
72 | * @dev See {IProxy-setImplementationAuthority}.
73 | */
74 | function setImplementationAuthority(address _newImplementationAuthority) external override {
75 | require(msg.sender == getImplementationAuthority(), "only current implementationAuthority can call");
76 | require(_newImplementationAuthority != address(0), "invalid argument - zero address");
77 | require(
78 | (ITREXImplementationAuthority(_newImplementationAuthority)).getTokenImplementation() != address(0)
79 | && (ITREXImplementationAuthority(_newImplementationAuthority)).getCTRImplementation() != address(0)
80 | && (ITREXImplementationAuthority(_newImplementationAuthority)).getIRImplementation() != address(0)
81 | && (ITREXImplementationAuthority(_newImplementationAuthority)).getIRSImplementation() != address(0)
82 | && (ITREXImplementationAuthority(_newImplementationAuthority)).getMCImplementation() != address(0)
83 | && (ITREXImplementationAuthority(_newImplementationAuthority)).getTIRImplementation() != address(0)
84 | , "invalid Implementation Authority");
85 | _storeImplementationAuthority(_newImplementationAuthority);
86 | emit ImplementationAuthoritySet(_newImplementationAuthority);
87 | }
88 |
89 | /**
90 | * @dev See {IProxy-getImplementationAuthority}.
91 | */
92 | function getImplementationAuthority() public override view returns(address) {
93 | address implemAuth;
94 | // solhint-disable-next-line no-inline-assembly
95 | assembly {
96 | implemAuth := sload(0x821f3e4d3d679f19eacc940c87acf846ea6eae24a63058ea750304437a62aafc)
97 | }
98 | return implemAuth;
99 | }
100 |
101 | /**
102 | * @dev store the implementationAuthority contract address using the ERC-3643 implementation slot in storage
103 | * the slot storage is the result of `keccak256("ERC-3643.proxy.beacon")`
104 | */
105 | function _storeImplementationAuthority(address implementationAuthority) internal {
106 | // solhint-disable-next-line no-inline-assembly
107 | assembly {
108 | sstore(0x821f3e4d3d679f19eacc940c87acf846ea6eae24a63058ea750304437a62aafc, implementationAuthority)
109 | }
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/contracts/proxy/TokenProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "./AbstractProxy.sol";
66 |
67 | contract TokenProxy is AbstractProxy {
68 |
69 | constructor(
70 | address implementationAuthority,
71 | address _identityRegistry,
72 | address _compliance,
73 | string memory _name,
74 | string memory _symbol,
75 | uint8 _decimals,
76 | // _onchainID can be 0 address if the token has no ONCHAINID, ONCHAINID can be set later by the token Owner
77 | address _onchainID
78 | ) {
79 | require(
80 | implementationAuthority != address(0)
81 | && _identityRegistry != address(0)
82 | && _compliance != address(0)
83 | , "invalid argument - zero address");
84 | require(
85 | keccak256(abi.encode(_name)) != keccak256(abi.encode(""))
86 | && keccak256(abi.encode(_symbol)) != keccak256(abi.encode(""))
87 | , "invalid argument - empty string");
88 | require(0 <= _decimals && _decimals <= 18, "decimals between 0 and 18");
89 | _storeImplementationAuthority(implementationAuthority);
90 | emit ImplementationAuthoritySet(implementationAuthority);
91 |
92 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getTokenImplementation();
93 |
94 | // solhint-disable-next-line avoid-low-level-calls
95 | (bool success, ) = logic.delegatecall(
96 | abi.encodeWithSignature(
97 | "init(address,address,string,string,uint8,address)",
98 | _identityRegistry,
99 | _compliance,
100 | _name,
101 | _symbol,
102 | _decimals,
103 | _onchainID
104 | )
105 | );
106 | require(success, "Initialization failed.");
107 | }
108 |
109 | // solhint-disable-next-line no-complex-fallback
110 | fallback() external payable {
111 | address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getTokenImplementation();
112 |
113 | // solhint-disable-next-line no-inline-assembly
114 | assembly {
115 | calldatacopy(0x0, 0x0, calldatasize())
116 | let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
117 | let retSz := returndatasize()
118 | returndatacopy(0, 0, retSz)
119 | switch success
120 | case 0 {
121 | revert(0, retSz)
122 | }
123 | default {
124 | return(0, retSz)
125 | }
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/contracts/compliance/legacy/features/SupplyLimit.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | //
3 | // :+#####%%%%%%%%%%%%%%+
4 | // .-*@@@%+.:+%@@@@@%%#***%@@%=
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 | * NOTICE
41 | *
42 | * The T-REX software is licensed under a proprietary license or the GPL v.3.
43 | * If you choose to receive it under the GPL v.3 license, the following applies:
44 | * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45 | * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46 | *
47 | * Copyright (C) 2023, Tokeny sàrl.
48 | *
49 | * This program is free software: you can redistribute it and/or modify
50 | * it under the terms of the GNU General Public License as published by
51 | * the Free Software Foundation, either version 3 of the License, or
52 | * (at your option) any later version.
53 | *
54 | * This program is distributed in the hope that it will be useful,
55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 | * GNU General Public License for more details.
58 | *
59 | * You should have received a copy of the GNU General Public License
60 | * along with this program. If not, see .
61 | */
62 |
63 | pragma solidity 0.8.17;
64 |
65 | import "../BasicCompliance.sol";
66 |
67 | /**
68 | * this feature allows to put a supply limit on the token
69 | * If an agent tries to mint more tokens than the maximum threshold, the minting will fail
70 | */
71 | abstract contract SupplyLimit is BasicCompliance {
72 |
73 | /// supply limit variable
74 | uint256 public supplyLimit;
75 |
76 | /**
77 | * this event is emitted when the supply limit has been set.
78 | * `_limit` is the max amount of tokens in circulation.
79 | */
80 | event SupplyLimitSet(uint256 _limit);
81 |
82 | /**
83 | * @dev sets supply limit.
84 | * Supply limit has to be smaller or equal to the actual supply.
85 | * @param _limit max amount of tokens to be created
86 | * Only the owner of the Compliance smart contract can call this function
87 | * emits an `SupplyLimitSet` event
88 | */
89 | function setSupplyLimit(uint256 _limit) external onlyOwner {
90 | supplyLimit = _limit;
91 | emit SupplyLimitSet(_limit);
92 | }
93 |
94 | /**
95 | * @dev check on the compliance status of a transaction.
96 | * This check always returns true, real check is done at the creation action level
97 | */
98 | function complianceCheckOnSupplyLimit (address /*_from*/, address /*_to*/, uint256 /*_value*/)
99 | public view returns (bool) {
100 | return true;
101 | }
102 |
103 | /**
104 | * @dev state update of the compliance feature post-transfer.
105 | * this compliance feature doesn't require state update post-transfer
106 | * @param _from the address of the transfer sender
107 | * @param _to the address of the transfer receiver
108 | * @param _value the amount of tokens that `_from` sent to `_to`
109 | * internal function, can be called only from the functions of the Compliance smart contract
110 | */
111 | // solhint-disable-next-line no-empty-blocks
112 | function _transferActionOnSupplyLimit(address _from, address _to, uint256 _value) internal {}
113 |
114 | /**
115 | * @dev state update of the compliance feature post-minting.
116 | * reverts if the post-minting supply is higher than the max supply
117 | * internal function, can be called only from the functions of the Compliance smart contract
118 | */
119 | function _creationActionOnSupplyLimit(address /*_to*/, uint256 /*_value*/) internal {
120 | require(tokenBound.totalSupply() <= supplyLimit, "cannot mint more tokens");
121 | }
122 |
123 | /**
124 | * @dev state update of the compliance feature post-burning.
125 | * this compliance feature doesn't require state update post-burning
126 | * @param _from the wallet address on which tokens burnt
127 | * @param _value the amount of tokens burnt from `_from` wallet
128 | * internal function, can be called only from the functions of the Compliance smart contract
129 | */
130 | // solhint-disable-next-line no-empty-blocks
131 | function _destructionActionOnSupplyLimit(address _from, uint256 _value) internal {}
132 | }
133 |
--------------------------------------------------------------------------------