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

Function GetContractState

http/base/rpc/interfaces.go:328–362  ·  view source on GitHub ↗

get contract state

(params []interface{})

Source from the content-addressed store, hash-verified

326
327//get contract state
328func GetContractState(params []interface{}) map[string]interface{} {
329 if len(params) < 1 {
330 return responsePack(berr.INVALID_PARAMS, nil)
331 }
332 var contract *payload.DeployCode
333 switch params[0].(type) {
334 case string:
335 str := params[0].(string)
336 address, err := bcomn.GetAddress(str)
337 if err != nil {
338 return responsePack(berr.INVALID_PARAMS, "")
339 }
340 c, err := bactor.GetContractStateFromStore(address)
341 if err != nil {
342 return responsePack(berr.UNKNOWN_CONTRACT, berr.ErrMap[berr.UNKNOWN_CONTRACT])
343 }
344 contract = c
345 default:
346 return responsePack(berr.INVALID_PARAMS, "")
347 }
348 if len(params) >= 2 {
349 switch (params[1]).(type) {
350 case float64:
351 json := uint32(params[1].(float64))
352 if json == 1 {
353 return responseSuccess(bcomn.TransPayloadToHex(contract))
354 }
355 default:
356 return responsePack(berr.INVALID_PARAMS, "")
357 }
358 }
359 sink := common.NewZeroCopySink(nil)
360 contract.Serialization(sink)
361 return responseSuccess(common.ToHexString(sink.Bytes()))
362}
363
364//get smartconstract event
365func GetSmartCodeEvent(params []interface{}) map[string]interface{} {

Callers

nothing calls this directly

Calls 5

SerializationMethod · 0.95
BytesMethod · 0.95
responsePackFunction · 0.85
responseSuccessFunction · 0.85
ToHexStringMethod · 0.45

Tested by

no test coverage detected