Skip to content

Commit

Permalink
feat(ownable): implement trait
Browse files Browse the repository at this point in the history
An attepmt of re-implementing `Ownable.sol` from the Open Zeppelin directly in ink!
  • Loading branch information
tk-o committed Jul 17, 2021
1 parent 82f0f17 commit 02ae5f4
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 232 deletions.
2 changes: 2 additions & 0 deletions .idea/with-rust.iml

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

48 changes: 27 additions & 21 deletions .idea/workspace.xml

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

40 changes: 0 additions & 40 deletions smart-contracts/contracts/controller/Cargo.toml

This file was deleted.

34 changes: 0 additions & 34 deletions smart-contracts/contracts/controller/src/lib.rs

This file was deleted.

44 changes: 0 additions & 44 deletions smart-contracts/contracts/proxy/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions smart-contracts/contracts/proxy/src/lib.rs

This file was deleted.

9 changes: 9 additions & 0 deletions smart-contracts/contracts/tko_interfaces/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore build artifacts from the local tests sub-crate.
/target/

# Ignore backup files creates by cargo fmt.
**/*.rs.bk

# Remove Cargo.lock when creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock
35 changes: 35 additions & 0 deletions smart-contracts/contracts/tko_interfaces/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "tko_interfaces"
version = "0.1.0"
authors = ["[your_name] <[your_email]>"]
edition = "2018"

[dependencies]
ink_primitives = { version = "3.0.0-rc3", default-features = false }
ink_metadata = { version = "3.0.0-rc3", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc3", default-features = false }
ink_storage = { version = "3.0.0-rc3", default-features = false }
ink_lang = { version = "3.0.0-rc3", default-features = false }

scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6.0", default-features = false, features = ["derive"], optional = true }

[lib]
name = "tko_interfaces"
path = "lib.rs"
crate-type = [
# Used for normal contract Wasm blobs.
"cdylib",
]

[features]
default = ["std"]
std = [
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_primitives/std",
"scale/std",
"scale-info/std",
]
ink-as-dependency = []
36 changes: 36 additions & 0 deletions smart-contracts/contracts/tko_interfaces/access.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use ink_lang as ink;
use ink_env::AccountId;

#[ink::trait_definition]
pub trait IsOwnable {
// fn initialize(&mut self);
//
// #[ink(message)]
// fn owner(&self) -> Option<Address>;
//
// #[ink(message)]
// fn renounce_ownership(&mut self) {
// self._only_owner();
// self._set_owner(None);
// }
//
// #[ink(message)]
// fn transfer_ownership(&mut self, new_owner: Address) {
// self._only_owner();
// self._set_owner(Some(new_owner));
// }

/// Tells if the message sender is the owner
#[ink(message)]
fn owner(&self) -> AccountId;
// fn _only_owner(&self) {
// match self.owner() {
// Some(owner) => assert!(owner == self.message_sender(), "Ownable: caller is not the owner"),
// None => panic!("Ownable: caller is not the owner")
// }
// }
//
// fn _set_owner(&mut self, new_owner: Option<Address>);

// fn _message_sender(&self) -> Address;
}
1 change: 1 addition & 0 deletions smart-contracts/contracts/tko_interfaces/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod access;
Loading

0 comments on commit 02ae5f4

Please sign in to comment.