Skip to content

Commit cdf57db

Browse files
committed
fmt
1 parent bc3947a commit cdf57db

9 files changed

Lines changed: 24 additions & 27 deletions

File tree

src/protocol/BridgedERC1155.sol

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.28;
33

4-
import {IMintableERC1155} from "./IMintable.sol";
54
import {BridgedTokenBase} from "./BridgedTokenBase.sol";
5+
import {IMintableERC1155} from "./IMintable.sol";
66
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
77

88
/// @title BridgedERC1155
@@ -12,10 +12,7 @@ contract BridgedERC1155 is ERC1155, BridgedTokenBase, IMintableERC1155 {
1212
/// @dev Mapping from token ID to custom token URI
1313
mapping(uint256 => string) private _tokenURIs;
1414

15-
constructor(string memory uri_, address _originalToken)
16-
ERC1155(uri_)
17-
BridgedTokenBase(_originalToken)
18-
{}
15+
constructor(string memory uri_, address _originalToken) ERC1155(uri_) BridgedTokenBase(_originalToken) {}
1916

2017
/// @inheritdoc IMintableERC1155
2118
function mint(address to, uint256 id, uint256 amount, bytes memory data) external onlyOwner {

src/protocol/BridgedERC20.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.28;
33

4-
import {IMintableERC20} from "./IMintable.sol";
54
import {BridgedTokenBase} from "./BridgedTokenBase.sol";
5+
import {IMintableERC20} from "./IMintable.sol";
66
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
77

88
/// @title BridgedERC20

src/protocol/BridgedERC721.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.28;
33

4-
import {IMintableERC721} from "./IMintable.sol";
54
import {BridgedTokenBase} from "./BridgedTokenBase.sol";
5+
import {IMintableERC721} from "./IMintable.sol";
66
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
77

88
/// @title BridgedERC721

src/protocol/BridgedTokenBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ abstract contract BridgedTokenBase is Ownable {
1515
constructor(address _originalToken) Ownable(msg.sender) {
1616
originalToken = _originalToken;
1717
}
18-
}
18+
}

src/protocol/ERC1155Bridge.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ contract ERC1155Bridge is IERC1155Bridge, ReentrancyGuardTransient, IERC1155Rece
145145
// Store the mapping
146146
bytes32 key = keccak256(abi.encode(tokenInit.originalToken));
147147
_deployedTokens[key] = deployedToken;
148-
148+
149149
// Mark as a bridged token deployed by this bridge
150150
_isBridgedTokens[deployedToken] = true;
151151

src/protocol/ERC20Bridge.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@ contract ERC20Bridge is IERC20Bridge, ReentrancyGuardTransient {
138138
_provenInitializations[id] = true;
139139

140140
// Deploy the bridged token
141-
deployedToken = address(
142-
new BridgedERC20(tokenInit.name, tokenInit.symbol, tokenInit.decimals, tokenInit.originalToken)
143-
);
141+
deployedToken =
142+
address(new BridgedERC20(tokenInit.name, tokenInit.symbol, tokenInit.decimals, tokenInit.originalToken));
144143

145144
// Store the mapping
146145
bytes32 key = keccak256(abi.encode(tokenInit.originalToken));
147146
_deployedTokens[key] = deployedToken;
148-
147+
149148
// Mark as a bridged token deployed by this bridge
150149
_isBridgedTokens[deployedToken] = true;
151150

src/protocol/ERC721Bridge.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ contract ERC721Bridge is IERC721Bridge, ReentrancyGuardTransient, IERC721Receive
139139
// Store the mapping
140140
bytes32 key = keccak256(abi.encode(tokenInit.originalToken));
141141
_deployedTokens[key] = deployedToken;
142-
142+
143143
// Mark as a bridged token deployed by this bridge
144144
_isBridgedTokens[deployedToken] = true;
145145

test/ERC20Bridge/Basic.t.sol

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,24 @@ contract ERC20BridgeTest is Test {
345345
function testMaliciousTokenRejection() public {
346346
// Deploy a malicious token that could try to spoof bridge functionality
347347
MockMaliciousERC20 maliciousToken = new MockMaliciousERC20(address(bridge));
348-
349-
// Verify the malicious token still tries to spoof (even though bridge() function no longer exists in real bridged tokens)
348+
349+
// Verify the malicious token still tries to spoof (even though bridge() function no longer exists in real
350+
// bridged tokens)
350351
assertEq(maliciousToken.bridge(), address(bridge), "Malicious token should spoof bridge address");
351-
352+
352353
// Transfer some malicious tokens to alice
353354
maliciousToken.transfer(alice, 100);
354-
355+
355356
// Try to deposit the malicious token - should fail because it's not actually a bridged token
356357
vm.startPrank(alice);
357358
maliciousToken.approve(address(bridge), 100);
358-
359+
359360
// This should revert because the malicious token is not in the _isBridgedTokens mapping
360361
vm.expectRevert(); // TokenNotInitialized()
361362
bridge.deposit(alice, address(maliciousToken), 100, address(0));
362-
363+
363364
vm.stopPrank();
364-
365+
365366
// The malicious token is correctly rejected because bridge now uses secure mapping-based validation
366367
// rather than calling external functions that could be spoofed
367368
}
@@ -370,7 +371,7 @@ contract ERC20BridgeTest is Test {
370371
// Initialize and prove token initialization
371372
MockERC20 originalToken = new MockERC20("Original Token", "ORIG");
372373
bridge.initializeToken(address(originalToken));
373-
374+
374375
IERC20Bridge.TokenInitialization memory tokenInit = IERC20Bridge.TokenInitialization({
375376
originalToken: address(originalToken),
376377
name: "Original Token",
@@ -384,14 +385,14 @@ contract ERC20BridgeTest is Test {
384385

385386
// Test originalToken tracking
386387
assertEq(bridgedToken.originalToken(), address(originalToken), "originalToken should be tracked");
387-
388+
388389
// Test ownership (bridge is the owner)
389390
assertEq(bridgedToken.owner(), address(bridge), "Bridge should be the owner");
390-
391+
391392
// Test that only owner (bridge) can mint
392393
vm.expectRevert(); // Should revert with OwnableUnauthorizedAccount
393394
bridgedToken.mint(alice, 100);
394-
395+
395396
// Bridge (owner) should be able to mint
396397
vm.prank(address(bridge));
397398
bridgedToken.mint(alice, 100);

test/mocks/MockMaliciousERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ contract MockMaliciousERC20 is ERC20 {
1111

1212
constructor(address fakeBridge) ERC20("Malicious Token", "EVIL") {
1313
_fakeBridge = fakeBridge;
14-
_mint(msg.sender, 1000000 * 10**18);
14+
_mint(msg.sender, 1000000 * 10 ** 18);
1515
}
1616

1717
/// @dev Spoofs the bridge() function to return the provided address
@@ -23,4 +23,4 @@ contract MockMaliciousERC20 is ERC20 {
2323
function originalToken() external pure returns (address) {
2424
return address(0x1); // Fake original token
2525
}
26-
}
26+
}

0 commit comments

Comments
 (0)