Skip to content

Commit

Permalink
review: submit a new account with metadata filled
Browse files Browse the repository at this point in the history
Signed-off-by: Shunkichi Sato <[email protected]>
  • Loading branch information
s8sato committed Nov 6, 2024
1 parent bdd2a09 commit 255782e
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions crates/iroha_executor/src/default/custom/multisig/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,27 @@ impl VisitExecute for MultisigRegister {
fn execute<V: Execute + Visit + ?Sized>(self, executor: &mut V) -> Result<(), ValidationFail> {
let host = executor.host();
let registrant = executor.context().authority.clone();
let multisig_account = self.account;
let multisig_role = multisig_role_for(&multisig_account);
let multisig_role = multisig_role_for(&self.account);
let multisig_account = {
let metadata = [
(SIGNATORIES.parse().unwrap(), Json::new(&self.signatories)),
(QUORUM.parse().unwrap(), Json::new(self.quorum)),
(
TRANSACTION_TTL_MS.parse().unwrap(),
Json::new(self.transaction_ttl_ms),
),
]
.into_iter()
.fold(Metadata::default(), |mut acc, (k, v)| {
acc.insert(k, v).unwrap();
acc
});
Account::new(self.account.clone()).with_metadata(metadata)
};

host.submit(&Register::account(Account::new(multisig_account.clone())))
host.submit(&Register::account(multisig_account))
.dbg_expect("registrant should successfully register a multisig account");

host.submit(&SetKeyValue::account(
multisig_account.clone(),
SIGNATORIES.parse().unwrap(),
Json::new(&self.signatories),
))
.dbg_unwrap();

host.submit(&SetKeyValue::account(
multisig_account.clone(),
QUORUM.parse().unwrap(),
Json::new(&self.quorum),
))
.dbg_unwrap();

host.submit(&SetKeyValue::account(
multisig_account.clone(),
TRANSACTION_TTL_MS.parse().unwrap(),
Json::new(&self.transaction_ttl_ms),
))
.dbg_unwrap();

host.submit(&Register::role(
// Temporarily grant a multisig role to the registrant to delegate the role to the signatories
Role::new(multisig_role.clone(), registrant.clone()),
Expand Down

0 comments on commit 255782e

Please sign in to comment.