Skip to content

Commit

Permalink
fix: increment sequence number of owner after creating multisig acc (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
supra-yoga authored Oct 17, 2024
1 parent e06c18c commit cc1075b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
39 changes: 25 additions & 14 deletions aptos-move/framework/supra-framework/sources/genesis.move
Original file line number Diff line number Diff line change
Expand Up @@ -257,36 +257,47 @@ module supra_framework::genesis {
}


fun create_multiple_multisig_accounts_with_schema(supra_framework: &signer,
owner: address, additional_owners: vector<address>,num_signatures_required:u64,metadata_keys:vector<String>,metadata_values:vector<vector<u8>>,
timeout_duration:u64, balance:u64, num_of_accounts: u32): vector<address> {

fun create_multiple_multisig_accounts_with_schema(
supra_framework: &signer,
owner: address,
additional_owners: vector<address>,
num_signatures_required:u64,
metadata_keys:vector<String>,
metadata_values:vector<vector<u8>>,
timeout_duration:u64,
balance:u64,
num_of_accounts: u32
): vector<address> {
let counter = 0;
let result = vector::empty();
while (counter < num_of_accounts) {
let account_addr = create_multisig_account_with_balance(supra_framework, owner, additional_owners,
num_signatures_required,metadata_keys,metadata_values,timeout_duration,balance);
vector::push_back(&mut result,account_addr);
account::increment_sequence_number(owner);
counter = counter + 1;
};
result
}
fun create_multisig_account_with_balance(supra_framework: &signer, owner: address, additional_owners: vector<address>,
num_signatures_required:u64, metadata_keys: vector<String>,
metadata_values: vector<vector<u8>>, timeout_duration: u64, balance:u64 ) : address {


fun create_multisig_account_with_balance(
supra_framework: &signer,
owner: address,
additional_owners: vector<address>,
num_signatures_required:u64,
metadata_keys: vector<String>,
metadata_values: vector<vector<u8>>,
timeout_duration: u64,
balance:u64,
): address {
assert!(account::exists_at(owner),error::invalid_argument(EACCOUNT_DOES_NOT_EXIST));
assert!(vector::all(&additional_owners,|ao_addr|{account::exists_at(*ao_addr)}),error::invalid_argument(EACCOUNT_DOES_NOT_EXIST));
let addr = multisig_account::get_next_multisig_account_address(owner);
let owner_signer = create_signer(owner);
multisig_account::create_with_owners(&owner_signer,additional_owners,num_signatures_required,metadata_keys,metadata_values,timeout_duration);
supra_coin::mint(supra_framework,addr,balance);
addr

}

supra_coin::mint(supra_framework,addr,balance);
account::increment_sequence_number(owner);
addr
}

fun create_employee_validators(
employee_vesting_start: u64,
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ pub fn encode_genesis_change_set_for_testnet(

create_accounts(&mut session, accounts);

create_multisig_accounts_with_balance(&mut session, multisig_account);

if let Some(owner_group) = owner_group {
create_multiple_multisig_accounts_with_schema(&mut session, owner_group);
}

create_multisig_accounts_with_balance(&mut session, multisig_account);

if validators.len() > 0 {
create_and_initialize_validators(&mut session, validators);
} else {
Expand Down

0 comments on commit cc1075b

Please sign in to comment.