import { hex2VarBytes , hexstr2str , str2VarBytes , StringReader } from '../../utils' ; import { num2hexstring } from './../../utils' ; import Payload from './payload' ; export enum VmType { NEOVM_TYPE = 1 , WASMVM_TYPE = 3 } /**
 * Describes the payload of deploy code
 */ export default class DeployCode extends Payload { /**
     * Hex encoded contract content
     */ code : string ; /**
     * Decides if the contract need storage(Deprecated)
     * Change to VmType to support wasm vm
     */ vmType : VmType ; /**
     * Name of the smart contract
     */ name : string ; /**
     * Version of the contract
     */ version : string ; /**
     * Author of the contract
     */ author : string ; /**
     * Email of the author
     */ email : string ; /**
     * Description of the contract
     */ description : string ; /**
     * Serialize deploy code to hex string
     */ serialize ( ) { let result = '' ; result += hex2VarBytes ( this . code ) ; result += num2hexstring ( this . vmType ) ; result += str2VarBytes ( this . name ) ; result += str2VarBytes ( this . version ) ; result += str2VarBytes ( this . author ) ; result += str2VarBytes ( this . email ) ; result += str2VarBytes ( this . description ) ; return result ; } param sr deserialize ( sr ) { const code = sr . readNextBytes ( ) ; this . code = code ; const type = sr . readUint8 ( ) ; this . vmType = type ; const name = sr . readNextBytes ( ) ; this . name = hexstr2str ( name ) ; const codeVersion = sr . readNextBytes ( ) ; this . version = hexstr2str ( codeVersion ) ; const author = sr . readNextBytes ( ) ; this . author = hexstr2str ( author ) ; const email = sr . readNextBytes ( ) ; this . email = hexstr2str ( email ) ; const description = sr . readNextBytes ( ) ; this . description = hexstr2str ( description ) ; } }