Skip to content

Commit f96667c

Browse files
h4x3rotabclaude
andcommitted
chore: format Solidity code with forge fmt
Run forge fmt to apply consistent formatting to all Solidity files: - Update interface definitions formatting - Improve multi-line function declarations - Standardize spacing and indentation - Format test files and scripts 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 206953c commit f96667c

File tree

13 files changed

+366
-435
lines changed

13 files changed

+366
-435
lines changed

kms/auth-eth/contracts/DstackApp.sol

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ contract DstackApp is
4949
bool _allowAnyDevice,
5050
bytes32 initialDeviceId,
5151
bytes32 initialComposeHash
52-
) public initializer {
52+
)
53+
public
54+
initializer
55+
{
5356
require(initialOwner != address(0), "invalid owner address");
5457

5558
_upgradesDisabled = _disableUpgrades;
@@ -85,10 +88,9 @@ contract DstackApp is
8588
override(ERC165Upgradeable, IERC165)
8689
returns (bool)
8790
{
88-
return
89-
interfaceId == 0x1e079198 || // IAppAuth
90-
interfaceId == 0x8fd37527 || // IAppAuthBasicManagement
91-
super.supportsInterface(interfaceId);
91+
return interfaceId == 0x1e079198 // IAppAuth
92+
|| interfaceId == 0x8fd37527 // IAppAuthBasicManagement
93+
|| super.supportsInterface(interfaceId);
9294
}
9395

9496
// Function to authorize upgrades (required by UUPSUpgradeable)
@@ -127,9 +129,12 @@ contract DstackApp is
127129
}
128130

