github.com/mavryk-network/mvgo@v1.19.9/rpc/increase_storage.go (about) 1 // Copyright (c) 2022 Blockwatch Data Inc. 2 // Author: alex@blockwatch.cc 3 4 package rpc 5 6 import "github.com/mavryk-network/mvgo/mavryk" 7 8 // Ensure IncreasePaidStorage implements the TypedOperation interface. 9 var _ TypedOperation = (*IncreasePaidStorage)(nil) 10 11 // IncreasePaidStorage represents a transaction operation 12 type IncreasePaidStorage struct { 13 Manager 14 Destination mavryk.Address `json:"destination"` 15 Amount int64 `json:"amount,string"` 16 } 17 18 // Costs returns operation cost to implement TypedOperation interface. 19 func (t IncreasePaidStorage) Costs() mavryk.Costs { 20 res := t.Metadata.Result 21 cost := mavryk.Costs{ 22 Fee: t.Manager.Fee, 23 GasUsed: res.Gas(), 24 } 25 if !t.Result().IsSuccess() { 26 return cost 27 } 28 for _, v := range res.BalanceUpdates { 29 if v.Kind != CONTRACT { 30 continue 31 } 32 burn := v.Amount() 33 if burn >= 0 { 34 continue 35 } 36 cost.StorageBurn += -burn 37 } 38 return cost 39 }