(dep *DeployCode)
| 188 | const maxWasmCodeSize = 512 * 1024 |
| 189 | |
| 190 | func validateDeployCode(dep *DeployCode) error { |
| 191 | err := checkVmFlags(dep.vmFlags) |
| 192 | if err != nil { |
| 193 | return err |
| 194 | } |
| 195 | |
| 196 | if dep.VmType() == WASMVM_TYPE { |
| 197 | if len(dep.code) > maxWasmCodeSize { |
| 198 | return errors.NewErr("[contract] Code too long!") |
| 199 | } |
| 200 | } else { |
| 201 | if len(dep.code) > 1024*1024 { |
| 202 | return errors.NewErr("[contract] Code too long!") |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | if len(dep.Name) > 252 { |
| 207 | return errors.NewErr("[contract] name too long!") |
| 208 | } |
| 209 | |
| 210 | if len(dep.Version) > 252 { |
| 211 | return errors.NewErr("[contract] version too long!") |
| 212 | } |
| 213 | |
| 214 | if len(dep.Author) > 252 { |
| 215 | return errors.NewErr("[contract] version too long!") |
| 216 | } |
| 217 | |
| 218 | if len(dep.Email) > 252 { |
| 219 | return errors.NewErr("[contract] email too long!") |
| 220 | } |
| 221 | |
| 222 | if len(dep.Description) > 65536 { |
| 223 | return errors.NewErr("[contract] description too long!") |
| 224 | } |
| 225 | |
| 226 | return nil |
| 227 | } |
| 228 | |
| 229 | func CreateDeployCode(code []byte, |
| 230 | vmType uint32, |
no test coverage detected