Skip to content

Commit

Permalink
Add comment on feature flag. (#1589)
Browse files Browse the repository at this point in the history
* Add comment on feature flag.

* Bump version.

* Add rust-toolchain for reproducable builds.

* Update example contracts.
  • Loading branch information
Neopallium authored Feb 6, 2024
1 parent a45b4b6 commit 8fa312a
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 83 deletions.
2 changes: 1 addition & 1 deletion contracts/upgradeable-polymesh-ink/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion contracts/upgradeable-polymesh-ink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polymesh-ink"
version = "3.0.0"
version = "3.1.0"
authors = ["PolymeshAssociation"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -28,6 +28,8 @@ features = ["as-library"]

[features]
default = ["std"]

# Needs Polymesh >=6.2.0
use_call_runtime_with_error = ["polymesh-api-ink/use_call_runtime_with_error"]

# Compile as upgradable library.
Expand Down
23 changes: 12 additions & 11 deletions contracts/upgradeable-polymesh-ink/examples/simple/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink = { version = "4.3", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

polymesh-ink = { version = "3.0.0", path = "../../", default-features = false, features = ["as-library"] }
polymesh-ink = { version = "3.1.0", path = "../../", default-features = false, features = ["as-library"] }

[lib]
path = "lib.rs"
Expand Down
64 changes: 9 additions & 55 deletions contracts/upgradeable-polymesh-ink/examples/simple/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ pub mod test_polymesh_ink {
use crate::*;
use alloc::vec::Vec;

/// A simple proxy contract.
/// A simple test contract.
#[ink(storage)]
pub struct Proxy {
/// The `AccountId` of a privileged account that override the
/// code hash for `PolymeshInk`.
///
/// This address is set to the account that instantiated this contract.
admin: AccountId,
/// Upgradable Polymesh Ink API.
api: PolymeshInk,
pub struct SimpleTest {
}

/// The contract error types.
Expand All @@ -40,58 +33,18 @@ pub mod test_polymesh_ink {
/// The contract result type.
pub type Result<T> = core::result::Result<T, Error>;

impl Proxy {
impl SimpleTest {
/// Instantiate this contract with an address of the `logic` contract.
///
/// Sets the privileged account to the caller. Only this account may
/// later changed the `forward_to` address.
#[ink(constructor)]
pub fn new() -> Result<Self> {
Ok(Self {
admin: Self::env().caller(),
api: PolymeshInk::new()?,
})
}

/// Instantiate this contract with an address of the `logic` contract.
///
/// Sets the privileged account to the caller. Only this account may
/// later changed the `forward_to` address.
#[ink(constructor)]
pub fn new_with_hash(hash: Hash) -> Self {
Self {
admin: Self::env().caller(),
api: PolymeshInk::new_with_hash(hash),
}
}

/// Update the code hash of the polymesh runtime API.
///
/// Only the `admin` is allowed to call this.
#[ink(message)]
pub fn update_code_hash(&mut self, hash: Hash) {
assert_eq!(
self.env().caller(),
self.admin,
"caller {:?} does not have sufficient permissions, only {:?} does",
self.env().caller(),
self.admin,
);
self.api.update_code_hash(hash);
}

/// Update the `polymesh-ink` API using the tracker.
///
/// Anyone can pay the gas fees to do the update using the tracker.
#[ink(message)]
pub fn update_polymesh_ink(&mut self) -> Result<()> {
self.api.check_for_upgrade()?;
Ok(())
}

#[ink(message)]
pub fn system_remark(&mut self, remark: Vec<u8>) -> Result<()> {
self.api.system_remark(remark)?;
let api = PolymeshInk::new()?;
api.system_remark(remark)?;
Ok(())
}

Expand All @@ -107,8 +60,8 @@ pub mod test_polymesh_ink {

#[ink(message)]
pub fn create_venue(&mut self, details: Vec<u8>) -> Result<VenueId> {
Ok(self
.api
let api = PolymeshInk::new()?;
Ok(api
.create_venue(VenueDetails(details), VenueType::Other)?)
}

Expand All @@ -120,7 +73,8 @@ pub mod test_polymesh_ink {
ticker: Ticker,
amount: Balance,
) -> Result<()> {
self.api.asset_create_and_issue(
let api = PolymeshInk::new()?;
api.asset_create_and_issue(
AssetName(name),
ticker,
AssetType::EquityCommon,
Expand Down
5 changes: 5 additions & 0 deletions contracts/upgradeable-polymesh-ink/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "1.70.0"
targets = [ "wasm32-unknown-unknown" ]
components = [ "rustfmt", "rust-std", "rust-src" ]
profile = "minimal"
27 changes: 15 additions & 12 deletions contracts/wrapped-polyx/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions contracts/wrapped-polyx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wrapped-polyx"
version = "3.0.0"
version = "3.1.0"
authors = ["PolymeshAssociation"]
edition = "2021"
publish = false
Expand All @@ -11,7 +11,7 @@ ink = { version = "4.3", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

polymesh-ink = { version = "3.0.0", path = "../upgradeable-polymesh-ink/", default-features = false, features = ["as-library"] }
polymesh-ink = { version = "3.1.0", default-features = false, features = ["as-library"] }

[lib]
path = "lib.rs"
Expand Down
5 changes: 5 additions & 0 deletions contracts/wrapped-polyx/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "1.70.0"
targets = [ "wasm32-unknown-unknown" ]
components = [ "rustfmt", "rust-std", "rust-src" ]
profile = "minimal"

0 comments on commit 8fa312a

Please sign in to comment.