Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Add multisig governance tooling, docs #8346

Merged
merged 8 commits into from May 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

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

8 changes: 3 additions & 5 deletions aptos-move/move-examples/cli_args/Move.toml
Expand Up @@ -4,9 +4,7 @@ version = "0.1.0"
upgrade_policy = "compatible"

[addresses]
deploy_address = "_"
std = "0x1"
aptos_framework = "0x1"
test_account = "_"

[dependencies]
AptosFramework = { local = "../../framework/aptos-framework" }
[dependencies.AptosFramework]
local = "../../framework/aptos-framework"
30 changes: 30 additions & 0 deletions aptos-move/move-examples/cli_args/entry_function_arguments.json
@@ -0,0 +1,30 @@
{
alnoki marked this conversation as resolved.
Show resolved Hide resolved
"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 aptos-move/move-examples/cli_args/script_function_arguments.json
@@ -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"
}
]
}
20 changes: 20 additions & 0 deletions aptos-move/move-examples/cli_args/scripts/set_vals.move
@@ -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);
alnoki marked this conversation as resolved.
Show resolved Hide resolved
let addr_vec_vec = vector[vector[address_solo]];
cli_args::set_vals<T1, T2>(account, u8_solo, bool_vec, addr_vec_vec);
}
} // <:!:script
71 changes: 49 additions & 22 deletions aptos-move/move-examples/cli_args/sources/cli_args.move
@@ -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 aptos-move/move-examples/cli_args/view_function_arguments.json
@@ -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>"
}
]
}
8 changes: 8 additions & 0 deletions crates/aptos/CHANGELOG.md
Expand Up @@ -2,6 +2,14 @@

All notable changes to the Aptos CLI will be captured in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format set out by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.14] - 2023/05/25

### Added
- Recursive nested vector parsing
- Multisig v2 governance support
- JSON support for both input files and CLI argument input
- **Breaking change**: You can no longer pass in a vector like this: `--arg vector<address>:0x1,0x2`, you must do it like this: `--arg 'address:["0x1", "0x2"]'`
alnoki marked this conversation as resolved.
Show resolved Hide resolved

## [1.0.13] - 2023/04/27
### Fixed
* Previously `--skip-fetch-latest-git-deps` would not actually do anything when used with `aptos move test`. This has been fixed.
Expand Down
3 changes: 2 additions & 1 deletion crates/aptos/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "aptos"
description = "Aptos tool for management of nodes and interacting with the blockchain"
version = "1.0.13"
version = "1.0.14"

# Workspace inherited keys
authors = { workspace = true }
Expand Down Expand Up @@ -69,6 +69,7 @@ move-prover-boogie-backend = { workspace = true }
move-symbol-pool = { workspace = true }
move-unit-test = { workspace = true, features = [ "debugging" ] }
move-vm-runtime = { workspace = true, features = [ "testing" ] }
once_cell = { workspace = true }
rand = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/aptos/src/account/mod.rs
Expand Up @@ -52,7 +52,9 @@ pub enum MultisigAccountTool {
CreateTransaction(multisig_account::CreateTransaction),
Execute(multisig_account::Execute),
ExecuteReject(multisig_account::ExecuteReject),
ExecuteWithPayload(multisig_account::ExecuteWithPayload),
Reject(multisig_account::Reject),
VerifyProposal(multisig_account::VerifyProposal),
}

impl MultisigAccountTool {
Expand All @@ -63,7 +65,9 @@ impl MultisigAccountTool {
MultisigAccountTool::CreateTransaction(tool) => tool.execute_serialized().await,
MultisigAccountTool::Execute(tool) => tool.execute_serialized().await,
MultisigAccountTool::ExecuteReject(tool) => tool.execute_serialized().await,
MultisigAccountTool::ExecuteWithPayload(tool) => tool.execute_serialized().await,
MultisigAccountTool::Reject(tool) => tool.execute_serialized().await,
MultisigAccountTool::VerifyProposal(tool) => tool.execute_serialized().await,
}
}
}