github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/wasm/types/validation.go (about) 1 package types 2 3 import ( 4 sdkerrors "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/errors" 5 ) 6 7 var ( 8 // MaxLabelSize is the longest label that can be used when Instantiating a contract 9 MaxLabelSize = 128 // extension point for chains to customize via compile flag. 10 11 // MaxWasmSize is the largest a compiled contract code can be when storing code on chain 12 MaxWasmSize = 800 * 1024 // extension point for chains to customize via compile flag. 13 ) 14 15 func validateWasmCode(s []byte) error { 16 if len(s) == 0 { 17 return sdkerrors.Wrap(ErrEmpty, "is required") 18 } 19 if len(s) > MaxWasmSize { 20 return sdkerrors.Wrapf(ErrLimit, "cannot be longer than %d bytes", MaxWasmSize) 21 } 22 return nil 23 } 24 25 func validateLabel(label string) error { 26 if label == "" { 27 return sdkerrors.Wrap(ErrEmpty, "is required") 28 } 29 if len(label) > MaxLabelSize { 30 return sdkerrors.Wrap(ErrLimit, "cannot be longer than 128 characters") 31 } 32 return nil 33 }