Skip to content

Commit 061118b

Browse files
0o-de-lallyLucietta LeLegatoPaoletta Saint FortissimoChiaretta FortissimoMontague Von Wren
authored andcommitted
[txs] better error messages on txs that need auth (#407)
Co-authored-by: Lucietta LeLegato <[email protected]> Co-authored-by: Paoletta Saint Fortissimo <[email protected]> Co-authored-by: Chiaretta Fortissimo <[email protected]> Co-authored-by: Montague Von Wren <[email protected]> Co-authored-by: Caro Polecat <[email protected]> Co-authored-by: Peregrine De Beaver <[email protected]> Co-authored-by: Algernon di Leveret <[email protected]>
1 parent 3bbec82 commit 061118b

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

framework/libra-framework/sources/coin.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ module diem_framework::coin {
552552
// NOTE 0L: Locking down transfers so that only system contracts can use this
553553
// to enforce transfer limits on higher order contracts.
554554
/// Transfers `amount` of coins `CoinType` from `from` to `to`.
555-
public(friend) entry fun transfer<CoinType>(
555+
public(friend) fun transfer<CoinType>(
556556
from: &signer,
557557
to: address,
558558
amount: u64,

framework/libra-framework/sources/ol_sources/activity.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module ol_framework::activity {
9797
}
9898
}
9999

100-
fun assert_initialized(user: address) {
100+
public fun assert_initialized(user: address) {
101101
// check malformed accounts with microsecs
102102
assert!(exists<Activity>(user), error::invalid_state(EACCOUNT_NOT_MIGRATED));
103103
}

framework/libra-framework/sources/ol_sources/community_wallet_init.move

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module ol_framework::community_wallet_init {
1414
use ol_framework::match_index;
1515
use ol_framework::community_wallet;
1616
use ol_framework::community_wallet_advance;
17+
use ol_framework::reauthorization;
1718

1819

1920
#[test_only]
@@ -71,11 +72,14 @@ module ol_framework::community_wallet_init {
7172
initial_authorities: vector<address>,
7273
check_threshold: u64,
7374
) {
75+
let signer_addr = signer::address_of(sig);
76+
reauthorization::assert_v8_authorized(signer_addr);
77+
7478
check_proposed_auths(initial_authorities, check_threshold);
7579

7680
donor_voice_txs::make_donor_voice(sig);
7781

78-
if (!donor_voice_txs::is_liquidate_to_match_index(signer::address_of(sig))) {
82+
if (!donor_voice_txs::is_liquidate_to_match_index(signer_addr)) {
7983
donor_voice_txs::set_liquidate_to_match_index(sig, true);
8084
};
8185
match_index::opt_into_match_index(sig);

framework/libra-framework/sources/ol_sources/donor_voice_txs.move

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,11 @@ module ol_framework::donor_voice_txs {
894894
let pro_rata_addresses = vector::empty<address>();
895895
let pro_rata_amounts = vector::empty<u64>();
896896

897+
// If there are no donations yet, return empty vectors
898+
if (all_time_donations == 0) {
899+
return (pro_rata_addresses, pro_rata_amounts)
900+
};
901+
897902
let i = 0;
898903
let len = vector::length(&donors);
899904
while (i < len) {
@@ -1005,6 +1010,8 @@ module ol_framework::donor_voice_txs {
10051010
description: vector<u8>,
10061011
advance_unlocked: bool,
10071012
) acquires TxSchedule {
1013+
reauthorization::assert_v8_authorized(signer::address_of(&auth));
1014+
10081015
donor_voice_reauth::assert_authorized(multisig_address);
10091016

10101017
let pay_is_slow = slow_wallet::is_slow(payee);
@@ -1031,6 +1038,8 @@ module ol_framework::donor_voice_txs {
10311038
/// by the tx_id.
10321039
/// Public entry function required for txs cli.
10331040
public entry fun propose_veto_tx(donor: &signer, multisig_address: address, tx_id: u64) acquires TxSchedule, Freeze{
1041+
reauthorization::assert_v8_authorized(signer::address_of(donor));
1042+
10341043
let guid = guid::create_id(multisig_address, tx_id);
10351044
// one thing is the id of the scheduled payment
10361045
// another ID is that of the veto proposal
@@ -1041,24 +1050,12 @@ module ol_framework::donor_voice_txs {
10411050
}
10421051
}
10431052

1044-
// /// A signer of the multisig can propose a payment
1045-
// /// Public entry function required for txs cli
1046-
// public entry fun propose_advance_tx(
1047-
// auth: signer,
1048-
// multisig_address: address,
1049-
// payee: address,
1050-
// value: u64,
1051-
// description: vector<u8>,
1052-
// ) {
1053-
// donor_voice_reauth::assert_authorized(multisig_address);
1054-
// propose_advance(&auth, multisig_address, payee, value, description);
1055-
// }
1056-
10571053
// REAUTH TXs
10581054

10591055
/// After proposed, subsequent donors can vote to reauth an account
10601056
/// Public entry function required for txs cli.
10611057
public entry fun vote_reauth_tx(donor: &signer, multisig_address: address) acquires TxSchedule {
1058+
reauthorization::assert_v8_authorized(signer::address_of(donor));
10621059
donor_voice_governance::assert_is_voter(donor, multisig_address);
10631060
let state = borrow_global<TxSchedule>(multisig_address);
10641061
let guid_cap = &state.guid_capability;
@@ -1075,10 +1072,14 @@ module ol_framework::donor_voice_txs {
10751072
/// A donor can propose the liquidation of a Donor Voice account
10761073
/// Public entry function required for txs cli.
10771074
public entry fun propose_liquidate_tx(donor: &signer, multisig_address: address) acquires TxSchedule {
1075+
reauthorization::assert_v8_authorized(signer::address_of(donor));
1076+
10781077
propose_liquidation(donor, multisig_address);
10791078
}
10801079
/// After proposed, subsequent voters call this to vote liquidation
10811080
public entry fun vote_liquidation_tx(donor: &signer, multisig_address: address) acquires Freeze {
1081+
reauthorization::assert_v8_authorized(signer::address_of(donor));
1082+
10821083
liquidation_handler(donor, multisig_address);
10831084
}
10841085

framework/libra-framework/sources/ol_sources/ol_account.move

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ module ol_framework::ol_account {
276276
public entry fun transfer(sender: &signer, to: address, amount: u64)
277277
acquires BurnTracker {
278278
let payer = signer::address_of(sender);
279+
reauthorization::assert_v8_authorized(payer);
279280

280281
// community wallets cannot use ol_transfer, they have a dedicated workflow
281282
assert!(!community_wallet::is_init(payer),

framework/libra-framework/sources/ol_sources/vouch_lib/vouch_txs.move

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ module ol_framework::vouch_txs {
55
use std::signer;
66
use diem_framework::stake;
77
use diem_framework::transaction_fee;
8+
use ol_framework::activity;
89
use ol_framework::founder;
910
use ol_framework::ol_account;
1011
use ol_framework::page_rank_lazy;
1112
use ol_framework::vouch;
1213
use ol_framework::vouch_limits;
1314

1415
public entry fun vouch_for(grantor: &signer, friend_account: address) {
16+
// better error message
17+
activity::assert_initialized(friend_account);
18+
19+
// You say you want a revolution
1520
let grantor_addr = signer::address_of(grantor);
1621
vouch_limits::assert_under_limit(grantor_addr, friend_account);
1722
page_rank_lazy::mark_as_stale(friend_account);
1823
vouch::vouch_for(grantor, friend_account);
1924
maybe_debit_validator_cost(grantor, friend_account);
2025
founder::maybe_set_friendly_founder(friend_account);
26+
// you better free your mind instead
2127
}
2228

2329
public entry fun revoke(grantor: &signer, friend_account: address) {

0 commit comments

Comments
 (0)