Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor: add lsp1 data in ownership function hooks #789

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
YamenMerhi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -598,20 +598,21 @@ abstract contract LSP0ERC725AccountCore is

_setOwner(pendingOwnerAddress);
delete _pendingOwner;
delete _renounceOwnershipStartedAt;
} else {
_acceptOwnership();
}

// 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
Expand Down Expand Up @@ -644,7 +645,7 @@ abstract contract LSP0ERC725AccountCore is
if (owner() == address(0)) {
previousOwner.notifyUniversalReceiver(
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
""
abi.encode(accountOwner, address(0))
);
}
} else {
Expand All @@ -658,7 +659,7 @@ abstract contract LSP0ERC725AccountCore is
if (owner() == address(0)) {
previousOwner.notifyUniversalReceiver(
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
""
abi.encode(accountOwner, address(0))
);
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {

newOwner.notifyUniversalReceiver(
_TYPEID_LSP14_OwnershipTransferStarted,
""
abi.encode(currentOwner, newOwner)
);

// reset the transfer ownership lock
Expand All @@ -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)
);
}

Expand All @@ -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))
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/LSP9Vault/LSP9VaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ contract LSP9VaultCore is

newOwner.notifyUniversalReceiver(
_TYPEID_LSP9_OwnershipTransferStarted,
""
abi.encode(currentOwner, newOwner)
);

// reset the transfer ownership lock
Expand All @@ -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)
);
}

Expand All @@ -490,7 +490,7 @@ contract LSP9VaultCore is
if (owner() == address(0)) {
previousOwner.notifyUniversalReceiver(
_TYPEID_LSP9_OwnershipTransferred_SenderNotification,
""
abi.encode(previousOwner, address(0))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
});
Expand Down Expand Up @@ -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,
);
});
Expand Down Expand Up @@ -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,
);
});
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -237,7 +238,10 @@ export const shouldBehaveLikeLSP20 = (buildContext: () => Promise<LSP20TestConte
context.universalProfile.address,
0,
LSP1_TYPE_IDS.LSP0OwnershipTransferred_SenderNotification,
'0x',
abiCoder.encode(
['address', 'address'],
[newContractOwner.address, ethers.constants.AddressZero],
),
'0x',
);
});
Expand Down
5 changes: 4 additions & 1 deletion tests/LSP9Vault/LSP9Vault.behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
5 changes: 4 additions & 1 deletion tests/UniversalProfile.behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,10 @@ export const shouldBehaveLikeLSP3 = (
context.universalProfile.address,
0,
LSP1_TYPE_IDS.LSP0OwnershipTransferred_SenderNotification,
'0x',
abiCoder.encode(
['address', 'address'],
[newContractOwner.address, ethers.constants.AddressZero],
),
'0x',
);
});
Expand Down
Loading