@@ -30,6 +30,10 @@ access(all) contract PDS{
3030 ///
3131 access (all ) event DistributionCreated (DistId : UInt64 , title : String , metadata : {String : String }, state : UInt8 )
3232
33+ /// Emitted when an issuer has updated a distribution.
34+ ///
35+ access (all ) event DistributionUpdated (DistId : UInt64 , title : String , metadata : {String : String }, state : UInt8 )
36+
3337 /// Emmitted when a distribution manager has updated a distribution state.
3438 ///
3539 access (all ) event DistributionStateUpdated (DistId : UInt64 , state : UInt8 )
@@ -45,14 +49,19 @@ access(all) contract PDS{
4549 /// Struct that defines the details of a Distribution.
4650 ///
4751 access (all ) struct DistInfo {
48- access (all ) let title : String
49- access (all ) let metadata : {String : String }
52+ access (all ) var title : String
53+ access (all ) var metadata : {String : String }
5054 access (all ) var state : PDS .DistState
5155
5256 access (contract ) fun setState (newState : PDS .DistState ) {
5357 self .state = newState
5458 }
5559
60+ access (contract ) fun update (title : String , metadata : {String : String }) {
61+ self .title = title
62+ self .metadata = metadata
63+ }
64+
5665 /// DistInfo struct initializer.
5766 ///
5867 view init (title : String , metadata : {String : String }) {
@@ -246,6 +255,16 @@ access(all) contract PDS{
246255 emit DistributionStateUpdated (DistId : distId , state : state .rawValue )
247256 }
248257
258+ access (Operate ) fun updateDist (distId : UInt64 , title : String , metadata : {String : String }) {
259+ pre {
260+ title .length > 0 : " Title must not be empty"
261+ }
262+ let d = PDS .Distributions .remove (key : distId ) ?? panic (" No such distribution" )
263+ d .update (title : title , metadata : metadata )
264+ PDS .Distributions .insert (key : distId , d )
265+ emit DistributionUpdated (DistId : distId , title : title , metadata : metadata , state : d .state .rawValue )
266+ }
267+
249268 access (Operate ) fun withdraw (distId : UInt64 , nftIDs : [UInt64 ], escrowCollectionPublic : PublicPath ) {
250269 assert (PDS .DistSharedCap .containsKey (distId ), message : " No such distribution" )
251270 let d <- PDS .DistSharedCap .remove (key : distId )!
0 commit comments