From a977312f99a3f957e581f5b502ef818f033f3846 Mon Sep 17 00:00:00 2001 From: Johann BICH <2253470+kalote@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:24:19 +0200 Subject: [PATCH] fix: ts configs and tests (#733) * fix ts config and types on tests * lint * test: fix Typescript errors in `Benchmark.test.ts` * docs: update auto-generated docs --------- Co-authored-by: CJ42 --- tests/Benchmark.test.ts | 73 ++----------------- .../LSP14Ownable2Step.behaviour.ts | 8 ++ ...P1UniversalReceiverDelegateUP.behaviour.ts | 4 +- .../LSP20WithLSP14.behaviour.ts | 8 ++ .../LSP6/Interactions/Security.test.ts | 2 + .../LSP23LinkedContractsDeployment.test.ts | 49 +++++++------ .../LSP23LinkedContractsDeployment/helpers.ts | 17 +++-- .../PermissionTransferValue.test.ts | 30 +++++--- .../PermissionChangeAddController.test.ts | 16 ++-- .../LSP8CompatibleERC721.behaviour.ts | 1 + .../LSP8IdentifiableDigitalAsset.behaviour.ts | 2 +- tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts | 20 +++-- ...gleExecuteRelayCallToSingleExecute.test.ts | 45 ++---------- ...eRelayCallToSingleExecuteRelayCall.test.ts | 43 ++--------- tests/Reentrancy/LSP6/reentrancyHelpers.ts | 14 ++-- tsconfig.json | 10 +-- tsconfig.module.json | 1 - 17 files changed, 126 insertions(+), 217 deletions(-) diff --git a/tests/Benchmark.test.ts b/tests/Benchmark.test.ts index aff0d2a1b..03ad2700f 100644 --- a/tests/Benchmark.test.ts +++ b/tests/Benchmark.test.ts @@ -546,12 +546,12 @@ describe('⛽📊 Gas Benchmark', () => { false, ); - // deploy a LSP8 NFT + // deploy a LSP8 token lsp8Token = await new LSP8Mintable__factory(context.owner).deploy( 'My NFT', 'MNFT', context.owner.address, - LSP8_TOKEN_ID_TYPES.NUMBER, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); universalProfile1 = await new UniversalProfile__factory(context.owner).deploy( @@ -654,8 +654,6 @@ describe('⛽📊 Gas Benchmark', () => { describe('KeyManager', () => { describe('`execute(...)` via Key Manager', () => { describe('main controller (this browser extension)', () => { - const casesExecuteMainController: Row[] = []; - let context: LSP6TestContext; let recipientEOA: SignerWithAddress; @@ -705,7 +703,7 @@ describe('⛽📊 Gas Benchmark', () => { 'MetaNFT', 'MNF', context.owner.address, - LSP8_TOKEN_ID_TYPES.NUMBER, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); // mint some tokens to the UP @@ -724,11 +722,6 @@ describe('⛽📊 Gas Benchmark', () => { const tx = await context.universalProfile.connect(context.owner).execute(OPERATION_TYPES.CALL, recipientEOA.address, lyxAmount, "0x"); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer LYX to an EOA', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_1'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -741,11 +734,6 @@ describe('⛽📊 Gas Benchmark', () => { const tx = await context.universalProfile.connect(context.owner).execute(OPERATION_TYPES.CALL, aliceUP.address, lyxAmount, "0x"); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer LYX to a UP', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_2'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -769,11 +757,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer tokens (LSP7) to an EOA (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_3'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -797,11 +780,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer tokens (LSP7) to a UP (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_4'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -825,11 +803,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer a NFT (LSP8) to a EOA (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_5'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -853,11 +826,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteMainController.push([ - 'transfer a NFT (LSP8) to a UP (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_6'][ 'main_controller' ] = receipt.gasUsed.toNumber(); @@ -865,7 +833,6 @@ describe('⛽📊 Gas Benchmark', () => { }); describe('controllers with some restrictions', () => { - const casesExecuteRestrictedController: Row[] = []; let context: LSP6TestContext; let recipientEOA: SignerWithAddress; @@ -936,7 +903,7 @@ describe('⛽📊 Gas Benchmark', () => { 'MetaNFT', 'MNF', context.owner.address, - LSP8_TOKEN_ID_TYPES.NUMBER, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); lsp8LyxPunks = await new LSP8Mintable__factory(context.owner).deploy( @@ -1002,11 +969,6 @@ describe('⛽📊 Gas Benchmark', () => { .execute(OPERATION_TYPES.CALL, allowedAddressToTransferValue, lyxAmount, '0x'); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfer some LYXes to an EOA - restricted to 2 x allowed address only (an EOA + a UP) (TRANSFERVALUE + 2x AllowedCalls)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_1'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1021,11 +983,6 @@ describe('⛽📊 Gas Benchmark', () => { .execute(OPERATION_TYPES.CALL, aliceUP.address, lyxAmount, '0x'); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfer some LYXes to a UP - restricted to 2 x allowed address only (an EOA + a UP) (TRANSFERVALUE + 2x AllowedCalls)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_2'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1049,11 +1006,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfers some tokens (LSP7) to an EOA - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_3'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1077,11 +1029,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfers some tokens (LSP7) to an other UP - restricted to LSP7 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_4'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1105,11 +1052,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfers a NFT (LSP8) to an EOA - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_5'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1133,11 +1075,6 @@ describe('⛽📊 Gas Benchmark', () => { ); const receipt = await tx.wait(); - casesExecuteRestrictedController.push([ - 'transfers a NFT (LSP8) to an other UP - restricted to LSP8 + 2x allowed contracts only (CALL + 2x AllowedCalls) (no data)', - receipt.gasUsed.toNumber().toString(), - ]); - gasBenchmark['runtime_costs']['KeyManager_owner']['execute']['case_6'][ 'restricted_controller' ] = receipt.gasUsed.toNumber(); @@ -1642,7 +1579,7 @@ describe('⛽📊 Gas Benchmark', () => { // prettier-ignore const dataKeys = [ ERC725YDataKeys.LSP6["AddressPermissions[]"].length, - ERC725YDataKeys.LSP6["AddressPermissions[]"].index + ethers.utils.hexZeroPad(ethers.BigNumber.from(AddressPermissionsArrayLength).sub(1), 16).substring(2), + ERC725YDataKeys.LSP6["AddressPermissions[]"].index + ethers.utils.hexZeroPad(ethers.BigNumber.from(AddressPermissionsArrayLength).sub(1).toHexString(), 16).substring(2), ERC725YDataKeys.LSP6["AddressPermissions:Permissions"] + newController.address.substring(2), ERC725YDataKeys.LSP6["AddressPermissions:AllowedERC725YDataKeys"] + newController.address.substring(2), ]; diff --git a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts index c3e55b646..c962c6914 100644 --- a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts +++ b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts @@ -288,6 +288,8 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -375,6 +377,8 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -440,6 +444,8 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -527,6 +533,8 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, diff --git a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts index e38f35450..49c0a6d01 100644 --- a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts +++ b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts @@ -1126,7 +1126,7 @@ export const shouldBehaveLikeLSP1Delegate = ( before(async () => { const setDataPayload = context.universalProfile1.interface.encodeFunctionData('setData', [ lsp5ArrayLengthDataKey, - lsp5ArrayLengthDataValue, + lsp5ArrayLengthDataValue.toHexString(), ]); await context.lsp6KeyManager1.connect(context.accounts.owner1).execute(setDataPayload); @@ -1173,7 +1173,7 @@ export const shouldBehaveLikeLSP1Delegate = ( before(async () => { const setDataPayload = context.universalProfile1.interface.encodeFunctionData('setData', [ lsp5ArrayLengthDataKey, - lsp5ArrayLengthDataValue, + lsp5ArrayLengthDataValue.toHexString(), ]); await context.lsp6KeyManager1.connect(context.accounts.owner1).execute(setDataPayload); diff --git a/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts b/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts index 8a767e99e..de7debaff 100644 --- a/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts +++ b/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts @@ -294,6 +294,8 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -383,6 +385,8 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -449,6 +453,8 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -540,6 +546,8 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, diff --git a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts index ede08ed98..1c38af65f 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts @@ -304,6 +304,8 @@ export const testSecurityScenarios = (buildContext: () => Promise { if (elem.label === '_reentrancyStatus') return elem; })[0].slot, diff --git a/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts b/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts index d0b2884a5..b94465f54 100644 --- a/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts +++ b/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts @@ -2,10 +2,11 @@ import { ethers } from 'hardhat'; import { expect } from 'chai'; import { - LSP23LinkedContractsFactory, + ILSP23LinkedContractsFactory, + KeyManagerWithExtraParams, LSP6KeyManager, UniversalProfile, -} from '../../typechain-types'; +} from '../../types'; import { ERC725YDataKeys } from '../../constants'; import { calculateProxiesAddresses, @@ -35,16 +36,16 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = + const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = { salt, fundingAmount: 0, creationBytecode: universalProfileCreationCode, }; - const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct = { - fundingAmount: 0, + fundingAmount: ethers.BigNumber.from(0), creationBytecode: keyManagerBytecode, addPrimaryContractAddress: true, extraConstructorParams: '0x', @@ -125,8 +126,10 @@ describe('UniversalProfileDeployer', function () { expect(upContract).to.equal(expectedUpAddress); expect(keyManagerContract).to.equal(expectedKeyManagerAddress); - const keyManagerInstance: LSP6KeyManager = KeyManagerFactory.attach(keyManagerContract); - const universalProfileInstance: UniversalProfile = UniversalProfileFactory.attach(upContract); + const keyManagerInstance = KeyManagerFactory.attach(keyManagerContract) as LSP6KeyManager; + const universalProfileInstance = UniversalProfileFactory.attach( + upContract, + ) as UniversalProfile; // CHECK that the UP is owned by the KeyManager contract expect(await universalProfileInstance.owner()).to.equal(keyManagerContract); @@ -154,14 +157,14 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = + const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = { salt, fundingAmount: universalProfileFundAmount, creationBytecode: universalProfileCreationCode, }; - const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct = { fundingAmount: 0, creationBytecode: keyManagerBytecode, @@ -253,14 +256,14 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = + const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = { salt, fundingAmount: universalProfileFundAmount, creationBytecode: universalProfileCreationCode, }; - const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct = { fundingAmount: 0, creationBytecode: keyManagerBytecode, @@ -341,7 +344,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = + const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = { salt, fundingAmount: 0, @@ -364,7 +367,7 @@ describe('UniversalProfileDeployer', function () { keyManagerBytecode = keyManagerBytecode + secondaryContractFirstParam.slice(2); - const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct = { fundingAmount: 0, creationBytecode: keyManagerBytecode, @@ -447,8 +450,12 @@ describe('UniversalProfileDeployer', function () { expect(upContract).to.equal(expectedUpAddress); expect(keyManagerContract).to.equal(expectedKeyManagerAddress); - const keyManagerInstance: LSP6KeyManager = KeyManagerFactory.attach(keyManagerContract); - const universalProfileInstance: UniversalProfile = UniversalProfileFactory.attach(upContract); + const keyManagerInstance = KeyManagerFactory.attach( + keyManagerContract, + ) as KeyManagerWithExtraParams; + const universalProfileInstance = UniversalProfileFactory.attach( + upContract, + ) as UniversalProfile; // CHECK that the UP is owned by the KeyManager contract expect(await universalProfileInstance.owner()).to.equal(keyManagerContract); @@ -475,7 +482,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = + const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = { salt, fundingAmount: 0, @@ -485,7 +492,7 @@ describe('UniversalProfileDeployer', function () { ]), }; - const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = { fundingAmount: 0, implementationContract: keyManagerInit.address, @@ -605,7 +612,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = + const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = { salt, fundingAmount: primaryFundingAmount, @@ -615,7 +622,7 @@ describe('UniversalProfileDeployer', function () { ]), }; - const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = { fundingAmount: secondaryFundingAmount, implementationContract: keyManagerInit.address, @@ -672,7 +679,7 @@ describe('UniversalProfileDeployer', function () { const primaryFundingAmount = ethers.utils.parseEther('1'); const secondaryFundingAmount = ethers.utils.parseEther('0'); // key manager does not accept funds - const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = + const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = { salt, fundingAmount: primaryFundingAmount, @@ -682,7 +689,7 @@ describe('UniversalProfileDeployer', function () { ]), }; - const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = { fundingAmount: secondaryFundingAmount, implementationContract: keyManagerInit.address, diff --git a/tests/LSP23LinkedContractsDeployment/helpers.ts b/tests/LSP23LinkedContractsDeployment/helpers.ts index 1c48b9e09..2622b5ab3 100644 --- a/tests/LSP23LinkedContractsDeployment/helpers.ts +++ b/tests/LSP23LinkedContractsDeployment/helpers.ts @@ -1,13 +1,14 @@ import { ethers } from 'hardhat'; import { BytesLike } from 'ethers'; +import { PromiseOrValue } from '../../types/common'; export async function calculateProxiesAddresses( - salt: BytesLike, - primaryImplementationContractAddress: string, - secondaryImplementationContractAddress: string, - secondaryContractInitializationCalldata: BytesLike, - secondaryContractAddControlledContractAddress: boolean, - secondaryContractExtraInitializationParams: BytesLike, + salt: PromiseOrValue, + primaryImplementationContractAddress: PromiseOrValue, + secondaryImplementationContractAddress: PromiseOrValue, + secondaryContractInitializationCalldata: PromiseOrValue, + secondaryContractAddControlledContractAddress: PromiseOrValue, + secondaryContractExtraInitializationParams: PromiseOrValue, upPostDeploymentModuleAddress: string, postDeploymentCalldata: BytesLike, linkedContractsFactoryAddress: string, @@ -32,7 +33,7 @@ export async function calculateProxiesAddresses( generatedSalt, ethers.utils.keccak256( '0x3d602d80600a3d3981f3363d3d373d3d3d363d73' + - primaryImplementationContractAddress.slice(2) + + (primaryImplementationContractAddress as string).slice(2) + '5af43d82803e903d91602b57fd5bf3', ), ); @@ -42,7 +43,7 @@ export async function calculateProxiesAddresses( ethers.utils.keccak256(expectedPrimaryContractAddress), ethers.utils.keccak256( '0x3d602d80600a3d3981f3363d3d373d3d3d363d73' + - secondaryImplementationContractAddress.slice(2) + + (secondaryImplementationContractAddress as string).slice(2) + '5af43d82803e903d91602b57fd5bf3', ), ); diff --git a/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts b/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts index 2b8db6f30..1fb62b25f 100644 --- a/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts +++ b/tests/LSP6KeyManager/Interactions/PermissionTransferValue.test.ts @@ -312,10 +312,12 @@ export const shouldBehaveLikePermissionTransferValue = ( const initialBalanceUP = await provider.getBalance(context.universalProfile.address); const initialBalanceRecipient = await provider.getBalance(recipient.address); - const transferPayload = universalProfileInterface.encodeFunctionData( - 'execute(uint256,address,uint256,bytes)', - [OPERATION_TYPES.CALL, recipient.address, ethers.utils.parseEther('3'), data], - ); + const transferPayload = universalProfileInterface.encodeFunctionData('execute', [ + OPERATION_TYPES.CALL, + recipient.address, + ethers.utils.parseEther('3'), + data, + ]); await expect( context.keyManager.connect(canTransferValue)['execute(bytes)'](transferPayload), @@ -334,10 +336,12 @@ export const shouldBehaveLikePermissionTransferValue = ( it('should pass when caller has permission TRANSFERVALUE + CALL', async () => { const amount = ethers.utils.parseEther('3'); - const transferPayload = universalProfileInterface.encodeFunctionData( - 'execute(uint256,address,uint256,bytes)', - [OPERATION_TYPES.CALL, recipient.address, amount, data], - ); + const transferPayload = universalProfileInterface.encodeFunctionData('execute', [ + OPERATION_TYPES.CALL, + recipient.address, + amount, + data, + ]); await expect(() => context.keyManager @@ -450,10 +454,12 @@ export const shouldBehaveLikePermissionTransferValue = ( const initialBalanceUP = await provider.getBalance(context.universalProfile.address); const initialBalanceRecipient = await provider.getBalance(recipientUP.address); - const transferPayload = universalProfileInterface.encodeFunctionData( - 'execute(uint256,address,uint256,bytes)', - [OPERATION_TYPES.CALL, recipientUP.address, ethers.utils.parseEther('3'), data], - ); + const transferPayload = universalProfileInterface.encodeFunctionData('execute', [ + OPERATION_TYPES.CALL, + recipientUP.address, + ethers.utils.parseEther('3'), + data, + ]); await expect( context.keyManager.connect(canTransferValue)['execute(bytes)'](transferPayload), diff --git a/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts b/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts index 01ffa480b..da93c8b64 100644 --- a/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts +++ b/tests/LSP6KeyManager/SetPermissions/PermissionChangeAddController.test.ts @@ -74,28 +74,28 @@ export const shouldBehaveLikePermissionChangeOrAddController = ( context = await buildContext(); callerHasAllPermissionsTestCase.addressWith16BytesHexPermissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasAllPermissionsTestCase.addressWith40BytesHexPermsissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasAddControllerTestCase.addressWith16BytesHexPermissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasAddControllerTestCase.addressWith40BytesHexPermsissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasEditPermissionsTestCase.addressWith16BytesHexPermissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasEditPermissionsTestCase.addressWith40BytesHexPermsissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasSetDataTestCase.addressWith16BytesHexPermissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); callerHasSetDataTestCase.addressWith40BytesHexPermsissionsLength = - new ethers.Wallet.createRandom().address.toLowerCase(); + ethers.Wallet.createRandom().address.toLowerCase(); const firstSetupPermissionsKeys = [ ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + diff --git a/tests/LSP8IdentifiableDigitalAsset/LSP8CompatibleERC721.behaviour.ts b/tests/LSP8IdentifiableDigitalAsset/LSP8CompatibleERC721.behaviour.ts index 95076e985..44eaf4d7d 100644 --- a/tests/LSP8IdentifiableDigitalAsset/LSP8CompatibleERC721.behaviour.ts +++ b/tests/LSP8IdentifiableDigitalAsset/LSP8CompatibleERC721.behaviour.ts @@ -49,6 +49,7 @@ type LSP8CompatibleERC721DeployParams = { symbol: string; newOwner: string; lsp4MetadataValue: string; + tokenIdType: number; }; export type LSP8CompatibleERC721TestContext = { diff --git a/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts b/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts index 7c726b6c5..0e9cf9021 100644 --- a/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts +++ b/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts @@ -1824,7 +1824,7 @@ export const shouldInitializeLikeLSP8 = ( let context: LSP8InitializeTestContext; before(async () => { - context = await buildContext(0); + context = await buildContext(); }); describe('when the contract was initialized', () => { diff --git a/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts b/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts index 0ec0943fe..363d5c3c4 100644 --- a/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts +++ b/tests/Reentrancy/LSP6/LSP6Reentrancy.test.ts @@ -355,10 +355,12 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( const firstTargetSelector = firstReentrant.interface.encodeFunctionData('firstTarget'); - const payload = context.universalProfile.interface.encodeFunctionData( - 'execute(uint256,address,uint256,bytes)', - [OPERATION_TYPES.CALL, firstReentrant.address, 0, firstTargetSelector], - ); + const payload = context.universalProfile.interface.encodeFunctionData('execute', [ + OPERATION_TYPES.CALL, + firstReentrant.address, + 0, + firstTargetSelector, + ]); await expect(context.keyManager.connect(context.owner).execute(payload)) .to.be.revertedWithCustomError(context.keyManager, 'NotAuthorised') @@ -384,10 +386,12 @@ export const shouldBehaveLikeLSP6ReentrancyScenarios = ( const firstTargetSelector = firstReentrant.interface.encodeFunctionData('firstTarget'); - const payload = context.universalProfile.interface.encodeFunctionData( - 'execute(uint256,address,uint256,bytes)', - [OPERATION_TYPES.CALL, firstReentrant.address, 0, firstTargetSelector], - ); + const payload = context.universalProfile.interface.encodeFunctionData('execute', [ + OPERATION_TYPES.CALL, + firstReentrant.address, + 0, + firstTargetSelector, + ]); await context.keyManager.connect(context.owner).execute(payload); diff --git a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts index 70728e772..848bcd970 100644 --- a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts +++ b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { ethers } from 'hardhat'; //types -import { BigNumber, BytesLike } from 'ethers'; +import { BigNumber } from 'ethers'; // constants import { ERC725YDataKeys } from '../../../constants'; @@ -25,6 +25,7 @@ import { generateRelayCall, generateExecutePayload, loadTestCase, + RelayCallParams, } from './reentrancyHelpers'; export const testSingleExecuteRelayCallToSingleExecute = ( @@ -40,12 +41,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and transferring value', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, @@ -145,12 +141,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and setting data', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, @@ -241,12 +232,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and adding permissions', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, @@ -317,12 +303,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and changing permissions', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, @@ -392,12 +373,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and adding URD', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, @@ -468,12 +444,7 @@ export const testSingleExecuteRelayCallToSingleExecute = ( }); describe('when reentering and changing URD', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { const executePayload = generateExecutePayload( context.keyManager.address, diff --git a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecuteRelayCall.test.ts b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecuteRelayCall.test.ts index 50d3b66b6..35d4b41ed 100644 --- a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecuteRelayCall.test.ts +++ b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecuteRelayCall.test.ts @@ -26,6 +26,7 @@ import { generateRelayCall, generateSingleRelayPayload, loadTestCase, + RelayCallParams, } from './reentrancyHelpers'; export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( @@ -53,12 +54,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and transferring value', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, @@ -162,12 +158,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and setting data', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, @@ -262,12 +253,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and adding permissions', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, @@ -342,12 +328,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and changing permissions', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, @@ -421,12 +402,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and adding URD', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, @@ -501,12 +477,7 @@ export const testSingleExecuteRelayCallToSingleExecuteRelayCall = ( }); describe('when reentering and changing URD', () => { - let relayCallParams: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike; - payload: BytesLike; - }; + let relayCallParams: RelayCallParams; before(async () => { relayCallParams = await generateRelayCall( context.keyManager, diff --git a/tests/Reentrancy/LSP6/reentrancyHelpers.ts b/tests/Reentrancy/LSP6/reentrancyHelpers.ts index 7f6fa70e5..9c0cafa6d 100644 --- a/tests/Reentrancy/LSP6/reentrancyHelpers.ts +++ b/tests/Reentrancy/LSP6/reentrancyHelpers.ts @@ -67,6 +67,13 @@ export type ReentrancyContext = { randomLSP1TypeId: string; }; +export type RelayCallParams = { + signature: BytesLike; + nonce: BigNumber; + validityTimestamps: number | BytesLike; + payload: BytesLike; +}; + export const transferValueTestCases = { NotAuthorised: [ { @@ -382,12 +389,7 @@ export const generateRelayCall = async ( payload.toString(), ); - const relayCallContext: { - signature: BytesLike; - nonce: BigNumber; - validityTimestamps: BytesLike | number; - payload: BytesLike; - } = { + const relayCallContext: RelayCallParams = { signature, nonce, validityTimestamps, diff --git a/tsconfig.json b/tsconfig.json index a38d1f94b..9364e1eff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,14 +10,6 @@ "skipLibCheck": true, "lib": ["ES2019", "es2019.array"] }, - "include": ["./src", "./test", "hardhat"], - "exclude": [ - "node_modules", - "dist", - "build", - "coverage", - "artifacts", - "cache" - ], + "include": ["./tests", "./deploy", "hardhat"], "files": ["./hardhat.config.ts"] } diff --git a/tsconfig.module.json b/tsconfig.module.json index 83997ab57..db1b7f1fd 100644 --- a/tsconfig.module.json +++ b/tsconfig.module.json @@ -3,7 +3,6 @@ "compilerOptions": { "module": "esNext", "target": "esNext", - "outDir": "module", "declaration": true, "skipLibCheck": false },