Skip to content

Commit

Permalink
chore: Natspec, whitespace, and checksums (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
deluca-mike authored Dec 26, 2021
1 parent cc2e8d8 commit 776de27
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 44 deletions.
38 changes: 19 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
version: 2.1

jobs:
dapp_test:
docker:
- image: bakii0499/dapptools:0.48.0-solc-0.8.7
steps:
- run:
name: Checkout maple-proxy-factory
command: |
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone [email protected]:maple-labs/maple-proxy-factory.git .
git checkout $CIRCLE_BRANCH
- run:
name: Build and test contracts
command: |
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive
./test.sh -c ./config/ci.json -r 10
dapp_test:
docker:
- image: bakii0499/dapptools:0.48.0-solc-0.8.7
steps:
- run:
name: Checkout maple-proxy-factory
command: |
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone [email protected]:maple-labs/maple-proxy-factory.git .
git checkout $CIRCLE_BRANCH
- run:
name: Build and test contracts
command: |
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive
./test.sh -c ./config/ci.json -r 10
workflows:
version: 2
test_all:
jobs:
- dapp_test:
context: seth
version: 2
test_all:
jobs:
- dapp_test:
context: seth
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ hevm*
.vscode/*
/package
.DS_Store
artifacts/*
docs/*
metadata.json
7 changes: 0 additions & 7 deletions contracts/MapleProxied.sol

This file was deleted.

7 changes: 7 additions & 0 deletions contracts/MapleProxiedInternals.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.7;

import { ProxiedInternals } from "../modules/proxy-factory/contracts/ProxiedInternals.sol";

/// @title A Maple implementation that is to be proxied, will need MapleProxiedInternals.
abstract contract MapleProxiedInternals is ProxiedInternals {}
7 changes: 4 additions & 3 deletions contracts/MapleProxyFactory.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.7;

import { IProxied } from "../modules/proxy-factory/contracts/interfaces/IProxied.sol";
import { ProxyFactory } from "../modules/proxy-factory/contracts/ProxyFactory.sol";

import { IMapleProxyFactory } from "./interfaces/IMapleProxyFactory.sol";
import { IMapleGlobalsLike } from "./interfaces/Interfaces.sol";
import { IMapleProxied } from "./interfaces/IMapleProxied.sol";
import { IMapleProxyFactory } from "./interfaces/IMapleProxyFactory.sol";

/// @title A Maple factory for Proxy contracts that proxy MapleProxied implementations.
contract MapleProxyFactory is IMapleProxyFactory, ProxyFactory {
Expand All @@ -16,6 +16,7 @@ contract MapleProxyFactory is IMapleProxyFactory, ProxyFactory {

mapping(uint256 => mapping(uint256 => bool)) public override upgradeEnabledForPath;

/// @param mapleGlobals_ The address of a Maple Globals contract.
constructor(address mapleGlobals_) {
require(IMapleGlobalsLike(mapleGlobals = mapleGlobals_).governor() != address(0), "MPF:C:INVALID_GLOBALS");
}
Expand Down Expand Up @@ -86,7 +87,7 @@ contract MapleProxyFactory is IMapleProxyFactory, ProxyFactory {

// NOTE: The implementation proxied by the instance defines the access control logic for its own upgrade.
function upgradeInstance(uint256 toVersion_, bytes calldata arguments_) public override virtual {
uint256 fromVersion = _versionOf[IProxied(msg.sender).implementation()];
uint256 fromVersion = _versionOf[IMapleProxied(msg.sender).implementation()];

require(upgradeEnabledForPath[fromVersion][toVersion_], "MPF:UI:NOT_ALLOWED");

Expand Down
8 changes: 4 additions & 4 deletions contracts/interfaces/IMapleProxied.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface IMapleProxied is IProxied {
event Upgraded(uint256 toVersion_, bytes arguments_);

/**
* @notice Upgrades a contract implementation to a specific version.
* @dev Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
* @param toVersion_ The version to upgrade to.
* @param arguments_ Some encoded arguments to use for the upgrade.
* @dev Upgrades a contract implementation to a specific version.
* Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
* @param toVersion_ The version to upgrade to.
* @param arguments_ Some encoded arguments to use for the upgrade.
*/
function upgrade(uint256 toVersion_, bytes calldata arguments_) external;

Expand Down
14 changes: 7 additions & 7 deletions contracts/interfaces/IMapleProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ interface IMapleProxyFactory is IDefaultImplementationBeacon {

/**
* @dev Deploys a new instance proxying the default implementation version, with some initialization arguments.
* @dev Uses a nonce and `msg.sender` as a salt for the CREATE2 opcode during instantiation to produce deterministic addresses.
* Uses a nonce and `msg.sender` as a salt for the CREATE2 opcode during instantiation to produce deterministic addresses.
* @param arguments_ The initialization arguments to use for the instance deployment, if any.
* @param salt_ The salt to use in the contract creation process.
* @return instance_ The address of the deployed proxy contract.
Expand All @@ -99,7 +99,7 @@ interface IMapleProxyFactory is IDefaultImplementationBeacon {

/**
* @dev Enables upgrading from a version to a version of an implementation, with an optional migrator.
* @dev Only the Governor can call this function.
* Only the Governor can call this function.
* @param fromVersion_ The starting version of the upgrade path.
* @param toVersion_ The destination version of the upgrade path.
* @param migrator_ The address of the migrator, if any.
Expand All @@ -108,15 +108,15 @@ interface IMapleProxyFactory is IDefaultImplementationBeacon {

/**
* @dev Disables upgrading from a version to a version of a implementation.
* @dev Only the Governor can call this function.
* Only the Governor can call this function.
* @param fromVersion_ The starting version of the upgrade path.
* @param toVersion_ The destination version of the upgrade path.
*/
function disableUpgradePath(uint256 fromVersion_, uint256 toVersion_) external;

/**
* @dev Registers the address of an implementation contract as a version, with an optional initializer.
* @dev Only the Governor can call this function.
* Only the Governor can call this function.
* @param version_ The version to register.
* @param implementationAddress_ The address of the implementation.
* @param initializer_ The address of the initializer, if any.
Expand All @@ -125,14 +125,14 @@ interface IMapleProxyFactory is IDefaultImplementationBeacon {

/**
* @dev Sets the default version.
* @dev Only the Governor can call this function.
* Only the Governor can call this function.
* @param version_ The implementation version to set as the default.
*/
function setDefaultVersion(uint256 version_) external;

/**
* @dev Sets the Maple Globals contract.
* @dev Only the Governor can call this function.
* Only the Governor can call this function.
* @param mapleGlobals_ The address of a Maple Globals contract.
*/
function setGlobals(address mapleGlobals_) external;
Expand Down Expand Up @@ -165,7 +165,7 @@ interface IMapleProxyFactory is IDefaultImplementationBeacon {

/**
* @dev Returns the address of a migrator contract for a migration path (from version, to version).
* @dev If oldVersion_ == newVersion_, the migrator is a initializer.
* If oldVersion_ == newVersion_, the migrator is an initializer.
* @param oldVersion_ The old version.
* @param newVersion_ The new version.
* @return migrator_ The address of a migrator contract.
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/mocks/Mocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.7;
import { IMapleProxied } from "../../interfaces/IMapleProxied.sol";
import { IMapleProxyFactory } from "../../interfaces/IMapleProxyFactory.sol";

import { MapleProxied } from "../../MapleProxied.sol";
import { MapleProxiedInternals } from "../../MapleProxiedInternals.sol";

contract MapleGlobalsMock {

Expand All @@ -16,7 +16,7 @@ contract MapleGlobalsMock {

}

contract MapleInstanceMock is IMapleProxied, MapleProxied {
contract MapleInstanceMock is IMapleProxied, MapleProxiedInternals {

function upgrade(uint256 toVersion_, bytes calldata arguments_) override external {
IMapleProxyFactory(_factory()).upgradeInstance(toVersion_, arguments_);
Expand Down
6 changes: 5 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: maple-proxy-factory
version: 2.0.0
version: 1.0.0
source: contracts
packages:
- path: contracts/MapleProxyFactory.sol
contractName: MapleProxyFactory
customChecksum: 0x48376956b7d296532583145b1e04f24d68bf44ca0372721b66ffd1b2b3be6ee9
customDescription: Maple Proxy Factory Artifacts and ABIs

0 comments on commit 776de27

Please sign in to comment.