From ad4f8ab1b9f9e01cfdda5495761177c1ddf33b33 Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Mon, 6 Nov 2023 10:56:46 +0200 Subject: [PATCH 1/5] refactor: add lsp1 data in ownership function hooks --- .../LSP0ERC725Account/LSP0ERC725AccountCore.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol index 848675f96..d04534932 100644 --- a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +++ b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol @@ -543,7 +543,7 @@ abstract contract LSP0ERC725AccountCore is // notify the pending owner through LSP1 pendingNewOwner.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferStarted, - "" + abi.encode(currentOwner, pendingNewOwner) ); // reset the transfer ownership lock @@ -563,7 +563,7 @@ abstract contract LSP0ERC725AccountCore is // notify the pending owner through LSP1 pendingNewOwner.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferStarted, - "" + abi.encode(currentOwner, pendingNewOwner) ); // reset the transfer ownership lock @@ -605,13 +605,13 @@ abstract contract LSP0ERC725AccountCore is // notify the previous owner if supports LSP1 previousOwner.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferred_SenderNotification, - "" + abi.encode(previousOwner, pendingOwnerAddress) ); // notify the pending owner if supports LSP1 pendingOwnerAddress.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferred_RecipientNotification, - "" + abi.encode(previousOwner, pendingOwnerAddress) ); // If msg.sender != pendingOwnerAddress & verifyAfter is true, Call {lsp20VerifyCallResult} on the new owner @@ -644,7 +644,7 @@ abstract contract LSP0ERC725AccountCore is if (owner() == address(0)) { previousOwner.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferred_SenderNotification, - "" + abi.encode(accountOwner, address(0)) ); } } else { @@ -658,7 +658,7 @@ abstract contract LSP0ERC725AccountCore is if (owner() == address(0)) { previousOwner.notifyUniversalReceiver( _TYPEID_LSP0_OwnershipTransferred_SenderNotification, - "" + abi.encode(accountOwner, address(0)) ); } From a8777943b4b429a0d18b67cfe90902f65de10f2b Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Mon, 6 Nov 2023 11:15:00 +0200 Subject: [PATCH 2/5] test: resolve failing tests to latest behavior --- .../LSP20CallVerification.behaviour.ts | 6 +++++- tests/UniversalProfile.behaviour.ts | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/LSP20CallVerification/LSP20CallVerification.behaviour.ts b/tests/LSP20CallVerification/LSP20CallVerification.behaviour.ts index 3298975a8..712194e87 100644 --- a/tests/LSP20CallVerification/LSP20CallVerification.behaviour.ts +++ b/tests/LSP20CallVerification/LSP20CallVerification.behaviour.ts @@ -26,6 +26,7 @@ import { // constants import { LSP1_TYPE_IDS, LSP20_SUCCESS_VALUES, OPERATION_TYPES } from '../../constants'; +import { abiCoder } from './..//utils/helpers'; export type LSP20TestContext = { accounts: SignerWithAddress[]; @@ -237,7 +238,10 @@ export const shouldBehaveLikeLSP20 = (buildContext: () => Promise Date: Mon, 6 Nov 2023 11:46:40 +0200 Subject: [PATCH 3/5] refactor: add the hooks in LSP14 and LSP9 --- contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol | 8 ++++---- contracts/LSP9Vault/LSP9VaultCore.sol | 8 ++++---- tests/LSP9Vault/LSP9Vault.behaviour.ts | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol b/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol index 84d7bd3e0..3f03e1915 100644 --- a/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +++ b/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol @@ -99,7 +99,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset { newOwner.notifyUniversalReceiver( _TYPEID_LSP14_OwnershipTransferStarted, - "" + abi.encode(currentOwner, newOwner) ); // reset the transfer ownership lock @@ -118,12 +118,12 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset { previousOwner.notifyUniversalReceiver( _TYPEID_LSP14_OwnershipTransferred_SenderNotification, - "" + abi.encode(previousOwner, msg.sender) ); msg.sender.notifyUniversalReceiver( _TYPEID_LSP14_OwnershipTransferred_RecipientNotification, - "" + abi.encode(previousOwner, msg.sender) ); } @@ -144,7 +144,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset { if (owner() == address(0)) { previousOwner.notifyUniversalReceiver( _TYPEID_LSP14_OwnershipTransferred_SenderNotification, - "" + abi.encode(previousOwner, address(0)) ); } } diff --git a/contracts/LSP9Vault/LSP9VaultCore.sol b/contracts/LSP9Vault/LSP9VaultCore.sol index 650fbc6a6..d3ea84089 100644 --- a/contracts/LSP9Vault/LSP9VaultCore.sol +++ b/contracts/LSP9Vault/LSP9VaultCore.sol @@ -440,7 +440,7 @@ contract LSP9VaultCore is newOwner.notifyUniversalReceiver( _TYPEID_LSP9_OwnershipTransferStarted, - "" + abi.encode(currentOwner, newOwner) ); // reset the transfer ownership lock @@ -462,12 +462,12 @@ contract LSP9VaultCore is previousOwner.notifyUniversalReceiver( _TYPEID_LSP9_OwnershipTransferred_SenderNotification, - "" + abi.encode(previousOwner, msg.sender) ); msg.sender.notifyUniversalReceiver( _TYPEID_LSP9_OwnershipTransferred_RecipientNotification, - "" + abi.encode(previousOwner, msg.sender) ); } @@ -490,7 +490,7 @@ contract LSP9VaultCore is if (owner() == address(0)) { previousOwner.notifyUniversalReceiver( _TYPEID_LSP9_OwnershipTransferred_SenderNotification, - "" + abi.encode(previousOwner, address(0)) ); } } diff --git a/tests/LSP9Vault/LSP9Vault.behaviour.ts b/tests/LSP9Vault/LSP9Vault.behaviour.ts index e1debc273..e51ffb2ba 100644 --- a/tests/LSP9Vault/LSP9Vault.behaviour.ts +++ b/tests/LSP9Vault/LSP9Vault.behaviour.ts @@ -767,7 +767,10 @@ export const shouldBehaveLikeLSP9 = ( context.lsp9Vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferStarted, - '0x', + abiCoder.encode( + ['address', 'address'], + [context.accounts.owner.address, context.universalProfile.address], + ), abiCoder.encode( ['bytes', 'bytes'], [ethers.utils.hexlify(ethers.utils.toUtf8Bytes('LSP1: typeId out of scope')), '0x'], From f414a2c8ab39462aa0b5f5ca394eaef3fb8f55ae Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Mon, 6 Nov 2023 12:16:46 +0200 Subject: [PATCH 4/5] test: resolve lsp1 failing tests --- ...P1UniversalReceiverDelegateUP.behaviour.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts index f5b241ff1..036d0e187 100644 --- a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts +++ b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts @@ -1573,7 +1573,10 @@ export const shouldBehaveLikeLSP1Delegate = ( vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferred_SenderNotification, - '0x', + abiCoder.encode( + ['address', 'address'], + [context.universalProfile1.address, context.accounts.owner1.address], + ), lsp1ReturnedData, ); }); @@ -1649,7 +1652,10 @@ export const shouldBehaveLikeLSP1Delegate = ( vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferred_SenderNotification, - '0x', + abiCoder.encode( + ['address', 'address'], + [context.universalProfile1.address, context.accounts.owner1.address], + ), lsp1ReturnedData, ); }); @@ -1732,7 +1738,10 @@ export const shouldBehaveLikeLSP1Delegate = ( vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferred_SenderNotification, - '0x', + abiCoder.encode( + ['address', 'address'], + [context.universalProfile1.address, context.accounts.owner1.address], + ), lsp1ReturnedData, ); }); @@ -2882,7 +2891,10 @@ export const shouldBehaveLikeLSP1Delegate = ( vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferred_SenderNotification, - '0x', + abiCoder.encode( + ['address', 'address'], + [testContext.universalProfile.address, newVaultOwner.address], + ), expectedReturnedValues, ); @@ -3004,7 +3016,10 @@ export const shouldBehaveLikeLSP1Delegate = ( vault.address, 0, LSP1_TYPE_IDS.LSP9OwnershipTransferred_RecipientNotification, - '0x', + abiCoder.encode( + ['address', 'address'], + [vaultOwner.address, context.universalProfile1.address], + ), expectedReturnedValues, ); From 5e302d3f0c5469c5c2c3a9fcb60dc3c3fbdcf3b9 Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Mon, 6 Nov 2023 13:19:27 +0200 Subject: [PATCH 5/5] chore: delete renounceOwnershipStartedAt in acceptOwnership --- contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol index d04534932..cf60d3432 100644 --- a/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +++ b/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol @@ -598,6 +598,7 @@ abstract contract LSP0ERC725AccountCore is _setOwner(pendingOwnerAddress); delete _pendingOwner; + delete _renounceOwnershipStartedAt; } else { _acceptOwnership(); }