forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warning about using zero address as ownership in SwayBook (FuelLabs#2127
) * Add warning about BASE_ASSET_ID and write example ownership contract * Typos * Run forc fmt * Update docs/src/blockchain-development/access_control.md Co-authored-by: John Adler <[email protected]> * Update docs/src/blockchain-development/access_control.md Co-authored-by: John Adler <[email protected]> * Update to account for BASE_ASSET_ID now to be a ContractID and refer to the zero address in general * Typo * Commit suggestions * Update docs/src/blockchain-development/access_control.md Co-authored-by: John Adler <[email protected]> Co-authored-by: John Adler <[email protected]> Co-authored-by: Mohammad Fawaz <[email protected]>
- Loading branch information
1 parent
bffa13c
commit 02c010c
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-636C01A16D569E34' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'ownership' | ||
source = 'root' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-636C01A16D569E34' | ||
dependencies = ['core'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "ownership" | ||
|
||
[dependencies] | ||
std = { path = "../../sway-lib-std" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
contract; | ||
|
||
use std::{identity::Identity, option::Option}; | ||
|
||
abi OwnershipExample { | ||
#[storage(write)]fn revoke_ownership(); | ||
#[storage(write)]fn set_owner(identity: Identity); | ||
#[storage(read)]fn owner() -> Option<Identity>; | ||
} | ||
|
||
storage { | ||
owner: Option<Identity>, | ||
} | ||
|
||
impl OwnershipExample for Contract { | ||
// ANCHOR: revoke_owner_example | ||
#[storage(write)]fn revoke_ownership() { | ||
storage.owner = Option::None(); | ||
} | ||
// ANCHOR_END: revoke_owner_example | ||
|
||
// ANCHOR: set_owner_example | ||
#[storage(write)]fn set_owner(identity: Identity) { | ||
storage.owner = Option::Some(identity); | ||
} | ||
// ANCHOR_END: set_owner_example | ||
|
||
#[storage(read)]fn owner() -> Option<Identity> { | ||
storage.owner | ||
} | ||
} |