From ba501e25a7eb8db70c4d7e8926bfa41570ad4a14 Mon Sep 17 00:00:00 2001 From: CJ42 Date: Wed, 27 Sep 2023 18:48:15 +0100 Subject: [PATCH] tests: change name from `owner` to `mainController` in LSP6 tests --- tests/Benchmark.test.ts | 136 +++++++++--------- ...P1UniversalReceiverDelegateUP.behaviour.ts | 8 +- .../PermissionChangeAddExtensions.test.ts | 27 ++-- .../LSP6/Admin/PermissionChangeAddURD.test.ts | 27 ++-- .../LSP6/Admin/PermissionChangeOwner.test.ts | 44 +++--- .../Interactions/AllowedAddresses.test.ts | 7 +- .../Interactions/AllowedStandards.test.ts | 13 +- .../LSP6/Interactions/OtherScenarios.test.ts | 5 +- .../LSP6/Interactions/PermissionCall.test.ts | 12 +- .../PermissionDelegateCall.test.ts | 11 +- .../Interactions/PermissionDeploy.test.ts | 7 +- .../Interactions/PermissionStaticCall.test.ts | 5 +- .../PermissionTransferValue.test.ts | 10 +- .../LSP6/Interactions/Security.test.ts | 24 ++-- .../LSP6/LSP20WithLSP6.test.ts | 17 ++- .../LSP6/LSP20WithLSP6Init.test.ts | 14 +- .../SetData/AllowedERC725YDataKeys.test.ts | 24 ++-- .../LSP6/SetData/PermissionSetData.test.ts | 16 ++- .../PermissionChangeAddController.test.ts | 53 ++++--- .../PermissionChangeAddExtensions.test.ts | 33 ++--- .../Admin/PermissionChangeAddURD.test.ts | 27 ++-- .../Admin/PermissionChangeOwner.test.ts | 63 ++++---- .../Admin/PermissionSign.test.ts | 3 +- .../Interactions/AllowedAddresses.test.ts | 7 +- .../Interactions/AllowedStandards.test.ts | 15 +- .../Interactions/BatchExecute.test.ts | 39 ++--- .../InvalidExecutePayloads.test.ts | 5 +- .../Interactions/PermissionCall.test.ts | 20 +-- .../PermissionDelegateCall.test.ts | 11 +- .../Interactions/PermissionDeploy.test.ts | 31 ++-- .../Interactions/PermissionStaticCall.test.ts | 20 ++- .../PermissionTransferValue.test.ts | 14 +- .../LSP6ControlledToken.test.ts | 75 +++++----- tests/LSP6KeyManager/LSP6KeyManager.test.ts | 29 ++-- .../LSP6KeyManager/LSP6KeyManagerInit.test.ts | 14 +- .../Relay/ExecuteRelayCall.test.ts | 36 ++--- .../Relay/MultiChannelNonce.test.ts | 3 +- .../SetData/AllowedERC725YDataKeys.test.ts | 27 ++-- .../SetData/PermissionSetData.test.ts | 18 +-- .../PermissionChangeAddController.test.ts | 43 +++--- .../internals/AllowedCalls.internal.ts | 24 ++-- .../internals/Execute.internal.ts | 11 +- .../internals/ReadPermissions.internal.ts | 13 +- .../internals/SetData.internal.ts | 9 +- tests/Mocks/KeyManagerExecutionCosts.test.ts | 20 ++- tests/Reentrancy/LSP20/reentrancyHelpers.ts | 2 +- tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts | 27 ++-- tests/Reentrancy/LSP6/reentrancyHelpers.ts | 2 +- tests/Reentrancy/Reentrancy.test.ts | 17 ++- tests/Reentrancy/ReentrancyInit.test.ts | 14 +- tests/utils/context.ts | 4 +- tests/utils/fixtures.ts | 21 +-- 52 files changed, 640 insertions(+), 517 deletions(-) diff --git a/tests/Benchmark.test.ts b/tests/Benchmark.test.ts index 03ad2700f..302f0a722 100644 --- a/tests/Benchmark.test.ts +++ b/tests/Benchmark.test.ts @@ -35,7 +35,7 @@ import { BigNumber } from 'ethers'; export type UniversalProfileContext = { accounts: SignerWithAddress[]; - owner: SignerWithAddress; + mainController: SignerWithAddress; universalProfile: UniversalProfile; initialFunding?: BigNumber; }; @@ -46,27 +46,35 @@ function generateRandomData(length) { const buildLSP6TestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; - - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address, { - value: initialFunding, - }); - const keyManager = await new LSP6KeyManager__factory(owner).deploy(universalProfile.address); - - return { accounts, owner, universalProfile, keyManager }; + const mainController = accounts[0]; + + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + { + value: initialFunding, + }, + ); + const keyManager = await new LSP6KeyManager__factory(mainController).deploy( + universalProfile.address, + ); + + return { accounts, mainController, universalProfile, keyManager }; }; const buildUniversalProfileContext = async ( initialFunding?: BigNumber, ): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address, { - value: initialFunding, - }); + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + { + value: initialFunding, + }, + ); - return { accounts, owner, universalProfile }; + return { accounts, mainController, universalProfile }; }; describe('⛽📊 Gas Benchmark', () => { @@ -154,7 +162,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 1 LYX to an EOA without data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute( OPERATION_TYPES.CALL, context.accounts[1].address, @@ -170,7 +178,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 1 LYX to a UP without data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute( OPERATION_TYPES.CALL, context.universalProfile.address, @@ -186,7 +194,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 1 LYX to an EOA with 256 bytes of data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute( OPERATION_TYPES.CALL, context.accounts[1].address, @@ -202,7 +210,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 1 LYX to a UP with 256 bytes of data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute( OPERATION_TYPES.CALL, context.universalProfile.address, @@ -223,22 +231,22 @@ describe('⛽📊 Gas Benchmark', () => { before(async () => { context = await buildUniversalProfileContext(ethers.utils.parseEther('50')); - universalProfile1 = await new UniversalProfile__factory(context.owner).deploy( + universalProfile1 = await new UniversalProfile__factory(context.mainController).deploy( context.accounts[2].address, ); - universalProfile2 = await new UniversalProfile__factory(context.owner).deploy( + universalProfile2 = await new UniversalProfile__factory(context.mainController).deploy( context.accounts[3].address, ); - universalProfile3 = await new UniversalProfile__factory(context.owner).deploy( + universalProfile3 = await new UniversalProfile__factory(context.mainController).deploy( context.accounts[4].address, ); }); it('Transfer 0.1 LYX to 3x EOA without data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .executeBatch( [OPERATION_TYPES.CALL, OPERATION_TYPES.CALL, OPERATION_TYPES.CALL], [ @@ -262,7 +270,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 0.1 LYX to 3x UP without data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .executeBatch( [OPERATION_TYPES.CALL, OPERATION_TYPES.CALL, OPERATION_TYPES.CALL], [universalProfile1.address, universalProfile2.address, universalProfile3.address], @@ -282,7 +290,7 @@ describe('⛽📊 Gas Benchmark', () => { it('Transfer 0.1 LYX to 3x EOA with 256 bytes of data', async () => { const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .executeBatch( [OPERATION_TYPES.CALL, OPERATION_TYPES.CALL, OPERATION_TYPES.CALL], [ @@ -311,7 +319,7 @@ describe('⛽📊 Gas Benchmark', () => { ]); const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .executeBatch( [OPERATION_TYPES.CALL, OPERATION_TYPES.CALL, OPERATION_TYPES.CALL], [universalProfile1.address, universalProfile2.address, universalProfile3.address], @@ -539,22 +547,22 @@ describe('⛽📊 Gas Benchmark', () => { before(async () => { context = await buildUniversalProfileContext(ethers.utils.parseEther('50')); // deploy a LSP7 token - lsp7Token = await new LSP7Mintable__factory(context.owner).deploy( + lsp7Token = await new LSP7Mintable__factory(context.mainController).deploy( 'Token', 'MTKN', - context.owner.address, + context.mainController.address, false, ); // deploy a LSP8 token - lsp8Token = await new LSP8Mintable__factory(context.owner).deploy( + lsp8Token = await new LSP8Mintable__factory(context.mainController).deploy( 'My NFT', 'MNFT', - context.owner.address, + context.mainController.address, LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); - universalProfile1 = await new UniversalProfile__factory(context.owner).deploy( + universalProfile1 = await new UniversalProfile__factory(context.mainController).deploy( context.accounts[2].address, ); }); @@ -588,7 +596,7 @@ describe('⛽📊 Gas Benchmark', () => { ]); const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, lsp7Token.address, 0, lsp7TransferPayload); const receipt = await tx.wait(); @@ -639,7 +647,7 @@ describe('⛽📊 Gas Benchmark', () => { ]); const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, lsp8Token.address, 0, lsp8TransferPayload); const receipt = await tx.wait(); @@ -691,18 +699,18 @@ describe('⛽📊 Gas Benchmark', () => { ); // deploy a LSP7 token - lsp7MetaCoin = await new LSP7Mintable__factory(context.owner).deploy( + lsp7MetaCoin = await new LSP7Mintable__factory(context.mainController).deploy( 'MetaCoin', 'MTC', - context.owner.address, + context.mainController.address, false, ); // deploy a LSP8 NFT - lsp8MetaNFT = await new LSP8Mintable__factory(context.owner).deploy( + lsp8MetaNFT = await new LSP8Mintable__factory(context.mainController).deploy( 'MetaNFT', 'MNF', - context.owner.address, + context.mainController.address, LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); @@ -719,7 +727,7 @@ describe('⛽📊 Gas Benchmark', () => { const lyxAmount = ethers.utils.parseEther('3'); // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute(OPERATION_TYPES.CALL, recipientEOA.address, lyxAmount, "0x"); + const tx = await context.universalProfile.connect(context.mainController).execute(OPERATION_TYPES.CALL, recipientEOA.address, lyxAmount, "0x"); const receipt = await tx.wait(); gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_1'][ @@ -731,7 +739,7 @@ describe('⛽📊 Gas Benchmark', () => { const lyxAmount = ethers.utils.parseEther('3'); // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute(OPERATION_TYPES.CALL, aliceUP.address, lyxAmount, "0x"); + const tx = await context.universalProfile.connect(context.mainController).execute(OPERATION_TYPES.CALL, aliceUP.address, lyxAmount, "0x"); const receipt = await tx.wait(); gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_2'][ @@ -743,7 +751,7 @@ describe('⛽📊 Gas Benchmark', () => { const tokenAmount = 100; // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute( + const tx = await context.universalProfile.connect(context.mainController).execute( OPERATION_TYPES.CALL, lsp7MetaCoin.address, 0, @@ -766,7 +774,7 @@ describe('⛽📊 Gas Benchmark', () => { const tokenAmount = 100; // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute( + const tx = await context.universalProfile.connect(context.mainController).execute( OPERATION_TYPES.CALL, lsp7MetaCoin.address, 0, @@ -789,7 +797,7 @@ describe('⛽📊 Gas Benchmark', () => { const nftId = nftList[0]; // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute( + const tx = await context.universalProfile.connect(context.mainController).execute( OPERATION_TYPES.CALL, lsp8MetaNFT.address, 0, @@ -812,7 +820,7 @@ describe('⛽📊 Gas Benchmark', () => { const nftId = nftList[1]; // prettier-ignore - const tx = await context.universalProfile.connect(context.owner).execute( + const tx = await context.universalProfile.connect(context.mainController).execute( OPERATION_TYPES.CALL, lsp8MetaNFT.address, 0, @@ -878,17 +886,17 @@ describe('⛽📊 Gas Benchmark', () => { // LSP7 token transfer scenarios canTransferTwoTokens = context.accounts[3]; - lsp7MetaCoin = await new LSP7Mintable__factory(context.owner).deploy( + lsp7MetaCoin = await new LSP7Mintable__factory(context.mainController).deploy( 'MetaCoin', 'MTC', - context.owner.address, + context.mainController.address, false, ); - lsp7LyxDai = await new LSP7Mintable__factory(context.owner).deploy( + lsp7LyxDai = await new LSP7Mintable__factory(context.mainController).deploy( 'LyxDai', 'LDAI', - context.owner.address, + context.mainController.address, false, ); @@ -899,17 +907,17 @@ describe('⛽📊 Gas Benchmark', () => { // LSP8 NFT transfer scenarios canTransferTwoNFTs = context.accounts[4]; - lsp8MetaNFT = await new LSP8Mintable__factory(context.owner).deploy( + lsp8MetaNFT = await new LSP8Mintable__factory(context.mainController).deploy( 'MetaNFT', 'MNF', - context.owner.address, + context.mainController.address, LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); - lsp8LyxPunks = await new LSP8Mintable__factory(context.owner).deploy( + lsp8LyxPunks = await new LSP8Mintable__factory(context.mainController).deploy( 'LyxPunks', 'LPK', - context.owner.address, + context.mainController.address, LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); @@ -1123,10 +1131,10 @@ describe('⛽📊 Gas Benchmark', () => { // Set some JSONURL for LSP3Profile metadata to test gas cost of updating your profile details '0x6f357c6a70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3697066733a2f2f516d65637247656a555156587057347a53393438704e76636e51724a314b69416f4d36626466725663575a736e35', ethers.utils.hexZeroPad(ethers.BigNumber.from(3).toHexString(), 16), - context.owner.address, + context.mainController.address, ]; - // The `context.owner` is given `ALL_PERMISSIONS` as the first data key through `setupKeyManager` method. + // The `context.mainController` is given `ALL_PERMISSIONS` as the first data key through `setupKeyManager` method. await setupKeyManager(context, permissionKeys, permissionValues); }); @@ -1137,7 +1145,7 @@ describe('⛽📊 Gas Benchmark', () => { '0x6f357c6a820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361696670733a2f2f516d597231564a4c776572673670456f73636468564775676f3339706136727963455a4c6a7452504466573834554178'; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(dataKey, dataValue); const receipt = await tx.wait(); @@ -1180,7 +1188,7 @@ describe('⛽📊 Gas Benchmark', () => { ]; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1202,7 +1210,7 @@ describe('⛽📊 Gas Benchmark', () => { const dataValue = combinePermissions(PERMISSIONS.SETDATA, PERMISSIONS.SUPER_SETDATA); const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(dataKey, dataValue); const receipt = await tx.wait(); @@ -1243,7 +1251,7 @@ describe('⛽📊 Gas Benchmark', () => { ]; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1276,7 +1284,7 @@ describe('⛽📊 Gas Benchmark', () => { ]; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(issuedAssetsDataKeys, issuedAssetsDataValues); const receipt = await tx.wait(); @@ -1295,7 +1303,7 @@ describe('⛽📊 Gas Benchmark', () => { const dataValue = '0xaabbccdd'; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(dataKey, dataValue); const receipt = await tx.wait(); @@ -1310,7 +1318,7 @@ describe('⛽📊 Gas Benchmark', () => { const dataValues = ['0xaabbccdd', '0xaabbccdd', '0xaabbccdd']; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1325,7 +1333,7 @@ describe('⛽📊 Gas Benchmark', () => { const dataValues = ['0xaabbccdd', '0xaabbccdd', '0xaabbccdd']; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1340,7 +1348,7 @@ describe('⛽📊 Gas Benchmark', () => { const dataValues = ['0xaabbccdd', '0xaabbccdd', '0xaabbccdd']; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1411,7 +1419,7 @@ describe('⛽📊 Gas Benchmark', () => { ]; const tx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(dataKeys, dataValues); const receipt = await tx.wait(); @@ -1459,7 +1467,7 @@ describe('⛽📊 Gas Benchmark', () => { // Set some JSONURL for LSP3Profile metadata to test gas cost of updating your profile details '0x6f357c6a70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3697066733a2f2f516d65637247656a555156587057347a53393438704e76636e51724a314b69416f4d36626466725663575a736e35', ethers.utils.hexZeroPad(ethers.BigNumber.from(6).toHexString(), 16), - context.owner.address, + context.mainController.address, PERMISSIONS.SETDATA, encodeCompactBytesArray([ ERC725YDataKeys.LSP3.LSP3Profile, @@ -1477,7 +1485,7 @@ describe('⛽📊 Gas Benchmark', () => { ]), ]; - // The `context.owner` is given `ALL_PERMISSIONS` as the first data key through `setupKeyManager` method. + // The `context.mainController` is given `ALL_PERMISSIONS` as the first data key through `setupKeyManager` method. await setupKeyManager(context, permissionKeys, permissionValues); }); diff --git a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts index 49c0a6d01..31ca3a20f 100644 --- a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts +++ b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts @@ -2785,7 +2785,7 @@ export const shouldBehaveLikeLSP1Delegate = ( testContext = { accounts: signerAddresses, - owner: profileOwner, + mainController: profileOwner, universalProfile: deployedUniversalProfile, keyManager: deployedKeyManager, }; @@ -2803,7 +2803,9 @@ export const shouldBehaveLikeLSP1Delegate = ( [ERC725YDataKeys.LSP1.LSP1UniversalReceiverDelegate, lsp1Delegate.address], ); - await testContext.keyManager.connect(testContext.owner).execute(setLSP1DelegatePayload); + await testContext.keyManager + .connect(testContext.mainController) + .execute(setLSP1DelegatePayload); }); it('check that the LSP9Vault address is not set under LSP10', async () => { @@ -2848,7 +2850,7 @@ export const shouldBehaveLikeLSP1Delegate = ( [OPERATION_TYPES.CALL, vault.address, 0, transferOwnershipPayload], ); - await testContext.keyManager.connect(testContext.owner).execute(executePayload); + await testContext.keyManager.connect(testContext.mainController).execute(executePayload); // check that the new vault owner is the pending owner expect(await vault.pendingOwner()).to.equal(newVaultOwner.address); diff --git a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddExtensions.test.ts b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddExtensions.test.ts index 75363c66e..7b96c5875 100644 --- a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddExtensions.test.ts +++ b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddExtensions.test.ts @@ -80,7 +80,8 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( canOnlyCall = context.accounts[6]; let permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canAddAndChangeExtensions.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -126,7 +127,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(7), 16), - context.owner.address, + context.mainController.address, canAddAndChangeExtensions.address, canOnlyAddExtensions.address, canOnlyChangeExtensions.address, @@ -150,7 +151,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -164,7 +165,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -178,7 +179,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -348,7 +349,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); it('should NOT be allowed to ADD another ExtensionHandler key', async () => { @@ -407,7 +408,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); @@ -467,7 +468,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); @@ -535,7 +536,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -558,7 +559,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -577,7 +578,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -661,7 +662,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); }); describe('when adding multiple ExtensionHandler keys', () => { @@ -936,7 +937,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); }); describe('When adding ExtensionHandler key and one of his allowedERC725Y Data Key', () => { diff --git a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddURD.test.ts b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddURD.test.ts index 367d81cfb..d0dde441b 100644 --- a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddURD.test.ts +++ b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeAddURD.test.ts @@ -78,7 +78,8 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( canOnlyCall = context.accounts[6]; let permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canAddAndChangeUniversalReceiverDelegate.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -128,7 +129,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(7), 16), - context.owner.address, + context.mainController.address, canAddAndChangeUniversalReceiverDelegate.address, canOnlyAddUniversalReceiverDelegate.address, canOnlyChangeUniversalReceiverDelegate.address, @@ -152,7 +153,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -166,7 +167,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -180,7 +181,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); const result = await context.universalProfile.getData(payloadParam.dataKey); @@ -362,7 +363,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); it('should NOT be allowed to ADD another UniversalReceiverDelegate key', async () => { @@ -421,7 +422,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); @@ -481,7 +482,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(payloadParam.dataKey, payloadParam.dataValue); }); @@ -549,7 +550,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -572,7 +573,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -591,7 +592,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -678,7 +679,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); }); describe('when adding multiple UniversalReceiverDelegate keys', () => { @@ -981,7 +982,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( }; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(payloadParam.dataKeys, payloadParam.dataValues); }); describe('When adding UniversalReceiverDelegate key and one of his allowedERC725Y Data Key', () => { diff --git a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeOwner.test.ts b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeOwner.test.ts index 9fb87df9a..c89b0cc22 100644 --- a/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeOwner.test.ts +++ b/tests/LSP20CallVerification/LSP6/Admin/PermissionChangeOwner.test.ts @@ -33,7 +33,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( canChangeOwner = context.accounts[1]; cannotChangeOwner = context.accounts[2]; - newKeyManager = await new LSP6KeyManager__factory(context.owner).deploy( + newKeyManager = await new LSP6KeyManager__factory(context.mainController).deploy( context.universalProfile.address, ); @@ -74,13 +74,13 @@ export const shouldBehaveLikePermissionChangeOwner = ( describe('when caller has ALL PERMISSIONS', () => { before('`transferOwnership(...)` to new Key Manager', async () => { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(newKeyManager.address); }); after('reset ownership', async () => { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(ethers.constants.AddressZero); }); @@ -93,7 +93,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const ownerBefore = await context.universalProfile.owner(); await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(newKeyManager.address); const ownerAfter = await context.universalProfile.owner(); @@ -107,7 +107,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const key = '0xcafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe'; const value = '0xabcd'; - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -121,7 +121,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const accountBalanceBefore = await provider.getBalance(context.universalProfile.address); await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, recipient.address, amount, '0x'); const recipientBalanceAfter = await provider.getBalance(recipient.address); @@ -139,7 +139,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const overridenPendingOwner = ethers.Wallet.createRandom().address; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(overridenPendingOwner); const pendingOwner = await context.universalProfile.pendingOwner(); @@ -156,7 +156,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( after('reset ownership', async () => { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(ethers.constants.AddressZero); }); @@ -179,9 +179,9 @@ export const shouldBehaveLikePermissionChangeOwner = ( }); it('should override the pendingOwner when transferOwnership(...) is called twice', async () => { - const overridenPendingOwner = await new LSP6KeyManager__factory(context.owner).deploy( - context.universalProfile.address, - ); + const overridenPendingOwner = await new LSP6KeyManager__factory( + context.mainController, + ).deploy(context.universalProfile.address); await context.universalProfile .connect(canChangeOwner) @@ -201,9 +201,9 @@ export const shouldBehaveLikePermissionChangeOwner = ( const payload = context.universalProfile.interface.getSighash('acceptOwnership'); - await expect(notPendingKeyManager.connect(context.owner).execute(payload)).to.be.revertedWith( - 'LSP14: caller is not the pendingOwner', - ); + await expect( + notPendingKeyManager.connect(context.mainController).execute(payload), + ).to.be.revertedWith('LSP14: caller is not the pendingOwner'); }); }); @@ -212,7 +212,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( before(async () => { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(newKeyManager.address); pendingOwner = await context.universalProfile.pendingOwner(); @@ -220,7 +220,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const acceptOwnershipPayload = context.universalProfile.interface.getSighash('acceptOwnership'); - await newKeyManager.connect(context.owner).execute(acceptOwnershipPayload); + await newKeyManager.connect(context.mainController).execute(acceptOwnershipPayload); }); it("should have change the account's owner to the pendingOwner (= pending KeyManager)", async () => { @@ -251,7 +251,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( value, ]); - await expect(oldKeyManager.connect(context.owner).execute(payload)) + await expect(oldKeyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(newKeyManager, 'NoPermissionsSet') .withArgs(oldKeyManager.address); }); @@ -267,7 +267,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( '0x', ]); - await expect(oldKeyManager.connect(context.owner).execute(payload)) + await expect(oldKeyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(newKeyManager, 'NoPermissionsSet') .withArgs(oldKeyManager.address); }); @@ -283,7 +283,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( value, ]); - await newKeyManager.connect(context.owner).execute(payload); + await newKeyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -303,7 +303,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( '0x', ]); - await newKeyManager.connect(context.owner).execute(payload); + await newKeyManager.connect(context.mainController).execute(payload); const recipientBalanceAfter = await provider.getBalance(recipient.address); const accountBalanceAfter = await provider.getBalance(context.universalProfile.address); @@ -325,7 +325,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( before(async () => { // 1st call renounceOwnershipFirstTx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .renounceOwnership(); // mine 200 blocks @@ -333,7 +333,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( // 2nd call renounceOwnershipSecondTx = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .renounceOwnership(); }); diff --git a/tests/LSP20CallVerification/LSP6/Interactions/AllowedAddresses.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/AllowedAddresses.test.ts index 09c059816..fb76b459d 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/AllowedAddresses.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/AllowedAddresses.test.ts @@ -52,7 +52,8 @@ export const shouldBehaveLikeAllowedAddresses = (buildContext: () => Promise Promise Promise Promise Promise Promise Promise { it('ERC1271', async () => { const sampleHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('Sample Message')); - const sampleSignature = await context.owner.signMessage('Sample Message'); + const sampleSignature = await context.mainController.signMessage('Sample Message'); const payload = signatureValidatorContract.interface.encodeFunctionData( 'isValidSignature', @@ -125,7 +126,7 @@ export const shouldBehaveLikeAllowedStandards = (buildContext: () => Promise Promise Promise) targetContract = await new TargetContract__factory(context.accounts[0]).deploy(); const permissionsKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanMakeCall.address.substring(2), ]; @@ -42,7 +43,7 @@ export const otherTestScenarios = (buildContext: () => Promise) await expect( context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(INVALID_OPERATION_TYPE, targetContract.address, 0, targetPayload), ).to.be.revertedWithCustomError(context.universalProfile, 'ERC725X_UnknownOperationType'); }); diff --git a/tests/LSP20CallVerification/LSP6/Interactions/PermissionCall.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/PermissionCall.test.ts index 4346ff2b6..ec906ccb9 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/PermissionCall.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/PermissionCall.test.ts @@ -330,7 +330,8 @@ export const shouldBehaveLikePermissionCall = ( targetContract = await new TargetContract__factory(context.accounts[0]).deploy(); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanMakeCallNoAllowedCalls.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -365,7 +366,7 @@ export const shouldBehaveLikePermissionCall = ( const targetPayload = targetContract.interface.encodeFunctionData('setName', [argument]); await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, targetContract.address, 0, targetPayload); const result = await targetContract.callStatic.getName(); @@ -379,7 +380,7 @@ export const shouldBehaveLikePermissionCall = ( const targetContractPayload = targetContract.interface.encodeFunctionData('getName'); const result = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .callStatic.execute( OPERATION_TYPES.CALL, targetContract.address, @@ -397,7 +398,7 @@ export const shouldBehaveLikePermissionCall = ( const targetContractPayload = targetContract.interface.encodeFunctionData('getNumber'); const result = await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .callStatic.execute( OPERATION_TYPES.CALL, targetContract.address, @@ -486,7 +487,8 @@ export const shouldBehaveLikePermissionCall = ( context = await buildContext(); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ]; const permissionValues = [ALL_PERMISSIONS]; diff --git a/tests/LSP20CallVerification/LSP6/Interactions/PermissionDelegateCall.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/PermissionDelegateCall.test.ts index a67fd8d97..c4b5f09ec 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/PermissionDelegateCall.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/PermissionDelegateCall.test.ts @@ -35,12 +35,13 @@ export const shouldBehaveLikePermissionDelegateCall = ( addressCanDelegateCall = context.accounts[1]; addressCannotDelegateCall = context.accounts[2]; - erc725YDelegateCallContract = await new ERC725YDelegateCall__factory(context.owner).deploy( - context.universalProfile.address, - ); + erc725YDelegateCallContract = await new ERC725YDelegateCall__factory( + context.mainController, + ).deploy(context.universalProfile.address); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanDelegateCall.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -70,7 +71,7 @@ export const shouldBehaveLikePermissionDelegateCall = ( await expect( context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute( OPERATION_TYPES.DELEGATECALL, erc725YDelegateCallContract.address, diff --git a/tests/LSP20CallVerification/LSP6/Interactions/PermissionDeploy.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/PermissionDeploy.test.ts index 6d03d4306..f7232c6d3 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/PermissionDeploy.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/PermissionDeploy.test.ts @@ -29,7 +29,8 @@ export const shouldBehaveLikePermissionDeploy = (buildContext: () => Promise Promise Promise context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, recipient.address, amount, data), ).to.changeEtherBalances( [context.universalProfile.address, recipient.address], @@ -207,7 +208,7 @@ export const shouldBehaveLikePermissionTransferValue = ( const initialBalanceRecipient = await provider.getBalance(recipient.address); await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .execute(OPERATION_TYPES.CALL, recipient.address, ethers.utils.parseEther('3'), data); const newBalanceUP = await provider.getBalance(context.universalProfile.address); @@ -396,7 +397,8 @@ export const shouldBehaveLikePermissionTransferValue = ( ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + contractCanTransferValue.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + diff --git a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts index 8df443a2f..61880dc6f 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts @@ -60,7 +60,8 @@ export const testSecurityScenarios = (buildContext: () => Promise Promise Promise Promise Promise { it('should allow the URD to use `setData(..)` through the LSP6', async () => { const universalReceiverDelegateDataUpdater = - await new UniversalReceiverDelegateDataUpdater__factory(context.owner).deploy(); + await new UniversalReceiverDelegateDataUpdater__factory(context.mainController).deploy(); const randomHardcodedKey = ethers.utils.keccak256( ethers.utils.toUtf8Bytes('some random data key'), @@ -180,7 +181,7 @@ export const testSecurityScenarios = (buildContext: () => Promise Promise Promise Promise Promise Promise { const buildTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address, { - value: initialFunding, - }); + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + { + value: initialFunding, + }, + ); - const keyManager = await new LSP6KeyManager__factory(owner).deploy(universalProfile.address); + const keyManager = await new LSP6KeyManager__factory(mainController).deploy( + universalProfile.address, + ); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; describe('when testing deployed contract', () => { diff --git a/tests/LSP20CallVerification/LSP6/LSP20WithLSP6Init.test.ts b/tests/LSP20CallVerification/LSP6/LSP20WithLSP6Init.test.ts index 4db9f0ddc..5d9729e17 100644 --- a/tests/LSP20CallVerification/LSP6/LSP20WithLSP6Init.test.ts +++ b/tests/LSP20CallVerification/LSP6/LSP20WithLSP6Init.test.ts @@ -12,21 +12,21 @@ import { shouldBehaveLikeLSP6 } from './LSP20WithLSP6.behaviour'; describe('LSP20 Init + LSP6 Init with proxy', () => { const buildProxyTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const baseUP = await new UniversalProfileInit__factory(owner).deploy(); - const upProxy = await deployProxy(baseUP.address, owner); + const baseUP = await new UniversalProfileInit__factory(mainController).deploy(); + const upProxy = await deployProxy(baseUP.address, mainController); const universalProfile = await baseUP.attach(upProxy); - const baseKM = await new LSP6KeyManagerInit__factory(owner).deploy(); - const kmProxy = await deployProxy(baseKM.address, owner); + const baseKM = await new LSP6KeyManagerInit__factory(mainController).deploy(); + const kmProxy = await deployProxy(baseKM.address, mainController); const keyManager = await baseKM.attach(kmProxy); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; const initializeProxy = async (context: LSP6TestContext) => { - await context.universalProfile['initialize(address)'](context.owner.address, { + await context.universalProfile['initialize(address)'](context.mainController.address, { value: context.initialFunding, }); diff --git a/tests/LSP20CallVerification/LSP6/SetData/AllowedERC725YDataKeys.test.ts b/tests/LSP20CallVerification/LSP6/SetData/AllowedERC725YDataKeys.test.ts index 5a70b2299..96b4735ce 100644 --- a/tests/LSP20CallVerification/LSP6/SetData/AllowedERC725YDataKeys.test.ts +++ b/tests/LSP20CallVerification/LSP6/SetData/AllowedERC725YDataKeys.test.ts @@ -38,7 +38,8 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( controllerCanSetManyKeys = context.accounts[2]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetOneKey.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -653,7 +654,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( const key = ethers.utils.hexlify(ethers.utils.randomBytes(32)); const value = ethers.utils.hexlify(ethers.utils.toUtf8Bytes('Some data')); - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -673,7 +674,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( ethers.utils.hexlify(ethers.utils.toUtf8Bytes('Some data 3')), ]; - await context.universalProfile.connect(context.owner).setDataBatch(keys, values); + await context.universalProfile.connect(context.mainController).setDataBatch(keys, values); const result = await context.universalProfile.getDataBatch(keys); @@ -704,7 +705,8 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( controllerCanSetMappingKeys = context.accounts[1]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetMappingKeys.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + @@ -897,7 +899,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( ); await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setData(randomMappingKey, randomMappingValue); const result = await context.universalProfile.getData(randomMappingKey); @@ -919,7 +921,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( ]; await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(randomMappingKeys, randomMappingValues); const result = await context.universalProfile.getDataBatch(randomMappingKeys); @@ -952,7 +954,8 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( controllerCanSetArrayKeys = context.accounts[1]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetArrayKeys.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + @@ -1101,7 +1104,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( const permissionKeys = [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetSomeKeys.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + @@ -1228,7 +1231,7 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( const permissionKeys = [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetSomeKeys.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + @@ -1373,7 +1376,8 @@ export const shouldBehaveLikeAllowedERC725YDataKeys = ( controllerCanSetSomeKeys = context.accounts[1]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + controllerCanSetSomeKeys.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + diff --git a/tests/LSP20CallVerification/LSP6/SetData/PermissionSetData.test.ts b/tests/LSP20CallVerification/LSP6/SetData/PermissionSetData.test.ts index c9eb4d23e..d1ea42ea4 100644 --- a/tests/LSP20CallVerification/LSP6/SetData/PermissionSetData.test.ts +++ b/tests/LSP20CallVerification/LSP6/SetData/PermissionSetData.test.ts @@ -64,7 +64,8 @@ export const shouldBehaveLikePermissionSetData = (buildContext: () => Promise Promise Promise Promise Promise Promise { context = await buildContext(); - contractCanSetData = await new ExecutorLSP20__factory(context.owner).deploy( + contractCanSetData = await new ExecutorLSP20__factory(context.mainController).deploy( context.universalProfile.address, ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + contractCanSetData.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + diff --git a/tests/LSP20CallVerification/LSP6/SetPermissions/PermissionChangeAddController.test.ts b/tests/LSP20CallVerification/LSP6/SetPermissions/PermissionChangeAddController.test.ts index 73c05fbe6..2f0eb16b0 100644 --- a/tests/LSP20CallVerification/LSP6/SetPermissions/PermissionChangeAddController.test.ts +++ b/tests/LSP20CallVerification/LSP6/SetPermissions/PermissionChangeAddController.test.ts @@ -18,7 +18,7 @@ async function setupPermissions( permissionValues: string[], ) { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(permissionsKeys, permissionValues); } @@ -27,7 +27,7 @@ async function setupPermissions( */ async function resetPermissions(context: LSP6TestContext, permissionsKeys: string[]) { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .setDataBatch(permissionsKeys, Array(permissionsKeys.length).fill('0x')); } @@ -47,7 +47,10 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( await setupKeyManager( context, - [ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2)], + [ + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), + ], [ALL_PERMISSIONS], ); }); @@ -106,7 +109,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(6), 16), - context.owner.address, + context.mainController.address, canOnlyAddController.address, canOnlyEditPermissions.address, canOnlySetData.address, @@ -143,7 +146,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + newController.address.substr(2); - await context.universalProfile.connect(context.owner).setData(key, PERMISSIONS.SETDATA); + await context.universalProfile + .connect(context.mainController) + .setData(key, PERMISSIONS.SETDATA); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -157,7 +162,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( const value = PERMISSIONS.SETDATA; - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -174,7 +179,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 16); - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -190,7 +195,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 16); - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -205,7 +210,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( '00000000000000000000000000000006'; const value = ethers.Wallet.createRandom().address.toLowerCase(); - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -219,7 +224,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( // set some random bytes under AddressPermissions[7] - await expect(context.universalProfile.connect(context.owner).setData(key, randomValue)) + await expect( + context.universalProfile.connect(context.mainController).setData(key, randomValue), + ) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -232,7 +239,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( // set some random bytes under AddressPermissions[7] - await expect(context.universalProfile.connect(context.owner).setData(key, randomValue)) + await expect( + context.universalProfile.connect(context.mainController).setData(key, randomValue), + ) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -248,7 +257,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( const value = randomWallet.address; - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -263,7 +272,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( // set some random bytes under AddressPermissions[7] - await expect(context.universalProfile.connect(context.owner).setData(key, randomValue)) + await expect( + context.universalProfile.connect(context.mainController).setData(key, randomValue), + ) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -276,7 +287,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( // set some random bytes under AddressPermissions[7] - await expect(context.universalProfile.connect(context.owner).setData(key, randomValue)) + await expect( + context.universalProfile.connect(context.mainController).setData(key, randomValue), + ) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -290,7 +303,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( const value = '0x'; - await context.universalProfile.connect(context.owner).setData(key, value); + await context.universalProfile.connect(context.mainController).setData(key, value); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -309,7 +322,9 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( // the value does not matter in the case of the test here const value = '0x0000000000000000000000000000000000000000000000000000000000000008'; - await expect(context.universalProfile.connect(context.owner).setData(key, value)) + await expect( + context.universalProfile.connect(context.mainController).setData(key, value), + ) .to.be.revertedWithCustomError(context.keyManager, 'NotRecognisedPermissionKey') .withArgs(key.toLowerCase()); }); @@ -906,7 +921,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( PERMISSIONS.SETDATA, ]; - await context.universalProfile.connect(context.owner).setDataBatch(keys, values); + await context.universalProfile.connect(context.mainController).setDataBatch(keys, values); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); @@ -930,7 +945,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( combinePermissions(PERMISSIONS.SETDATA, PERMISSIONS.TRANSFERVALUE), ]; - await context.universalProfile.connect(context.owner).setDataBatch(keys, values); + await context.universalProfile.connect(context.mainController).setDataBatch(keys, values); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); @@ -956,7 +971,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( combinePermissions(PERMISSIONS.SETDATA, PERMISSIONS.TRANSFERVALUE), ]; - await context.universalProfile.connect(context.owner).setDataBatch(keys, values); + await context.universalProfile.connect(context.mainController).setDataBatch(keys, values); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); diff --git a/tests/LSP6KeyManager/Admin/PermissionChangeAddExtensions.test.ts b/tests/LSP6KeyManager/Admin/PermissionChangeAddExtensions.test.ts index dad51e43a..5cb9a7ab2 100644 --- a/tests/LSP6KeyManager/Admin/PermissionChangeAddExtensions.test.ts +++ b/tests/LSP6KeyManager/Admin/PermissionChangeAddExtensions.test.ts @@ -80,7 +80,8 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( canOnlyCall = context.accounts[6]; let permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canAddAndChangeExtensions.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -126,7 +127,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(7), 16), - context.owner.address, + context.mainController.address, canAddAndChangeExtensions.address, canOnlyAddExtensions.address, canOnlyChangeExtensions.address, @@ -154,7 +155,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -171,7 +172,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -188,7 +189,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -212,7 +213,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( ]); await expect( - context.keyManager.connect(context.owner).execute(payload), + context.keyManager.connect(context.mainController).execute(payload), ).to.be.revertedWithCustomError( context.keyManager, 'KeyManagerCannotBeSetAsExtensionForLSP20Functions', @@ -237,7 +238,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( ]); await expect( - context.keyManager.connect(context.owner).execute(payload), + context.keyManager.connect(context.mainController).execute(payload), ).to.be.revertedWithCustomError( context.keyManager, 'KeyManagerCannotBeSetAsExtensionForLSP20Functions', @@ -268,7 +269,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); expect(result).to.deep.equal(payloadParam.dataValues); @@ -463,7 +464,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another ExtensionHandler key', async () => { const payloadParam = { @@ -528,7 +529,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another ExtensionHandler key even when ExtensionHandler key is allowed in AllowedERC725YDataKey', async () => { @@ -594,7 +595,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another ExtensionHandler key', async () => { @@ -668,7 +669,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -694,7 +695,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -716,7 +717,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -808,7 +809,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); describe('when adding multiple ExtensionHandler keys', () => { it('should pass', async () => { @@ -1105,7 +1106,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); describe('When adding ExtensionHandler key and one of his allowedERC725Y Data Key', () => { it('should pass', async () => { diff --git a/tests/LSP6KeyManager/Admin/PermissionChangeAddURD.test.ts b/tests/LSP6KeyManager/Admin/PermissionChangeAddURD.test.ts index d2ebf63da..8474edacf 100644 --- a/tests/LSP6KeyManager/Admin/PermissionChangeAddURD.test.ts +++ b/tests/LSP6KeyManager/Admin/PermissionChangeAddURD.test.ts @@ -78,7 +78,8 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( canOnlyCall = context.accounts[6]; let permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canAddAndChangeUniversalReceiverDelegate.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -128,7 +129,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(7), 16), - context.owner.address, + context.mainController.address, canAddAndChangeUniversalReceiverDelegate.address, canOnlyAddUniversalReceiverDelegate.address, canOnlyChangeUniversalReceiverDelegate.address, @@ -156,7 +157,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -173,7 +174,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -190,7 +191,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(payloadParam.dataKey); expect(result).to.equal(payloadParam.dataValue); @@ -411,7 +412,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another UniversalReceiverDelegate key', async () => { const payloadParam = { @@ -476,7 +477,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another UniversalReceiverDelegate key even when UniversalReceiverDelegate key is allowed in AllowedERC725YDataKey', async () => { @@ -542,7 +543,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValue, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); it('should NOT be allowed to ADD another UniversalReceiverDelegate key', async () => { @@ -616,7 +617,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -642,7 +643,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -664,7 +665,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getDataBatch(payloadParam.dataKeys); @@ -765,7 +766,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); describe('when adding multiple UniversalReceiverDelegate keys', () => { it('should pass', async () => { @@ -1106,7 +1107,7 @@ export const shouldBehaveLikePermissionChangeOrAddURD = ( payloadParam.dataValues, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); describe('When adding UniversalReceiverDelegate key and one of his allowedERC725Y Data Key', () => { it('should pass', async () => { diff --git a/tests/LSP6KeyManager/Admin/PermissionChangeOwner.test.ts b/tests/LSP6KeyManager/Admin/PermissionChangeOwner.test.ts index a21d617a2..44aa2c626 100644 --- a/tests/LSP6KeyManager/Admin/PermissionChangeOwner.test.ts +++ b/tests/LSP6KeyManager/Admin/PermissionChangeOwner.test.ts @@ -35,7 +35,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( canChangeOwner = context.accounts[1]; cannotChangeOwner = context.accounts[2]; - newKeyManager = await new LSP6KeyManager__factory(context.owner).deploy( + newKeyManager = await new LSP6KeyManager__factory(context.mainController).deploy( context.universalProfile.address, ); @@ -86,11 +86,11 @@ export const shouldBehaveLikePermissionChangeOwner = ( describe('when caller has ALL PERMISSIONS', () => { before('`transferOwnership(...)` to new Key Manager', async () => { - await context.keyManager.connect(context.owner).execute(transferOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(transferOwnershipPayload); }); after('reset ownership', async () => { - await context.keyManager.connect(context.owner).execute(resetOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(resetOwnershipPayload); }); it('should have set newKeyManager as pendingOwner', async () => { @@ -106,7 +106,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( [newKeyManager.address], ); - await context.keyManager.connect(context.owner).execute(transferOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(transferOwnershipPayload); const ownerAfter = await context.universalProfile.owner(); @@ -124,7 +124,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -142,7 +142,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( ]); await expect( - context.keyManager.connect(context.owner).execute(payload), + context.keyManager.connect(context.mainController).execute(payload), ).to.changeEtherBalances([context.universalProfile, recipient], [`-${amount}`, amount]); }); }); @@ -151,7 +151,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const overridenPendingOwner = ethers.Wallet.createRandom().address; await context.keyManager - .connect(context.owner) + .connect(context.mainController) .execute( context.universalProfile.interface.encodeFunctionData('transferOwnership', [ overridenPendingOwner, @@ -170,7 +170,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( }); after('reset ownership', async () => { - await context.keyManager.connect(context.owner).execute(resetOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(resetOwnershipPayload); }); it('should have set newKeyManager as pendingOwner', async () => { @@ -195,9 +195,9 @@ export const shouldBehaveLikePermissionChangeOwner = ( }); it('should override the pendingOwner when transferOwnership(...) is called twice', async () => { - const overridenPendingOwner = await new LSP6KeyManager__factory(context.owner).deploy( - context.universalProfile.address, - ); + const overridenPendingOwner = await new LSP6KeyManager__factory( + context.mainController, + ).deploy(context.universalProfile.address); await context.keyManager .connect(canChangeOwner) @@ -215,7 +215,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( describe('when calling acceptOwnership(...) from a KeyManager that is not the pendingOwner', () => { before('`transferOwnership(...)` to new Key Manager', async () => { - await context.keyManager.connect(context.owner).execute(transferOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(transferOwnershipPayload); }); it('should revert', async () => { @@ -225,9 +225,9 @@ export const shouldBehaveLikePermissionChangeOwner = ( const payload = context.universalProfile.interface.getSighash('acceptOwnership'); - await expect(notPendingKeyManager.connect(context.owner).execute(payload)).to.be.revertedWith( - 'LSP14: caller is not the pendingOwner', - ); + await expect( + notPendingKeyManager.connect(context.mainController).execute(payload), + ).to.be.revertedWith('LSP14: caller is not the pendingOwner'); }); }); @@ -236,7 +236,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( before('`transferOwnership(...)` to new Key Manager', async () => { await context.universalProfile - .connect(context.owner) + .connect(context.mainController) .transferOwnership(newKeyManager.address); pendingOwner = await context.universalProfile.pendingOwner(); @@ -244,7 +244,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( const acceptOwnershipPayload = context.universalProfile.interface.getSighash('acceptOwnership'); - await newKeyManager.connect(context.owner).execute(acceptOwnershipPayload); + await newKeyManager.connect(context.mainController).execute(acceptOwnershipPayload); }); it("should have change the account's owner to the pendingOwner (= pending KeyManager)", async () => { @@ -276,7 +276,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( value, ]); - await expect(oldKeyManager.connect(context.owner).execute(payload)) + await expect(oldKeyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(newKeyManager, 'NoPermissionsSet') .withArgs(oldKeyManager.address); }); @@ -292,7 +292,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( '0x', ]); - await expect(oldKeyManager.connect(context.owner).execute(payload)) + await expect(oldKeyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(newKeyManager, 'NoPermissionsSet') .withArgs(oldKeyManager.address); }); @@ -308,7 +308,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( value, ]); - await newKeyManager.connect(context.owner).execute(payload); + await newKeyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -325,10 +325,9 @@ export const shouldBehaveLikePermissionChangeOwner = ( '0x', ]); - await expect(newKeyManager.connect(context.owner).execute(payload)).to.changeEtherBalances( - [recipient, context.universalProfile], - [amount, `-${amount}`], - ); + await expect( + newKeyManager.connect(context.mainController).execute(payload), + ).to.changeEtherBalances([recipient, context.universalProfile], [amount, `-${amount}`]); }); }); }); @@ -343,13 +342,17 @@ export const shouldBehaveLikePermissionChangeOwner = ( const payload = context.universalProfile.interface.getSighash('renounceOwnership'); // 1st call - renounceOwnershipFirstTx = await newKeyManager.connect(context.owner).execute(payload); + renounceOwnershipFirstTx = await newKeyManager + .connect(context.mainController) + .execute(payload); // mine 200 blocks await network.provider.send('hardhat_mine', [ethers.utils.hexValue(200)]); // 2nd call - renounceOwnershipSecondTx = await newKeyManager.connect(context.owner).execute(payload); + renounceOwnershipSecondTx = await newKeyManager + .connect(context.mainController) + .execute(payload); }); it('should emit `RenounceOwnershipStarted` on first call', async () => { @@ -397,7 +400,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( // ---------------------------------------------- // ------ 1st call ------ - const firstNonce = await context.keyManager.getNonce(context.owner.address, 0); + const firstNonce = await context.keyManager.getNonce(context.mainController.address, 0); const firstEncodedMessage = ethers.utils.solidityPack( ['uint256', 'uint256', 'uint256', 'uint256', 'uint256', 'bytes'], @@ -411,7 +414,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( ).signature; renounceOwnershipFirstTx = await context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCall(firstSignature, firstNonce, validityTimestamps, payload, { value: valueToSend, }); @@ -421,7 +424,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( await network.provider.send('hardhat_mine', [ethers.utils.hexValue(200)]); // ------ 2nd call ------ - const secondNonce = await context.keyManager.getNonce(context.owner.address, 0); + const secondNonce = await context.keyManager.getNonce(context.mainController.address, 0); const secondEncodedMessage = ethers.utils.solidityPack( ['uint256', 'uint256', 'uint256', 'uint256', 'uint256', 'bytes'], @@ -435,7 +438,7 @@ export const shouldBehaveLikePermissionChangeOwner = ( ).signature; renounceOwnershipSecondTx = await context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCall(secondSignature, secondNonce, validityTimestamps, payload, { value: valueToSend, }); diff --git a/tests/LSP6KeyManager/Admin/PermissionSign.test.ts b/tests/LSP6KeyManager/Admin/PermissionSign.test.ts index 202197a16..f6a02ea7b 100644 --- a/tests/LSP6KeyManager/Admin/PermissionSign.test.ts +++ b/tests/LSP6KeyManager/Admin/PermissionSign.test.ts @@ -26,7 +26,8 @@ export const shouldBehaveLikePermissionSign = (buildContext: () => Promise Promise Promise Promise Promise Promise Promise Promise { it('ERC1271', async () => { const sampleHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('Sample Message')); - const sampleSignature = await context.owner.signMessage('Sample Message'); + const sampleSignature = await context.mainController.signMessage('Sample Message'); const payload = signatureValidatorContract.interface.encodeFunctionData( 'isValidSignature', @@ -136,7 +137,9 @@ export const shouldBehaveLikeAllowedStandards = (buildContext: () => Promise Promise Promise Promise { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -120,10 +121,10 @@ export const shouldBehaveLikePermissionDeploy = ( // do first a callstatic to retrieve the address of the contract expected to be deployed // so we can check it against the address emitted in the ContractCreated event const expectedContractAddress = await context.keyManager - .connect(context.owner) + .connect(context.mainController) .callStatic.execute(payload); - await expect(context.keyManager.connect(context.owner).execute(payload)) + await expect(context.keyManager.connect(context.mainController).execute(payload)) .to.emit(context.universalProfile, 'ContractCreated') .withArgs( OPERATION_TYPES.CREATE, @@ -159,14 +160,14 @@ export const shouldBehaveLikePermissionDeploy = ( contractBytecodeToDeploy, ).toLowerCase(); - await expect(context.keyManager.connect(context.owner).execute(payload)) + await expect(context.keyManager.connect(context.mainController).execute(payload)) .to.emit(context.universalProfile, 'ContractCreated') .withArgs(OPERATION_TYPES.CREATE2, ethers.utils.getAddress(preComputedAddress), 0, salt); }); it('should be allowed to deploy + fund a contract with CREATE2', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -191,7 +192,7 @@ export const shouldBehaveLikePermissionDeploy = ( contractBytecodeToDeploy, ).toLowerCase(); - await expect(context.keyManager.connect(context.owner).execute(payload)) + await expect(context.keyManager.connect(context.mainController).execute(payload)) .to.emit(context.universalProfile, 'ContractCreated') .withArgs( OPERATION_TYPES.CREATE2, @@ -237,7 +238,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should revert with error `NotAuthorised(SUPER_TRANSFERVALUE)` when trying to deploy + fund a contract with CREATE', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -283,7 +284,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should revert with error `NotAuthorised(SUPER_TRANSFERVALUE)` when trying to deploy + fund a contract with CREATE2', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -337,7 +338,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should revert with error `NotAuthorised(SUPER_TRANSFERVALUE)` when trying to deploy + fund a contract with CREATE', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -383,7 +384,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should revert with error `NotAuthorised(SUPER_TRANSFERVALUE)` when trying to deploy + fund a contract with CREATE2', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -439,7 +440,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should be allowed to deploy + fund a contract with CREATE', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( @@ -509,7 +510,7 @@ export const shouldBehaveLikePermissionDeploy = ( it('should be allowed to deploy + fund a contract with CREATE2', async () => { // deploy a UP from another UP and check that the new UP is funded + its owner was set - const initialUpOwner = context.owner.address; + const initialUpOwner = context.mainController.address; // generate the init code that contains the constructor args with the initial UP owner const upDeploymentTx = new UniversalProfile__factory( diff --git a/tests/LSP6KeyManager/Interactions/PermissionStaticCall.test.ts b/tests/LSP6KeyManager/Interactions/PermissionStaticCall.test.ts index eab6894a9..28a4dd437 100644 --- a/tests/LSP6KeyManager/Interactions/PermissionStaticCall.test.ts +++ b/tests/LSP6KeyManager/Interactions/PermissionStaticCall.test.ts @@ -62,7 +62,8 @@ export const shouldBehaveLikePermissionStaticCall = ( ).deploy(); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanMakeStaticCall.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + @@ -107,7 +108,7 @@ export const shouldBehaveLikePermissionStaticCall = ( ]); const result = await context.keyManager - .connect(context.owner) + .connect(context.mainController) .callStatic.execute(executePayload); const [decodedResult] = abiCoder.decode(['string'], result); @@ -162,7 +163,7 @@ export const shouldBehaveLikePermissionStaticCall = ( describe('when calling `isValidSignature(bytes32,bytes)` on a contract', () => { it('should pass and return data when `value` param is 0', async () => { const message = 'some message to sign'; - const signature = await context.owner.signMessage(message); + const signature = await context.mainController.signMessage(message); const messageHash = ethers.utils.hashMessage(message); const erc1271ContractPayload = signatureValidator.interface.encodeFunctionData( @@ -189,7 +190,7 @@ export const shouldBehaveLikePermissionStaticCall = ( const lyxAmount = ethers.utils.parseEther('3'); const message = 'some message to sign'; - const signature = await context.owner.signMessage(message); + const signature = await context.mainController.signMessage(message); const messageHash = ethers.utils.hashMessage(message); const erc1271ContractPayload = signatureValidator.interface.encodeFunctionData( @@ -219,8 +220,8 @@ export const shouldBehaveLikePermissionStaticCall = ( const onERC721Payload = onERC721ReceivedContract.interface.encodeFunctionData( 'onERC721Received', [ - context.owner.address, - context.owner.address, + context.mainController.address, + context.mainController.address, 1, ethers.utils.toUtf8Bytes('some data'), ], @@ -251,7 +252,12 @@ export const shouldBehaveLikePermissionStaticCall = ( // the params are not relevant for this test and just used as placeholders. const onERC721Payload = onERC721ReceivedContract.interface.encodeFunctionData( 'onERC721Received', - [context.owner.address, context.owner.address, 1, ethers.utils.toUtf8Bytes('some data')], + [ + context.mainController.address, + context.mainController.address, + 1, + ethers.utils.toUtf8Bytes('some data'), + ], ); const executePayload = context.universalProfile.interface.encodeFunctionData('execute', [ diff --git a/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts b/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts index 1fb62b25f..c59d65538 100644 --- a/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts +++ b/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts @@ -91,7 +91,8 @@ export const shouldBehaveLikePermissionTransferValue = ( ).to.equal(graffitiExtension.address); const permissionsKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canTransferValue.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + @@ -149,7 +150,7 @@ export const shouldBehaveLikePermissionTransferValue = ( * @see https://hardhat.org/hardhat-chai-matchers/docs/reference#.changeetherbalances */ await expect( - context.keyManager.connect(context.owner).execute(transferPayload), + context.keyManager.connect(context.mainController).execute(transferPayload), ).to.changeEtherBalances( [context.universalProfile.address, recipient.address], [`-${amount}`, amount], @@ -231,7 +232,7 @@ export const shouldBehaveLikePermissionTransferValue = ( data, ]); - await context.keyManager.connect(context.owner).execute(transferPayload); + await context.keyManager.connect(context.mainController).execute(transferPayload); const newBalanceUP = await provider.getBalance(context.universalProfile.address); expect(newBalanceUP).to.be.lt(initialBalanceUP); @@ -384,7 +385,7 @@ export const shouldBehaveLikePermissionTransferValue = ( ); // ethereum signed message prefix - const signature = await context.owner.signMessage(encodedMessage); + const signature = await context.mainController.signMessage(encodedMessage); await expect( context.keyManager.executeRelayCall( @@ -434,7 +435,7 @@ export const shouldBehaveLikePermissionTransferValue = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCall(signature, 0, validityTimestamps, executeRelayCallPayload, { value: valueToSend, }), @@ -525,7 +526,8 @@ export const shouldBehaveLikePermissionTransferValue = ( ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + contractCanTransferValue.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + diff --git a/tests/LSP6KeyManager/LSP6ControlledToken.test.ts b/tests/LSP6KeyManager/LSP6ControlledToken.test.ts index c0a3e1fae..3254e30f2 100644 --- a/tests/LSP6KeyManager/LSP6ControlledToken.test.ts +++ b/tests/LSP6KeyManager/LSP6ControlledToken.test.ts @@ -20,7 +20,7 @@ export type LSP6ControlledToken = { accounts: SignerWithAddress[]; token: LSP7Mintable | LSP8Mintable; keyManager: LSP6KeyManager; - owner: SignerWithAddress; + mainController: SignerWithAddress; }; const buildContext = async () => { @@ -50,7 +50,7 @@ const buildContext = async () => { accounts, token: lsp7, keyManager, - owner: accounts[0], + mainController: accounts[0], }; }; @@ -71,7 +71,7 @@ const addControllerWithPermission = async ( const payload = context.token.interface.encodeFunctionData('setDataBatch', [keys, values]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }; describe('When deploying LSP7 with LSP6 as owner', () => { @@ -107,10 +107,11 @@ describe('When deploying LSP7 with LSP6 as owner', () => { const keys = [ ERC725YDataKeys.LSP6['AddressPermissions[]'].length, ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '0', - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ]; - const values = [ARRAY_LENGTH.ONE, context.owner.address, ALL_PERMISSIONS]; + const values = [ARRAY_LENGTH.ONE, context.mainController.address, ALL_PERMISSIONS]; expect(await context.token.getDataBatch(keys)).to.deep.equal(values); }); @@ -119,13 +120,13 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it('should revert because function does not exist on LSP6', async () => { const LSP7 = context.token as LSP7Mintable; const mintPayload = LSP7.interface.encodeFunctionData('mint', [ - context.owner.address, + context.mainController.address, 1, true, '0x', ]); - await expect(context.keyManager.connect(context.owner).execute(mintPayload)) + await expect(context.keyManager.connect(context.mainController).execute(mintPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidERC725Function') .withArgs(mintPayload.substring(0, 10)); }); @@ -136,7 +137,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { const renounceOwnershipPayload = context.token.interface.encodeFunctionData('renounceOwnership'); - await context.keyManager.connect(context.owner).execute(renounceOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(renounceOwnershipPayload); expect(await context.token.owner()).to.equal(ethers.constants.AddressZero); }); @@ -153,7 +154,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { newOwner.address, ]); - await context.keyManager.connect(context.owner).execute(transferOwnershipPayload); + await context.keyManager.connect(context.mainController).execute(transferOwnershipPayload); expect(await context.token.owner()).to.equal(newOwner.address); }); @@ -163,9 +164,9 @@ describe('When deploying LSP7 with LSP6 as owner', () => { const value = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('SecondRandomString')); const payload = context.token.interface.encodeFunctionData('setData', [key, value]); - await expect(context.keyManager.connect(context.owner).execute(payload)).to.be.revertedWith( - 'Ownable: caller is not the owner', - ); + await expect( + context.keyManager.connect(context.mainController).execute(payload), + ).to.be.revertedWith('Ownable: caller is not the owner'); }); it('should allow the new owner to call setData(..)', async () => { @@ -180,13 +181,13 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it("`mint(..)` -> should revert with 'InvalidERC725Function' error.", async () => { const LSP7 = context.token as LSP7Mintable; const mintPayload = LSP7.interface.encodeFunctionData('mint', [ - context.owner.address, + context.mainController.address, 1, true, '0x', ]); - await expect(context.keyManager.connect(context.owner).execute(mintPayload)) + await expect(context.keyManager.connect(context.mainController).execute(mintPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidERC725Function') .withArgs(mintPayload.substring(0, 10)); }); @@ -194,9 +195,9 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it('should allow the new owner to call mint(..)', async () => { const LSP7 = context.token as LSP7Mintable; - await LSP7.connect(newOwner).mint(context.owner.address, 1, true, '0x'); + await LSP7.connect(newOwner).mint(context.mainController.address, 1, true, '0x'); - expect(await LSP7.balanceOf(context.owner.address)).to.equal(1); + expect(await LSP7.balanceOf(context.mainController.address)).to.equal(1); }); it("`transferOwnership(..)` -> should revert with 'caller is not the owner' error.", async () => { @@ -206,7 +207,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ); await expect( - context.keyManager.connect(context.owner).execute(transferOwnershipPayload), + context.keyManager.connect(context.mainController).execute(transferOwnershipPayload), ).to.be.revertedWith('Ownable: caller is not the owner'); }); @@ -221,7 +222,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { context.token.interface.encodeFunctionData('renounceOwnership'); await expect( - context.keyManager.connect(context.owner).execute(renounceOwnershipPayload), + context.keyManager.connect(context.mainController).execute(renounceOwnershipPayload), ).to.be.revertedWith('Ownable: caller is not the owner'); }); @@ -255,13 +256,13 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '0', ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '1', ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanChangeOwner.address.substring(2), ]; const values = [ ARRAY_LENGTH.TWO, - context.owner.address, + context.mainController.address, addressCanChangeOwner.address, ALL_PERMISSIONS, PERMISSIONS.CHANGEOWNER, @@ -320,7 +321,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '1', ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '2', ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanChangeOwner.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -328,7 +329,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ]; const values = [ ARRAY_LENGTH.THREE, - context.owner.address, + context.mainController.address, addressCanChangeOwner.address, addressCanEditPermissions.address, ALL_PERMISSIONS, @@ -342,7 +343,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it("should revert if caller doesn't have EDITPERMISSIONS permission", async () => { const key = ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2); + context.mainController.address.substring(2); const value = PERMISSIONS.CALL; const payload = context.token.interface.encodeFunctionData('setData', [key, value]); @@ -354,7 +355,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it('should change ALL_PERMISSIONS to CALL permission of the address', async () => { const key = ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2); + context.mainController.address.substring(2); const value = PERMISSIONS.CALL; const payload = context.token.interface.encodeFunctionData('setData', [key, value]); @@ -366,7 +367,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { it('should add back ALL_PERMISSIONS of the address', async () => { const key = ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2); + context.mainController.address.substring(2); const value = ALL_PERMISSIONS; const payload = context.token.interface.encodeFunctionData('setData', [key, value]); @@ -396,7 +397,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '2', ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '3', ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanChangeOwner.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -406,7 +407,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ]; const values = [ ARRAY_LENGTH.FOUR, - context.owner.address, + context.mainController.address, addressCanChangeOwner.address, addressCanEditPermissions.address, addressCanAddController.address, @@ -450,7 +451,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { const value = '0x'; const payload = context.token.interface.encodeFunctionData('setData', [key, value]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); }); }); @@ -485,7 +486,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '3', ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '4', ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanChangeOwner.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -497,7 +498,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ]; const values = [ ARRAY_LENGTH.FIVE, - context.owner.address, + context.mainController.address, addressCanChangeOwner.address, addressCanEditPermissions.address, addressCanAddController.address, @@ -529,7 +530,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { const value = encodeCompactBytesArray([firstRandomSringKey.substring(0, 34)]); const payload = context.token.interface.encodeFunctionData('setData', [key, value]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); expect(await context.token.getData(key)).to.equal(value); }); @@ -592,14 +593,14 @@ describe('When deploying LSP7 with LSP6 as owner', () => { describe('when trying to call execute(..) function on LSP7 through LSP6', () => { it('should revert because function does not exist on LSP7', async () => { // deploying a dummy token contract with public mint function - const newTokenContract = await new LSP7Tester__factory(context.owner).deploy( + const newTokenContract = await new LSP7Tester__factory(context.mainController).deploy( 'NewTokenName', 'NewTokenSymbol', - context.owner.address, + context.mainController.address, ); // creating a payload to mint tokens in the new contract const mintPayload = newTokenContract.interface.encodeFunctionData('mint', [ - context.owner.address, + context.mainController.address, 1000, true, '0x', @@ -613,7 +614,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ]); await expect( - context.keyManager.connect(context.owner).execute(payload), + context.keyManager.connect(context.mainController).execute(payload), ).to.be.revertedWithCustomError(newTokenContract, 'NoExtensionFoundForFunctionSelector'); }); }); @@ -640,7 +641,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '4', ERC725YDataKeys.LSP6['AddressPermissions[]'].index + '0'.repeat(31) + '5', ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanChangeOwner.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -654,7 +655,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => { ]; const values = [ ARRAY_LENGTH.SIX, - context.owner.address, + context.mainController.address, addressCanChangeOwner.address, addressCanEditPermissions.address, addressCanAddController.address, diff --git a/tests/LSP6KeyManager/LSP6KeyManager.test.ts b/tests/LSP6KeyManager/LSP6KeyManager.test.ts index f2adeee39..d01ea7192 100644 --- a/tests/LSP6KeyManager/LSP6KeyManager.test.ts +++ b/tests/LSP6KeyManager/LSP6KeyManager.test.ts @@ -18,15 +18,20 @@ import { describe('LSP6KeyManager with constructor', () => { const buildTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address, { - value: initialFunding, - }); + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + { + value: initialFunding, + }, + ); - const keyManager = await new LSP6KeyManager__factory(owner).deploy(universalProfile.address); + const keyManager = await new LSP6KeyManager__factory(mainController).deploy( + universalProfile.address, + ); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; describe('when deploying the contract', () => { @@ -42,14 +47,16 @@ describe('LSP6KeyManager with constructor', () => { describe('testing internal functions', () => { testLSP6InternalFunctions(async () => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address); - const keyManagerInternalTester = await new KeyManagerInternalTester__factory(owner).deploy( - universalProfile.address, + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, ); + const keyManagerInternalTester = await new KeyManagerInternalTester__factory( + mainController, + ).deploy(universalProfile.address); - return { owner, accounts, universalProfile, keyManagerInternalTester }; + return { mainController, accounts, universalProfile, keyManagerInternalTester }; }); }); }); diff --git a/tests/LSP6KeyManager/LSP6KeyManagerInit.test.ts b/tests/LSP6KeyManager/LSP6KeyManagerInit.test.ts index e2b46c20f..5d1869cb9 100644 --- a/tests/LSP6KeyManager/LSP6KeyManagerInit.test.ts +++ b/tests/LSP6KeyManager/LSP6KeyManagerInit.test.ts @@ -11,21 +11,21 @@ describe('LSP6KeyManager with proxy', () => { const buildProxyTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const baseUP = await new UniversalProfileInit__factory(owner).deploy(); - const upProxy = await deployProxy(baseUP.address, owner); + const baseUP = await new UniversalProfileInit__factory(mainController).deploy(); + const upProxy = await deployProxy(baseUP.address, mainController); const universalProfile = await baseUP.attach(upProxy); - const baseKM = await new LSP6KeyManagerInit__factory(owner).deploy(); - const kmProxy = await deployProxy(baseKM.address, owner); + const baseKM = await new LSP6KeyManagerInit__factory(mainController).deploy(); + const kmProxy = await deployProxy(baseKM.address, mainController); const keyManager = await baseKM.attach(kmProxy); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; const initializeProxies = async (context: LSP6TestContext) => { - await context.universalProfile['initialize(address)'](context.owner.address, { + await context.universalProfile['initialize(address)'](context.mainController.address, { value: context.initialFunding, }); diff --git a/tests/LSP6KeyManager/Relay/ExecuteRelayCall.test.ts b/tests/LSP6KeyManager/Relay/ExecuteRelayCall.test.ts index 29a71b9cc..a3c49da70 100644 --- a/tests/LSP6KeyManager/Relay/ExecuteRelayCall.test.ts +++ b/tests/LSP6KeyManager/Relay/ExecuteRelayCall.test.ts @@ -64,7 +64,8 @@ export const shouldBehaveLikeExecuteRelayCall = ( targetContract = await new TargetContract__factory(context.accounts[0]).deploy(); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + signer.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + signer.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -1204,7 +1205,8 @@ export const shouldBehaveLikeExecuteRelayCall = ( ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ]; const permissionsValues = [ALL_PERMISSIONS]; @@ -1222,7 +1224,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch(signatures, nonces, validityTimestamps, values, payloads), ).to.be.revertedWithCustomError( context.keyManager, @@ -1241,7 +1243,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( '0x', ]); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const validityTimestamps = 0; @@ -1292,7 +1294,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( // the incorrectly recovered address (as explained above) await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( [transferLyxSignature, transferLyxSignature], [ownerNonce, ownerNonce.add(1)], @@ -1330,7 +1332,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( ], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const ownerGivePermissionsSignature = await signLSP6ExecuteRelayCall( context.keyManager, @@ -1389,7 +1391,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( ); await context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( [ownerGivePermissionsSignature, minterMintSignature, ownerRemovePermissionsSignature], [ownerNonce, minterNonce, newOwnerNonce], @@ -1456,7 +1458,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( [OPERATION_TYPES.CALL, thirdRecipient, transferAmounts[2], '0x'], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const validityTimestamps = 0; @@ -1487,7 +1489,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( [firstTransferLyxSignature, secondTransferLyxSignature, thirdTransferLyxSignature], [ownerNonce, ownerNonce.add(1), ownerNonce.add(2)], @@ -1542,7 +1544,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( [OPERATION_TYPES.CALL, thirdRecipient, transferAmounts[2], '0x'], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const validityTimestamps = 0; @@ -1573,7 +1575,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( [firstTransferLyxSignature, secondTransferLyxSignature, thirdTransferLyxSignature], [ownerNonce, ownerNonce.add(1), ownerNonce.add(2)], @@ -1625,7 +1627,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( [OPERATION_TYPES.CALL, thirdRecipient, transferAmounts[2], '0x'], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const validityTimestamps = 0; @@ -1655,7 +1657,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( ); const tx = await context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( [firstTransferLyxSignature, secondTransferLyxSignature, thirdTransferLyxSignature], [ownerNonce, ownerNonce.add(1), ownerNonce.add(2)], @@ -1700,7 +1702,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( [OPERATION_TYPES.CALL, randomRecipient, validAmount, '0x'], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const nonces = [ownerNonce, ownerNonce.add(1), ownerNonce.add(2)]; @@ -1738,7 +1740,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( signatures, nonces, @@ -1775,7 +1777,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( [OPERATION_TYPES.CALL, randomRecipient, validAmount, '0x'], ); - const ownerNonce = await context.keyManager.getNonce(context.owner.address, 0); + const ownerNonce = await context.keyManager.getNonce(context.mainController.address, 0); const nonces = [ownerNonce, ownerNonce.add(1), ownerNonce.add(2)]; const values = [0, 0, 0]; @@ -1814,7 +1816,7 @@ export const shouldBehaveLikeExecuteRelayCall = ( await expect( context.keyManager - .connect(context.owner) + .connect(context.mainController) .executeRelayCallBatch( signatures, nonces, diff --git a/tests/LSP6KeyManager/Relay/MultiChannelNonce.test.ts b/tests/LSP6KeyManager/Relay/MultiChannelNonce.test.ts index 6c8ab53b0..cc4cf1050 100644 --- a/tests/LSP6KeyManager/Relay/MultiChannelNonce.test.ts +++ b/tests/LSP6KeyManager/Relay/MultiChannelNonce.test.ts @@ -35,7 +35,8 @@ export const shouldBehaveLikeMultiChannelNonce = (buildContext: () => Promise Promise Promise Promise Promise Promise Promise Promise { context = await buildContext(); - contractCanSetData = await new Executor__factory(context.owner).deploy( + contractCanSetData = await new Executor__factory(context.mainController).deploy( context.universalProfile.address, context.keyManager.address, ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + contractCanSetData.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedERC725YDataKeys'] + diff --git a/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts b/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts index da93c8b64..4551588f7 100644 --- a/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts +++ b/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts @@ -22,7 +22,7 @@ async function setupPermissions( permissionValues, ]); - await context.keyManager.connect(context.owner).execute(setupPayload); + await context.keyManager.connect(context.mainController).execute(setupPayload); } /** @@ -34,7 +34,7 @@ async function resetPermissions(context: LSP6TestContext, permissionsKeys: strin Array(permissionsKeys.length).fill('0x'), ]); - await context.keyManager.connect(context.owner).execute(teardownPayload); + await context.keyManager.connect(context.mainController).execute(teardownPayload); } export const shouldBehaveLikePermissionChangeOrAddController = ( @@ -135,7 +135,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( await setupKeyManager( context, [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ...firstSetupPermissionsKeys, ], [ALL_PERMISSIONS, ...firstSetupPermissionsValues], @@ -200,7 +201,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( permissionArrayValues = [ ethers.utils.hexZeroPad(ethers.utils.hexlify(6), 16), - context.owner.address, + context.mainController.address, canOnlyAddController.address, canOnlyEditPermissions.address, canOnlySetData.address, @@ -243,7 +244,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( PERMISSIONS.SETDATA, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -262,7 +263,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -280,7 +281,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); expect(await context.universalProfile.getData(key)).to.equal(value); }); @@ -295,7 +296,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); expect(await context.universalProfile.getData(key)).to.equal(value); }); @@ -314,7 +315,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -335,7 +336,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -353,7 +354,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile.getData(key); expect(result).to.equal(value); @@ -369,7 +370,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( randomValue, ]); - await expect(context.keyManager.connect(context.owner).execute(setupPayload)) + await expect(context.keyManager.connect(context.mainController).execute(setupPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -384,7 +385,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( randomValue, ]); - await expect(context.keyManager.connect(context.owner).execute(setupPayload)) + await expect(context.keyManager.connect(context.mainController).execute(setupPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -403,7 +404,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -420,7 +421,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( randomValue, ]); - await expect(context.keyManager.connect(context.owner).execute(setupPayload)) + await expect(context.keyManager.connect(context.mainController).execute(setupPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -435,7 +436,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( randomValue, ]); - await expect(context.keyManager.connect(context.owner).execute(setupPayload)) + await expect(context.keyManager.connect(context.mainController).execute(setupPayload)) .to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys') .withArgs(key, randomValue); }); @@ -452,7 +453,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const result = await context.universalProfile.getData(key); @@ -476,7 +477,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( value, ]); - await expect(context.keyManager.connect(context.owner).execute(payload)) + await expect(context.keyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(context.keyManager, 'NotRecognisedPermissionKey') .withArgs(key.toLowerCase()); }); @@ -1285,7 +1286,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( values, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); @@ -1314,7 +1315,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( values, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); @@ -1345,7 +1346,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( values, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); // prettier-ignore const fetchedResult = await context.universalProfile.getDataBatch(keys); diff --git a/tests/LSP6KeyManager/internals/AllowedCalls.internal.ts b/tests/LSP6KeyManager/internals/AllowedCalls.internal.ts index 26b6f5017..de2e1b21c 100644 --- a/tests/LSP6KeyManager/internals/AllowedCalls.internal.ts +++ b/tests/LSP6KeyManager/internals/AllowedCalls.internal.ts @@ -29,7 +29,7 @@ async function teardownKeyManagerHelper( Array(permissionsKeys.length).fill('0x'), ]); - await context.keyManagerInternalTester.connect(context.owner).execute(teardownPayload); + await context.keyManagerInternalTester.connect(context.mainController).execute(teardownPayload); } export const testAllowedCallsInternals = ( @@ -157,7 +157,8 @@ export const testAllowedCallsInternals = ( ); const permissionsKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + canCallOnlyTwoAddresses.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + @@ -184,13 +185,13 @@ export const testAllowedCallsInternals = ( it('should return no bytes when no allowed calls were set', async () => { const bytesResult = await context.keyManagerInternalTester.getAllowedCallsFor( - context.owner.address, + context.mainController.address, ); expect(bytesResult).to.equal('0x'); const resultFromAccount = await context.universalProfile['getData(bytes32)']( ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ); expect(resultFromAccount).to.equal('0x'); }); @@ -333,7 +334,7 @@ export const testAllowedCallsInternals = ( permissionValues, ]); - await context.keyManagerInternalTester.connect(context.owner).execute(setup); + await context.keyManagerInternalTester.connect(context.mainController).execute(setup); }); after('reset permissions', async () => { @@ -444,7 +445,7 @@ export const testAllowedCallsInternals = ( permissionValues, ]); - await context.keyManagerInternalTester.connect(context.owner).execute(setup); + await context.keyManagerInternalTester.connect(context.mainController).execute(setup); }); after('reset permissions', async () => { @@ -555,7 +556,7 @@ export const testAllowedCallsInternals = ( permissionValues, ]); - await context.keyManagerInternalTester.connect(context.owner).execute(setup); + await context.keyManagerInternalTester.connect(context.mainController).execute(setup); }); after('reset permissions', async () => { @@ -674,7 +675,8 @@ export const testAllowedCallsInternals = ( ]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ...Object.values(controllers).map( (controller) => ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -775,7 +777,8 @@ export const testAllowedCallsInternals = ( context = await buildContext(); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.accounts[1].address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -837,7 +840,8 @@ export const testAllowedCallsInternals = ( anyAllowedCalls = context.accounts[1]; const permissionsKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + anyAllowedCalls.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + diff --git a/tests/LSP6KeyManager/internals/Execute.internal.ts b/tests/LSP6KeyManager/internals/Execute.internal.ts index 9541523d6..e908e4d19 100644 --- a/tests/LSP6KeyManager/internals/Execute.internal.ts +++ b/tests/LSP6KeyManager/internals/Execute.internal.ts @@ -14,7 +14,8 @@ export const testExecuteInternals = (buildContext: () => Promise Promise Promise { expect( - await context.keyManagerInternalTester.getPermissionsFor(context.owner.address), + await context.keyManagerInternalTester.getPermissionsFor(context.mainController.address), ).to.equal(ALL_PERMISSIONS); // ALL_PERMISSIONS = "0xffff..." }); @@ -125,7 +126,8 @@ export const testReadingPermissionsInternals = ( addressCanSetData = context.accounts[1]; const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + addressCanSetData.address.substring(2), ]; @@ -164,7 +166,8 @@ export const testReadingPermissionsInternals = ( fourthBeneficiary = context.accounts[4]; let permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + firstBeneficiary.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -196,7 +199,7 @@ export const testReadingPermissionsInternals = ( // set AddressPermissions array values permissionArrayValues = [ '0x05', - context.owner.address, + context.mainController.address, firstBeneficiary.address, secondBeneficiary.address, thirdBeneficiary.address, diff --git a/tests/LSP6KeyManager/internals/SetData.internal.ts b/tests/LSP6KeyManager/internals/SetData.internal.ts index 4d56d2f13..b252504bf 100644 --- a/tests/LSP6KeyManager/internals/SetData.internal.ts +++ b/tests/LSP6KeyManager/internals/SetData.internal.ts @@ -13,7 +13,8 @@ export const testSetDataInternals = (buildContext: () => Promise Promise Promise Promise { describe('when using LSP6KeyManager with constructor', () => { const buildLSP6TestContext = async (): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address); - const keyManager = await new LSP6KeyManager__factory(owner).deploy(universalProfile.address); + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + ); + const keyManager = await new LSP6KeyManager__factory(mainController).deploy( + universalProfile.address, + ); - return { accounts, owner, universalProfile, keyManager }; + return { accounts, mainController, universalProfile, keyManager }; }; describe('after deploying the contract', () => { @@ -54,7 +58,7 @@ describe('Key Manager gas cost interactions', () => { const permissionKeys = [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + restrictedToOneAddress.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -85,7 +89,7 @@ describe('Key Manager gas cost interactions', () => { await setupKeyManager(context, permissionKeys, permissionValues); - await context.owner.sendTransaction({ + await context.mainController.sendTransaction({ to: context.universalProfile.address, value: ethers.utils.parseEther('10'), }); @@ -107,7 +111,9 @@ describe('Key Manager gas cost interactions', () => { ], ); - const tx = await context.keyManager.connect(context.owner).execute(transferLyxPayload); + const tx = await context.keyManager + .connect(context.mainController) + .execute(transferLyxPayload); const receipt = await tx.wait(); diff --git a/tests/Reentrancy/LSP20/reentrancyHelpers.ts b/tests/Reentrancy/LSP20/reentrancyHelpers.ts index bdef32d0c..13495a86a 100644 --- a/tests/Reentrancy/LSP20/reentrancyHelpers.ts +++ b/tests/Reentrancy/LSP20/reentrancyHelpers.ts @@ -662,5 +662,5 @@ export const loadTestCase = async ( 'setDataBatch', [permissionKeys, permissionValues], ); - await context.keyManager.connect(context.owner).execute(permissionsPayload); + await context.keyManager.connect(context.mainController).execute(permissionsPayload); }; diff --git a/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts b/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts index d0d46c2f0..71cc74b75 100644 --- a/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts +++ b/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts @@ -68,7 +68,8 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( ); const permissionKeys = [ - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + signer.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:AllowedCalls'] + signer.address.substring(2), ]; @@ -95,7 +96,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( await setupKeyManager(context, permissionKeys, permissionValues); // Fund Universal Profile with some LYXe - await context.owner.sendTransaction({ + await context.mainController.sendTransaction({ to: context.universalProfile.address, value: ethers.utils.parseEther('10'), }); @@ -126,7 +127,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( // send LYX to malicious contract // at this point, the malicious contract receive function try to drain funds by re-entering the KeyManager // this should not be possible since it does not have the permission `REENTRANCY` - await expect(context.keyManager.connect(context.owner).execute(transferPayload)) + await expect(context.keyManager.connect(context.mainController).execute(transferPayload)) .to.be.revertedWithCustomError(context.keyManager, 'NotAuthorised') .withArgs(maliciousContract.address, 'REENTRANCY'); @@ -207,13 +208,13 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( await maliciousContract.loadPayload(executePayload); - await expect(context.keyManager.connect(context.owner).execute(transferPayload)) + await expect(context.keyManager.connect(context.mainController).execute(transferPayload)) .to.be.revertedWithCustomError(context.keyManager, 'NotAuthorised') .withArgs(maliciousContract.address, 'REENTRANCY'); }); it('should pass when reentered by URD and the URD has REENTRANCY permission', async () => { - const URDDummy = await new Reentrancy__factory(context.owner).deploy( + const URDDummy = await new Reentrancy__factory(context.mainController).deploy( context.keyManager.address, ); @@ -240,7 +241,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( ], ); - await context.keyManager.connect(context.owner).execute(setDataPayload); + await context.keyManager.connect(context.mainController).execute(setDataPayload); const transferPayload = context.universalProfile.interface.encodeFunctionData('execute', [ OPERATION_TYPES.CALL, @@ -258,7 +259,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( const initialAccountBalance = await provider.getBalance(context.universalProfile.address); const initialAttackerContractBalance = await provider.getBalance(maliciousContract.address); - await context.keyManager.connect(context.owner).execute(transferPayload); + await context.keyManager.connect(context.mainController).execute(transferPayload); const newAccountBalance = await provider.getBalance(context.universalProfile.address); const newAttackerContractBalance = await provider.getBalance(URDDummy.address); @@ -271,7 +272,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( it('should allow the URD to use `setData(..)` through the LSP6', async () => { const universalReceiverDelegateDataUpdater = - await new UniversalReceiverDelegateDataUpdater__factory(context.owner).deploy(); + await new UniversalReceiverDelegateDataUpdater__factory(context.mainController).deploy(); const randomHardcodedKey = ethers.utils.keccak256( ethers.utils.toUtf8Bytes('some random data key'), @@ -298,7 +299,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( ], ); - await context.keyManager.connect(context.owner).execute(setDataPayload); + await context.keyManager.connect(context.mainController).execute(setDataPayload); const universalReceiverDelegatePayload = universalReceiverDelegateDataUpdater.interface.encodeFunctionData('universalReceiver', [ @@ -313,7 +314,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( universalReceiverDelegatePayload, ]); - await context.keyManager.connect(context.owner).execute(executePayload); + await context.keyManager.connect(context.mainController).execute(executePayload); expect(await context.universalProfile.getData(randomHardcodedKey)).to.equal( randomHardcodedValue, @@ -336,7 +337,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( const permissionKeys = [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - context.owner.address.substring(2), + context.mainController.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + firstReentrant.address.substring(2), ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + @@ -366,7 +367,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( firstTargetSelector, ]); - await expect(context.keyManager.connect(context.owner).execute(payload)) + await expect(context.keyManager.connect(context.mainController).execute(payload)) .to.be.revertedWithCustomError(context.keyManager, 'NotAuthorised') .withArgs(secondReentrant.address, 'REENTRANCY'); }); @@ -397,7 +398,7 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( firstTargetSelector, ]); - await context.keyManager.connect(context.owner).execute(payload); + await context.keyManager.connect(context.mainController).execute(payload); const result = await context.universalProfile['getData(bytes32)']( ethers.constants.HashZero, diff --git a/tests/Reentrancy/LSP6/reentrancyHelpers.ts b/tests/Reentrancy/LSP6/reentrancyHelpers.ts index cb4292540..b32efb594 100644 --- a/tests/Reentrancy/LSP6/reentrancyHelpers.ts +++ b/tests/Reentrancy/LSP6/reentrancyHelpers.ts @@ -664,5 +664,5 @@ export const loadTestCase = async ( 'setDataBatch', [permissionKeys, permissionValues], ); - await context.keyManager.connect(context.owner).execute(permissionsPayload); + await context.keyManager.connect(context.mainController).execute(permissionsPayload); }; diff --git a/tests/Reentrancy/Reentrancy.test.ts b/tests/Reentrancy/Reentrancy.test.ts index 70e6530ec..9ab0f7cb0 100644 --- a/tests/Reentrancy/Reentrancy.test.ts +++ b/tests/Reentrancy/Reentrancy.test.ts @@ -11,15 +11,20 @@ import { shouldBehaveLikeLSP20WithLSP6ReentrancyScenarios } from './LSP20/LSP20W describe('Reentrancy scenarios with constructor', () => { const buildTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const universalProfile = await new UniversalProfile__factory(owner).deploy(owner.address, { - value: initialFunding, - }); + const universalProfile = await new UniversalProfile__factory(mainController).deploy( + mainController.address, + { + value: initialFunding, + }, + ); - const keyManager = await new LSP6KeyManager__factory(owner).deploy(universalProfile.address); + const keyManager = await new LSP6KeyManager__factory(mainController).deploy( + universalProfile.address, + ); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; describe('when testing Reentrancy scenarios for LSP6', () => { diff --git a/tests/Reentrancy/ReentrancyInit.test.ts b/tests/Reentrancy/ReentrancyInit.test.ts index 0645d1819..2a3c0a33e 100644 --- a/tests/Reentrancy/ReentrancyInit.test.ts +++ b/tests/Reentrancy/ReentrancyInit.test.ts @@ -12,21 +12,21 @@ import { shouldBehaveLikeLSP20WithLSP6ReentrancyScenarios } from './LSP20/LSP20W describe('Reentrancy scenarios with proxy', () => { const buildProxyTestContext = async (initialFunding?: BigNumber): Promise => { const accounts = await ethers.getSigners(); - const owner = accounts[0]; + const mainController = accounts[0]; - const baseUP = await new UniversalProfileInit__factory(owner).deploy(); - const upProxy = await deployProxy(baseUP.address, owner); + const baseUP = await new UniversalProfileInit__factory(mainController).deploy(); + const upProxy = await deployProxy(baseUP.address, mainController); const universalProfile = await baseUP.attach(upProxy); - const baseKM = await new LSP6KeyManagerInit__factory(owner).deploy(); - const kmProxy = await deployProxy(baseKM.address, owner); + const baseKM = await new LSP6KeyManagerInit__factory(mainController).deploy(); + const kmProxy = await deployProxy(baseKM.address, mainController); const keyManager = await baseKM.attach(kmProxy); - return { accounts, owner, universalProfile, keyManager, initialFunding }; + return { accounts, mainController, universalProfile, keyManager, initialFunding }; }; const initializeProxies = async (context: LSP6TestContext) => { - await context.universalProfile['initialize(address)'](context.owner.address, { + await context.universalProfile['initialize(address)'](context.mainController.address, { value: context.initialFunding, }); diff --git a/tests/utils/context.ts b/tests/utils/context.ts index 266d1856c..7433a2ea6 100644 --- a/tests/utils/context.ts +++ b/tests/utils/context.ts @@ -4,7 +4,7 @@ import { KeyManagerInternalTester, LSP6KeyManager, UniversalProfile } from '../. export type LSP6TestContext = { accounts: SignerWithAddress[]; - owner: SignerWithAddress; + mainController: SignerWithAddress; universalProfile: UniversalProfile; keyManager: LSP6KeyManager; initialFunding?: BigNumber; @@ -12,7 +12,7 @@ export type LSP6TestContext = { export type LSP6InternalsTestContext = { accounts: SignerWithAddress[]; - owner: SignerWithAddress; + mainController: SignerWithAddress; universalProfile: UniversalProfile; keyManagerInternalTester: KeyManagerInternalTester; }; diff --git a/tests/utils/fixtures.ts b/tests/utils/fixtures.ts index 8b9934130..772b146d4 100644 --- a/tests/utils/fixtures.ts +++ b/tests/utils/fixtures.ts @@ -49,24 +49,25 @@ export async function setupKeyManager( _dataKeys: string[], _dataValues: string[], ) { - await _context.universalProfile.connect(_context.owner).setDataBatch( + await _context.universalProfile.connect(_context.mainController).setDataBatch( [ - // required to set owner permission so that it can acceptOwnership(...) via the KeyManager - // otherwise, the KeyManager will flag the calling owner as not having the permission CHANGEOWNER + // required to set main controller permission so that it can acceptOwnership(...) via the KeyManager + // otherwise, the KeyManager will flag the calling main controller as not having the permission CHANGEOWNER // when trying to setup the KeyManager - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + _context.owner.address.substring(2), + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + + _context.mainController.address.substring(2), ..._dataKeys, ], [ALL_PERMISSIONS, ..._dataValues], ); await _context.universalProfile - .connect(_context.owner) + .connect(_context.mainController) .transferOwnership(_context.keyManager.address); const payload = _context.universalProfile.interface.getSighash('acceptOwnership'); - await _context.keyManager.connect(_context.owner).execute(payload); + await _context.keyManager.connect(_context.mainController).execute(payload); } export async function setupKeyManagerHelper( @@ -75,23 +76,23 @@ export async function setupKeyManagerHelper( _permissionsValues: string[], ) { await _context.universalProfile - .connect(_context.owner) + .connect(_context.mainController) .setDataBatch( [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - _context.owner.address.substring(2), + _context.mainController.address.substring(2), ..._permissionsKeys, ], [ALL_PERMISSIONS, ..._permissionsValues], ); await _context.universalProfile - .connect(_context.owner) + .connect(_context.mainController) .transferOwnership(_context.keyManagerInternalTester.address); const payload = _context.universalProfile.interface.getSighash('acceptOwnership'); - await _context.keyManagerInternalTester.connect(_context.owner).execute(payload); + await _context.keyManagerInternalTester.connect(_context.mainController).execute(payload); } /**