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,
salt,
unique,
initializer_args,
initializer='initializer',
alias=None,
max_fee_declare_impl=None,
max_fee_declare_proxy=None,
max_fee_deploy_proxy=None,
)
-
nre
- theNileRuntimeEnvironment
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 to0
. -
unique
- whether the account address should be taken into account for proxy address generation. Defaults toFalse
. -
alias
- Unique identifier for your proxy. Defaults toNone
. -
max_fee_declare_impl
- Maximum fee for declaring the implementation contract. Defaults toNone
. -
max_fee_declare_proxy
- Maximum fee for declaring the proxy contract. Defaults toNone
. -
max_fee_deploy_proxy
- Maximum fee for deploying the proxy contract. Defaults toNone
.
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
- theNileRuntimeEnvironment
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 toNone
. -
max_fee_upgrade_proxy
- Maximum fee for upgrading the proxy to the new implementation. Defaults toNone
.
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
- Install Poetry
- Clone this project.
- 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
- Install Poetry
- Clone https://github.com/OpenZeppelin/nile
- Clone this project.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nile_upgrades-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc2f4a1b51728d237e3f97b49597bb9ad69daf121ff21ffc1e016c74f1ef3e04 |
|
MD5 | fa8fe37046c1501ff1e81179112b6a44 |
|
BLAKE2b-256 | c465d1e1cda9514b718a2e62d173407c685637810ef8e49689e5a1e6b443d071 |