Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLI] Add multisig governance tooling, docs (#8346)
- Loading branch information
Showing
20 changed files
with
1,947 additions
and
279 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
30 changes: 30 additions & 0 deletions
30
aptos-move/move-examples/cli_args/entry_function_arguments.json
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,30 @@ | ||
{ | ||
"function_id": "<test_account>::cli_args::set_vals", | ||
"type_args": [ | ||
"0x1::account::Account", | ||
"0x1::chain_id::ChainId" | ||
], | ||
"args": [ | ||
{ | ||
"type": "u8", | ||
"value": 123 | ||
}, | ||
{ | ||
"type": "bool", | ||
"value": [false, true, false, false] | ||
}, | ||
{ | ||
"type": "address", | ||
"value": [ | ||
[ | ||
"0xace", | ||
"0xbee" | ||
], | ||
[ | ||
"0xcad" | ||
], | ||
[] | ||
] | ||
} | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
aptos-move/move-examples/cli_args/script_function_arguments.json
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,20 @@ | ||
{ | ||
"type_args": [ | ||
"0x1::account::Account", | ||
"0x1::chain_id::ChainId" | ||
], | ||
"args": [ | ||
{ | ||
"type": "u8", | ||
"value": 123 | ||
}, | ||
{ | ||
"type": "u8", | ||
"value": [122, 123, 124, 125] | ||
}, | ||
{ | ||
"type": "address", | ||
"value": "0xace" | ||
} | ||
] | ||
} |
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,20 @@ | ||
// :!:>script | ||
script { | ||
use test_account::cli_args; | ||
use std::vector; | ||
|
||
/// Get a `bool` vector where each element indicates `true` if the | ||
/// corresponding element in `u8_vec` is greater than `u8_solo`. | ||
/// Then pack `address_solo` in a `vector<vector<<address>>` and | ||
/// pass resulting argument set to public entry function. | ||
fun set_vals<T1, T2>( | ||
account: signer, | ||
u8_solo: u8, | ||
u8_vec: vector<u8>, | ||
address_solo: address, | ||
) { | ||
let bool_vec = vector::map_ref(&u8_vec, |e_ref| *e_ref > u8_solo); | ||
let addr_vec_vec = vector[vector[address_solo]]; | ||
cli_args::set_vals<T1, T2>(account, u8_solo, bool_vec, addr_vec_vec); | ||
} | ||
} // <:!:script |
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 |
---|---|---|
@@ -1,37 +1,64 @@ | ||
module deploy_address::cli_args { | ||
// :!:>resource | ||
module test_account::cli_args { | ||
use std::signer; | ||
use aptos_std::type_info::{Self, TypeInfo}; | ||
|
||
struct Holder has key { | ||
|
||
struct Holder has key, drop { | ||
u8_solo: u8, | ||
bool_vec: vector<bool>, | ||
address_vec_vec: vector<vector<address>>, | ||
} | ||
type_info_1: TypeInfo, | ||
type_info_2: TypeInfo, | ||
} //<:!:resource | ||
|
||
|
||
#[view] | ||
public fun reveal(host: address): (u8, vector<bool>, vector<vector<address>>) acquires Holder { | ||
let holder_ref = borrow_global<Holder>(host); | ||
(holder_ref.u8_solo, holder_ref.bool_vec, holder_ref.address_vec_vec) | ||
} | ||
|
||
public entry fun set_vals( | ||
// :!:>setter | ||
/// Set values in a `Holder` under `account`. | ||
public entry fun set_vals<T1, T2>( | ||
account: signer, | ||
u8_solo: u8, | ||
bool_vec: vector<bool>, | ||
address_vec_vec: vector<vector<address>>, | ||
) acquires Holder { | ||
let account_addr = signer::address_of(&account); | ||
if (!exists<Holder>(account_addr)) { | ||
move_to(&account, Holder { | ||
u8_solo, | ||
bool_vec, | ||
address_vec_vec, | ||
}) | ||
} else { | ||
let old_holder = borrow_global_mut<Holder>(account_addr); | ||
old_holder.u8_solo = u8_solo; | ||
old_holder.bool_vec = bool_vec; | ||
old_holder.address_vec_vec = address_vec_vec; | ||
if (exists<Holder>(account_addr)) { | ||
move_from<Holder>(account_addr); | ||
}; | ||
move_to(&account, Holder { | ||
u8_solo, | ||
bool_vec, | ||
address_vec_vec, | ||
type_info_1: type_info::type_of<T1>(), | ||
type_info_2: type_info::type_of<T2>(), | ||
}); | ||
} //<:!:setter | ||
|
||
// :!:>view | ||
struct RevealResult has drop { | ||
u8_solo: u8, | ||
bool_vec: vector<bool>, | ||
address_vec_vec: vector<vector<address>>, | ||
type_info_1_match: bool, | ||
type_info_2_match: bool | ||
} | ||
|
||
#[view] | ||
/// Pack into a `RevealResult` the first three fields in host's | ||
/// `Holder`, as well as two `bool` flags denoting if `T1` & `T2` | ||
/// respectively match `Holder.type_info_1` & `Holder.type_info_2`, | ||
/// then return the `RevealResult`. | ||
public fun reveal<T1, T2>(host: address): RevealResult acquires Holder { | ||
let holder_ref = borrow_global<Holder>(host); | ||
RevealResult { | ||
u8_solo: holder_ref.u8_solo, | ||
bool_vec: holder_ref.bool_vec, | ||
address_vec_vec: holder_ref.address_vec_vec, | ||
type_info_1_match: | ||
type_info::type_of<T1>() == holder_ref.type_info_1, | ||
type_info_2_match: | ||
type_info::type_of<T2>() == holder_ref.type_info_2 | ||
} | ||
} | ||
} | ||
|
||
} //<:!:view |
13 changes: 13 additions & 0 deletions
13
aptos-move/move-examples/cli_args/view_function_arguments.json
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,13 @@ | ||
{ | ||
"function_id": "<test_account>::cli_args::reveal", | ||
"type_args": [ | ||
"0x1::account::Account", | ||
"0x1::account::Account" | ||
], | ||
"args": [ | ||
{ | ||
"type": "address", | ||
"value": "<test_account>" | ||
} | ||
] | ||
} |
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
Oops, something went wrong.