Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: ts configs and tests #733

Merged
merged 5 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 5 additions & 68 deletions tests/Benchmark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -853,19 +826,13 @@ 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();
});
});

describe('controllers with some restrictions', () => {
const casesExecuteRestrictedController: Row[] = [];
let context: LSP6TestContext;

let recipientEOA: SignerWithAddress;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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),
];
Expand Down
8 changes: 8 additions & 0 deletions tests/LSP14Ownable2Step/LSP14Ownable2Step.behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tests/LSP20CallVerification/LSP20WithLSP14.behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export const testSecurityScenarios = (buildContext: () => Promise<LSP6TestContex
)
)?.output.contracts[
'contracts/LSP6KeyManager/LSP6KeyManager.sol'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
].LSP6KeyManager.storageLayout.storage.filter((elem) => {
if (elem.label === '_reentrancyStatus') return elem;
})[0].slot,
Expand Down
Loading
Loading