-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Labels
Description
Description
The current API hides the Storage object from the user, which might not be the desired for all use cases.
We need an API which takes a mut reference to an existing Storage object that is manually handled and uses this exclusively. The function to get the Storage object, should be customizable.
It should check and extend the Storage object if the size is to small.
Reasoning
I'm implementing nix on SUI/Walrus which stores nix flakes. These are package repositories, that consist of many blobs. The sui flake implements the permission which users can push new versions to the flake, but on the backend side, all blobs should end in the same Storage object, so they can be managed together and extended as fit.
public struct Flake has key, store {
id: UID,
name: String,
storage: Storage,
description: Option<String>,
project_url: Option<Url>,
source_url: Option<Url>,
/// List of public keys allowed
sign_keys: vector<String>,
// list to generations
generations: VecMap<u64, Generation>,
active_generation: u64,
next_generation: u64,
// permissions
uploaders: vector<address>,
}
/// Returns a reference to the storage resource
public fun get_storage(flake: &mut Flake, ctx: &mut TxContext): &Storage {
if !array::contains(&flake.uploaders, &ctx.sender()) {
assert!(false, EPermissionDenied);
}
&mut flake.storage
}
Code of Conduct
- I agree to follow this project's Code of Conduct.