MCPcopy Create free account
hub / github.com/DNAProject/DNA / validateDeployCode

Function validateDeployCode

core/payload/deploy_code.go:190–227  ·  view source on GitHub ↗
(dep *DeployCode)

Source from the content-addressed store, hash-verified

188const maxWasmCodeSize = 512 * 1024
189
190func 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
229func CreateDeployCode(code []byte,
230 vmType uint32,

Callers 3

NewDeployCodeFunction · 0.85
DeserializationMethod · 0.85
CreateDeployCodeFunction · 0.85

Calls 3

NewErrFunction · 0.92
checkVmFlagsFunction · 0.85
VmTypeMethod · 0.80

Tested by

no test coverage detected