Skip to content
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
2 changes: 1 addition & 1 deletion src/shared/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const resolveUpgrade = async (params: {
trace(`[Will not remove] method [${f}] pointing to facet ${liveFunctions[f]} (PROTECTED)`)
} else {
trace(`[Remove] method [${f}] pointing to facet ${liveFunctions[f]}`)
todo.remove[ZeroAddress] = todo.remove[liveFunctions[f]] || []
todo.remove[ZeroAddress] ??= []
todo.remove[ZeroAddress].push(f)
}
}
Expand Down
27 changes: 26 additions & 1 deletion test/common-deploy-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,32 @@ export const addDeployTestSteps = ({
expect(contract.getInt1()).to.be.rejectedWith('execution reverted')
})

it('and can handle multiple removals from the same facet', async () => {
writeFile(join(cwd, `${contractSrcBasePath}/facets/ExampleFacet.sol`), `
pragma solidity >=0.8.21;
import "../libs/LibAppStorage.sol";
contract ExampleFacet {
function setInt2(uint i) external {
AppStorage storage s = LibAppStorage.diamondStorage();
s.data.i1 = i + 1;
}
}
`)

expect(cli('build', { cwd }).success).to.be.true
expect(cli_deploy([]).success).to.be.true

const { contract } = await loadDiamondContract(cwd, [
'function setInt2(uint i) external',
'function setInt1(uint i) external',
'function getInt1() external view returns (uint)',
])

await sendTx(contract.setInt2(2))
await expect(contract.setInt1(2)).to.be.rejected
await expect(contract.getInt1()).to.be.rejected
})

it('and can prevent removals of protected methods', async () => {
writeFile(join(cwd, `${contractSrcBasePath}/facets/ExampleFacet.sol`), `
pragma solidity >=0.8.21;
Expand Down Expand Up @@ -972,4 +998,3 @@ export const addDeployTestSteps = ({

})
}

Loading