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

Function ParseReturnValue

cmd/utils/params.go:215–231  ·  view source on GitHub ↗

ParseReturnValue return the value of rawReturnTypeStr type. Return type can be: bytearray, string, int, bool. Types can be split with "," each other, such as int,string,bool Type array can be express with "[]", such [int,string], param array can be nested, such as [int,[int,bool]]

(rawValue interface{}, rawReturnTypeStr string, vmtype payload.VmType)

Source from the content-addressed store, hash-verified

213//Types can be split with "," each other, such as int,string,bool
214//Type array can be express with "[]", such [int,string], param array can be nested, such as [int,[int,bool]]
215func ParseReturnValue(rawValue interface{}, rawReturnTypeStr string, vmtype payload.VmType) ([]interface{}, error) {
216 returnTypes, _, err := parseRawParamsString(rawReturnTypeStr)
217 if err != nil {
218 return nil, fmt.Errorf("parse raw return types:%s error:%s", rawReturnTypeStr, err)
219 }
220 var rawValues []interface{}
221 rawValues, ok := rawValue.([]interface{})
222 if !ok {
223 rawValues = append(rawValues, rawValue)
224 }
225 if vmtype == payload.NEOVM_TYPE {
226 return parseReturnNeoValueArray(rawValues, returnTypes)
227 } else {
228 return parasReturnValueWasmArray(rawValues, returnTypes)
229 }
230
231}
232
233func parasReturnValueWasmArray(rawValues []interface{}, returnTypes []interface{}) ([]interface{}, error) {
234 values := make([]interface{}, 0)

Callers 2

invokeCodeContractFunction · 0.92
invokeContractFunction · 0.92

Calls 4

parseRawParamsStringFunction · 0.85
parseReturnNeoValueArrayFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected