Skip to main content

Nile plugin to deploy and manage upgradeable smart contracts on StarkNet

Project description

OpenZeppelin Nile Upgrades

Plugin for Nile to deploy and manage upgradeable smart contracts on StarkNet.

⚠️ WARNING! ⚠️

This plugin does not currently validate contracts for upgrade safety (see issue 34). Review your contracts for upgrade safety before performing any deployments or upgrades.

⚠️ WARNING! ⚠️

This repo contains highly experimental code. Expect rapid iteration. Use at your own risk.

Installation

pip install nile-upgrades

Usage

Run the following functions from scripts with the NileRuntimeEnvironment.

deploy_proxy

Deploy an upgradeable proxy for an implementation contract.

Returns a Nile Transaction instance representing the proxy deployment.

async def deploy_proxy(
    nre,
    account,
    contract_name,
    initializer_args,
    initializer='initializer',
    salt=0,
    unique=True,
    alias=None,
    max_fee_declare_impl=None,
    max_fee_declare_proxy=None,
    max_fee_deploy_proxy=None,
)
  • nre - the NileRuntimeEnvironment object.

  • account - the Account to use.

  • contract_name - the name of the implementation contract.

  • initializer_args - array of arguments for the initializer function.

  • initializer - initializer function name. Defaults to 'initializer'.

  • salt - the salt for proxy address generation. Defaults to 0.

  • unique - whether the account address should be taken into account for proxy address generation. Defaults to True.

  • alias - Unique identifier for your proxy. Defaults to None.

  • max_fee_declare_impl - Maximum fee for declaring the implementation contract. Defaults to None.

  • max_fee_declare_proxy - Maximum fee for declaring the proxy contract. Defaults to None.

  • max_fee_deploy_proxy - Maximum fee for deploying the proxy contract. Defaults to None.

Example usage:

tx = await nre.deploy_proxy(nre, account, "my_contract_v1", 123, True, ["arg for initializer"])
tx_status, proxy_address, abi = await tx.execute(watch_mode="track")

upgrade_proxy

Upgrade a proxy to a different implementation contract.

Returns a Nile Transaction instance representing the upgrade operation.

async def upgrade_proxy(
    nre,
    account,
    proxy_address_or_alias,
    contract_name,
    max_fee_declare_impl=None,
    max_fee_upgrade_proxy=None,
)
  • nre - the NileRuntimeEnvironment object.

  • account - the Account to use.

  • proxy_address_or_alias - the proxy address or alias.

  • contract_name - the name of the implementation contract to upgrade to.

  • max_fee_declare_impl - Maximum fee for declaring the new implementation contract. Defaults to None.

  • max_fee_upgrade_proxy - Maximum fee for upgrading the proxy to the new implementation. Defaults to None.

Example usage:

tx = await nre.upgrade_proxy(nre, account, proxy_address, "my_contract_v2")
tx_status = await tx.execute(watch_mode="track")

Contribute

Setup

Using the latest Nile release supported by this plugin

  1. Install Poetry
  2. Clone this project.
  3. From this project's root, create a virtualenv, activate it, and install dependencies:
python3.9 -m venv env
source env/bin/activate
pip install -U pip setuptools
poetry install
pip install -e .
poetry run compile

or

Using current Nile source code

  1. Install Poetry
  2. Clone https://github.com/OpenZeppelin/nile
  3. Clone this project.
  4. From this project's root, create a virtualenv, activate it, and install dependencies:
python3.9 -m venv env
source env/bin/activate
pip install -U pip setuptools
poetry install
pip install -e <your_path_to_nile_repo_from_step_2>
pip install -e .
poetry run compile

Testing

poetry run pytest tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nile_upgrades-0.0.3.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

nile_upgrades-0.0.3-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file nile_upgrades-0.0.3.tar.gz.

File metadata

  • Download URL: nile_upgrades-0.0.3.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.15 Darwin/21.6.0

File hashes

Hashes for nile_upgrades-0.0.3.tar.gz
Algorithm Hash digest
SHA256 32a8ec85a5b6495f8c4a64457ae2c420e1b2554e398e3c13deb4123994dcd1e3
MD5 7975274a224973aabd7c50b163d65d34
BLAKE2b-256 3a97ad29cf53f4b6f08375e76c4067a44f0e839dbb64e5a30e34884276c486f7

See more details on using hashes here.

File details

Details for the file nile_upgrades-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nile_upgrades-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.15 Darwin/21.6.0

File hashes

Hashes for nile_upgrades-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ecf5dc60e1f3018dd87b4379793c1af6157ad62e9778e91145b423c65b74e8e4
MD5 2000fc6a62a12b4511b1268501fc3d70
BLAKE2b-256 1431f948d9436a63af864db7b27b76058717e0ce5383baba526de5685008e7d2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page