From c3270ca73e20b7c5502fbc0d62c824b877727500 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Wed, 9 Apr 2025 23:09:16 +0200 Subject: [PATCH] Remove unneeded --- rust/upgradable-v1/Cargo.toml | 25 ----------------- rust/upgradable-v1/README.md | 17 ------------ rust/upgradable-v1/src/lib.rs | 51 ----------------------------------- 3 files changed, 93 deletions(-) delete mode 100644 rust/upgradable-v1/Cargo.toml delete mode 100644 rust/upgradable-v1/README.md delete mode 100644 rust/upgradable-v1/src/lib.rs diff --git a/rust/upgradable-v1/Cargo.toml b/rust/upgradable-v1/Cargo.toml deleted file mode 100644 index 5697ffc..0000000 --- a/rust/upgradable-v1/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "todo-upgradable-v1" -readme = "README.md" -version.workspace = true -description.workspace = true -homepage.workspace = true -repository.workspace = true -documentation.workspace = true -edition.workspace = true -license.workspace = true - -[lib] -crate-type = ['rlib', 'cdylib'] - -[dependencies] -pbc_contract_common.workspace = true -pbc_traits.workspace = true -pbc_lib.workspace = true -read_write_rpc_derive.workspace = true -read_write_state_derive.workspace = true -create_type_spec_derive.workspace = true -pbc_contract_codegen.workspace = true - -[features] -abi = ["pbc_contract_common/abi", "pbc_contract_codegen/abi", "pbc_traits/abi", "create_type_spec_derive/abi", "pbc_lib/abi"] diff --git a/rust/upgradable-v1/README.md b/rust/upgradable-v1/README.md deleted file mode 100644 index a7d191d..0000000 --- a/rust/upgradable-v1/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Upgradable v1 - -The simplest possible upgradable example contract that retains some amount of -security and usability. - -The [`UpgradableV1State`] contains the address of the account or contract that is -allowed to upgrade this contract. - -Contract can only be upgraded to a different contract, it cannot be upgraded to -itself, or from any other kind of contract. - -## About upgrade governance - -This contract is an example, and does not reflect what good upgrade logic for a -contract should look like. Please read documentation page for [upgradable smart -contracts](https://partisiablockchain.gitlab.io/documentation/smart-contracts/upgradable-smart-contracts.html) -for suggestion of how to implement the upgrade governance. diff --git a/rust/upgradable-v1/src/lib.rs b/rust/upgradable-v1/src/lib.rs deleted file mode 100644 index 82b3c03..0000000 --- a/rust/upgradable-v1/src/lib.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![doc = include_str!("../README.md")] - -#[macro_use] -extern crate pbc_contract_codegen; -use pbc_contract_codegen::{init, state, upgrade_is_allowed}; - -use pbc_contract_common::address::Address; -use pbc_contract_common::context::ContractContext; -use pbc_contract_common::upgrade::ContractHashes; - -/// Contract state. -#[state] -pub struct ContractState { - /// Contract or account allowed to upgrade this contract. - upgrader: Address, - /// Counter to demonstrate changes in behaviour - counter: u32, -} - -/// Initialize contract with the upgrader address. -#[init] -pub fn initialize(_ctx: ContractContext, upgrader: Address) -> ContractState { - ContractState { - counter: 0, - upgrader, - } -} - -/// Checks whether the upgrade is allowed. -/// -/// This contract allows the [`ContractState::upgrader`] to upgrade the contract at any time. -#[upgrade_is_allowed] -pub fn is_upgrade_allowed( - context: ContractContext, - state: ContractState, - _old_contract_hashes: ContractHashes, - _new_contract_hashes: ContractHashes, - _new_contract_rpc: Vec, -) -> bool { - context.sender == state.upgrader -} - -/// Increment the counter by one. -#[action(shortname = 0x01)] -pub fn increment_counter_by_one( - _context: ContractContext, - mut state: ContractState, -) -> ContractState { - state.counter += 1; - state -}