Skip to content

Commit a8d8779

Browse files
authored
style: Run formatter (#317)
1 parent f30ad4a commit a8d8779

File tree

5 files changed

+119
-111
lines changed

5 files changed

+119
-111
lines changed

contracts/facets/IexecEscrowNativeFacet.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {IexecEscrowNative} from "../interfaces/IexecEscrowNative.sol";
99
import {PocoStorageLib} from "../libs/PocoStorageLib.sol";
1010

1111
contract IexecEscrowNativeFacet is IexecEscrowNative, FacetBase, IexecERC20Core {
12-
1312
uint256 internal constant nRLCtoWei = 10 ** 9;
1413
/***************************************************************************
1514
* Escrow methods: public *

contracts/registries/proxy/Address.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ library Address {
3737

3838
uint256 size;
3939
// solhint-disable-next-line no-inline-assembly
40-
assembly { size := extcodesize(account) }
40+
assembly {
41+
size := extcodesize(account)
42+
}
4143
return size > 0;
4244
}
4345
}

contracts/registries/proxy/BaseUpgradeabilityProxy.sol

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,50 +22,54 @@ import {Proxy} from "./Proxy.sol";
2222
* Such a change is called an implementation upgrade.
2323
*/
2424
contract BaseUpgradeabilityProxy is Proxy {
25-
/**
26-
* @dev Emitted when the implementation is upgraded.
27-
* @param implementation Address of the new implementation.
28-
*/
29-
event Upgraded(address indexed implementation);
25+
/**
26+
* @dev Emitted when the implementation is upgraded.
27+
* @param implementation Address of the new implementation.
28+
*/
29+
event Upgraded(address indexed implementation);
3030

31-
/**
32-
* @dev Storage slot with the address of the current implementation.
33-
* This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
34-
* validated in the constructor.
35-
*/
36-
bytes32 internal constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
31+
/**
32+
* @dev Storage slot with the address of the current implementation.
33+
* This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
34+
* validated in the constructor.
35+
*/
36+
bytes32 internal constant IMPLEMENTATION_SLOT =
37+
0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
3738

38-
/**
39-
* @dev Returns the current implementation.
40-
* @return impl Address of the current implementation
41-
*/
42-
function _implementation() internal override view returns (address impl) {
43-
bytes32 slot = IMPLEMENTATION_SLOT;
44-
assembly {
45-
impl := sload(slot)
39+
/**
40+
* @dev Returns the current implementation.
41+
* @return impl Address of the current implementation
42+
*/
43+
function _implementation() internal view override returns (address impl) {
44+
bytes32 slot = IMPLEMENTATION_SLOT;
45+
assembly {
46+
impl := sload(slot)
47+
}
4648
}
47-
}
4849

49-
/**
50-
* @dev Upgrades the proxy to a new implementation.
51-
* @param newImplementation Address of the new implementation.
52-
*/
53-
function _upgradeTo(address newImplementation) internal {
54-
_setImplementation(newImplementation);
55-
emit Upgraded(newImplementation);
56-
}
50+
/**
51+
* @dev Upgrades the proxy to a new implementation.
52+
* @param newImplementation Address of the new implementation.
53+
*/
54+
function _upgradeTo(address newImplementation) internal {
55+
_setImplementation(newImplementation);
56+
emit Upgraded(newImplementation);
57+
}
5758

58-
/**
59-
* @dev Sets the implementation address of the proxy.
60-
* @param newImplementation Address of the new implementation.
61-
*/
62-
function _setImplementation(address newImplementation) internal {
63-
require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
59+
/**
60+
* @dev Sets the implementation address of the proxy.
61+
* @param newImplementation Address of the new implementation.
62+
*/
63+
function _setImplementation(address newImplementation) internal {
64+
require(
65+
Address.isContract(newImplementation),
66+
"Cannot set a proxy implementation to a non-contract address"
67+
);
6468

65-
bytes32 slot = IMPLEMENTATION_SLOT;
69+
bytes32 slot = IMPLEMENTATION_SLOT;
6670

67-
assembly {
68-
sstore(slot, newImplementation)
71+
assembly {
72+
sstore(slot, newImplementation)
73+
}
6974
}
70-
}
7175
}

contracts/registries/proxy/InitializableUpgradeabilityProxy.sol

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ import {BaseUpgradeabilityProxy} from "./BaseUpgradeabilityProxy.sol";
1919
* implementation and init data.
2020
*/
2121
contract InitializableUpgradeabilityProxy is BaseUpgradeabilityProxy {
22-
/**
23-
* @dev Contract initializer.
24-
* @param _logic Address of the initial implementation.
25-
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
26-
* It should include the signature and the parameters of the function to be called, as described in
27-
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
28-
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
29-
*/
30-
function initialize(address _logic, bytes memory _data) public payable {
31-
require(_implementation() == address(0));
32-
assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
33-
_setImplementation(_logic);
34-
if(_data.length > 0) {
35-
(bool success,) = _logic.delegatecall(_data);
36-
require(success);
22+
/**
23+
* @dev Contract initializer.
24+
* @param _logic Address of the initial implementation.
25+
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
26+
* It should include the signature and the parameters of the function to be called, as described in
27+
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
28+
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
29+
*/
30+
function initialize(address _logic, bytes memory _data) public payable {
31+
require(_implementation() == address(0));
32+
assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
33+
_setImplementation(_logic);
34+
if (_data.length > 0) {
35+
(bool success, ) = _logic.delegatecall(_data);
36+
require(success);
37+
}
3738
}
38-
}
3939
}

contracts/registries/proxy/Proxy.sol

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,71 @@ pragma solidity ^0.8.0;
1818
* returned by the abstract _implementation() internal function.
1919
*/
2020
abstract contract Proxy {
21-
/**
22-
* @dev Receive function.
23-
* Implemented entirely in `_fallback`.
24-
*/
25-
receive() external payable virtual {
26-
_fallback();
27-
}
21+
/**
22+
* @dev Receive function.
23+
* Implemented entirely in `_fallback`.
24+
*/
25+
receive() external payable virtual {
26+
_fallback();
27+
}
2828

29-
/**
30-
* @dev Fallback function.
31-
* Implemented entirely in `_fallback`.
32-
*/
33-
fallback() external payable {
34-
_fallback();
35-
}
29+
/**
30+
* @dev Fallback function.
31+
* Implemented entirely in `_fallback`.
32+
*/
33+
fallback() external payable {
34+
_fallback();
35+
}
3636

37-
/**
38-
* @return impl The Address of the implementation.
39-
*/
40-
function _implementation() internal virtual view returns (address impl);
37+
/**
38+
* @return impl The Address of the implementation.
39+
*/
40+
function _implementation() internal view virtual returns (address impl);
4141

42-
/**
43-
* @dev Delegates execution to an implementation contract.
44-
* This is a low level function that doesn't return to its internal call site.
45-
* It will return to the external caller whatever the implementation returns.
46-
* @param implementation Address to delegate.
47-
*/
48-
function _delegate(address implementation) internal {
49-
assembly {
50-
// Copy msg.data. We take full control of memory in this inline assembly
51-
// block because it will not return to Solidity code. We overwrite the
52-
// Solidity scratch pad at memory position 0.
53-
calldatacopy(0, 0, calldatasize())
42+
/**
43+
* @dev Delegates execution to an implementation contract.
44+
* This is a low level function that doesn't return to its internal call site.
45+
* It will return to the external caller whatever the implementation returns.
46+
* @param implementation Address to delegate.
47+
*/
48+
function _delegate(address implementation) internal {
49+
assembly {
50+
// Copy msg.data. We take full control of memory in this inline assembly
51+
// block because it will not return to Solidity code. We overwrite the
52+
// Solidity scratch pad at memory position 0.
53+
calldatacopy(0, 0, calldatasize())
5454

55-
// Call the implementation.
56-
// out and outsize are 0 because we don't know the size yet.
57-
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
55+
// Call the implementation.
56+
// out and outsize are 0 because we don't know the size yet.
57+
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
5858

59-
// Copy the returned data.
60-
returndatacopy(0, 0, returndatasize())
59+
// Copy the returned data.
60+
returndatacopy(0, 0, returndatasize())
6161

62-
switch result
63-
// delegatecall returns 0 on error.
64-
case 0 { revert(0, returndatasize()) }
65-
default { return(0, returndatasize()) }
62+
switch result
63+
// delegatecall returns 0 on error.
64+
case 0 {
65+
revert(0, returndatasize())
66+
}
67+
default {
68+
return(0, returndatasize())
69+
}
70+
}
6671
}
67-
}
6872

69-
/**
70-
* @dev Function that is run as the first thing in the fallback function.
71-
* Can be redefined in derived contracts to add functionality.
72-
* Redefinitions must call super._willFallback().
73-
*/
74-
function _willFallback() internal virtual {
75-
}
73+
/**
74+
* @dev Function that is run as the first thing in the fallback function.
75+
* Can be redefined in derived contracts to add functionality.
76+
* Redefinitions must call super._willFallback().
77+
*/
78+
function _willFallback() internal virtual {}
7679

77-
/**
78-
* @dev fallback implementation.
79-
* Extracted to enable manual triggering.
80-
*/
81-
function _fallback() internal {
82-
_willFallback();
83-
_delegate(_implementation());
84-
}
80+
/**
81+
* @dev fallback implementation.
82+
* Extracted to enable manual triggering.
83+
*/
84+
function _fallback() internal {
85+
_willFallback();
86+
_delegate(_implementation());
87+
}
8588
}

0 commit comments

Comments
 (0)