npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

upgradeable-proxy-plus

v1.1.3

Published

Extends https://github.com/CCEG-Blockchain-UN-Lab/upgradeable-proxy with Ownable super contract and utilizing safe policies for the upgrade mechanism.

Downloads

15

Readme

Upgradeable Proxy Plus

Based on upgradeable-proxy. More info here.

Features

  • Implements both upgradeable-proxy features at same time:
    • Upgrade safety and protection
      • Experimental safety features* were implemented to the upgradeable pattern to protect the contract from being accidentally or maliciousl upgraded to the wrong contract. A target contract for the SafeProxy must satisfy, at a minimum, the following conditions to be able to call Proxy.upgradeTo() to change the target:
        1. Must have a address target variable
        2. Must have a upgradeTo(address) public function
        3. Must have a transferOwnership(address) public function
    • Permissioned (Ownable) proxy upgrade
      • Ownable to allow the administrator of the proxy to be set as a multisig or DAO-like contract to provide distributed governance.
  • Inherits from upgradeable-proxy
    • 100% Upgradeable strategy
    • Comprehensive test suite

Note:

  • empty functions that do nothing will satisfy these conditions.
  • one of the safety features depends on the use of the EXTCODESIZE opcode which may not work after the Serenity hard fork.
  • carefully consider if these safety features are necessary, onced deployed they cannot be changed.

Instalation

npm install upgradeable-proxy-plus

Usage

Deploy Upgradeable CheckContract

Deploy Upgradeable CheckContract so that after Serenity hardfork, the method to check if an address is a contract can be upgraded. More information here

let checkContractInstance = await deployer.deploy(CheckContract);

Deploy CheckContract's Proxy.

Deploy a Proxy for the just deployed CheckContract.

let proxyInstance = await deployer.deploy(
  Proxy,
  checkContractInstance.address
);

Get CheckContract's instance by proxy

Get the instance of the CheckContract by proxy, and initialize.

let checkContractInstanceByProxy = CheckContract.at(proxyInstance.address);
await checkContractInstanceByProxy.initialize();

Make some tests

(OPTIONAL) Make some tests to make sure the method isContract called by proxy is properly working.

let testOne = await checkContractInstanceByProxy.isContract.call(
  checkContractInstanceByProxy.address
);
assert.equal(testOne, true);
let testTwo = await checkContractInstanceByProxy.isContract.call(
  "0x627306090abab3a6e1400e9345bc60c78a8bef57"
);
assert.equal(testTwo, false);

Deploy the UpgradeablePlus contract

let addressSimpleV1 = await deployer.deploy(AddressSimpleV1);

Deploy AddressSimpleV1's ProxyPlus

Deploy a ProxyPlus for the just deployed AddressSimpleV1Safe.

let proxyPlus = await ProxyPlus.new(
  addressSimpleV1.address,
  checkContractInstanceByProxy.address
);

Get AddressSimpleV1's instance by proxy

Get the instance of the AddressSimpleV1Safe by proxy, and initialize.

let addressSimpleV1byProxy = AddressSimpleV1.at(proxyPlus.address);
await addressSimpleV1byProxy.initialize();

Make some tests

(OPTIONAL) Make some tests to make sure the UpgradeablePlus contract called by proxy is properly working.

const inputValue = "0xa4532e9f6f9c4e4abb89bdbb73d3003210ede61c",
  inputValue2 = "0x5c28D962c93282C6Fbe820f9AB33844D96b4853e";
await addressSimpleV1byProxy.setValue(inputValue);
let value = await addressSimpleV1byProxy.getValue.call();
assert.equal(value, inputValue, "Not equal to inputValue");

let addressSimpleV2 = await deployer.deploy(AddressSimpleV2);
await addressSimpleV1byProxy.upgradeTo(addressSimpleV2.address);
await addressSimpleV1byProxy.initialize();
value = await addressSimpleV1byProxy.getValue.call();
assert.equal(value, inputValue, "Not equal to inputValue");

await addressSimpleV1byProxy.setValue(inputValue2);
value = await addressSimpleV1byProxy.getValue.call();
assert.equal(
  value,
  "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
  "Not equal to constant defined in function"
);

The full example was written inside migrations and is fully functional here.

How to import these library contracts?

Use the following strategy to import library contracts to your own contracts

import "upgradeable-proxy-plus/contracts/UpgradeablePlus.sol";