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 2 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
2 changes: 1 addition & 1 deletion docs/contracts/LSP6KeyManager/LSP6KeyManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion tests/Benchmark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -696,6 +698,7 @@ describe('⛽📊 Gas Benchmark', () => {
'MetaNFT',
'MNF',
context.owner.address,
LSP8_TOKEN_ID_TYPES.UNIQUE_ID,
);

// mint some tokens to the UP
Expand Down Expand 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,
);

[
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -341,7 +344,7 @@ describe('UniversalProfileDeployer', function () {

const salt = ethers.utils.randomBytes(32);

const primaryContractDeployment: LSP23LinkedContractsFactory.PrimaryContractDeploymentStruct =
const primaryContractDeployment: ILSP23LinkedContractsFactory.PrimaryContractDeploymentStruct =
{
salt,
fundingAmount: 0,
Expand All @@ -364,7 +367,7 @@ describe('UniversalProfileDeployer', function () {

keyManagerBytecode = keyManagerBytecode + secondaryContractFirstParam.slice(2);

const secondaryContractDeployment: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
const secondaryContractDeployment: ILSP23LinkedContractsFactory.SecondaryContractDeploymentStruct =
{
fundingAmount: 0,
creationBytecode: keyManagerBytecode,
Expand Down Expand Up @@ -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);
Expand All @@ -475,7 +482,7 @@ describe('UniversalProfileDeployer', function () {

const salt = ethers.utils.randomBytes(32);

const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct =
const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct =
{
salt,
fundingAmount: 0,
Expand All @@ -485,7 +492,7 @@ describe('UniversalProfileDeployer', function () {
]),
};

const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
{
fundingAmount: 0,
implementationContract: keyManagerInit.address,
Expand Down Expand Up @@ -605,7 +612,7 @@ describe('UniversalProfileDeployer', function () {

const salt = ethers.utils.randomBytes(32);

const primaryContractDeploymentInit: LSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct =
const primaryContractDeploymentInit: ILSP23LinkedContractsFactory.PrimaryContractDeploymentInitStruct =
{
salt,
fundingAmount: primaryFundingAmount,
Expand All @@ -615,7 +622,7 @@ describe('UniversalProfileDeployer', function () {
]),
};

const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
{
fundingAmount: secondaryFundingAmount,
implementationContract: keyManagerInit.address,
Expand Down Expand Up @@ -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,
Expand All @@ -682,7 +689,7 @@ describe('UniversalProfileDeployer', function () {
]),
};

const secondaryContractDeploymentInit: LSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
const secondaryContractDeploymentInit: ILSP23LinkedContractsFactory.SecondaryContractDeploymentInitStruct =
{
fundingAmount: secondaryFundingAmount,
implementationContract: keyManagerInit.address,
Expand Down
17 changes: 9 additions & 8 deletions tests/LSP23LinkedContractsDeployment/helpers.ts
Original file line number Diff line number Diff line change
@@ -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<BytesLike>,
primaryImplementationContractAddress: PromiseOrValue<string>,
secondaryImplementationContractAddress: PromiseOrValue<string>,
secondaryContractInitializationCalldata: PromiseOrValue<BytesLike>,
secondaryContractAddControlledContractAddress: PromiseOrValue<boolean>,
secondaryContractExtraInitializationParams: PromiseOrValue<BytesLike>,
upPostDeploymentModuleAddress: string,
postDeploymentCalldata: BytesLike,
linkedContractsFactoryAddress: string,
Expand All @@ -32,7 +33,7 @@ export async function calculateProxiesAddresses(
generatedSalt,
ethers.utils.keccak256(
'0x3d602d80600a3d3981f3363d3d373d3d3d363d73' +
primaryImplementationContractAddress.slice(2) +
(primaryImplementationContractAddress as string).slice(2) +
'5af43d82803e903d91602b57fd5bf3',
),
);
Expand All @@ -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',
),
);
Expand Down
Loading