Skip to content

Commit

Permalink
Merge pull request #974 from lukso-network/refactor/lsp7-with-erc725-v8
Browse files Browse the repository at this point in the history
refactor!: Remove `Core` contracts from LSP7 and LSP8 + use latest `@erc725/smart-contracts` to remove dependency with `OwnableUnset`
  • Loading branch information
CJ42 authored Oct 23, 2024
2 parents 62949a9 + b428604 commit 5b709dc
Show file tree
Hide file tree
Showing 94 changed files with 5,196 additions and 3,232 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/solc_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
"0.8.21",
"0.8.22",
"0.8.23",
"0.8.24",
"0.8.25",
"0.8.26",
"0.8.27",
]
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ typings/

# Output of 'npm pack'
package/
*.tgz

# Yarn Integrity file
.yarn-integrity
Expand Down
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ solc_version = "0.8.17"
runs = 10_000
max_test_rejects = 200_000

[profile.lsp0]
src = 'packages/lsp0-contracts/contracts'
test = 'packages/lsp0-contracts/foundry'
out = 'packages/lsp0-contracts/contracts/foundry_artifacts'

[profile.lsp2]
src = 'packages/lsp2-contracts/contracts'
test = 'packages/lsp2-contracts/foundry'
Expand Down
2,921 changes: 1,650 additions & 1,271 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"test:reentrancy": "hardhat test --no-compile packages/lsp-smart-contracts/tests/Reentrancy/Reentrancy.test.ts",
"test:reentrancyinit": "hardhat test --no-compile packages/lsp-smart-contracts/tests/Reentrancy/ReentrancyInit.test.ts"
},
"dependencies": {
"@erc725/smart-contracts-v8": "npm:@erc725/[email protected]"
},
"devDependencies": {
"@b00ste/hardhat-dodoc": "^0.3.16",
"@erc725/erc725.js": "0.23.0",
Expand All @@ -88,9 +91,9 @@
"npm-run-all": "^4.1.5",
"pluralize": "^8.0.0",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3",
"prettier-plugin-solidity": "^1.4.1",
"rollup-plugin-esbuild": "^5.0.0",
"solhint": "^3.6.2",
"solhint": "^5.0.3",
"ts-node": "^10.2.0",
"turbo": "latest",
"typechain": "^8.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/lsp-smart-contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"reason-string": ["warn", { "maxLength": 120 }],
"avoid-low-level-calls": "off",
"no-empty-blocks": ["error", { "ignoreConstructors": true }],
"custom-errors": "off"
"gas-custom-errors": "off"
}
}
4 changes: 2 additions & 2 deletions packages/lsp-smart-contracts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export type {
LSP4DigitalAssetMetadataJSON,
LSP4DigitalAssetMetadata,
AttributeMetadata,
AssetFile,
DigitalAsset,
FileAsset,
ContractAsset,
} from '@lukso/lsp4-contracts';
export type { LSP6PermissionName } from '@lukso/lsp6-contracts';

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

46 changes: 23 additions & 23 deletions packages/lsp-smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,33 @@
"lint": "eslint . --ext .ts,.js",
"lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'",
"package": "hardhat prepare-package",
"test": "hardhat test --no-compile tests/**/*.test.ts",
"test": "hardhat test --no-compile tests/**/*.test.ts tests/LSP7DigitalAsset/**/*.ts tests/LSP8IdentifiableDigitalAsset/**/*.ts",
"test:foundry": "FOUNDRY_PROFILE=lsp_smart_contracts forge test --no-match-test Skip -vvv",
"test:coverage": "hardhat coverage",
"test:benchmark": "hardhat test --no-compile tests/Benchmark.test.ts"
},
"dependencies": {
"@lukso/lsp0-contracts": "~0.15.0",
"@lukso/lsp1-contracts": "~0.15.0",
"@lukso/lsp10-contracts": "~0.15.0",
"@lukso/lsp12-contracts": "~0.15.0",
"@lukso/lsp14-contracts": "~0.15.0",
"@lukso/lsp16-contracts": "~0.15.0",
"@lukso/lsp17-contracts": "~0.15.0",
"@lukso/lsp17contractextension-contracts": "~0.15.0",
"@lukso/lsp1delegate-contracts": "~0.15.0",
"@lukso/lsp2-contracts": "~0.15.0",
"@lukso/lsp20-contracts": "~0.15.0",
"@lukso/lsp23-contracts": "~0.15.0",
"@lukso/lsp25-contracts": "~0.15.0",
"@lukso/lsp26-contracts": "~0.15.0",
"@lukso/lsp3-contracts": "~0.15.0",
"@lukso/lsp4-contracts": "~0.15.0",
"@lukso/lsp5-contracts": "~0.15.0",
"@lukso/lsp6-contracts": "~0.15.0",
"@lukso/lsp7-contracts": "~0.15.0",
"@lukso/lsp8-contracts": "~0.15.0",
"@lukso/lsp9-contracts": "~0.15.0",
"@lukso/universalprofile-contracts": "~0.15.0"
"@lukso/lsp0-contracts": "*",
"@lukso/lsp1-contracts": "*",
"@lukso/lsp10-contracts": "*",
"@lukso/lsp12-contracts": "*",
"@lukso/lsp14-contracts": "*",
"@lukso/lsp16-contracts": "*",
"@lukso/lsp17-contracts": "*",
"@lukso/lsp17contractextension-contracts": "*",
"@lukso/lsp1delegate-contracts": "*",
"@lukso/lsp2-contracts": "*",
"@lukso/lsp20-contracts": "*",
"@lukso/lsp23-contracts": "*",
"@lukso/lsp25-contracts": "*",
"@lukso/lsp26-contracts": "*",
"@lukso/lsp3-contracts": "*",
"@lukso/lsp4-contracts": "*",
"@lukso/lsp5-contracts": "*",
"@lukso/lsp6-contracts": "*",
"@lukso/lsp7-contracts": "*",
"@lukso/lsp8-contracts": "*",
"@lukso/lsp9-contracts": "*",
"@lukso/universalprofile-contracts": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ERC725YDataKeys } from '../../../../constants';
import { OPERATION_TYPES } from '@lukso/lsp0-contracts';
import { PERMISSIONS } from '@lukso/lsp6-contracts';

