forked from TrueCloudLab/neoneo-go
native: save native contract state on deploy
This commit is contained in:
parent
f9f3192b48
commit
301c1b7601
1 changed files with 18 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue