New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redprint-forge

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redprint-forge

A developer-friendly framework/library in solidity to modify & deploy OPStack ’s contracts in a modular style.

  • 0.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-40.62%
Maintainers
0
Weekly downloads
 
Created
Source

Keep Optimistic and be OPStack deployer!!

  • Installation
  • What is it for
  • Quickstart
  • Contributing
  • Acknowledgement

[!NOTE] You can find our alpha mvp and relevant examples here

[!WARNING] The code is not audited yet. Please use it carefully in production.

Installation

There are 2 ways: with Node.js and one Git Submodules

with Node

This is the recommended approach.

We assume that you already setup your working environment with hardhat + foundry as specified in foundry 's guide or hardhat 's guide and cd into it

cd my-project;
  1. Add the redprint-forge using your favorite package manager, e.g., with Yarn:
yarn add -D redprint-forge
  1. Adding remappings.txt with following line:
@redprint-core/=node_modules/redprint-forge/src
@redprint-deploy/=node_modules/redprint-forge/script
@redprint-test/=node_modules/test/
@redprint-forge-std/=node_modules/redprint-forge/lib/forge-std/src
@redprint-openzeppelin/=node_modules/redprint-forge/lib/openzeppelin-4_7_3/contracts
@redprint-openzeppelin-upgradeable/=node_modules/redprint-forge/lib/openzeppelin-upgradeable-4_7_3/contracts
@redprint-safe-contracts/=node_modules/redprint-forge/lib/safe-smart-account/contracts
@redprint-lib-keccak/=node_modules/redprint-forge/lib/lib-keccak/contracts/lib/
@redprint-solady/=node_modules/redprint-forge/lib/solady/src/

or use/modify it from Optimism' monorepo

forge install --no-git optimism-v1.9.4=ethereum-optimism/optimism@v1.9.4
@redprint-core/=lib/optimism-v1.9.4/packages/contracts-bedrock/src/
@redprint-deploy/=node_modules/redprint-forge/script
@redprint-test/=node_modules/redprint-forge/test/
@redprint-forge-std/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/forge-std/src
@redprint-openzeppelin/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/openzeppelin-contracts/contracts
@redprint-openzeppelin-upgradeable/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable/contracts
@redprint-safe-contracts/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/safe-contracts/contracts
@redprint-lib-keccak/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/lib-keccak/contracts/lib/
@redprint-solady/=lib/optimism-v1.9.4/packages/contracts-bedrock/lib/solady/src/

[!NOTE] All OPStack's contracts are based on v1.9.4

[!TIP] We use @redprint-/ as a convention to avoid any naming conflicts with your previously installed libararies ( i.e. @redprint-forge-std/ vs @forge-std/)

What Is It For

One of our Swiss army knife toolset: redprint-forge is a developer-friendly framework/library in solidity to modify & deploy OPStack ’s contracts in a modular style.

The features include:

  • Type-safe smart contract deployment

  • Re-usable smart contract deployment and testing pipeline

  • Standardized framework, minimizing developer mistake and enhancing better security

  • All-Solidity-based so no context switching, no new scripting syntax in other languages

  • Tx Management via Safe Smart Contract Deploy Script

Together with Redprint Wizard UI, which is a code generator/ interactive playground oriented for OPStack development, it does not only help novice developers to deploy OPStack's smart contracts to deploy on OP mainnet, but also help them to use generated deployment script in their own projects.

Quickstart

Tx Management Via Safe-Multisig

You can write solidity script, then execute it from command-line in order to make any smart contract calls, or send transactions from your own safe multi-sig wallet.

You can access both _upgradeAndCallViaSafe and _callViaSafe easily by inheriting and using from in redprint-forge module ’s parent contract SafeScript.

Call and Upgrade Proxy Contract

Let’s see a practical example when initializing one of OPStack's proxy contract ( eg. ProtocolVersions ) by calling _upgradeAndCallViaSafe:


/** ... */

// `redprint-forge` 's core engine
import { SafeScript} from "@redprint-deploy/safe-management/SafeScript.sol";

/** ... */

contract DeployAndInitializeProtocolVersionsScript is DeployScript, SafeScript {

    /** ... */

    function initializeProtocolVersions() public {
      console.log("Upgrading and initializing ProtocolVersions proxy");

      /** ... */

      address proxyAdmin = deployer.mustGetAddress("ProxyAdmin");
      address safe = deployer.mustGetAddress("SystemOwnerSafe");

      /** ... */

      _upgradeAndCallViaSafe({
          _proxyAdmin: proxyAdmin,
          _safe: safe,
          _owner: owner,
          _proxy: payable(protocolVersionsProxy),
          _implementation: protocolVersions,
          _innerCallData: abi.encodeCall(
              ProtocolVersions.initialize,
              (
                  finalSystemOwner,
                  ProtocolVersion.wrap(requiredProtocolVersion),
                  ProtocolVersion.wrap(recommendedProtocolVersion)
              )
          )
      });
      /** ... */
    }

}

[!NOTE] You can the see full example here: 03B_DeployAndInitializeProtocolVersions.s.sol

Call to Any Contract with arbitrary data

Let’s see another example at SafeScript itselfs. Our internal function just calls _callViaSafe:

/** ... */

abstract contract SafeScript {

  /** ... */

  function _upgradeAndCallViaSafe( address _owner, address _proxyAdmin, address _safe, address _proxy, address _implementation, bytes memory _innerCallData) internal {

      bytes memory data =
          abi.encodeCall(ProxyAdmin.upgradeAndCall, (payable(_proxy), _implementation, _innerCallData));

      Safe safe = Safe(payable(_safe));
      _callViaSafe({ _safe: safe, _owner: _owner, _target: _proxyAdmin, _data: data });
  }

  /** ... */

}

Contributing

We are currently still in an experimental phase leading up to a first audit and would love to hear your feedback on how we can improve Reprint.

If you want to say thank you or/and support active development of redprint-forge:

  • Add a GitHub Star to the project.
  • Tweet about redprint.
  • Write interesting articles about the project on Medium, or your personal blog.
  • Keep Optimistic !!

Acknowledgement

This project would not have been possible to build without the advanced iniatiative from opensource software including forge-deploy, so we are deeply thankful for their contributions in our web3 ecosystem.

If we’ve overlooked anyone, please open an issue so we can correct it. While we always aim to acknowledge the inspirations and code we utilize, mistakes can happen in a team setting, and a reference might unintentionally be missed.

Keywords

FAQs

Package last updated on 13 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc