Remove unneeded
This commit is contained in:
parent
cdb9c0b6bc
commit
c3270ca73e
|
@ -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"]
|
|
|
@ -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.
|
|
|
@ -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<u8>,
|
|
||||||
) -> 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
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user