129131
// Check if an app is allowed to boot
130-
function isAppAllowed(
131-
IAppAuth.AppBootInfo calldata bootInfo
132-
) external view override returns (bool isAllowed, string memory reason) {
132+
function isAppAllowed(IAppAuth.AppBootInfo calldata bootInfo)
133+
external
134+
view
135+
override
136+
returns (bool isAllowed, string memory reason)
137+
{
133138
// Check if compose hash is allowed
134139
if (!allowedComposeHashes[bootInfo.composeHash]) {
135140
return (false, "Compose hash not allowed");

kms/auth-eth/contracts/DstackKms.sol

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
1313
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
1414
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
1515

16-
contract DstackKms is
17-
Initializable,
18-
OwnableUpgradeable,
19-
UUPSUpgradeable,
20-
ERC165Upgradeable,
21-
IAppAuth
22-
{
16+
contract DstackKms is Initializable, OwnableUpgradeable, UUPSUpgradeable, ERC165Upgradeable, IAppAuth {
2317
// Struct for KMS information
2418
struct KmsInfo {
2519
bytes k256Pubkey;
@@ -94,15 +88,12 @@ contract DstackKms is
9488
override(ERC165Upgradeable, IERC165)
9589
returns (bool)
9690
{
97-
return
98-
interfaceId == 0x1e079198 || // IAppAuth
99-
super.supportsInterface(interfaceId);
91+
return interfaceId == 0x1e079198 // IAppAuth
92+
|| super.supportsInterface(interfaceId);
10093
}
10194

10295
// Function to authorize upgrades (required by UUPSUpgradeable)
103-
function _authorizeUpgrade(
104-
address newImplementation
105-
) internal override onlyOwner {}
96+
function _authorizeUpgrade(address newImplementation) internal override onlyOwner { }
10697

10798
// Function to set KMS information
10899
function setKmsInfo(KmsInfo memory info) external onlyOwner {
@@ -147,7 +138,10 @@ contract DstackKms is
147138
bool allowAnyDevice,
148139
bytes32 initialDeviceId,
149140
bytes32 initialComposeHash
150-
) external returns (address appId) {
141+
)
142+
external
143+
returns (address appId)
144+
{
151145
require(appImplementation != address(0), "DstackApp implementation not set");
152146
require(initialOwner != address(0), "Invalid owner address");
153147

@@ -205,14 +199,9 @@ contract DstackKms is
205199
}
206200

207201
// Function to check if KMS is allowed to boot
208-
function isKmsAllowed(
209-
AppBootInfo calldata bootInfo
210-
) external view returns (bool isAllowed, string memory reason) {
202+
function isKmsAllowed(AppBootInfo calldata bootInfo) external view returns (bool isAllowed, string memory reason) {
211203
// Check if the TCB status is up to date
212-
if (
213-
keccak256(abi.encodePacked(bootInfo.tcbStatus)) !=
214-
keccak256(abi.encodePacked("UpToDate"))
215-
) {
204+
if (keccak256(abi.encodePacked(bootInfo.tcbStatus)) != keccak256(abi.encodePacked("UpToDate"))) {
216205
return (false, "TCB status is not up to date");
217206
}
218207

@@ -235,9 +224,12 @@ contract DstackKms is
235224
}
236225

237226
// Function to check if an app is allowed to boot
238-
function isAppAllowed(
239-
AppBootInfo calldata bootInfo
240-
) external view override returns (bool isAllowed, string memory reason) {
227+
function isAppAllowed(AppBootInfo calldata bootInfo)
228+
external
229+
view
230+
override
231+
returns (bool isAllowed, string memory reason)
232+
{
241233
// Check if app is registered
242234
if (!registeredApps[bootInfo.appId]) {
243235
return (false, "App not registered");
@@ -260,7 +252,7 @@ contract DstackKms is
260252
uint256[50] private __gap;
261253
}
262254

263-
function isContract(address addr) view returns (bool){
255+
function isContract(address addr) view returns (bool) {
264256
uint32 size;
265257
assembly {
266258
size := extcodesize(addr)

kms/auth-eth/contracts/IAppAuth.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
1212
* @title IAppAuth
1313
* @notice Core interface for App Authentication contracts
1414
* @dev This interface defines the core function for validating app boot information.
15-
* Any contract implementing this interface should also implement ERC-165 to
15+
* Any contract implementing this interface should also implement ERC-165 to
1616
* allow interface detection.
17-
*
17+
*
1818
* Interface ID: 0x1e079198
19-
*
19+
*
2020
* This interface can be checked using:
2121
* contract.supportsInterface(0x1e079198)
2222
*/
@@ -52,7 +52,5 @@ interface IAppAuth is IERC165 {
5252
* @return isAllowed True if the app is authorized to boot, false otherwise
5353
* @return reason Human-readable reason for the decision (empty if allowed)
5454
*/
55-
function isAppAllowed(
56-
AppBootInfo calldata bootInfo
57-
) external view returns (bool isAllowed, string memory reason);
55+
function isAppAllowed(AppBootInfo calldata bootInfo) external view returns (bool isAllowed, string memory reason);
5856
}

kms/auth-eth/contracts/IAppAuthBasicManagement.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
1414
* @dev This interface defines the standard functions that UI tools and other contracts
1515
* can use to interact with App Auth contracts. Any contract implementing this
1616
* interface should also implement ERC-165 to allow interface detection.
17-
*
17+
*
1818
* Interface ID: 0x8fd37527
19-
*
19+
*
2020
* UI tools can check if a contract supports this interface by calling:
2121
* contract.supportsInterface(type(IAppAuthBasicManagement).interfaceId)
2222
*/
2323
interface IAppAuthBasicManagement is IERC165 {
2424
/// @notice Emitted when a new compose hash is added to the allowed list
2525
/// @param composeHash The compose hash that was added
2626
event ComposeHashAdded(bytes32 composeHash);
27-
27+
2828
/// @notice Emitted when a compose hash is removed from the allowed list
2929
/// @param composeHash The compose hash that was removed
3030
event ComposeHashRemoved(bytes32 composeHash);
31-
31+
3232
/// @notice Emitted when a new device ID is added to the allowed list
3333
/// @param deviceId The device ID that was added
3434
event DeviceAdded(bytes32 deviceId);
35-
35+
3636
/// @notice Emitted when a device ID is removed from the allowed list
3737
/// @param deviceId The device ID that was removed
3838
event DeviceRemoved(bytes32 deviceId);
@@ -44,7 +44,7 @@ interface IAppAuthBasicManagement is IERC165 {
4444
* @param composeHash The compose hash to add
4545
*/
4646
function addComposeHash(bytes32 composeHash) external;
47-
47+
4848
/**
4949
* @notice Remove a compose hash from the allowed list
5050
* @dev MUST emit ComposeHashRemoved event on success
@@ -68,4 +68,4 @@ interface IAppAuthBasicManagement is IERC165 {
6868
* @param deviceId The device ID to remove
6969
*/
7070
function removeDevice(bytes32 deviceId) external;
71-
}
71+
}

kms/auth-eth/contracts/test-utils/DstackAppV2.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import "../DstackApp.sol";
1414
contract DstackAppV2 is DstackApp {
1515
// Minimal V2 contract that can be upgraded from DstackApp
1616
// Inherits all functionality from DstackApp
17-
17+
1818
/// @custom:oz-upgrades-unsafe-allow constructor
1919
constructor() {
2020
_disableInitializers();
2121
}
22-
22+
2323
// Optional: Add a version identifier for testing
2424
function version() public pure returns (string memory) {
2525
return "2.0.0";
2626
}
27-
}
27+
}

kms/auth-eth/contracts/test-utils/DstackKmsV2.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import "../DstackKms.sol";
1414
contract DstackKmsV2 is DstackKms {
1515
// Minimal V2 contract that can be upgraded from DstackKms
1616
// Inherits all functionality from DstackKms
17-
17+
1818
/// @custom:oz-upgrades-unsafe-allow constructor
1919
constructor() {
2020
_disableInitializers();
2121
}
22-
22+
2323
// Optional: Add a version identifier for testing
2424
function version() public pure returns (string memory) {
2525
return "2.0.0";
2626
}
27-
}
27+
}

kms/auth-eth/script/Deploy.s.sol

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,27 @@ contract DeployScript is Script {
1515
function run() external {
1616
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
1717
address deployer = vm.addr(deployerPrivateKey);
18-
18+
1919
console.log("Deploying with account:", deployer);
2020
console.log("Account balance:", deployer.balance);
21-
21+
2222
vm.startBroadcast(deployerPrivateKey);
23-
23+
2424
// Deploy DstackApp implementation
2525
DstackApp appImpl = new DstackApp();
2626
console.log("DstackApp implementation deployed to:", address(appImpl));
27-
27+
2828
// Deploy DstackKms implementation
2929
DstackKms kmsImpl = new DstackKms();
3030
console.log("DstackKms implementation deployed to:", address(kmsImpl));
31-
31+
3232
// Deploy DstackKms proxy
33-
bytes memory initData = abi.encodeCall(
34-
DstackKms.initialize,
35-
(deployer, address(appImpl))
36-
);
33+
bytes memory initData = abi.encodeCall(DstackKms.initialize, (deployer, address(appImpl)));
3734
ERC1967Proxy kmsProxy = new ERC1967Proxy(address(kmsImpl), initData);
3835
console.log("DstackKms proxy deployed to:", address(kmsProxy));
39-
36+
4037
vm.stopBroadcast();
41-
38+
4239
console.log("Deployment complete!");
4340
console.log("- DstackApp implementation:", address(appImpl));
4441
console.log("- DstackKms implementation:", address(kmsImpl));
@@ -51,27 +48,24 @@ contract DeployKmsOnly is Script {
5148
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
5249
address deployer = vm.addr(deployerPrivateKey);
5350
address appImplementation = vm.envAddress("APP_IMPLEMENTATION");
54-
51+
5552
console.log("Deploying DstackKms with account:", deployer);
5653
console.log("Account balance:", deployer.balance);
5754
console.log("Using DstackApp implementation:", appImplementation);
58-
55+
5956
vm.startBroadcast(deployerPrivateKey);
60-
57+
6158
// Deploy DstackKms implementation
6259
DstackKms kmsImpl = new DstackKms();
6360
console.log("DstackKms implementation deployed to:", address(kmsImpl));
64-
61+
6562
// Deploy DstackKms proxy
66-
bytes memory initData = abi.encodeCall(
67-
DstackKms.initialize,
68-
(deployer, appImplementation)
69-
);
63+
bytes memory initData = abi.encodeCall(DstackKms.initialize, (deployer, appImplementation));
7064
ERC1967Proxy kmsProxy = new ERC1967Proxy(address(kmsImpl), initData);
7165
console.log("DstackKms proxy deployed to:", address(kmsProxy));
72-
66+
7367
vm.stopBroadcast();
74-
68+
7569
console.log("KMS deployment complete!");
7670
console.log("- DstackKms implementation:", address(kmsImpl));
7771
console.log("- DstackKms proxy:", address(kmsProxy));
@@ -82,19 +76,19 @@ contract DeployAppOnly is Script {
8276
function run() external {
8377
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
8478
address deployer = vm.addr(deployerPrivateKey);
85-
79+
8680
console.log("Deploying DstackApp implementation with account:", deployer);
8781
console.log("Account balance:", deployer.balance);
88-
82+
8983
vm.startBroadcast(deployerPrivateKey);
90-
84+
9185
// Deploy DstackApp implementation
9286
DstackApp appImpl = new DstackApp();
9387
console.log("DstackApp implementation deployed to:", address(appImpl));
94-
88+
9589
vm.stopBroadcast();
96-
90+
9791
console.log("App implementation deployment complete!");
9892
console.log("- DstackApp implementation:", address(appImpl));
9993
}
100-
}
94+
}

0 commit comments

Comments
 (0)