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

Method Invoke

smartcontract/service/native/native_service.go:64–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62}
63
64func (this *NativeService) Invoke() ([]byte, error) {
65 contract := this.InvokeParam
66 services, ok := Contracts[contract.Address]
67 if !ok {
68 return BYTE_FALSE, fmt.Errorf("Native contract address %x haven't been registered.", contract.Address)
69 }
70 services(this)
71 service, ok := this.ServiceMap[contract.Method]
72 if !ok {
73 return BYTE_FALSE, fmt.Errorf("Native contract %x doesn't support this function %s.",
74 contract.Address, contract.Method)
75 }
76 args := this.Input
77 this.Input = contract.Args
78 this.ContextRef.PushContext(&context.Context{ContractAddress: contract.Address})
79 notifications := this.Notifications
80 this.Notifications = []*event.NotifyEventInfo{}
81 result, err := service(this)
82 if err != nil {
83 return result, errors.NewDetailErr(err, errors.ErrNoCode, "[Invoke] Native serivce function execute error!")
84 }
85 this.ContextRef.PopContext()
86 this.ContextRef.PushNotifications(this.Notifications)
87 this.Notifications = notifications
88 this.Input = args
89 return result, nil
90}
91
92func (this *NativeService) NativeCall(address common.Address, method string, args []byte) (interface{}, error) {
93 c := states.ContractInvokeParam{

Callers 3

NativeInvokeFunction · 0.95
CallContractFunction · 0.95
NativeCallMethod · 0.95

Calls 5

NewDetailErrFunction · 0.92
ErrorfMethod · 0.80
PushContextMethod · 0.65
PopContextMethod · 0.65
PushNotificationsMethod · 0.65

Tested by

no test coverage detected