From b45c1be72a799c108a90dc30a5301ee1d9a58b21 Mon Sep 17 00:00:00 2001 From: Johann BICH <2253470+kalote@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:04:42 +0200 Subject: [PATCH 1/4] fix ts config and types on tests --- tests/Benchmark.test.ts | 7 ++- .../LSP14Ownable2Step.behaviour.ts | 4 ++ ...P1UniversalReceiverDelegateUP.behaviour.ts | 4 +- .../LSP20WithLSP14.behaviour.ts | 4 ++ .../LSP6/Interactions/Security.test.ts | 1 + .../LSP23LinkedContractsDeployment.test.ts | 50 +++++++++++-------- .../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 | 43 +++------------- ...eRelayCallToSingleExecuteRelayCall.test.ts | 43 +++------------- tests/Reentrancy/LSP6/reentrancyHelpers.ts | 14 +++--- tsconfig.json | 10 +--- tsconfig.module.json | 1 - 17 files changed, 118 insertions(+), 149 deletions(-) diff --git a/tests/Benchmark.test.ts b/tests/Benchmark.test.ts index 1d4cdc8a9..1d63a6f0a 100644 --- a/tests/Benchmark.test.ts +++ b/tests/Benchmark.test.ts @@ -21,6 +21,7 @@ import { OPERATION_TYPES, PERMISSIONS, CALLTYPE, + LSP8_TOKEN_ID_TYPES, } from '../constants'; import { LSP6TestContext } from './utils/context'; import { setupKeyManager, setupProfileWithKeyManagerWithURD } from './utils/fixtures'; @@ -525,11 +526,12 @@ describe('⛽📊 Gas Benchmark', () => { false, ); - // deploy a LSP7 token + // deploy a LSP8 token lsp8Token = await new LSP8Mintable__factory(context.owner).deploy( 'Token', 'MTKN', context.owner.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); universalProfile1 = await new UniversalProfile__factory(context.owner).deploy( @@ -696,6 +698,7 @@ describe('⛽📊 Gas Benchmark', () => { 'MetaNFT', 'MNF', context.owner.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); // mint some tokens to the UP @@ -911,12 +914,14 @@ describe('⛽📊 Gas Benchmark', () => { 'MetaNFT', 'MNF', context.owner.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); lsp8LyxPunks = await new LSP8Mintable__factory(context.owner).deploy( 'LyxPunks', 'LPK', context.owner.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); [ diff --git a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts index c3e55b646..1c2c66e7b 100644 --- a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts +++ b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts @@ -288,6 +288,7 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -375,6 +376,7 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -440,6 +442,7 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // @ts-ignore ].LSP9Vault.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -527,6 +530,7 @@ export const shouldBehaveLikeLSP14 = ( await artifacts.getBuildInfo('contracts/LSP9Vault/LSP9Vault.sol:LSP9Vault') )?.output.contracts[ 'contracts/LSP9Vault/LSP9Vault.sol' + // @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..b65032fef 100644 --- a/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts +++ b/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts @@ -294,6 +294,7 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -383,6 +384,7 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -449,6 +451,7 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // @ts-ignore ].LSP0ERC725Account.storageLayout.storage.filter((elem) => { if (elem.label === '_renounceOwnershipStartedAt') return elem; })[0].slot, @@ -540,6 +543,7 @@ export const shouldBehaveLikeLSP14WithLSP20 = ( ) )?.output.contracts[ 'contracts/LSP0ERC725Account/LSP0ERC725Account.sol' + // @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..b07dfce18 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts @@ -304,6 +304,7 @@ 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..7fa93a89b 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, @@ -13,6 +14,7 @@ import { createDataKey, deployImplementationContracts, } from './helpers'; +import { BigNumber, BytesLike } from 'ethers'; describe('UniversalProfileDeployer', function () { describe('for non-proxies deployment', async function () { @@ -35,16 +37,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 +127,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 +158,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 +257,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 +345,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = + const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct = { salt, fundingAmount: 0, @@ -364,7 +368,7 @@ describe('UniversalProfileDeployer', function () { keyManagerBytecode = keyManagerBytecode + secondaryContractFirstParam.slice(2); - const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct = { fundingAmount: 0, creationBytecode: keyManagerBytecode, @@ -447,8 +451,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 +483,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = + const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = { salt, fundingAmount: 0, @@ -485,7 +493,7 @@ describe('UniversalProfileDeployer', function () { ]), }; - const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = { fundingAmount: 0, implementationContract: keyManagerInit.address, @@ -605,7 +613,7 @@ describe('UniversalProfileDeployer', function () { const salt = ethers.utils.randomBytes(32); - const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = + const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct = { salt, fundingAmount: primaryFundingAmount, @@ -615,7 +623,7 @@ describe('UniversalProfileDeployer', function () { ]), }; - const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = + const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct = { fundingAmount: secondaryFundingAmount, implementationContract: keyManagerInit.address, @@ -672,7 +680,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 +690,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..03716d70f 100644 --- a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts +++ b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts @@ -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 }, From 6dfe54d2e48f9f9ca6c01d26211380d23fea3fbd Mon Sep 17 00:00:00 2001 From: Johann BICH <2253470+kalote@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:18:00 +0200 Subject: [PATCH 2/4] lint --- docs/contracts/LSP6KeyManager/LSP6KeyManager.md | 2 +- .../LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md | 2 +- docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md | 2 +- .../presets/LSP8CompatibleERC721Mintable.md | 2 +- .../LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md | 2 +- tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts | 4 ++++ tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts | 4 ++++ .../LSP20CallVerification/LSP6/Interactions/Security.test.ts | 1 + .../LSP23LinkedContractsDeployment.test.ts | 1 - .../LSP6/SingleExecuteRelayCallToSingleExecute.test.ts | 2 +- 10 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/contracts/LSP6KeyManager/LSP6KeyManager.md b/docs/contracts/LSP6KeyManager/LSP6KeyManager.md index 024890611..3b0187c19 100644 --- a/docs/contracts/LSP6KeyManager/LSP6KeyManager.md +++ b/docs/contracts/LSP6KeyManager/LSP6KeyManager.md @@ -36,7 +36,7 @@ When marked as 'public', a method can be called both externally and internally, constructor(address target_); ``` -_Deploying a LSP6KeyManager linked to the contract at address `target_`._ +_Deploying a LSP6KeyManager linked to the contract at address `target_`.\_ Deploy a Key Manager and set the `target_` address in the contract storage, making this Key Manager linked to this `target_` contract. diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md index 8a5d97d56..911831b8f 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md @@ -34,7 +34,7 @@ When marked as 'public', a method can be called both externally and internally, constructor(string name_, string symbol_, address newOwner_); ``` -_Deploying a `LSP7CompatibleERC20Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ +_Deploying a `LSP7CompatibleERC20Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ #### Parameters diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md index b9de110e4..50efc19ad 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP7Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ +_Deploying a `LSP7Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md index 33d19c009..0d0a66de2 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP8CompatibleERC721Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ +_Deploying a `LSP8CompatibleERC721Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md index e71fb2a68..b46e005c0 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP8Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ +_Deploying a `LSP8Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ #### Parameters diff --git a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts index 1c2c66e7b..c962c6914 100644 --- a/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts +++ b/tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts @@ -288,6 +288,7 @@ 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; @@ -376,6 +377,7 @@ 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; @@ -442,6 +444,7 @@ 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; @@ -530,6 +533,7 @@ 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; diff --git a/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts b/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts index b65032fef..de7debaff 100644 --- a/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts +++ b/tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts @@ -294,6 +294,7 @@ 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; @@ -384,6 +385,7 @@ 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; @@ -451,6 +453,7 @@ 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; @@ -543,6 +546,7 @@ 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; diff --git a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts index b07dfce18..1c38af65f 100644 --- a/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts +++ b/tests/LSP20CallVerification/LSP6/Interactions/Security.test.ts @@ -304,6 +304,7 @@ export const testSecurityScenarios = (buildContext: () => Promise { if (elem.label === '_reentrancyStatus') return elem; diff --git a/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts b/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts index 7fa93a89b..b94465f54 100644 --- a/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts +++ b/tests/LSP23LinkedContractsDeployment/LSP23LinkedContractsDeployment.test.ts @@ -14,7 +14,6 @@ import { createDataKey, deployImplementationContracts, } from './helpers'; -import { BigNumber, BytesLike } from 'ethers'; describe('UniversalProfileDeployer', function () { describe('for non-proxies deployment', async function () { diff --git a/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts b/tests/Reentrancy/LSP6/SingleExecuteRelayCallToSingleExecute.test.ts index 03716d70f..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'; From 1b6ec54e11b71b20dcbbfcbf08a6c29f7bb3affa Mon Sep 17 00:00:00 2001 From: CJ42 Date: Mon, 2 Oct 2023 09:52:59 +0100 Subject: [PATCH 3/4] test: fix Typescript errors in `Benchmark.test.ts` --- tests/Benchmark.test.ts | 65 +---------------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/tests/Benchmark.test.ts b/tests/Benchmark.test.ts index c10714518..03ad2700f 100644 --- a/tests/Benchmark.test.ts +++ b/tests/Benchmark.test.ts @@ -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; @@ -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; @@ -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), ]; From 4e63de0ec0da27de3ce4607be34a8460e5b9636f Mon Sep 17 00:00:00 2001 From: CJ42 Date: Mon, 2 Oct 2023 10:02:32 +0100 Subject: [PATCH 4/4] docs: update auto-generated docs --- docs/contracts/LSP6KeyManager/LSP6KeyManager.md | 2 +- .../LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md | 2 +- docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md | 2 +- .../presets/LSP8CompatibleERC721Mintable.md | 2 +- .../LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/contracts/LSP6KeyManager/LSP6KeyManager.md b/docs/contracts/LSP6KeyManager/LSP6KeyManager.md index 3b0187c19..024890611 100644 --- a/docs/contracts/LSP6KeyManager/LSP6KeyManager.md +++ b/docs/contracts/LSP6KeyManager/LSP6KeyManager.md @@ -36,7 +36,7 @@ When marked as 'public', a method can be called both externally and internally, constructor(address target_); ``` -_Deploying a LSP6KeyManager linked to the contract at address `target_`.\_ +_Deploying a LSP6KeyManager linked to the contract at address `target_`._ Deploy a Key Manager and set the `target_` address in the contract storage, making this Key Manager linked to this `target_` contract. diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md index 911831b8f..8a5d97d56 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md @@ -34,7 +34,7 @@ When marked as 'public', a method can be called both externally and internally, constructor(string name_, string symbol_, address newOwner_); ``` -_Deploying a `LSP7CompatibleERC20Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ +_Deploying a `LSP7CompatibleERC20Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md index 50efc19ad..b9de110e4 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP7Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ +_Deploying a `LSP7Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md index 0d0a66de2..33d19c009 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP8CompatibleERC721Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ +_Deploying a `LSP8CompatibleERC721Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md index b46e005c0..e71fb2a68 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md @@ -39,7 +39,7 @@ constructor( ); ``` -_Deploying a `LSP8Mintable` token contract with: token name = `name_`, token symbol = `symbol*`, and address `newOwner*` as the token contract owner.\_ +_Deploying a `LSP8Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters