From 301c1b76018ce2644b2515f81a71e8e6f5fc5a2c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 7 May 2020 14:03:14 +0300 Subject: [PATCH] native: save native contract state on deploy --- pkg/core/native/interop.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/core/native/interop.go b/pkg/core/native/interop.go index b535313f9..24a6a28b4 100644 --- a/pkg/core/native/interop.go +++ b/pkg/core/native/interop.go @@ -5,6 +5,8 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/core/interop" + "github.com/nspcc-dev/neo-go/pkg/core/state" + "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/vm" ) @@ -15,8 +17,23 @@ func Deploy(ic *interop.Context, _ *vm.VM) error { } for _, native := range ic.Natives { + md := native.Metadata() + + ps := md.Manifest.ABI.EntryPoint.Parameters + params := make([]smartcontract.ParamType, len(ps)) + for i := range ps { + params[i] = ps[i].Type + } + + cs := &state.Contract{ + Script: md.Script, + ParamList: params, + ReturnType: md.Manifest.ABI.EntryPoint.ReturnType, + } + if err := ic.DAO.PutContractState(cs); err != nil { + return err + } if err := native.Initialize(ic); err != nil { - md := native.Metadata() return fmt.Errorf("initializing %s native contract: %v", md.ServiceName, err) } }