Skip to content

Commit

Permalink
Merge 83899d6 into 79decf7
Browse files Browse the repository at this point in the history
  • Loading branch information
d1ll0n committed Oct 24, 2020
2 parents 79decf7 + 83899d6 commit b681221
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 124 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,10 @@ Smart contracts for upgradeable proxies.
npm install --save @indexed-finance/proxies
```

**Notes for developers**

If you deploy a new version of `DelegateCallProxyManager.sol` without using the artifact in /artifacts (handled automatically by buidler), your local build may result in different bytecode. If that happens, the code hashes in `CodeHashes.sol` will be incorrect and the proxy address derivation functions will not work. Either use the already built artifacts in the package or replace the codehashes with the new values. See: [script for generating the CodeHashes contract](./scripts/write-code-hashes.js)

## Test

```
Expand Down
6 changes: 3 additions & 3 deletions contracts/CodeHashes.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
pragma solidity ^0.6.0;


/**
Expand All @@ -8,7 +8,7 @@ pragma solidity =0.6.12;
* values when they import the salt library.
*/
library CodeHashes {
bytes32 internal constant ONE_TO_ONE_CODEHASH = 0x980843d7182154db438d410718903ca4c4116c8f430643d49eb654ed1776ed41;
bytes32 internal constant MANY_TO_ONE_CODEHASH = 0xb4e09618634e1d4fad81090ab8fb8259b749a9202aa02d7720af654b9b4ca17b;
bytes32 internal constant ONE_TO_ONE_CODEHASH = 0xdf533b6e999d326280ce88ca39ea2eddf95ed96f6c153ed5642d9b0a95dba4a2;
bytes32 internal constant MANY_TO_ONE_CODEHASH = 0x8fb4522edc5e0645a7ae5cfdbfe3b34d4a14de9e0279b74da795856b5ef4f1e6;
bytes32 internal constant IMPLEMENTATION_HOLDER_CODEHASH = 0xfc7aed17e5c5d36a15e443235cb9c59bae4a013202cde6ab3e657fa1176d7f3e;
}
6 changes: 3 additions & 3 deletions contracts/DelegateCallProxyManyToOne.sol
Expand Up @@ -18,20 +18,20 @@ import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
* this safety check before updating the implementation on the holder.
*/
contract DelegateCallProxyManyToOne is Proxy {
/* --- Constants --- */
/* ========== Constants ========== */

// Address that stores the implementation address.
address internal immutable _implementationHolder;

/* --- Constructor --- */
/* ========== Constructor ========== */

constructor() public {
// Calls the sender rather than receiving the address in the constructor
// arguments so that the address is computable using create2.
_implementationHolder = ProxyDeployer(msg.sender).getImplementationHolder();
}

/* --- Internal Overrides --- */
/* ========== Internal Overrides ========== */

/**
* @dev Queries the implementation address from the implementation holder.
Expand Down
6 changes: 3 additions & 3 deletions contracts/DelegateCallProxyOneToOne.sol
Expand Up @@ -23,15 +23,15 @@ import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
* The manager must perform this safety check.
*/
contract DelegateCallProxyOneToOne is Proxy {
/* --- Constants --- */
/* ========== Constants ========== */
address internal immutable _manager;

/* --- Constructor --- */
/* ========== Constructor ========== */
constructor() public {
_manager = msg.sender ;
}

/* --- Internal Overrides --- */
/* ========== Internal Overrides ========== */

/**
* @dev Reads the implementation address from storage.
Expand Down
7 changes: 1 addition & 6 deletions deploy/1_deploy.js
Expand Up @@ -14,14 +14,11 @@ const logger = {

module.exports = async ({
deployments,
getChainId,
getNamedAccounts,
ethers
getNamedAccounts
}) => {
const { save } = deployments;
const { deployer } = await getNamedAccounts();

// For some reason the contractName field wasn't properly being saved to deployments.
const deploy = async (name, contractName, opts) => {
logger.info(`Deploying ${contractName} [${name}]`);
const deployment = await deployments.deploy(name, {
Expand All @@ -34,8 +31,6 @@ module.exports = async ({
return deployment;
};

logger.info('Executing deployment script.');

await deploy('DelegateCallProxyManager', 'proxyManager', {
from: deployer,
gas: 4000000,
Expand Down
255 changes: 207 additions & 48 deletions deployments/rinkeby/DelegateCallProxyManager.json

Large diffs are not rendered by default.

255 changes: 207 additions & 48 deletions deployments/rinkeby/proxyManager.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@indexed-finance/proxies",
"version": "1.0.11",
"version": "1.0.12",
"description": "Solidity delegatecall proxy contracts.",
"repository": {
"url": "https://github.com/indexed-finance/proxies"
Expand Down
2 changes: 1 addition & 1 deletion scripts/write-code-hashes.js
Expand Up @@ -19,7 +19,7 @@ import { DelegateCallProxyOneToOne } from "./DelegateCallProxyOneToOne.sol";
` : '';

const CodeHashesLibrary = `// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
pragma solidity ^0.6.0;
${imports}
/**
Expand Down

0 comments on commit b681221

Please sign in to comment.