-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finishing the resource account tutorial with kevin's package manager,…
… explanation of it and features, and separating the guide into 3 sections. Updated unit test.
- Loading branch information
Showing
13 changed files
with
313 additions
and
234 deletions.
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
12 changes: 12 additions & 0 deletions
12
aptos-move/move-examples/upgradeable_resource_account_package/Move.toml
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,12 @@ | ||
[package] | ||
name = "Upgradeable Module With Resource Account" | ||
version = "0.0.0" | ||
upgrade_policy = "compatible" | ||
|
||
[addresses] | ||
aptos_framework = "0x1" | ||
deployer = "_" | ||
upgradeable_resource_account_package = "_" | ||
|
||
[dependencies] | ||
AptosFramework = { local = "../../framework/aptos-framework" } |
33 changes: 33 additions & 0 deletions
33
aptos-move/move-examples/upgradeable_resource_account_package/sources/basic_contract.move
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,33 @@ | ||
module upgradeable_resource_account_package::basic_contract { | ||
use upgradeable_resource_account_package::package_manager; | ||
use std::error; | ||
use std::signer; | ||
|
||
struct SomeResource has key { | ||
value: u64, | ||
} | ||
|
||
/// You are not authorized to perform this action. | ||
const ENOT_AUTHORIZED: u64 = 0; | ||
|
||
#[view] | ||
public fun upgradeable_function(): u64 { | ||
9000 | ||
} | ||
|
||
// An example of doing something with the resource account that requires its signer | ||
public entry fun move_to_resource_account(deployer: &signer) { | ||
// Only the deployer can call this function. | ||
assert!(signer::address_of(deployer) == @deployer, error::permission_denied(ENOT_AUTHORIZED)); | ||
|
||
// Do something with the resource account's signer | ||
// For example, a simple `move_to` call | ||
let resource_signer = package_manager::get_signer(); | ||
move_to( | ||
&resource_signer, | ||
SomeResource { | ||
value: 42, | ||
} | ||
); | ||
} | ||
} |
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
File renamed without changes.
12 changes: 0 additions & 12 deletions
12
aptos-move/move-examples/upgradeable_resource_contract/Move.toml
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
aptos-move/move-examples/upgradeable_resource_contract/sources/basic_contract.move
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.