Skip to content

Commit

Permalink
feat: add entry for plugin marketplace (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
yubing744 committed Nov 9, 2022
1 parent 40178bb commit 459ce12
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
44 changes: 44 additions & 0 deletions sources/daospace/DAOExtensionPoint.move
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ module StarcoinFramework::DAOExtensionPoint {
);
}

public fun has_star_plugin<ExtPointT>(sender: &signer): bool {
let sender_addr = Signer::address_of(sender);
return exists<Star<ExtPointT>>(sender_addr)
}

public fun star<ExtPointT>(sender: &signer) acquires Entry, ExtensionPointEventHandlers {
let sender_addr = Signer::address_of(sender);
assert!(!exists<Star<ExtPointT>>(sender_addr), Errors::invalid_state(ERR_STAR_ALREADY_STARED));
Expand Down Expand Up @@ -390,4 +395,43 @@ module StarcoinFramework::DAOExtensionPoint {
},
);
}

// public entrys
public(script) fun register_entry<ExtPointT: store>(sender: signer, name: vector<u8>, description: vector<u8>, types_d_ts:vector<u8>, dts_doc:vector<u8>,
labels: vector<vector<u8>>) acquires Registry, NFTMintCapHolder, RegistryEventHandlers {
let option_labels = if(Vector::length(&labels) == 0){
Option::none<vector<vector<u8>>>()
} else {
Option::some(labels)
};

register<ExtPointT>(&sender, name, description, types_d_ts, dts_doc, option_labels);
}

public(script) fun publish_version_entry<ExtPointT: store>(
sender: signer,
tag: vector<u8>,
types_d_ts:vector<u8>,
dts_doc: vector<u8>,
) acquires Entry, ExtensionPointEventHandlers {
publish_version<ExtPointT>(&sender, tag, types_d_ts, dts_doc);
}

public(script) fun update_entry<ExtPointT>(sender: signer, name: vector<u8>, description: vector<u8>, labels: vector<vector<u8>>) acquires Entry, ExtensionPointEventHandlers {
let option_labels = if(Vector::length(&labels) == 0){
Option::none<vector<vector<u8>>>()
} else {
Option::some(labels)
};

update<ExtPointT>(&sender, name, description, option_labels);
}

public(script) fun star_entry<ExtPointT:store>(sender: signer) acquires Entry, ExtensionPointEventHandlers {
star<ExtPointT>(&sender);
}

public(script) fun unstar_entry<ExtPointT:store>(sender: signer) acquires Star, Entry, ExtensionPointEventHandlers {
unstar<ExtPointT>(&sender);
}
}
9 changes: 9 additions & 0 deletions sources/daospace/DAOPluginMarketplace.move
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,14 @@ module StarcoinFramework::DAOPluginMarketplace {
},
);
}

// public entrys
public(script) fun star_plugin_entry<PluginT>(sender: signer) acquires PluginEntry, PluginEventHandlers {
star_plugin<PluginT>(&sender);
}

public(script) fun unstar_plugin_entry<PluginT>(sender: signer) acquires PluginEntry, Star, PluginEventHandlers {
unstar_plugin<PluginT>(&sender);
}
}

0 comments on commit 459ce12

Please sign in to comment.