github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/monitor/del.go (about) 1 package monitor 2 3 import ( 4 "context" 5 6 "github.com/machinefi/w3bstream/cmd/srv-applet-mgr/apis/middleware" 7 "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" 8 "github.com/machinefi/w3bstream/pkg/modules/blockchain" 9 "github.com/machinefi/w3bstream/pkg/types" 10 ) 11 12 type RemoveContractLog struct { 13 httpx.MethodDelete 14 ContractLogID types.SFID `in:"path" name:"contractLogID"` 15 } 16 17 func (r *RemoveContractLog) Path() string { return "/contract_log/:contractLogID" } 18 19 func (r *RemoveContractLog) Output(ctx context.Context) (interface{}, error) { 20 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 21 WithContractLogBySFID(ctx, r.ContractLogID) 22 if err != nil { 23 return nil, err 24 } 25 26 return nil, blockchain.RemoveContractLogBySFID(ctx, r.ContractLogID) 27 } 28 29 type RemoveChainTx struct { 30 httpx.MethodDelete 31 ChainTxID types.SFID `in:"path" name:"chainTxID"` 32 } 33 34 func (r *RemoveChainTx) Path() string { return "/chain_tx/:chainTxID" } 35 36 func (r *RemoveChainTx) Output(ctx context.Context) (interface{}, error) { 37 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 38 WithChainTxBySFID(ctx, r.ChainTxID) 39 if err != nil { 40 return nil, err 41 } 42 43 return nil, blockchain.RemoveChainTxBySFID(ctx, r.ChainTxID) 44 } 45 46 type RemoveChainHeight struct { 47 httpx.MethodDelete 48 ChainHeightID types.SFID `in:"path" name:"chainHeightID"` 49 } 50 51 func (r *RemoveChainHeight) Path() string { return "/chain_height/:chainHeightID" } 52 53 func (r *RemoveChainHeight) Output(ctx context.Context) (interface{}, error) { 54 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 55 WithChainHeightBySFID(ctx, r.ChainHeightID) 56 if err != nil { 57 return nil, err 58 } 59 60 return nil, blockchain.RemoveChainHeightBySFID(ctx, r.ChainHeightID) 61 }