fix(standards): reject faucets whose policies lack their required storage slots - #3527
fix(standards): reject faucets whose policies lack their required storage slots#3527onurinanc wants to merge 5 commits into
Conversation
| let account = NetworkAccount::builder(init_seed, note_allowlist, fee_policy_manager) | ||
| .expect("MintNote + BurnNote allowlist is non-empty") | ||
| .with_component(faucet) | ||
| .with_components(access_control) | ||
| .with_components(token_policy_manager) | ||
| .with_component(Pausable::unpaused()) | ||
| .with_component(PausableManager) | ||
| .build() | ||
| .map_err(NonFungibleFaucetError::AccountCreationFailed) | ||
| .map_err(NonFungibleFaucetError::AccountCreationFailed)?; | ||
|
|
||
| verify_policy_dependencies(&required_slots, account.storage())?; |
There was a problem hiding this comment.
A preliminary question: should this check be actually happening in the AccountBuilder? This would be a more general solution, but probably a bit more difficult to implement (or at least to design).
If we do decide to how this route, the way to implement this is to specify dependencies at the AccountComponentMetadata level. Then, the builder would be able to read dependencies of all components and verify that they are all satisfied.
I think the main complexity here would come from figuring out how to specify dependencies. The approach taken in this PR is to use just slot names. Maybe this is enough, but maybe we want to list actual components as dependencies too.
There was a problem hiding this comment.
That's a good idea. I've implemented this in this commit: c606f32.
However, I'm not sure about adding some part in the AccountComponentMetadata. So, it would be good if you can review @PhilippGackstatter. I'm also fine with rebasing this PR to the commit: d9944c0 delegating this part of the issue as it is more related to the miden-protocol
Closes: #3526