Skip to content

Commit

Permalink
Applied prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
drinkcoffee committed Jan 24, 2024
1 parent d806ace commit a05f527
Show file tree
Hide file tree
Showing 40 changed files with 274 additions and 578 deletions.
98 changes: 16 additions & 82 deletions contracts/bridge/x/Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.11;

interface Core {

function announceAvailabilityVerifierRemovalIntent(address) external;
function announceVerifierRemovalIntent(address) external;
function getRegisteredAvailabilityVerifiers() external;
Expand Down Expand Up @@ -84,63 +83,27 @@ interface Core {
uint256 vaultId
) external view returns (uint256 balance);

function depositNft(
uint256 starkKey,
uint256 assetType,
uint256 vaultId,
uint256 tokenId
) external;
function depositNft(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId) external;

function getCancellationRequest(
uint256 starkKey,
uint256 assetId,
uint256 vaultId
) external view returns (uint256 request);

function depositERC20(
uint256 starkKey,
uint256 assetType,
uint256 vaultId,
uint256 quantizedAmount
) external;
function depositERC20(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount) external;

function depositEth(
uint256 starkKey,
uint256 assetType,
uint256 vaultId
) external payable;
function depositEth(uint256 starkKey, uint256 assetType, uint256 vaultId) external payable;

function deposit(
uint256 starkKey,
uint256 assetType,
uint256 vaultId,
uint256 quantizedAmount
) external;
function deposit(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount) external;

function deposit(
uint256 starkKey,
uint256 assetType,
uint256 vaultId
) external payable;
function deposit(uint256 starkKey, uint256 assetType, uint256 vaultId) external payable;

function depositCancel(
uint256 starkKey,
uint256 assetId,
uint256 vaultId
) external;
function depositCancel(uint256 starkKey, uint256 assetId, uint256 vaultId) external;

function depositReclaim(
uint256 starkKey,
uint256 assetId,
uint256 vaultId
) external;
function depositReclaim(uint256 starkKey, uint256 assetId, uint256 vaultId) external;

function depositNftReclaim(
uint256 starkKey,
uint256 assetType,
uint256 vaultId,
uint256 tokenId
) external;
function depositNftReclaim(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId) external;

event LogWithdrawalPerformed(
uint256 ownerKey,
Expand Down Expand Up @@ -177,24 +140,13 @@ interface Core {

event LogMintableWithdrawalAllowed(uint256 ownerKey, uint256 assetId, uint256 quantizedAmount);

function getWithdrawalBalance(uint256 ownerKey, uint256 assetId)
external
view
returns (uint256 balance);
function getWithdrawalBalance(uint256 ownerKey, uint256 assetId) external view returns (uint256 balance);

function withdraw(uint256 ownerKey, uint256 assetType) external;

function withdrawNft(
uint256 ownerKey,
uint256 assetType,
uint256 tokenId
) external ;
function withdrawNft(uint256 ownerKey, uint256 assetType, uint256 tokenId) external;

function withdrawAndMint(
uint256 ownerKey,
uint256 assetType,
bytes calldata mintingBlob
) external;
function withdrawAndMint(uint256 ownerKey, uint256 assetType, bytes calldata mintingBlob) external;

function getVaultRoot() external view returns (uint256 root);
function getVaultTreeHeight() external view returns (uint256 height);
Expand Down Expand Up @@ -224,39 +176,21 @@ interface Core {

function getQuantum(uint256 presumedAssetType) external view returns (uint256 quantum);

function escape(
uint256 starkKey,
uint256 vaultId,
uint256 assetId,
uint256 quantizedAmount
) external;
function escape(uint256 starkKey, uint256 vaultId, uint256 assetId, uint256 quantizedAmount) external;

event LogFullWithdrawalRequest(uint256 starkKey, uint256 vaultId);

function fullWithdrawalRequest(uint256 starkKey, uint256 vaultId) external;

function freezeRequest(uint256 starkKey, uint256 vaultId) external;

event LogRootUpdate(
uint256 sequenceNumber,
uint256 batchId,
uint256 vaultRoot,
uint256 orderRoot
);
event LogRootUpdate(uint256 sequenceNumber, uint256 batchId, uint256 vaultRoot, uint256 orderRoot);

event LogStateTransitionFact(bytes32 stateTransitionFact);

event LogVaultBalanceChangeApplied(
address ethKey,
uint256 assetId,
uint256 vaultId,
int256 quantizedAmountChange
);
event LogVaultBalanceChangeApplied(address ethKey, uint256 assetId, uint256 vaultId, int256 quantizedAmountChange);

function updateState(uint256[] calldata publicInput, uint256[] calldata applicationData) external;

function getFullWithdrawalRequest(uint256 starkKey, uint256 vaultId)
external
view
returns (uint256 res);
}
function getFullWithdrawalRequest(uint256 starkKey, uint256 vaultId) external view returns (uint256 res);
}
4 changes: 2 additions & 2 deletions contracts/bridge/x/Registration.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import { Core } from "./Core.sol";
import {Core} from "./Core.sol";

contract Registration {
Core public imx;
Expand Down Expand Up @@ -80,4 +80,4 @@ contract Registration {
function isRegistered(uint256 starkKey) public view returns (bool) {
return imx.getEthKey(starkKey) != address(0);
}
}
}
2 changes: 1 addition & 1 deletion contracts/mocks/MockDisguisedEOA.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockEIP1271Wallet.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockMarketplace.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockOnReceive.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockWallet.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockWalletFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.19;

contract MockWalletFactory {
bytes private constant walletCreationCode =
Expand Down
14 changes: 9 additions & 5 deletions contracts/random/offchainsources/SourceAdaptorBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ abstract contract SourceAdaptorBase is AccessControlEnumerable, IOffchainRandomS
}

/**
* @notice Callback called when random words are returned by the VRF.
* @dev Assumes external function that calls this checks that the random values are coming
* @notice Callback called when random words are returned by the VRF.
* @dev Assumes external function that calls this checks that the random values are coming
* @dev from the VRF.
* @dev NOTE that Chainlink assumes that this function will not fail.
* @param _requestId is the fulfilment index.
* @param _randomWords are the random values from the VRF.
*/
function _fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal {
// NOTE: This function call is not allowed to fail. However, if one word is requested
// and some other number of words has been returned, then maybe the source has been
// and some other number of words has been returned, then maybe the source has been
// compromised. Reverting the call is more likely to draw attention to the issue than
// emitting an event.
if (_randomWords.length != 1) {
Expand All @@ -54,7 +54,9 @@ abstract contract SourceAdaptorBase is AccessControlEnumerable, IOffchainRandomS
/**
* @inheritdoc IOffchainRandomSource
*/
function getOffchainRandom(uint256 _fulfillmentIndex) external override(IOffchainRandomSource) view returns (bytes32 _randomValue) {
function getOffchainRandom(
uint256 _fulfillmentIndex
) external view override(IOffchainRandomSource) returns (bytes32 _randomValue) {
bytes32 rand = randomOutput[_fulfillmentIndex];
if (rand == bytes32(0)) {
revert WaitForRandom();
Expand All @@ -65,7 +67,9 @@ abstract contract SourceAdaptorBase is AccessControlEnumerable, IOffchainRandomS
/**
* @inheritdoc IOffchainRandomSource
*/
function isOffchainRandomReady(uint256 _fulfillmentIndex) external override(IOffchainRandomSource) view returns (bool) {
function isOffchainRandomReady(
uint256 _fulfillmentIndex
) external view override(IOffchainRandomSource) returns (bool) {
return randomOutput[_fulfillmentIndex] != bytes32(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {IOffchainRandomSource} from "../IOffchainRandomSource.sol";
*/
contract ChainlinkSourceAdaptor is VRFConsumerBaseV2, SourceAdaptorBase {
/// @notice Log config changes.
event ConfigChanges( bytes32 _keyHash, uint64 _subId, uint32 _callbackGasLimit);
event ConfigChanges(bytes32 _keyHash, uint64 _subId, uint32 _callbackGasLimit);

/// @notice Relates to key that must sign the proof.
bytes32 public keyHash;
Expand Down
69 changes: 34 additions & 35 deletions contracts/random/offchainsources/chainlink/VRFConsumerBaseV2.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

// Code from Chainlink's repo.
// Code from Chainlink's repo.
// This file has been copied here that than installing the chainlink contracts
// using the following command to dependency clashes.
// npm install @chainlink/contracts


/** ****************************************************************************
* @notice Interface for contracts using VRF randomness
* *****************************************************************************
Expand Down Expand Up @@ -101,41 +100,41 @@ pragma solidity 0.8.19;
* @dev and so remains effective only in the case of unmodified oracle software).
*/
abstract contract VRFConsumerBaseV2 {
error OnlyCoordinatorCanFulfill(address have, address want);
// solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i
address private immutable vrfCoordinator;
error OnlyCoordinatorCanFulfill(address have, address want);
// solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i
address private immutable vrfCoordinator;

/**
* @param _vrfCoordinator address of VRFCoordinator contract
*/
constructor(address _vrfCoordinator) {
vrfCoordinator = _vrfCoordinator;
}
/**
* @param _vrfCoordinator address of VRFCoordinator contract
*/
constructor(address _vrfCoordinator) {
vrfCoordinator = _vrfCoordinator;
}

/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it. See "SECURITY CONSIDERATIONS" above for important
* @notice principles to keep in mind when implementing your fulfillRandomness
* @notice method.
*
* @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this
* @dev signature, and will call it once it has verified the proof
* @dev associated with the randomness. (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomWords the VRF output expanded to the requested number of words
*/
// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it. See "SECURITY CONSIDERATIONS" above for important
* @notice principles to keep in mind when implementing your fulfillRandomness
* @notice method.
*
* @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this
* @dev signature, and will call it once it has verified the proof
* @dev associated with the randomness. (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomWords the VRF output expanded to the requested number of words
*/
// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;

// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
if (msg.sender != vrfCoordinator) {
revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
if (msg.sender != vrfCoordinator) {
revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
}
fulfillRandomWords(requestId, randomWords);
}
fulfillRandomWords(requestId, randomWords);
}
}
1 change: 0 additions & 1 deletion contracts/random/offchainsources/supra/ISupraRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pragma solidity 0.8.19;
*/

interface ISupraRouter {

function generateRequest(
string memory _functionSig,
uint8 _rngCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ contract SupraSourceAdaptor is SourceAdaptorBase {
subscriptionAccount = _subscription;
}


/**
* @notice Change the subscription account address.
* @param _subscription The address of the new subscription.
Expand All @@ -47,7 +46,6 @@ contract SupraSourceAdaptor is SourceAdaptorBase {
emit SubscriptionChange(subscriptionAccount);
}


/**
* @inheritdoc IOffchainRandomSource
*/
Expand All @@ -62,7 +60,7 @@ contract SupraSourceAdaptor is SourceAdaptorBase {
}

/**
* @notice Callback called when random words are returned by the VRF.
* @notice Callback called when random words are returned by the VRF.
* @param _requestId is the fulfilment index.
* @param _randomWords are the random values from the VRF.
*/
Expand Down
Loading

0 comments on commit a05f527

Please sign in to comment.