Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed May 20, 2024
2 parents c29ae87 + 6e4a375 commit 8dce31f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions contracts/utils/UUPSSignableUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,21 @@ abstract contract UUPSSignableUpgradeable is UUPSUpgradeable {
_authorizeUpgrade(newImplementation_, signatures_);
_upgradeToAndCallUUPS(newImplementation_, new bytes(0), false);
}

/**
* @notice Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade} with the provided `newImplementation` and `signatures`.
*
* Emits an {Upgraded} event.
*/
function upgradeToWithSigAndCall(
address newImplementation_,
bytes[] calldata signatures_,
bytes calldata data_
) external virtual onlyProxy {
_authorizeUpgrade(newImplementation_, signatures_);
_upgradeToAndCallUUPS(newImplementation_, data_, false);
}
}
8 changes: 8 additions & 0 deletions test/bridge/Upgradeable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ describe("Upgradeable", () => {
await expect(newBridge.upgradeToWithSig(await newBridge.getAddress(), [])).to.be.rejectedWith(
"Function must be called through delegatecall",
);

await expect(newBridge.upgradeToWithSigAndCall(await newBridge.getAddress(), [], "0x")).to.be.rejectedWith(
"Function must be called through delegatecall",
);
});

it("should upgrade implementation", async () => {
Expand Down Expand Up @@ -85,6 +89,10 @@ describe("Upgradeable", () => {
await expect(proxyBridge.connect(SECOND).upgradeToWithSig(await newBridge.getAddress(), [])).to.be.rejectedWith(
"Ownable: caller is not the owner",
);

await expect(
proxyBridge.connect(SECOND).upgradeToWithSigAndCall(await newBridge.getAddress(), [], "0x"),
).to.be.rejectedWith("Ownable: caller is not the owner");
});

it("should receive ether through proxy", async () => {
Expand Down

0 comments on commit 8dce31f

Please sign in to comment.