An upgradable wrapper around the Polymesh Runtime API.
This allows contracts to use a stable API that can be updated to support each major Polymesh release.
The ./upgrade_tracker contract is an optional feature for easier
upgrades. It allows multiple contracts to use upgradable APIs
without having to have "admin" support in each contract.
Build the wrapped API contract.
Install cargo-contract.
cargo install cargo-contract --force
Build the contract:
cargo +nightly contract build --release
Contract file needed for upload ./target/ink/polymesh_ink.contract.
Example contract that uses the Polymesh Ink! API
Cargo.toml:
[]
= "example_contract"
= "1.0.0"
= ["<author>"]
= "2021"
= false
[]
= { = "3.0", = false }
= { = "3.0", = false }
= { = "3.0", = false, = ["derive"], = true }
= { = "3.0", = false }
= { = "3.0", = false }
= { = "3.0", = false }
= { = "3.0", = false }
= { = "parity-scale-codec", = "3", = false, = ["derive"] }
= { = "2", = false, = ["derive"], = true }
= { = "0.5.1", = "../../", = false, = ["as-library", "tracker", "always-delegate"] }
[]
= "example_contract"
= "lib.rs"
= ["cdylib"]
[]
= ["std"]
= [
"ink_primitives/std",
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_lang/std",
"scale/std",
"scale-info/std",
"polymesh-ink/std",
]
= []
lib.rs:
//! Example contract for upgradable `polymesh-ink` API.
extern crate alloc;
use ink_lang as ink;
use *;
Setup.
- (Optional) Build and deploy the upgrade tracker contract
./upgrade_tracker/. - Build and upload (don't deploy) the wrapped API contract
./target/ink/polymesh_ink.contract. - Build and deploy an example contract from
./examples/. Use the code hash from step #2 and the tracker contract address from step #1 if used.
Usable
The update_polymesh_ink or update_code_hash calls can be used to update the code hash for the Polymesh Ink! API.