-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into xiangyi/versioned_contract
- Loading branch information
Showing
18 changed files
with
501 additions
and
158 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use near_workspaces::{result::ExecutionFinalResult, Account, AccountId}; | ||
|
||
pub async fn vote_join( | ||
accounts: Vec<Account>, | ||
mpc_contract: &AccountId, | ||
account_id: &AccountId, | ||
) -> anyhow::Result<()> { | ||
let vote_futures = accounts | ||
.iter() | ||
.map(|account| { | ||
tracing::info!( | ||
"{} voting for new participant: {}", | ||
account.id(), | ||
account_id | ||
); | ||
account | ||
.call(mpc_contract, "vote_join") | ||
.args_json(serde_json::json!({ | ||
"candidate_account_id": account_id | ||
})) | ||
.transact() | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
futures::future::join_all(vote_futures) | ||
.await | ||
.iter() | ||
.for_each(|result| { | ||
assert!(result.as_ref().unwrap().failures().is_empty()); | ||
}); | ||
|
||
Ok(()) | ||
} | ||
|
||
pub async fn vote_leave( | ||
accounts: Vec<Account>, | ||
mpc_contract: &AccountId, | ||
account_id: &AccountId, | ||
) -> Vec<Result<ExecutionFinalResult, near_workspaces::error::Error>> { | ||
let vote_futures = accounts | ||
.iter() | ||
.filter(|account| account.id() != account_id) | ||
.map(|account| { | ||
account | ||
.call(mpc_contract, "vote_leave") | ||
.args_json(serde_json::json!({ | ||
"kick": account_id | ||
})) | ||
.transact() | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
futures::future::join_all(vote_futures).await | ||
} |
Oops, something went wrong.