From a685c7f37eefbe147fe7fcbb266432b6617206ef Mon Sep 17 00:00:00 2001 From: CJ42 Date: Fri, 24 Nov 2023 17:21:11 +0000 Subject: [PATCH 1/2] build: move LSP14 in its own package --- .../LSP0ERC725AccountCore.sol | 6 +- contracts/LSP17Extensions/Extension4337.sol | 2 +- .../LSP6KeyManager/LSP6KeyManagerCore.sol | 2 +- contracts/LSP9Vault/LSP9VaultCore.sol | 4 +- contracts/Mocks/ERC165Interfaces.sol | 4 +- contracts/Mocks/LSP1TypeIDsTester.sol | 2 +- .../LSP20Owners/FallbackReturnMagicValue.sol | 4 +- .../FirstCallReturnExpandedInvalidValue.sol | 4 +- .../FirstCallReturnInvalidMagicValue.sol | 4 +- .../LSP20Owners/ImplementingFallback.sol | 4 +- .../LSP20Owners/NotImplementingVerifyCall.sol | 4 +- contracts/Mocks/LSP20Owners/OwnerWIthURD.sol | 4 +- .../Mocks/UPWithInstantAcceptOwnership.sol | 4 +- .../UniversalReceiverDelegateDataUpdater.sol | 2 +- dodoc/config.ts | 2 +- package-lock.json | 143 ++++++++++++------ package.json | 1 + packages/LSP14Ownable2Step/.eslintrc.js | 4 + packages/LSP14Ownable2Step/.solhint.json | 25 +++ packages/LSP14Ownable2Step/README.md | 3 + .../contracts}/ILSP14Ownable2Step.sol | 0 .../contracts}/LSP14Constants.sol | 0 .../contracts}/LSP14Errors.sol | 0 .../contracts}/LSP14Ownable2Step.sol | 0 packages/LSP14Ownable2Step/hardhat.config.ts | 128 ++++++++++++++++ packages/LSP14Ownable2Step/package.json | 45 ++++++ packages/LSP14Ownable2Step/tsconfig.json | 4 + .../LSP14Ownable2Step/TwoStepOwnership.sol | 2 +- .../LSP6KeyManager/LSP6SetDataTest.t.sol | 2 +- 29 files changed, 328 insertions(+), 81 deletions(-) create mode 100644 packages/LSP14Ownable2Step/.eslintrc.js create mode 100644 packages/LSP14Ownable2Step/.solhint.json create mode 100755 packages/LSP14Ownable2Step/README.md rename {contracts/LSP14Ownable2Step => packages/LSP14Ownable2Step/contracts}/ILSP14Ownable2Step.sol (100%) rename {contracts/LSP14Ownable2Step => packages/LSP14Ownable2Step/contracts}/LSP14Constants.sol (100%) rename {contracts/LSP14Ownable2Step => packages/LSP14Ownable2Step/contracts}/LSP14Errors.sol (100%) rename {contracts/LSP14Ownable2Step => packages/LSP14Ownable2Step/contracts}/LSP14Ownable2Step.sol (100%) create mode 100755 packages/LSP14Ownable2Step/hardhat.config.ts create mode 100644 packages/LSP14Ownable2Step/package.json create mode 100755 packages/LSP14Ownable2Step/tsconfig.json diff --git a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol index 121503db3..5b0ab5c19 100644 --- a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +++ b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol @@ -20,6 +20,8 @@ import { import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {LSP1Utils} from "lsp1/contracts/LSP1Utils.sol"; import {LSP2Utils} from "lsp2/contracts/LSP2Utils.sol"; +import {LSP1Utils} from "lsp1/contracts/LSP1Utils.sol"; +import {LSP2Utils} from "lsp2/contracts/LSP2Utils.sol"; // modules import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol"; @@ -27,7 +29,7 @@ import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol"; import { OwnableUnset } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol"; -import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol"; +import {LSP14Ownable2Step} from "lsp14/contracts/LSP14Ownable2Step.sol"; import { LSP17Extendable } from "lsp17contractextension/contracts/LSP17Extendable.sol"; @@ -50,7 +52,7 @@ import { _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX, _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY } from "lsp1/contracts/LSP1Constants.sol"; -import {_INTERFACEID_LSP14} from "../LSP14Ownable2Step/LSP14Constants.sol"; +import {_INTERFACEID_LSP14} from "lsp14/contracts/LSP14Constants.sol"; import { _LSP17_EXTENSION_PREFIX diff --git a/contracts/LSP17Extensions/Extension4337.sol b/contracts/LSP17Extensions/Extension4337.sol index 4661dd820..6b31f8d5e 100644 --- a/contracts/LSP17Extensions/Extension4337.sol +++ b/contracts/LSP17Extensions/Extension4337.sol @@ -9,7 +9,7 @@ import { import {ILSP20CallVerifier} from "lsp20/contracts/ILSP20CallVerifier.sol"; // modules -import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol"; +import {LSP14Ownable2Step} from "lsp14/contracts/LSP14Ownable2Step.sol"; import { LSP17Extension } from "lsp17contractextension/contracts/LSP17Extension.sol"; diff --git a/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol b/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol index 5aac45486..13e1e9a44 100644 --- a/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +++ b/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol @@ -18,7 +18,7 @@ import { } from "lsp25/contracts/ILSP25ExecuteRelayCall.sol"; // modules -import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol"; import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {LSP6SetDataModule} from "./LSP6Modules/LSP6SetDataModule.sol"; diff --git a/contracts/LSP9Vault/LSP9VaultCore.sol b/contracts/LSP9Vault/LSP9VaultCore.sol index 459b3e395..955243b6e 100644 --- a/contracts/LSP9Vault/LSP9VaultCore.sol +++ b/contracts/LSP9Vault/LSP9VaultCore.sol @@ -24,7 +24,7 @@ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol"; import { OwnableUnset } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol"; -import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol"; +import {LSP14Ownable2Step} from "lsp14/contracts/LSP14Ownable2Step.sol"; import { LSP17Extendable } from "lsp17contractextension/contracts/LSP17Extendable.sol"; @@ -61,7 +61,7 @@ import { _TYPEID_LSP9_OwnershipTransferred_SenderNotification, _TYPEID_LSP9_OwnershipTransferred_RecipientNotification } from "./LSP9Constants.sol"; -import {_INTERFACEID_LSP14} from "../LSP14Ownable2Step/LSP14Constants.sol"; +import {_INTERFACEID_LSP14} from "lsp14/contracts/LSP14Constants.sol"; import { _LSP17_EXTENSION_PREFIX } from "lsp17contractextension/contracts/LSP17Constants.sol"; diff --git a/contracts/Mocks/ERC165Interfaces.sol b/contracts/Mocks/ERC165Interfaces.sol index eb8a17115..afec49cf0 100644 --- a/contracts/Mocks/ERC165Interfaces.sol +++ b/contracts/Mocks/ERC165Interfaces.sol @@ -51,7 +51,7 @@ import { } from "../LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol"; import { ILSP14Ownable2Step as ILSP14 -} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +} from "lsp14/contracts/ILSP14Ownable2Step.sol"; import { ILSP20CallVerifier as ILSP20 } from "lsp20/contracts/ILSP20CallVerifier.sol"; @@ -74,7 +74,7 @@ import {_INTERFACEID_LSP9} from "../LSP9Vault/LSP9Constants.sol"; import { _INTERFACEID_LSP11 } from "../LSP11BasicSocialRecovery/LSP11Constants.sol"; -import {_INTERFACEID_LSP14} from "../LSP14Ownable2Step/LSP14Constants.sol"; +import {_INTERFACEID_LSP14} from "lsp14/contracts/LSP14Constants.sol"; import { _INTERFACEID_LSP17_EXTENDABLE, _INTERFACEID_LSP17_EXTENSION diff --git a/contracts/Mocks/LSP1TypeIDsTester.sol b/contracts/Mocks/LSP1TypeIDsTester.sol index ac9615aba..49b452788 100644 --- a/contracts/Mocks/LSP1TypeIDsTester.sol +++ b/contracts/Mocks/LSP1TypeIDsTester.sol @@ -27,7 +27,7 @@ import { _TYPEID_LSP14_OwnershipTransferStarted, _TYPEID_LSP14_OwnershipTransferred_SenderNotification, _TYPEID_LSP14_OwnershipTransferred_RecipientNotification -} from "../LSP14Ownable2Step/LSP14Constants.sol"; +} from "lsp14/contracts/LSP14Constants.sol"; error LSP1TypeIdHashIsWrong(bytes32 typeIdHash, string typeIdname); diff --git a/contracts/Mocks/LSP20Owners/FallbackReturnMagicValue.sol b/contracts/Mocks/LSP20Owners/FallbackReturnMagicValue.sol index aebe22fd2..ab60dac45 100644 --- a/contracts/Mocks/LSP20Owners/FallbackReturnMagicValue.sol +++ b/contracts/Mocks/LSP20Owners/FallbackReturnMagicValue.sol @@ -2,9 +2,7 @@ pragma solidity ^0.8.4; import {ILSP20CallVerifier} from "lsp20/contracts/ILSP20CallVerifier.sol"; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; /** * @title sample contract used for testing diff --git a/contracts/Mocks/LSP20Owners/FirstCallReturnExpandedInvalidValue.sol b/contracts/Mocks/LSP20Owners/FirstCallReturnExpandedInvalidValue.sol index 320c08f45..3cc568415 100644 --- a/contracts/Mocks/LSP20Owners/FirstCallReturnExpandedInvalidValue.sol +++ b/contracts/Mocks/LSP20Owners/FirstCallReturnExpandedInvalidValue.sol @@ -1,9 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.4; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; /** * @title sample contract used for testing diff --git a/contracts/Mocks/LSP20Owners/FirstCallReturnInvalidMagicValue.sol b/contracts/Mocks/LSP20Owners/FirstCallReturnInvalidMagicValue.sol index c9e6b60a2..66375d087 100644 --- a/contracts/Mocks/LSP20Owners/FirstCallReturnInvalidMagicValue.sol +++ b/contracts/Mocks/LSP20Owners/FirstCallReturnInvalidMagicValue.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.4; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; /** * @title sample contract used for testing diff --git a/contracts/Mocks/LSP20Owners/ImplementingFallback.sol b/contracts/Mocks/LSP20Owners/ImplementingFallback.sol index df6d4f7f5..6813a5962 100644 --- a/contracts/Mocks/LSP20Owners/ImplementingFallback.sol +++ b/contracts/Mocks/LSP20Owners/ImplementingFallback.sol @@ -1,9 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.4; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; /** * @title sample contract used for testing diff --git a/contracts/Mocks/LSP20Owners/NotImplementingVerifyCall.sol b/contracts/Mocks/LSP20Owners/NotImplementingVerifyCall.sol index a6010ed3e..8b4f193cb 100644 --- a/contracts/Mocks/LSP20Owners/NotImplementingVerifyCall.sol +++ b/contracts/Mocks/LSP20Owners/NotImplementingVerifyCall.sol @@ -1,9 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.4; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; /** * @title sample contract used for testing diff --git a/contracts/Mocks/LSP20Owners/OwnerWIthURD.sol b/contracts/Mocks/LSP20Owners/OwnerWIthURD.sol index f6e649199..ccfa81309 100644 --- a/contracts/Mocks/LSP20Owners/OwnerWIthURD.sol +++ b/contracts/Mocks/LSP20Owners/OwnerWIthURD.sol @@ -5,9 +5,7 @@ import { ILSP1UniversalReceiver } from "lsp1/contracts/ILSP1UniversalReceiver.sol"; -import { - ILSP14Ownable2Step -} from "../../LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import {ILSP14Ownable2Step} from "lsp14/contracts/ILSP14Ownable2Step.sol"; import {ILSP20CallVerifier} from "lsp20/contracts/ILSP20CallVerifier.sol"; import { diff --git a/contracts/Mocks/UPWithInstantAcceptOwnership.sol b/contracts/Mocks/UPWithInstantAcceptOwnership.sol index a6854b70a..4e4ae63ef 100644 --- a/contracts/Mocks/UPWithInstantAcceptOwnership.sol +++ b/contracts/Mocks/UPWithInstantAcceptOwnership.sol @@ -8,7 +8,7 @@ import { import { OwnableUnset } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol"; -import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol"; +import {LSP14Ownable2Step} from "lsp14/contracts/LSP14Ownable2Step.sol"; // constants import { @@ -19,7 +19,7 @@ import { } from "../LSP9Vault/LSP9Constants.sol"; import { _TYPEID_LSP14_OwnershipTransferStarted -} from "../LSP14Ownable2Step/LSP14Constants.sol"; +} from "lsp14/contracts/LSP14Constants.sol"; /** * @dev This contract is used only for testing purposes diff --git a/contracts/Mocks/UniversalReceivers/UniversalReceiverDelegateDataUpdater.sol b/contracts/Mocks/UniversalReceivers/UniversalReceiverDelegateDataUpdater.sol index 3d463b48f..8e45124dc 100644 --- a/contracts/Mocks/UniversalReceivers/UniversalReceiverDelegateDataUpdater.sol +++ b/contracts/Mocks/UniversalReceivers/UniversalReceiverDelegateDataUpdater.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.4; // interfaces import {ILSP6KeyManager} from "../../LSP6KeyManager/ILSP6KeyManager.sol"; -import {LSP14Ownable2Step} from "../../LSP14Ownable2Step/LSP14Ownable2Step.sol"; +import {LSP14Ownable2Step} from "lsp14/contracts/LSP14Ownable2Step.sol"; import { ILSP1UniversalReceiverDelegate diff --git a/dodoc/config.ts b/dodoc/config.ts index e1b88e3d0..c5147afbf 100644 --- a/dodoc/config.ts +++ b/dodoc/config.ts @@ -11,7 +11,7 @@ export const dodocConfig = { 'contracts/LSP6KeyManager/LSP6KeyManager.sol', 'contracts/LSP9Vault/LSP9Vault.sol', 'contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol', - 'contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol', + 'lsp14/contracts/LSP14Ownable2Step.sol', 'contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol', 'lsp17contractextension/contracts/LSP17Extendable.sol', 'lsp17contractextension/contracts/LSP17Extension.sol', diff --git a/package-lock.json b/package-lock.json index 0b47b729a..e7fcf6011 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@openzeppelin/contracts-upgradeable": "^4.9.2", "lsp1": "*", "lsp10": "*", + "lsp14": "*", "lsp17contractextension": "*", "lsp2": "*", "lsp20": "*", @@ -4453,10 +4454,10 @@ "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/type-utils": "6.19.1", - "@typescript-eslint/utils": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/type-utils": "6.20.0", + "@typescript-eslint/utils": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -4494,10 +4495,10 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==", "dependencies": { - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/typescript-estree": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4" }, "engines": { @@ -4521,8 +4522,8 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==", "dependencies": { - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1" + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -4537,8 +4538,8 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", "dependencies": { - "@typescript-eslint/typescript-estree": "6.19.1", - "@typescript-eslint/utils": "6.19.1", + "@typescript-eslint/typescript-estree": "6.20.0", + "@typescript-eslint/utils": "6.20.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -4575,8 +4576,8 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==", "dependencies": { - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4632,9 +4633,9 @@ "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", "semver": "^7.5.4" }, "engines": { @@ -4653,7 +4654,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==", "dependencies": { - "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/types": "6.20.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -13333,6 +13334,10 @@ "resolved": "packages/LSP10ReceivedVaults", "link": true }, + "node_modules/lsp14": { + "resolved": "packages/LSP14Ownable2Step", + "link": true + }, "node_modules/lsp17contractextension": { "resolved": "packages/LSP17ContractExtension", "link": true @@ -23641,6 +23646,32 @@ "node": ">=4.2.0" } }, + "packages/LSP14Ownable2Step": { + "name": "lsp14", + "version": "0.12.1", + "license": "Apache-2.0", + "dependencies": { + "@erc725/smart-contracts": "^7.0.0", + "lsp1": "*" + }, + "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/LSP17ContractExtension": { "name": "lsp17contractextension", "version": "0.14.0", @@ -26988,10 +27019,10 @@ "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", "requires": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/type-utils": "6.19.1", - "@typescript-eslint/utils": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/type-utils": "6.20.0", + "@typescript-eslint/utils": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -27012,45 +27043,41 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==", "requires": { - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/typescript-estree": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==", "requires": { - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1" + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0" } }, "@typescript-eslint/type-utils": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", "requires": { - "@typescript-eslint/typescript-estree": "6.19.1", - "@typescript-eslint/utils": "6.19.1", + "@typescript-eslint/typescript-estree": "6.20.0", + "@typescript-eslint/utils": "6.20.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/types": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", "integrity": "sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==" }, "@typescript-eslint/typescript-estree": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==", "requires": { - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/visitor-keys": "6.19.1", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -27080,25 +27107,23 @@ } }, "@typescript-eslint/utils": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.19.1", - "@typescript-eslint/types": "6.19.1", - "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", + "version": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==", "requires": { - "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/types": "6.20.0", "eslint-visitor-keys": "^3.4.1" }, "dependencies": { @@ -34028,6 +34053,28 @@ } } }, + "lsp14": { + "version": "file:packages/LSP14Ownable2Step", + "requires": { + "@erc725/smart-contracts": "^7.0.0", + "@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", + "lsp1": "*", + "solhint": "^3.3.6", + "ts-node": "^10.2.0", + "tsconfig": "*", + "typechain": "^8.0.0", + "typescript": "^5.3.3" + } + }, "lsp17contractextension": { "version": "file:packages/LSP17ContractExtension", "requires": { diff --git a/package.json b/package.json index aea60ff99..00ba1e39b 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "lsp4": "*", "lsp5": "*", "lsp10": "*", + "lsp14": "*", "lsp17contractextension": "*", "lsp20": "*", "lsp25": "*" diff --git a/packages/LSP14Ownable2Step/.eslintrc.js b/packages/LSP14Ownable2Step/.eslintrc.js new file mode 100644 index 000000000..03ee7431b --- /dev/null +++ b/packages/LSP14Ownable2Step/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ['custom'], +}; diff --git a/packages/LSP14Ownable2Step/.solhint.json b/packages/LSP14Ownable2Step/.solhint.json new file mode 100644 index 000000000..26e01c48a --- /dev/null +++ b/packages/LSP14Ownable2Step/.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/LSP14Ownable2Step/README.md b/packages/LSP14Ownable2Step/README.md new file mode 100755 index 000000000..fc22873a4 --- /dev/null +++ b/packages/LSP14Ownable2Step/README.md @@ -0,0 +1,3 @@ +# LSP14 Ownable 2 Step + +Package for the LSP14 Ownable 2 Step standard. diff --git a/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol b/packages/LSP14Ownable2Step/contracts/ILSP14Ownable2Step.sol similarity index 100% rename from contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol rename to packages/LSP14Ownable2Step/contracts/ILSP14Ownable2Step.sol diff --git a/contracts/LSP14Ownable2Step/LSP14Constants.sol b/packages/LSP14Ownable2Step/contracts/LSP14Constants.sol similarity index 100% rename from contracts/LSP14Ownable2Step/LSP14Constants.sol rename to packages/LSP14Ownable2Step/contracts/LSP14Constants.sol diff --git a/contracts/LSP14Ownable2Step/LSP14Errors.sol b/packages/LSP14Ownable2Step/contracts/LSP14Errors.sol similarity index 100% rename from contracts/LSP14Ownable2Step/LSP14Errors.sol rename to packages/LSP14Ownable2Step/contracts/LSP14Errors.sol diff --git a/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol b/packages/LSP14Ownable2Step/contracts/LSP14Ownable2Step.sol similarity index 100% rename from contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol rename to packages/LSP14Ownable2Step/contracts/LSP14Ownable2Step.sol diff --git a/packages/LSP14Ownable2Step/hardhat.config.ts b/packages/LSP14Ownable2Step/hardhat.config.ts new file mode 100755 index 000000000..18a286598 --- /dev/null +++ b/packages/LSP14Ownable2Step/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: ['LSP14Ownable2Step'], + // 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/LSP14Ownable2Step/package.json b/packages/LSP14Ownable2Step/package.json new file mode 100644 index 000000000..e80643372 --- /dev/null +++ b/packages/LSP14Ownable2Step/package.json @@ -0,0 +1,45 @@ +{ + "name": "lsp14", + "version": "0.12.1", + "description": "Package for the LSP14 Ownable 2 Step 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": "eslint . --ext .ts,.js", + "lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'" + }, + "dependencies": { + "@erc725/smart-contracts": "^7.0.0", + "lsp1": "*" + }, + "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/LSP14Ownable2Step/tsconfig.json b/packages/LSP14Ownable2Step/tsconfig.json new file mode 100755 index 000000000..b7a34e03f --- /dev/null +++ b/packages/LSP14Ownable2Step/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "tsconfig/contracts.json", + "include": ["**/*.ts"] +} diff --git a/tests/foundry/LSP14Ownable2Step/TwoStepOwnership.sol b/tests/foundry/LSP14Ownable2Step/TwoStepOwnership.sol index c1e152a47..fabf77824 100644 --- a/tests/foundry/LSP14Ownable2Step/TwoStepOwnership.sol +++ b/tests/foundry/LSP14Ownable2Step/TwoStepOwnership.sol @@ -7,7 +7,7 @@ import "../../../contracts/LSP0ERC725Account/LSP0ERC725Account.sol"; import { LSP14MustAcceptOwnershipInSeparateTransaction -} from "../../../contracts/LSP14Ownable2Step/LSP14Errors.sol"; +} from "lsp14/contracts/LSP14Errors.sol"; contract Implementation is LSP0ERC725Account { constructor() LSP0ERC725Account(msg.sender) {} diff --git a/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol b/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol index 8586ee493..1fe94f4ef 100644 --- a/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol +++ b/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol @@ -5,7 +5,7 @@ import "forge-std/Test.sol"; import "../../../contracts/UniversalProfile.sol"; import "../../../contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol"; import "../../../contracts/LSP6KeyManager/LSP6KeyManager.sol"; -import "../../../contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol"; +import "../../../packages/LSP14Ownable2Step/contracts/ILSP14Ownable2Step.sol"; import "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol"; import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol"; From d71c72d558dbf308b7aef1acb0bf0c6a004cc982 Mon Sep 17 00:00:00 2001 From: CJ42 Date: Mon, 29 Jan 2024 23:11:01 +0000 Subject: [PATCH 2/2] refactor: update import paths + add LSP14 in remappings --- .github/workflows/solc_version.yml | 2 + .../LSP0ERC725AccountCore.sol | 2 - .../contracts}/LSP14Ownable2Step.md | 68 +-- docs/libraries/lsp2/contracts/LSP2Utils.md | 439 ++++++++++++++++++ package-lock.json | 107 ++--- remappings.txt | 3 +- .../LSP6KeyManager/LSP6SetDataTest.t.sol | 2 +- 7 files changed, 533 insertions(+), 90 deletions(-) rename docs/contracts/{LSP14Ownable2Step => lsp14/contracts}/LSP14Ownable2Step.md (76%) create mode 100644 docs/libraries/lsp2/contracts/LSP2Utils.md diff --git a/.github/workflows/solc_version.yml b/.github/workflows/solc_version.yml index a110dd066..951ab1fcd 100644 --- a/.github/workflows/solc_version.yml +++ b/.github/workflows/solc_version.yml @@ -85,6 +85,7 @@ jobs: lsp2/=packages/LSP2ERC725YJSONSchema/ \ lsp4/=packages/LSP4DigitalAssetMetadata/ \ lsp5/=packages/LSP5ReceivedAssets/ \ + lsp14/=packages/LSP14Ownable2Step/ \ lsp17contractextension/=packages/LSP17ContractExtension/ \ lsp20/=packages/LSP20CallVerification/ \ lsp25/=packages/LSP25ExecuteRelayCall/ @@ -96,6 +97,7 @@ jobs: lsp2/=packages/LSP2ERC725YJSONSchema/ \ lsp4/=packages/LSP4DigitalAssetMetadata/ \ lsp5/=packages/LSP5ReceivedAssets/ \ + lsp14/=packages/LSP14Ownable2Step/ \ lsp17contractextension/=packages/LSP17ContractExtension/ \ lsp20/=packages/LSP20CallVerification/ \ lsp25/=packages/LSP25ExecuteRelayCall/ diff --git a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol index 5b0ab5c19..3ea2e1a27 100644 --- a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +++ b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol @@ -20,8 +20,6 @@ import { import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {LSP1Utils} from "lsp1/contracts/LSP1Utils.sol"; import {LSP2Utils} from "lsp2/contracts/LSP2Utils.sol"; -import {LSP1Utils} from "lsp1/contracts/LSP1Utils.sol"; -import {LSP2Utils} from "lsp2/contracts/LSP2Utils.sol"; // modules import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol"; diff --git a/docs/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md b/docs/contracts/lsp14/contracts/LSP14Ownable2Step.md similarity index 76% rename from docs/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md rename to docs/contracts/lsp14/contracts/LSP14Ownable2Step.md index 1fc9130d7..c7021e9fb 100644 --- a/docs/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md +++ b/docs/contracts/lsp14/contracts/LSP14Ownable2Step.md @@ -5,12 +5,12 @@ :::info Standard Specifications -[`LSP-14-Ownable2Step`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md) +[`LSP-14-Ownable2Step.sol`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md) ::: :::info Solidity implementation -[`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +[`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) ::: @@ -27,8 +27,8 @@ When marked as 'public', a method can be called both externally and internally, :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#renounce_ownership_confirmation_delay) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#renounce_ownership_confirmation_delay) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY()` - Function selector: `0xead3fbdf` @@ -55,8 +55,8 @@ The number of block that MUST pass before one is able to confirm renouncing owne :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#renounce_ownership_confirmation_period) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#renounce_ownership_confirmation_period) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD()` - Function selector: `0x01bfba61` @@ -83,8 +83,8 @@ The number of blocks during which one can renounce ownership. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#acceptownership) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#acceptownership) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `acceptOwnership()` - Function selector: `0x79ba5097` @@ -116,8 +116,8 @@ Transfer ownership of the contract from the current [`owner()`](#owner) to the [ :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#owner) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#owner) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `owner()` - Function selector: `0x8da5cb5b` @@ -141,8 +141,8 @@ Returns the address of the current owner. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#pendingowner) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#pendingowner) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `pendingOwner()` - Function selector: `0xe30c3978` @@ -172,8 +172,8 @@ The address that ownership of the contract is transferred to. This address may u :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#renounceownership) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#renounceownership) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `renounceOwnership()` - Function selector: `0x715018a6` @@ -203,8 +203,8 @@ Renounce ownership of the contract in a 2-step process. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#transferownership) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#transferownership) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Function signature: `transferOwnership(address)` - Function selector: `0xf2fde38b` @@ -311,8 +311,8 @@ Initiate or confirm the process of renouncing ownership after a specific delay o :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#ownershiprenounced) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#ownershiprenounced) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Event signature: `OwnershipRenounced()` - Event topic hash: `0xd1f66c3d2bc1993a86be5e3d33709d98f0442381befcedd29f578b9b2506b1ce` @@ -332,8 +332,8 @@ Emitted when the ownership of the contract has been renounced. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#ownershiptransferstarted) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#ownershiptransferstarted) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Event signature: `OwnershipTransferStarted(address,address)` - Event topic hash: `0x38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700` @@ -363,8 +363,8 @@ Emitted when [`transferOwnership(..)`](#transferownership) was called and the fi :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#ownershiptransferred) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#ownershiptransferred) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Event signature: `OwnershipTransferred(address,address)` - Event topic hash: `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0` @@ -390,8 +390,8 @@ event OwnershipTransferred( :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#renounceownershipstarted) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#renounceownershipstarted) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Event signature: `RenounceOwnershipStarted()` - Event topic hash: `0x81b7f830f1f0084db6497c486cbe6974c86488dcc4e3738eab94ab6d6b1653e7` @@ -413,8 +413,8 @@ Emitted when starting the [`renounceOwnership(..)`](#renounceownership) 2-step p :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#lsp14callernotpendingowner) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#lsp14callernotpendingowner) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Error signature: `LSP14CallerNotPendingOwner(address)` - Error hash: `0x451e4528` @@ -438,8 +438,8 @@ Reverts when the `caller` that is trying to accept ownership of the contract is :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#lsp14cannottransferownershiptoself) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#lsp14cannottransferownershiptoself) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Error signature: `LSP14CannotTransferOwnershipToSelf()` - Error hash: `0xe052a6f8` @@ -459,8 +459,8 @@ Reverts when trying to transfer ownership to the `address(this)`. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#lsp14mustacceptownershipinseparatetransaction) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#lsp14mustacceptownershipinseparatetransaction) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Error signature: `LSP14MustAcceptOwnershipInSeparateTransaction()` - Error hash: `0x5758dd07` @@ -480,8 +480,8 @@ Reverts when pending owner accept ownership in the same transaction of transferr :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#lsp14notinrenounceownershipinterval) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#lsp14notinrenounceownershipinterval) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Error signature: `LSP14NotInRenounceOwnershipInterval(uint256,uint256)` - Error hash: `0x1b080942` @@ -511,8 +511,8 @@ Reverts when trying to renounce ownership before the initial confirmation delay. :::note References -- Specification details: [**LSP-14-Ownable2Step**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.md#ownablecallernottheowner) -- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol) +- Specification details: [**LSP-14-Ownable2Step.sol**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-14-Ownable2Step.sol.md#ownablecallernottheowner) +- Solidity implementation: [`LSP14Ownable2Step.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp14/contracts/LSP14Ownable2Step.sol) - Error signature: `OwnableCallerNotTheOwner(address)` - Error hash: `0xbf1169c5` diff --git a/docs/libraries/lsp2/contracts/LSP2Utils.md b/docs/libraries/lsp2/contracts/LSP2Utils.md new file mode 100644 index 000000000..84f3d12d5 --- /dev/null +++ b/docs/libraries/lsp2/contracts/LSP2Utils.md @@ -0,0 +1,439 @@ + + + +# LSP2Utils + +:::info Standard Specifications + +[`LSP-2-Utils.sol`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-2-Utils.sol.md) + +::: +:::info Solidity implementation + +[`LSP2Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/lsp2/contracts/LSP2Utils.sol) + +::: + +> LSP2 Utility library. + +LSP2Utils is a library of utility functions that can be used to encode data key of different key type defined on the LSP2 standard. Based on LSP2 ERC725Y JSON Schema standard. + +## Internal Methods + +Any method labeled as `internal` serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs. + +Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities. + +### generateSingletonKey + +```solidity +function generateSingletonKey(string keyName) internal pure returns (bytes32); +``` + +Generates a data key of keyType Singleton by hashing the string `keyName`. As: + +``` +keccak256("keyName") +``` + +#### Parameters + +| Name | Type | Description | +| --------- | :------: | ---------------------------------------------------- | +| `keyName` | `string` | The string to hash to generate a Singleton data key. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Singleton. | + +
+ +### generateArrayKey + +```solidity +function generateArrayKey(string arrayKeyName) internal pure returns (bytes32); +``` + +Generates a data key of keyType Array by hashing `arrayKeyName`. As: + +``` +keccak256("arrayKeyName[]") +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | :------: | ---------------------------------------------------------------------- | +| `arrayKeyName` | `string` | The string that will be used to generate a data key of key type Array. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | --------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Array. | + +
+ +### generateArrayElementKeyAtIndex + +```solidity +function generateArrayElementKeyAtIndex( + bytes32 arrayKey, + uint128 index +) internal pure returns (bytes32); +``` + +Generates an Array data key at a specific `index` by concatenating together the first 16 bytes of `arrayKey` +with the 16 bytes of `index`. As: + +``` +arrayKey[index] +``` + +#### Parameters + +| Name | Type | Description | +| ---------- | :-------: | ----------------------------------------------------------------------------------- | +| `arrayKey` | `bytes32` | The Array data key from which to generate the Array data key at a specific `index`. | +| `index` | `uint128` | The index number in the `arrayKey`. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Array at a specific `index`. | + +
+ +### generateMappingKey + +```solidity +function generateMappingKey( + string firstWord, + string lastWord +) internal pure returns (bytes32); +``` + +Generates a data key of key type Mapping that map `firstWord` to `lastWord`. This is done by hashing two strings words `firstWord` and `lastWord`. As: + +``` +bytes10(firstWordHash):0000:bytes20(lastWordHash) +``` + +#### Parameters + +| Name | Type | Description | +| ----------- | :------: | ---------------------------------------------------- | +| `firstWord` | `string` | The word to retrieve the first 10 bytes of its hash. | +| `lastWord` | `string` | The word to retrieve the first 10 bytes of its hash. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | --------------------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Mapping that map `firstWord` to a specific `lastWord`. | + +
+ +### generateMappingKey + +```solidity +function generateMappingKey( + string firstWord, + address addr +) internal pure returns (bytes32); +``` + +Generates a data key of key type Mapping that map `firstWord` to an address `addr`. +This is done by hashing the string word `firstWord` and concatenating its first 10 bytes with `addr`. As: + +``` +bytes10(firstWordHash):0000:
+``` + +#### Parameters + +| Name | Type | Description | +| ----------- | :-------: | ---------------------------------------------------- | +| `firstWord` | `string` | The word to retrieve the first 10 bytes of its hash. | +| `addr` | `address` | An address to map `firstWord` to. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ------------------------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Mapping that map `firstWord` to a specific address `addr`. | + +
+ +### generateMappingKey + +```solidity +function generateMappingKey( + bytes10 keyPrefix, + bytes20 bytes20Value +) internal pure returns (bytes32); +``` + +Generate a data key of key type Mapping that map a 10 bytes `keyPrefix` to a `bytes20Value`. As: + +``` +keyPrefix:bytes20Value +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | :-------: | ---------------------------------------------------- | +| `keyPrefix` | `bytes10` | The first part of the data key of key type Mapping. | +| `bytes20Value` | `bytes20` | The second part of the data key of key type Mapping. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | --------------------------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type Mapping that map a `keyPrefix` to a specific `bytes20Value`. | + +
+ +### generateMappingWithGroupingKey + +```solidity +function generateMappingWithGroupingKey( + string firstWord, + string secondWord, + address addr +) internal pure returns (bytes32); +``` + +Generate a data key of key type MappingWithGrouping by using two strings `firstWord` +mapped to a `secondWord` mapped itself to a specific address `addr`. As: + +``` +bytes6(keccak256("firstWord")):bytes4(keccak256("secondWord")):0000:
+``` + +#### Parameters + +| Name | Type | Description | +| ------------ | :-------: | ---------------------------------------------------------------- | +| `firstWord` | `string` | The word to retrieve the first 6 bytes of its hash. | +| `secondWord` | `string` | The word to retrieve the first 4 bytes of its hash. | +| `addr` | `address` | The address that makes the last part of the MappingWithGrouping. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | --------------------------------------------------------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type MappingWithGrouping that map a `firstWord` to a `secondWord` to a specific address `addr`. | + +
+ +### generateMappingWithGroupingKey + +```solidity +function generateMappingWithGroupingKey( + bytes6 keyPrefix, + bytes4 mapPrefix, + bytes20 subMapKey +) internal pure returns (bytes32); +``` + +Generate a data key of key type MappingWithGrouping that map a `keyPrefix` to an other `mapPrefix` to a specific `subMapKey`. As: + +``` +keyPrefix:mapPrefix:0000:subMapKey +``` + +#### Parameters + +| Name | Type | Description | +| ----------- | :-------: | ------------------------------------------------------------------------- | +| `keyPrefix` | `bytes6` | The first part (6 bytes) of the data key of keyType MappingWithGrouping. | +| `mapPrefix` | `bytes4` | The second part (4 bytes) of the data key of keyType MappingWithGrouping. | +| `subMapKey` | `bytes20` | The last part (bytes20) of the data key of keyType MappingWithGrouping. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | ----------------------------------------------------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type MappingWithGrouping that map a `keyPrefix` to a `mapPrefix` to a specific `subMapKey`. | + +
+ +### generateMappingWithGroupingKey + +```solidity +function generateMappingWithGroupingKey( + bytes10 keyPrefix, + bytes20 bytes20Value +) internal pure returns (bytes32); +``` + +Generate a data key of key type MappingWithGrouping that map a 10 bytes `keyPrefix` to a specific `bytes20Value`. As: + +#### Parameters + +| Name | Type | Description | +| -------------- | :-------: | -------------------------------------------------------------- | +| `keyPrefix` | `bytes10` | The first part of the data key of keyType MappingWithGrouping. | +| `bytes20Value` | `bytes20` | The last of the data key of keyType MappingWithGrouping. | + +#### Returns + +| Name | Type | Description | +| ---- | :-------: | --------------------------------------------------------------------------------------- | +| `0` | `bytes32` | The generated `bytes32` data key of key type MappingWithGrouping that map a `keyPrefix` | + +
+ +### generateJSONURLValue + +```solidity +function generateJSONURLValue( + string hashFunction, + string json, + string url +) internal pure returns (bytes); +``` + +Generate a JSONURL value content. + +#### Parameters + +| Name | Type | Description | +| -------------- | :------: | ---------------------------------------- | +| `hashFunction` | `string` | The function used to hash the JSON file. | +| `json` | `string` | Bytes value of the JSON file. | +| `url` | `string` | The URL where the JSON file is hosted. | + +
+ +### generateASSETURLValue + +```solidity +function generateASSETURLValue( + string hashFunction, + string assetBytes, + string url +) internal pure returns (bytes); +``` + +Generate a ASSETURL value content. + +#### Parameters + +| Name | Type | Description | +| -------------- | :------: | ---------------------------------------- | +| `hashFunction` | `string` | The function used to hash the JSON file. | +| `assetBytes` | `string` | Bytes value of the JSON file. | +| `url` | `string` | The URL where the JSON file is hosted. | + +#### Returns + +| Name | Type | Description | +| ---- | :-----: | ----------------------------------- | +| `0` | `bytes` | The encoded value as an `ASSETURL`. | + +
+ +### isCompactBytesArray + +```solidity +function isCompactBytesArray( + bytes compactBytesArray +) internal pure returns (bool); +``` + +Verify if `data` is a valid array of value encoded as a `CompactBytesArray` according to the LSP2 `CompactBytesArray` valueType specification. + +#### Parameters + +| Name | Type | Description | +| ------------------- | :-----: | -------------------------- | +| `compactBytesArray` | `bytes` | The bytes value to verify. | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | ------------------------------------------------------------------------------- | +| `0` | `bool` | `true` if the `data` is correctly encoded CompactBytesArray, `false` otherwise. | + +
+ +### isValidLSP2ArrayLengthValue + +```solidity +function isValidLSP2ArrayLengthValue( + bytes arrayLength +) internal pure returns (bool); +``` + +Validates if the bytes `arrayLength` are exactly 16 bytes long, and are of the exact size of an LSP2 Array length value + +#### Parameters + +| Name | Type | Description | +| ------------- | :-----: | ------------------------------------- | +| `arrayLength` | `bytes` | Plain bytes that should be validated. | + +#### Returns + +| Name | Type | Description | +| ---- | :----: | -------------------------------------------------------- | +| `0` | `bool` | `true` if the value is 16 bytes long, `false` otherwise. | + +
+ +### removeLastElementFromArrayAndMap + +```solidity +function removeLastElementFromArrayAndMap( + bytes32 arrayKey, + uint128 newArrayLength, + bytes32 removedElementIndexKey, + bytes32 removedElementMapKey +) internal pure returns (bytes32[] dataKeys, bytes[] dataValues); +``` + +Generates Data Key/Value pairs for removing the last element from an LSP2 Array and a mapping Data Key. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-------: | ------------------------------------------------------------- | +| `arrayKey` | `bytes32` | The Data Key of Key Type Array. | +| `newArrayLength` | `uint128` | The new Array Length for the `arrayKey`. | +| `removedElementIndexKey` | `bytes32` | The Data Key of Key Type Array Index for the removed element. | +| `removedElementMapKey` | `bytes32` | The Data Key of a mapping to be removed. | + +
+ +### removeElementFromArrayAndMap + +:::info + +The function assumes that the Data Value stored under the mapping Data Key is of length 20 where the last 16 bytes are the index of the element in the array. + +::: + +```solidity +function removeElementFromArrayAndMap(contract IERC725Y erc725YContract, bytes32 arrayKey, uint128 newArrayLength, bytes32 removedElementIndexKey, uint128 removedElementIndex, bytes32 removedElementMapKey) internal view returns (bytes32[] dataKeys, bytes[] dataValues); +``` + +Generates Data Key/Value pairs for removing an element from an LSP2 Array and a mapping Data Key. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-----------------: | ------------------------------------------------------------- | +| `erc725YContract` | `contract IERC725Y` | The ERC725Y contract. | +| `arrayKey` | `bytes32` | The Data Key of Key Type Array. | +| `newArrayLength` | `uint128` | The new Array Length for the `arrayKey`. | +| `removedElementIndexKey` | `bytes32` | The Data Key of Key Type Array Index for the removed element. | +| `removedElementIndex` | `uint128` | the index of the removed element. | +| `removedElementMapKey` | `bytes32` | The Data Key of a mapping to be removed. | + +
diff --git a/package-lock.json b/package-lock.json index e7fcf6011..a84b978f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4449,9 +4449,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz", - "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.20.0.tgz", + "integrity": "sha512-fTwGQUnjhoYHeSF6m5pWNkzmDDdsKELYrOBxhjMrofPqCkoC2k3B2wvGHFxa1CTIqkEn88nlW1HVMztjo2K8Hg==", "dependencies": { "@eslint-community/regexpp": "^4.5.1", "@typescript-eslint/scope-manager": "6.20.0", @@ -4491,9 +4491,9 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", - "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.20.0.tgz", + "integrity": "sha512-bYerPDF/H5v6V76MdMYhjwmwgMA+jlPVqjSDq2cRqMi8bP5sR3Z+RLOiOMad3nsnmDVmn2gAFCyNgh/dIrfP/w==", "dependencies": { "@typescript-eslint/scope-manager": "6.20.0", "@typescript-eslint/types": "6.20.0", @@ -4518,9 +4518,9 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", - "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", + "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", "dependencies": { "@typescript-eslint/types": "6.20.0", "@typescript-eslint/visitor-keys": "6.20.0" @@ -4534,9 +4534,9 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", - "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.20.0.tgz", + "integrity": "sha512-qnSobiJQb1F5JjN0YDRPHruQTrX7ICsmltXhkV536mp4idGAYrIyr47zF/JmkJtEcAVnIz4gUYJ7gOZa6SmN4g==", "dependencies": { "@typescript-eslint/typescript-estree": "6.20.0", "@typescript-eslint/utils": "6.20.0", @@ -4560,9 +4560,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", - "integrity": "sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", + "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==", "engines": { "node": "^16.0.0 || >=18.0.0" }, @@ -4572,9 +4572,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", - "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", + "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", "dependencies": { "@typescript-eslint/types": "6.20.0", "@typescript-eslint/visitor-keys": "6.20.0", @@ -4626,9 +4626,9 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", - "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", + "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", @@ -4650,9 +4650,9 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", - "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", + "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", "dependencies": { "@typescript-eslint/types": "6.20.0", "eslint-visitor-keys": "^3.4.1" @@ -7495,9 +7495,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.648", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.648.tgz", - "integrity": "sha512-EmFMarXeqJp9cUKu/QEciEApn0S/xRcpZWuAm32U7NgoZCimjsilKXHRO9saeEW55eHZagIDg6XTUOv32w9pjg==" + "version": "1.4.650", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.650.tgz", + "integrity": "sha512-sYSQhJCJa4aGA1wYol5cMQgekDBlbVfTRavlGZVr3WZpDdOPcp6a6xUnFfrt8TqZhsBYYbDxJZCjGfHuGupCRQ==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -23700,9 +23700,8 @@ }, "packages/LSP17ContractExtension/node_modules/typescript": { "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -27014,9 +27013,9 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz", - "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.20.0.tgz", + "integrity": "sha512-fTwGQUnjhoYHeSF6m5pWNkzmDDdsKELYrOBxhjMrofPqCkoC2k3B2wvGHFxa1CTIqkEn88nlW1HVMztjo2K8Hg==", "requires": { "@eslint-community/regexpp": "^4.5.1", "@typescript-eslint/scope-manager": "6.20.0", @@ -27039,9 +27038,9 @@ } }, "@typescript-eslint/parser": { - "version": "6.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", - "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.20.0.tgz", + "integrity": "sha512-bYerPDF/H5v6V76MdMYhjwmwgMA+jlPVqjSDq2cRqMi8bP5sR3Z+RLOiOMad3nsnmDVmn2gAFCyNgh/dIrfP/w==", "requires": { "@typescript-eslint/scope-manager": "6.20.0", "@typescript-eslint/types": "6.20.0", @@ -27051,16 +27050,18 @@ } }, "@typescript-eslint/scope-manager": { - "version": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", - "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", + "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", "requires": { "@typescript-eslint/types": "6.20.0", "@typescript-eslint/visitor-keys": "6.20.0" } }, "@typescript-eslint/type-utils": { - "version": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", - "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.20.0.tgz", + "integrity": "sha512-qnSobiJQb1F5JjN0YDRPHruQTrX7ICsmltXhkV536mp4idGAYrIyr47zF/JmkJtEcAVnIz4gUYJ7gOZa6SmN4g==", "requires": { "@typescript-eslint/typescript-estree": "6.20.0", "@typescript-eslint/utils": "6.20.0", @@ -27069,12 +27070,14 @@ } }, "@typescript-eslint/types": { - "version": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", - "integrity": "sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==" + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", + "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==" }, "@typescript-eslint/typescript-estree": { - "version": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", - "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", + "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", "requires": { "@typescript-eslint/types": "6.20.0", "@typescript-eslint/visitor-keys": "6.20.0", @@ -27107,8 +27110,9 @@ } }, "@typescript-eslint/utils": { - "version": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", - "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", + "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", @@ -27120,8 +27124,9 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", - "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", + "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", "requires": { "@typescript-eslint/types": "6.20.0", "eslint-visitor-keys": "^3.4.1" @@ -29290,9 +29295,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.648", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.648.tgz", - "integrity": "sha512-EmFMarXeqJp9cUKu/QEciEApn0S/xRcpZWuAm32U7NgoZCimjsilKXHRO9saeEW55eHZagIDg6XTUOv32w9pjg==" + "version": "1.4.650", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.650.tgz", + "integrity": "sha512-sYSQhJCJa4aGA1wYol5cMQgekDBlbVfTRavlGZVr3WZpDdOPcp6a6xUnFfrt8TqZhsBYYbDxJZCjGfHuGupCRQ==" }, "elliptic": { "version": "6.5.4", @@ -34099,8 +34104,6 @@ "dependencies": { "typescript": { "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true } } diff --git a/remappings.txt b/remappings.txt index 8d41b25b9..390367e7b 100644 --- a/remappings.txt +++ b/remappings.txt @@ -12,6 +12,7 @@ lsp2/=packages/LSP2ERC725YJSONSchema/ lsp4/=packages/LSP4DigitalAssetMetadata/ lsp5/=packages/LSP5ReceivedAssets/ lsp10/=packages/LSP10ReceivedVaults/ +lsp14/=packages/LSP14Ownable2Step/ +lsp17contractextension/=packages/LSP17ContractExtension/ lsp20/=packages/LSP20CallVerification/ lsp25/=packages/LSP25ExecuteRelayCall/ -lsp17contractextension/=packages/LSP17ContractExtension/ diff --git a/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol b/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol index 1fe94f4ef..d7d9fe192 100644 --- a/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol +++ b/tests/foundry/LSP6KeyManager/LSP6SetDataTest.t.sol @@ -5,7 +5,7 @@ import "forge-std/Test.sol"; import "../../../contracts/UniversalProfile.sol"; import "../../../contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol"; import "../../../contracts/LSP6KeyManager/LSP6KeyManager.sol"; -import "../../../packages/LSP14Ownable2Step/contracts/ILSP14Ownable2Step.sol"; +import "lsp14/contracts/ILSP14Ownable2Step.sol"; import "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol"; import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";