import { LSP6KeyManager, LSP6KeyManager__factory } from '../../types';
import { LSP6KeyManager, LSP6KeyManager__factory } from '../../../../types';

// setup
import { LSP6TestContext } from '../../../utils/context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';

import { TargetContract, TargetContract__factory } from '../../types';
import { TargetContract, TargetContract__factory } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
LSP7Mintable__factory,
LSP8Mintable,
LSP8Mintable__factory,
} from '../../types';
} from '../../../../types';

// constants
import { ERC725YDataKeys, INTERFACE_IDS } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
LSP7Mintable__factory,
UniversalProfile,
UniversalProfile__factory,
} from '../../types';
} from '../../../../types';

// constants
import { ERC725YDataKeys, INTERFACE_IDS } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
LSP7MintableInit,
LSP7MintableInit__factory,
LSP7Mintable__factory,
} from '../../types';
} from '../../../../types';

export const shouldBehaveLikeBatchExecute = (
buildContext: (initialFunding?: bigint) => Promise<LSP6TestContext>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';

import { TargetContract__factory, TargetContract } from '../../types';
import { TargetContract__factory, TargetContract } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
FallbackRevert__factory,
TargetContract,
TargetContract__factory,
} from '../../types';
} from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';

import { ERC725YDelegateCall, ERC725YDelegateCall__factory } from '../../types';
import { ERC725YDelegateCall, ERC725YDelegateCall__factory } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'hardhat';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';
import { calculateCreate2 } from 'eth-create2-calculator';

import { TargetContract__factory } from '../../types';
import { TargetContract__factory } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';

import { TargetContract, TargetContract__factory } from '../../types';
import { TargetContract, TargetContract__factory } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
UniversalProfile,
FallbackContract__factory,
FallbackContract,
} from '../../types';
} from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
TargetContract,
TargetContract__factory,
UniversalReceiverDelegateDataUpdater__factory,
} from '../../types';
} from '../../../../types';

// constants
import { ERC725YDataKeys, LSP1_TYPE_IDS } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'hardhat';
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';
import { encodeData, ERC725JSONSchema } from '@erc725/erc725.js';

import { ExecutorLSP20, ExecutorLSP20__factory } from '../../types';
import { ExecutorLSP20, ExecutorLSP20__factory } from '../../../../types';

// constants
import { ERC725YDataKeys } from '../../../../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => {

