From ad785dbd06596a22ac067997498bbf4a787dddcc Mon Sep 17 00:00:00 2001 From: Jean Cvllr <31145285+CJ42@users.noreply.github.com> Date: Tue, 6 Feb 2024 18:24:13 +0000 Subject: [PATCH] build!: move LSP3 and Universal Profile in their own package (#879) --- .github/workflows/solc_version.yml | 12 +- ...iversalProfileInitPostDeploymentModule.sol | 4 +- .../UniversalProfilePostDeploymentModule.sol | 4 +- contracts/Mocks/Executor.sol | 4 +- contracts/Mocks/ExecutorLSP20.sol | 4 +- .../contracts}/UniversalProfile.md | 0 dodoc/config.ts | 2 +- package-lock.json | 188 ++++++++++++++---- package.json | 3 +- packages/LSP3ProfileMetadata/.eslintrc.js | 4 + packages/LSP3ProfileMetadata/.solhint.json | 25 +++ packages/LSP3ProfileMetadata/README.md | 51 +++++ .../contracts}/LSP3Constants.sol | 0 .../LSP3ProfileMetadata/hardhat.config.ts | 128 ++++++++++++ packages/LSP3ProfileMetadata/package.json | 40 ++++ packages/LSP3ProfileMetadata/tsconfig.json | 4 + packages/UniversalProfile/.eslintrc.js | 4 + packages/UniversalProfile/.solhint.json | 25 +++ packages/UniversalProfile/README.md | 16 ++ .../UniversalProfile/contracts/Constants.sol | 14 ++ .../contracts}/UniversalProfile.sol | 2 +- .../contracts}/UniversalProfileInit.sol | 0 .../UniversalProfileInitAbstract.sol | 2 +- .../UniversalProfile/contracts/Version.sol | 17 ++ packages/UniversalProfile/hardhat.config.ts | 128 ++++++++++++ packages/UniversalProfile/package.json | 47 +++++ packages/UniversalProfile/tsconfig.json | 4 + 27 files changed, 682 insertions(+), 50 deletions(-) rename docs/contracts/{ => universalprofile/contracts}/UniversalProfile.md (100%) create mode 100644 packages/LSP3ProfileMetadata/.eslintrc.js create mode 100644 packages/LSP3ProfileMetadata/.solhint.json create mode 100644 packages/LSP3ProfileMetadata/README.md rename {contracts/LSP3ProfileMetadata => packages/LSP3ProfileMetadata/contracts}/LSP3Constants.sol (100%) create mode 100644 packages/LSP3ProfileMetadata/hardhat.config.ts create mode 100644 packages/LSP3ProfileMetadata/package.json create mode 100644 packages/LSP3ProfileMetadata/tsconfig.json create mode 100644 packages/UniversalProfile/.eslintrc.js create mode 100644 packages/UniversalProfile/.solhint.json create mode 100644 packages/UniversalProfile/README.md create mode 100644 packages/UniversalProfile/contracts/Constants.sol rename {contracts => packages/UniversalProfile/contracts}/UniversalProfile.sol (96%) rename {contracts => packages/UniversalProfile/contracts}/UniversalProfileInit.sol (100%) rename {contracts => packages/UniversalProfile/contracts}/UniversalProfileInitAbstract.sol (97%) create mode 100644 packages/UniversalProfile/contracts/Version.sol create mode 100644 packages/UniversalProfile/hardhat.config.ts create mode 100644 packages/UniversalProfile/package.json create mode 100644 packages/UniversalProfile/tsconfig.json diff --git a/.github/workflows/solc_version.yml b/.github/workflows/solc_version.yml index 131ac6868..6bfede0e1 100644 --- a/.github/workflows/solc_version.yml +++ b/.github/workflows/solc_version.yml @@ -78,12 +78,13 @@ jobs: then solc $(ls contracts/**/*.sol | grep -v "Extension4337\|contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset") \ --allow-paths $(pwd)/node_modules/,$(pwd)/packages/ \ + ../=$(pwd)/contracts/ \ @=node_modules/@ \ solidity-bytes-utils/=node_modules/solidity-bytes-utils/ \ - ../=$(pwd)/contracts/ \ lsp0/=packages/LSP0ERC725Account/ \ lsp1/=packages/LSP1UniversalReceiver/ \ lsp2/=packages/LSP2ERC725YJSONSchema/ \ + lsp3/=packages/LSP3ProfileMetadata/ \ lsp4/=packages/LSP4DigitalAssetMetadata/ \ lsp5/=packages/LSP5ReceivedAssets/ \ lsp6/=packages/LSP6KeyManager/ \ @@ -92,9 +93,11 @@ jobs: lsp10/=packages/LSP10ReceivedVaults/ \ lsp14/=packages/LSP14Ownable2Step/ \ lsp16/=packages/LSP16UniversalFactory/ \ + lsp17/=packages/LSP17Extensions/ \ lsp17contractextension/=packages/LSP17ContractExtension/ \ lsp20/=packages/LSP20CallVerification/ \ - lsp25/=packages/LSP25ExecuteRelayCall/ + lsp25/=packages/LSP25ExecuteRelayCall/ \ + universalprofile/=packages/UniversalProfile/ else solc contracts/**/*.sol \ @=node_modules/@ \ @@ -102,6 +105,7 @@ jobs: lsp0/=packages/LSP0ERC725Account/ \ lsp1/=packages/LSP1UniversalReceiver/ \ lsp2/=packages/LSP2ERC725YJSONSchema/ \ + lsp3/=packages/LSP3ProfileMetadata/ \ lsp4/=packages/LSP4DigitalAssetMetadata/ \ lsp5/=packages/LSP5ReceivedAssets/ \ lsp6/=packages/LSP6KeyManager/ \ @@ -110,7 +114,9 @@ jobs: lsp10/=packages/LSP10ReceivedVaults/ \ lsp14/=packages/LSP14Ownable2Step/ \ lsp16/=packages/LSP16UniversalFactory/ \ + lsp17/=packages/LSP17Extensions/ \ lsp17contractextension/=packages/LSP17ContractExtension/ \ lsp20/=packages/LSP20CallVerification/ \ - lsp25/=packages/LSP25ExecuteRelayCall/ + lsp25/=packages/LSP25ExecuteRelayCall/ \ + universalprofile/=packages/UniversalProfile/ fi; diff --git a/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol b/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol index 6e94fe845..1672a59da 100644 --- a/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol +++ b/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol @@ -5,7 +5,9 @@ import { OPERATION_4_DELEGATECALL } from "@erc725/smart-contracts/contracts/constants.sol"; -import {UniversalProfileInit} from "../../UniversalProfileInit.sol"; +import { + UniversalProfileInit +} from "universalprofile/contracts/UniversalProfileInit.sol"; contract UniversalProfileInitPostDeploymentModule is UniversalProfileInit { constructor() { diff --git a/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol b/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol index 7e2f861ff..3814d56d9 100644 --- a/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol +++ b/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol @@ -5,7 +5,9 @@ import { OPERATION_4_DELEGATECALL } from "@erc725/smart-contracts/contracts/constants.sol"; -import {UniversalProfile} from "../../UniversalProfile.sol"; +import { + UniversalProfile +} from "universalprofile/contracts/UniversalProfile.sol"; contract UniversalProfilePostDeploymentModule is UniversalProfile { constructor() UniversalProfile(address(0)) {} diff --git a/contracts/Mocks/Executor.sol b/contracts/Mocks/Executor.sol index 7fc7bd702..248655ea1 100644 --- a/contracts/Mocks/Executor.sol +++ b/contracts/Mocks/Executor.sol @@ -11,7 +11,9 @@ import { import {ILSP6KeyManager} from "lsp6/contracts/ILSP6KeyManager.sol"; // modules -import {UniversalProfile} from "../UniversalProfile.sol"; +import { + UniversalProfile +} from "universalprofile/contracts/UniversalProfile.sol"; import {LSP6KeyManager} from "lsp6/contracts/LSP6KeyManager.sol"; // constants diff --git a/contracts/Mocks/ExecutorLSP20.sol b/contracts/Mocks/ExecutorLSP20.sol index ac7a57617..a3db07702 100644 --- a/contracts/Mocks/ExecutorLSP20.sol +++ b/contracts/Mocks/ExecutorLSP20.sol @@ -10,7 +10,9 @@ import { } from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol"; // modules -import {UniversalProfile} from "../UniversalProfile.sol"; +import { + UniversalProfile +} from "universalprofile/contracts/UniversalProfile.sol"; // constants import { diff --git a/docs/contracts/UniversalProfile.md b/docs/contracts/universalprofile/contracts/UniversalProfile.md similarity index 100% rename from docs/contracts/UniversalProfile.md rename to docs/contracts/universalprofile/contracts/UniversalProfile.md diff --git a/dodoc/config.ts b/dodoc/config.ts index 3bf0c12a4..bf8087dce 100644 --- a/dodoc/config.ts +++ b/dodoc/config.ts @@ -4,7 +4,7 @@ import { HelperContent } from 'squirrelly/dist/types/containers'; export const dodocConfig = { runOnCompile: false, include: [ - 'contracts/UniversalProfile.sol', + 'universalprofile/contracts/UniversalProfile.sol', 'lsp0/contracts/LSP0ERC725Account.sol', 'contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol', 'contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol', diff --git a/package-lock.json b/package-lock.json index c4788c6fc..6834bfe1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,8 @@ "lsp6": "*", "lsp7": "*", "lsp8": "*", - "solidity-bytes-utils": "0.8.0" + "solidity-bytes-utils": "0.8.0", + "universalprofile": "*" }, "devDependencies": { "@b00ste/hardhat-dodoc": "^0.3.16", @@ -13570,6 +13571,10 @@ "resolved": "packages/LSP25ExecuteRelayCall", "link": true }, + "node_modules/lsp3": { + "resolved": "packages/LSP3ProfileMetadata", + "link": true + }, "node_modules/lsp4": { "resolved": "packages/LSP4DigitalAssetMetadata", "link": true @@ -17931,13 +17936,13 @@ } }, "node_modules/safe-regex-test": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.2.tgz", - "integrity": "sha512-83S9w6eFq12BBIJYvjMux6/dkirb8+4zJRA9cxNBVb7Wq5fJBW+Xze48WqR8pxua7bDuAaaAxtVVd4Idjp1dBQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", + "integrity": "sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==", "dev": true, "dependencies": { - "call-bind": "^1.0.5", - "get-intrinsic": "^1.2.2", + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", "is-regex": "^1.1.4" }, "engines": { @@ -18229,9 +18234,9 @@ "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, "node_modules/scule": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/scule/-/scule-1.2.0.tgz", - "integrity": "sha512-CRCmi5zHQnSoeCik9565PONMg0kfkvYmcSqrbOJY4txFfy1wvVULV4FDaiXhUblUgahdqz3F2NwHZ8i4eBTwUw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz", + "integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==", "dev": true }, "node_modules/secp256k1": { @@ -18382,13 +18387,14 @@ "dev": true }, "node_modules/set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", "dependencies": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.3", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" }, @@ -18515,13 +18521,17 @@ } }, "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -21324,6 +21334,10 @@ "node": ">= 4.0.0" } }, + "node_modules/universalprofile": { + "resolved": "packages/UniversalProfile", + "link": true + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -24078,6 +24092,28 @@ "typescript": "^5.3.3" } }, + "packages/LSP3ProfileMetadata": { + "name": "lsp3", + "version": "0.12.1", + "license": "Apache-2.0", + "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } + }, "packages/LSP4DigitalAssetMetadata": { "name": "lsp4", "version": "0.12.1", @@ -24218,6 +24254,34 @@ "typechain": "^8.0.0", "typescript": "^5.3.3" } + }, + "packages/UniversalProfile": { + "name": "universalprofile", + "version": "0.12.1", + "license": "Apache-2.0", + "dependencies": { + "@erc725/smart-contracts": "^7.0.0", + "@openzeppelin/contracts": "^4.9.3", + "lsp0": "*", + "lsp3": "*" + }, + "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } } }, "dependencies": { @@ -34675,6 +34739,26 @@ "typescript": "^5.3.3" } }, + "lsp3": { + "version": "file:packages/LSP3ProfileMetadata", + "requires": { + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } + }, "lsp4": { "version": "file:packages/LSP4DigitalAssetMetadata", "requires": { @@ -37900,13 +37984,13 @@ } }, "safe-regex-test": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.2.tgz", - "integrity": "sha512-83S9w6eFq12BBIJYvjMux6/dkirb8+4zJRA9cxNBVb7Wq5fJBW+Xze48WqR8pxua7bDuAaaAxtVVd4Idjp1dBQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", + "integrity": "sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==", "dev": true, "requires": { - "call-bind": "^1.0.5", - "get-intrinsic": "^1.2.2", + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", "is-regex": "^1.1.4" } }, @@ -38134,9 +38218,9 @@ "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, "scule": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/scule/-/scule-1.2.0.tgz", - "integrity": "sha512-CRCmi5zHQnSoeCik9565PONMg0kfkvYmcSqrbOJY4txFfy1wvVULV4FDaiXhUblUgahdqz3F2NwHZ8i4eBTwUw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz", + "integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==", "dev": true }, "secp256k1": { @@ -38268,13 +38352,14 @@ "dev": true }, "set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", "requires": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.3", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" } @@ -38368,13 +38453,14 @@ } }, "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" } }, "signal-exit": { @@ -40360,6 +40446,30 @@ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, + "universalprofile": { + "version": "file:packages/UniversalProfile", + "requires": { + "@erc725/smart-contracts": "^7.0.0", + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@openzeppelin/contracts": "^4.9.3", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "lsp0": "*", + "lsp3": "*", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 3d151d850..0cf56ad4b 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,8 @@ "lsp17": "*", "lsp17contractextension": "*", "lsp20": "*", - "lsp25": "*" + "lsp25": "*", + "universalprofile": "*" }, "devDependencies": { "@b00ste/hardhat-dodoc": "^0.3.16", diff --git a/packages/LSP3ProfileMetadata/.eslintrc.js b/packages/LSP3ProfileMetadata/.eslintrc.js new file mode 100644 index 000000000..03ee7431b --- /dev/null +++ b/packages/LSP3ProfileMetadata/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ['custom'], +}; diff --git a/packages/LSP3ProfileMetadata/.solhint.json b/packages/LSP3ProfileMetadata/.solhint.json new file mode 100644 index 000000000..26e01c48a --- /dev/null +++ b/packages/LSP3ProfileMetadata/.solhint.json @@ -0,0 +1,25 @@ +{ + "extends": "solhint:recommended", + "rules": { + "avoid-sha3": "error", + "avoid-suicide": "error", + "avoid-throw": "error", + "avoid-tx-origin": "error", + "check-send-result": "error", + "compiler-version": ["error", "^0.8.0"], + "func-visibility": ["error", { "ignoreConstructors": true }], + "not-rely-on-block-hash": "error", + "not-rely-on-time": "error", + "reentrancy": "error", + "constructor-syntax": "error", + "private-vars-leading-underscore": ["error", { "strict": false }], + "imports-on-top": "error", + "visibility-modifier-order": "error", + "no-unused-import": "error", + "no-global-import": "error", + "reason-string": ["warn", { "maxLength": 120 }], + "avoid-low-level-calls": "off", + "no-empty-blocks": ["error", { "ignoreConstructors": true }], + "custom-errors": "off" + } +} diff --git a/packages/LSP3ProfileMetadata/README.md b/packages/LSP3ProfileMetadata/README.md new file mode 100644 index 000000000..44c90d86b --- /dev/null +++ b/packages/LSP3ProfileMetadata/README.md @@ -0,0 +1,51 @@ +# LSP Package Template + +This project can be used as a skeleton to build a package for a LSP implementation in Solidity (LUKSO Standard Proposal) + +It is based on Hardhat. + +## How to setup a LSP as a package? + +1. Copy the `template/` folder and paste it under the `packages/` folder. Then rename this `template/` folder that you copied with the LSP name. + +You can do so either: + +- manually, by copying the folder and pasting it inside `packages` and then renaming it. + or +- by running the following command from the root of the repository. + +```bash +cp -r template packages/lsp-name +``` + +2. Update the `"name"` and `"description"` field inside the `package.json` for this LSP package you just created. + +3. Setup the dependencies + +If this LSP uses external dependencies like `@openzeppelin/contracts`, put them under `dependencies` with the version number. + +```json +"@openzeppelin/contracts": "^4.9.3" +``` + +If this LSP uses other LSP as dependencies, put each LSP dependency as shown below. This will use the current code in the package: + +```json +"@lsp2": "*" +``` + +4. Setup the npm commands for linting, building, testing, etc... under the `"scripts"` in the `package.json` + +5. Test that all commands you setup run successfully + +By running the commands below, your LSP package should come up in the list of packages that Turbo is running this command for. + +```bash +turbo build +turbo lint +turbo lint:solidity +turbo test +turbo test:foundry +``` + +6. Finally update the relevant information in the `README.md` file in the folder of the newly created package, such as the title at the top, some description, etc... diff --git a/contracts/LSP3ProfileMetadata/LSP3Constants.sol b/packages/LSP3ProfileMetadata/contracts/LSP3Constants.sol similarity index 100% rename from contracts/LSP3ProfileMetadata/LSP3Constants.sol rename to packages/LSP3ProfileMetadata/contracts/LSP3Constants.sol diff --git a/packages/LSP3ProfileMetadata/hardhat.config.ts b/packages/LSP3ProfileMetadata/hardhat.config.ts new file mode 100644 index 000000000..d818a205d --- /dev/null +++ b/packages/LSP3ProfileMetadata/hardhat.config.ts @@ -0,0 +1,128 @@ +import { HardhatUserConfig } from 'hardhat/config'; +import { NetworkUserConfig } from 'hardhat/types'; +import { config as dotenvConfig } from 'dotenv'; +import { resolve } from 'path'; + +/** + * this package includes: + * - @nomiclabs/hardhat-ethers + * - @nomicfoundation/hardhat-chai-matchers + * - @nomicfoundation/hardhat-network-helpers + * - @nomiclabs/hardhat-etherscan + * - hardhat-gas-reporter (is this true? Why do we have it as a separate dependency?) + * - @typechain/hardhat + * - solidity-coverage + */ +import '@nomicfoundation/hardhat-toolbox'; + +// additional hardhat plugins +import 'hardhat-packager'; +import 'hardhat-contract-sizer'; +import 'hardhat-deploy'; + +// custom built hardhat plugins and scripts +// can be imported here (e.g: docs generation, gas benchmark, etc...) + +dotenvConfig({ path: resolve(__dirname, './.env') }); + +function getTestnetChainConfig(): NetworkUserConfig { + const config: NetworkUserConfig = { + live: true, + url: 'https://rpc.testnet.lukso.network', + chainId: 4201, + }; + + if (process.env.CONTRACT_VERIFICATION_TESTNET_PK !== undefined) { + config['accounts'] = [process.env.CONTRACT_VERIFICATION_TESTNET_PK]; + } + + return config; +} + +const config: HardhatUserConfig = { + defaultNetwork: 'hardhat', + networks: { + hardhat: { + live: false, + saveDeployments: false, + allowBlocksWithSameTimestamp: true, + }, + luksoTestnet: getTestnetChainConfig(), + }, + namedAccounts: { + owner: 0, + }, + // uncomment if the contracts from this LSP package must be deployed at deterministic + // // addresses across multiple chains + // deterministicDeployment: { + // luksoTestnet: { + // // Nick Factory. See https://github.com/Arachnid/deterministic-deployment-proxy + // factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c', + // deployer: '0x3fab184622dc19b6109349b94811493bf2a45362', + // funding: '0x0000000000000000000000000000000000000000000000000000000000000000', + // signedTx: + // '0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222', + // }, + // }, + etherscan: { + apiKey: 'no-api-key-needed', + customChains: [ + { + network: 'luksoTestnet', + chainId: 4201, + urls: { + apiURL: 'https://api.explorer.execution.testnet.lukso.network/api', + browserURL: 'https://explorer.execution.testnet.lukso.network/', + }, + }, + ], + }, + gasReporter: { + enabled: true, + currency: 'USD', + gasPrice: 21, + excludeContracts: ['Helpers/'], + src: './contracts', + showMethodSig: true, + }, + solidity: { + version: '0.8.17', + settings: { + optimizer: { + enabled: true, + /** + * Optimize for how many times you intend to run the code. + * Lower values will optimize more for initial deployment cost, higher + * values will optimize more for high-frequency usage. + * @see https://docs.soliditylang.org/en/v0.8.6/internals/optimizer.html#opcode-based-optimizer-module + */ + runs: 1000, + }, + outputSelection: { + '*': { + '*': ['storageLayout'], + }, + }, + }, + }, + packager: { + // What contracts to keep the artifacts and the bindings for. + contracts: [], + // Whether to include the TypeChain factories or not. + // If this is enabled, you need to run the TypeChain files through the TypeScript compiler before shipping to the registry. + includeFactories: true, + }, + paths: { + artifacts: 'artifacts', + tests: 'tests', + }, + typechain: { + outDir: 'types', + target: 'ethers-v5', + }, + mocha: { + timeout: 10000000, + }, +}; + +export default config; diff --git a/packages/LSP3ProfileMetadata/package.json b/packages/LSP3ProfileMetadata/package.json new file mode 100644 index 000000000..7c4655860 --- /dev/null +++ b/packages/LSP3ProfileMetadata/package.json @@ -0,0 +1,40 @@ +{ + "name": "lsp3", + "version": "0.12.1", + "description": "Package for the LSP3 Profile Metadata standard", + "license": "Apache-2.0", + "author": "", + "keywords": [ + "LUKSO", + "LSP", + "Blockchain", + "Standards", + "Smart Contracts", + "Ethereum", + "EVM", + "Solidity" + ], + "scripts": { + "build": "hardhat compile --show-stack-traces", + "clean": "hardhat clean", + "format": "prettier --write .", + "lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'" + }, + "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } +} diff --git a/packages/LSP3ProfileMetadata/tsconfig.json b/packages/LSP3ProfileMetadata/tsconfig.json new file mode 100644 index 000000000..b7a34e03f --- /dev/null +++ b/packages/LSP3ProfileMetadata/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "tsconfig/contracts.json", + "include": ["**/*.ts"] +} diff --git a/packages/UniversalProfile/.eslintrc.js b/packages/UniversalProfile/.eslintrc.js new file mode 100644 index 000000000..03ee7431b --- /dev/null +++ b/packages/UniversalProfile/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ['custom'], +}; diff --git a/packages/UniversalProfile/.solhint.json b/packages/UniversalProfile/.solhint.json new file mode 100644 index 000000000..26e01c48a --- /dev/null +++ b/packages/UniversalProfile/.solhint.json @@ -0,0 +1,25 @@ +{ + "extends": "solhint:recommended", + "rules": { + "avoid-sha3": "error", + "avoid-suicide": "error", + "avoid-throw": "error", + "avoid-tx-origin": "error", + "check-send-result": "error", + "compiler-version": ["error", "^0.8.0"], + "func-visibility": ["error", { "ignoreConstructors": true }], + "not-rely-on-block-hash": "error", + "not-rely-on-time": "error", + "reentrancy": "error", + "constructor-syntax": "error", + "private-vars-leading-underscore": ["error", { "strict": false }], + "imports-on-top": "error", + "visibility-modifier-order": "error", + "no-unused-import": "error", + "no-global-import": "error", + "reason-string": ["warn", { "maxLength": 120 }], + "avoid-low-level-calls": "off", + "no-empty-blocks": ["error", { "ignoreConstructors": true }], + "custom-errors": "off" + } +} diff --git a/packages/UniversalProfile/README.md b/packages/UniversalProfile/README.md new file mode 100644 index 000000000..c1e0875bb --- /dev/null +++ b/packages/UniversalProfile/README.md @@ -0,0 +1,16 @@ +# Universal Profile + +Smart Contract implementation for **Universal Profile**, a combination of LSP0 ERC725 Account and LSP3 Profile Metadata. + +## Solidity constants + +The constants related to LSP3 Profile Metadata can be directly imported from the `Constants.sol` file. + + +```solidity +import { + _LSP3_SUPPORTED_STANDARDS_KEY, + _LSP3_SUPPORTED_STANDARDS_VALUE, + _LSP3_PROFILE_KEY +} from "universalprofile/contracts/Constants.sol"; +``` diff --git a/packages/UniversalProfile/contracts/Constants.sol b/packages/UniversalProfile/contracts/Constants.sol new file mode 100644 index 000000000..d90d6a291 --- /dev/null +++ b/packages/UniversalProfile/contracts/Constants.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/// @dev This files makes constants related to LSP3 Profile Metadata available to be imported +/// directly from the UniversalProfile package. + +// solhint-disable no-unused-import +import { + _LSP3_SUPPORTED_STANDARDS_KEY, + _LSP3_SUPPORTED_STANDARDS_VALUE, + _LSP3_PROFILE_KEY +} from "lsp3/contracts/LSP3Constants.sol"; + +// solhint-enable diff --git a/contracts/UniversalProfile.sol b/packages/UniversalProfile/contracts/UniversalProfile.sol similarity index 96% rename from contracts/UniversalProfile.sol rename to packages/UniversalProfile/contracts/UniversalProfile.sol index 46b3e5a97..8dcdcd2de 100644 --- a/contracts/UniversalProfile.sol +++ b/packages/UniversalProfile/contracts/UniversalProfile.sol @@ -8,7 +8,7 @@ import {LSP0ERC725Account} from "lsp0/contracts/LSP0ERC725Account.sol"; import { _LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE -} from "./LSP3ProfileMetadata/LSP3Constants.sol"; +} from "lsp3/contracts/LSP3Constants.sol"; /** * @title implementation of a LUKSO's Universal Profile based on LSP3 diff --git a/contracts/UniversalProfileInit.sol b/packages/UniversalProfile/contracts/UniversalProfileInit.sol similarity index 100% rename from contracts/UniversalProfileInit.sol rename to packages/UniversalProfile/contracts/UniversalProfileInit.sol diff --git a/contracts/UniversalProfileInitAbstract.sol b/packages/UniversalProfile/contracts/UniversalProfileInitAbstract.sol similarity index 97% rename from contracts/UniversalProfileInitAbstract.sol rename to packages/UniversalProfile/contracts/UniversalProfileInitAbstract.sol index 090337082..e9d6d9b4a 100644 --- a/contracts/UniversalProfileInitAbstract.sol +++ b/packages/UniversalProfile/contracts/UniversalProfileInitAbstract.sol @@ -10,7 +10,7 @@ import { import { _LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE -} from "./LSP3ProfileMetadata/LSP3Constants.sol"; +} from "lsp3/contracts/LSP3Constants.sol"; /** * @title Inheritable Proxy implementation of a LUKSO's Universal Profile based on LSP3 diff --git a/packages/UniversalProfile/contracts/Version.sol b/packages/UniversalProfile/contracts/Version.sol new file mode 100644 index 000000000..9227ca267 --- /dev/null +++ b/packages/UniversalProfile/contracts/Version.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.4; + +abstract contract Version { + /** + * @dev Get the version of the contract. + * @notice Contract version. + * + * @return The version of the the contract. + */ + // DO NOT CHANGE + // Comments block below is used by release-please to automatically update the version in this file. + // x-release-please-start-version + string public constant VERSION = "0.12.1"; + + // x-release-please-end +} diff --git a/packages/UniversalProfile/hardhat.config.ts b/packages/UniversalProfile/hardhat.config.ts new file mode 100644 index 000000000..d818a205d --- /dev/null +++ b/packages/UniversalProfile/hardhat.config.ts @@ -0,0 +1,128 @@ +import { HardhatUserConfig } from 'hardhat/config'; +import { NetworkUserConfig } from 'hardhat/types'; +import { config as dotenvConfig } from 'dotenv'; +import { resolve } from 'path'; + +/** + * this package includes: + * - @nomiclabs/hardhat-ethers + * - @nomicfoundation/hardhat-chai-matchers + * - @nomicfoundation/hardhat-network-helpers + * - @nomiclabs/hardhat-etherscan + * - hardhat-gas-reporter (is this true? Why do we have it as a separate dependency?) + * - @typechain/hardhat + * - solidity-coverage + */ +import '@nomicfoundation/hardhat-toolbox'; + +// additional hardhat plugins +import 'hardhat-packager'; +import 'hardhat-contract-sizer'; +import 'hardhat-deploy'; + +// custom built hardhat plugins and scripts +// can be imported here (e.g: docs generation, gas benchmark, etc...) + +dotenvConfig({ path: resolve(__dirname, './.env') }); + +function getTestnetChainConfig(): NetworkUserConfig { + const config: NetworkUserConfig = { + live: true, + url: 'https://rpc.testnet.lukso.network', + chainId: 4201, + }; + + if (process.env.CONTRACT_VERIFICATION_TESTNET_PK !== undefined) { + config['accounts'] = [process.env.CONTRACT_VERIFICATION_TESTNET_PK]; + } + + return config; +} + +const config: HardhatUserConfig = { + defaultNetwork: 'hardhat', + networks: { + hardhat: { + live: false, + saveDeployments: false, + allowBlocksWithSameTimestamp: true, + }, + luksoTestnet: getTestnetChainConfig(), + }, + namedAccounts: { + owner: 0, + }, + // uncomment if the contracts from this LSP package must be deployed at deterministic + // // addresses across multiple chains + // deterministicDeployment: { + // luksoTestnet: { + // // Nick Factory. See https://github.com/Arachnid/deterministic-deployment-proxy + // factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c', + // deployer: '0x3fab184622dc19b6109349b94811493bf2a45362', + // funding: '0x0000000000000000000000000000000000000000000000000000000000000000', + // signedTx: + // '0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222', + // }, + // }, + etherscan: { + apiKey: 'no-api-key-needed', + customChains: [ + { + network: 'luksoTestnet', + chainId: 4201, + urls: { + apiURL: 'https://api.explorer.execution.testnet.lukso.network/api', + browserURL: 'https://explorer.execution.testnet.lukso.network/', + }, + }, + ], + }, + gasReporter: { + enabled: true, + currency: 'USD', + gasPrice: 21, + excludeContracts: ['Helpers/'], + src: './contracts', + showMethodSig: true, + }, + solidity: { + version: '0.8.17', + settings: { + optimizer: { + enabled: true, + /** + * Optimize for how many times you intend to run the code. + * Lower values will optimize more for initial deployment cost, higher + * values will optimize more for high-frequency usage. + * @see https://docs.soliditylang.org/en/v0.8.6/internals/optimizer.html#opcode-based-optimizer-module + */ + runs: 1000, + }, + outputSelection: { + '*': { + '*': ['storageLayout'], + }, + }, + }, + }, + packager: { + // What contracts to keep the artifacts and the bindings for. + contracts: [], + // Whether to include the TypeChain factories or not. + // If this is enabled, you need to run the TypeChain files through the TypeScript compiler before shipping to the registry. + includeFactories: true, + }, + paths: { + artifacts: 'artifacts', + tests: 'tests', + }, + typechain: { + outDir: 'types', + target: 'ethers-v5', + }, + mocha: { + timeout: 10000000, + }, +}; + +export default config; diff --git a/packages/UniversalProfile/package.json b/packages/UniversalProfile/package.json new file mode 100644 index 000000000..19abb64d3 --- /dev/null +++ b/packages/UniversalProfile/package.json @@ -0,0 +1,47 @@ +{ + "name": "universalprofile", + "version": "0.12.1", + "description": "Package for Universal Profile, an implementation of LSP0 ERC725 Account & LSP3 Profile Metadata standards combined together.", + "license": "Apache-2.0", + "author": "", + "keywords": [ + "LUKSO", + "LSP", + "Blockchain", + "Standards", + "Smart Contracts", + "Ethereum", + "EVM", + "Solidity" + ], + "scripts": { + "build": "hardhat compile --show-stack-traces", + "clean": "hardhat clean", + "format": "prettier --write .", + "lint": "eslint . --ext .ts,.js", + "lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'" + }, + "dependencies": { + "@erc725/smart-contracts": "^7.0.0", + "@openzeppelin/contracts": "^4.9.3", + "lsp0": "*", + "lsp3": "*" + }, + "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^2.0.2", + "@typechain/ethers-v5": "^10.2.0", + "dotenv": "^16.0.3", + "eslint-config-custom": "*", + "ethers": "^5.7.2", + "hardhat": "^2.13.0", + "hardhat-contract-sizer": "^2.8.0", + "hardhat-deploy": "^0.11.25", + "hardhat-gas-reporter": "^1.0.9", + "hardhat-packager": "^1.4.2", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } +} diff --git a/packages/UniversalProfile/tsconfig.json b/packages/UniversalProfile/tsconfig.json new file mode 100644 index 000000000..b7a34e03f --- /dev/null +++ b/packages/UniversalProfile/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "tsconfig/contracts.json", + "include": ["**/*.ts"] +}