await expect(
context.keyManager.connect(context.mainController).execute(payload),
).to.be.revertedWithCustomError(context.token, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('should allow the new owner to call setData(..)', async () => {
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => {

await expect(
context.keyManager.connect(context.mainController).execute(transferOwnershipPayload),
).to.be.revertedWithCustomError(context.token, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('should allow the new owner to call transferOwnership(..)', async () => {
Expand All @@ -227,7 +227,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => {

await expect(
context.keyManager.connect(context.mainController).execute(renounceOwnershipPayload),
).to.be.revertedWithCustomError(context.token, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('should allow the new owner to call renounceOwnership(..)', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ERC725YDataKeys, INTERFACE_IDS, LSP1_TYPE_IDS, SupportedStandards } fro

import { abiCoder } from '../utils/helpers';
import { AddressZero } from '../LSP17Extensions/helpers/utils';
import { build } from 'unbuild';

export type LSP7TestAccounts = {
owner: SignerWithAddress;
Expand Down Expand Up @@ -444,8 +445,8 @@ export const shouldBehaveLikeLSP7 = (buildContext: () => Promise<LSP7TestContext
});

describe('when `operator` param is the zero address', () => {
const tokenOwner = context.accounts.owner.address;
it('should revert', async () => {
const tokenOwner = context.accounts.owner.address;
const subtractedAmount = toBigInt(1);

await expect(
Expand Down Expand Up @@ -2127,7 +2128,7 @@ export const shouldBehaveLikeLSP7 = (buildContext: () => Promise<LSP7TestContext
const newOwner = context.accounts.anyone;
await expect(
context.lsp7.connect(newOwner).transferOwnership(newOwner.address),
).to.be.revertedWithCustomError(context.lsp7, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

describe('after transferring ownership of the contract', () => {
Expand All @@ -2139,21 +2140,21 @@ export const shouldBehaveLikeLSP7 = (buildContext: () => Promise<LSP7TestContext
const randomAddress = context.accounts.anyone.address;
await expect(
context.lsp7.connect(oldOwner).transferOwnership(randomAddress),
).to.be.revertedWithCustomError(context.lsp7, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('old owner should not be allowed to use `renounceOwnership(..)`', async () => {
await expect(
context.lsp7.connect(oldOwner).renounceOwnership(),
).to.be.revertedWithCustomError(context.lsp7, 'OwnableCallerNotTheOwner');
await expect(context.lsp7.connect(oldOwner).renounceOwnership()).to.be.revertedWith(
'Ownable: caller is not the owner',
);
});

it('old owner should not be allowed to use `setData(..)`', async () => {
const key = ethers.keccak256(ethers.toUtf8Bytes('key'));
const value = ethers.keccak256(ethers.toUtf8Bytes('value'));
await expect(
context.lsp7.connect(oldOwner).setData(key, value),
).to.be.revertedWithCustomError(context.lsp7, 'OwnableCallerNotTheOwner');
await expect(context.lsp7.connect(oldOwner).setData(key, value)).to.be.revertedWith(
'Ownable: caller is not the owner',
);
});

it('new owner should be allowed to use `transferOwnership(..)`', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const shouldBehaveLikeLSP7Mintable = (

await expect(
context.lsp7Mintable.connect(nonOwner).mint(nonOwner.address, amountToMint, true, '0x'),
).to.be.revertedWithCustomError(context.lsp7Mintable, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const shouldBehaveLikeLSP8 = (
context.lsp8
.connect(context.accounts.anyone)
.setDataForTokenId(tokenId, dataKey, dataValue),
).to.be.revertedWithCustomError(context.lsp8, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('TokenIdDataChanged emitted when data is set for a specific tokenId', async () => {
Expand Down Expand Up @@ -1795,7 +1795,7 @@ export const shouldBehaveLikeLSP8 = (
const newOwner = context.accounts.anyone;
await expect(
context.lsp8.connect(newOwner).transferOwnership(newOwner.address),
).to.be.revertedWithCustomError(context.lsp8, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('should transfer ownership of the contract', async () => {
Expand All @@ -1814,21 +1814,21 @@ export const shouldBehaveLikeLSP8 = (
const randomAddress = context.accounts.anyone.address;
await expect(
context.lsp8.connect(oldOwner).transferOwnership(randomAddress),
).to.be.revertedWithCustomError(context.lsp8, 'OwnableCallerNotTheOwner');
).to.be.revertedWith('Ownable: caller is not the owner');
});

it('old owner should not be allowed to use `renounceOwnership(..)`', async () => {
await expect(
context.lsp8.connect(oldOwner).renounceOwnership(),
).to.be.revertedWithCustomError(context.lsp8, 'OwnableCallerNotTheOwner');
await expect(context.lsp8.connect(oldOwner).renounceOwnership()).to.be.revertedWith(
'Ownable: caller is not the owner',
);
});

it('old owner should not be allowed to use `setData(..)`', async () => {
const key = ethers.keccak256(ethers.toUtf8Bytes('key'));
const value = ethers.keccak256(ethers.toUtf8Bytes('value'));
await expect(
context.lsp8.connect(oldOwner).setData(key, value),
).to.be.revertedWithCustomError(context.lsp8, 'OwnableCallerNotTheOwner');
await expect(context.lsp8.connect(oldOwner).setData(key, value)).to.be.revertedWith(
'Ownable: caller is not the owner',
);
});

it('new owner should be allowed to use `transferOwnership(..)`', async () => {
Expand Down
Loading

0 comments on commit 5b709dc

Please sign in to comment.