2020-03-19 15:52:37 +00:00
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2020-04-20 17:38:47 +00:00
|
|
|
"fmt"
|
2020-03-19 15:52:37 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Deploy deploys native contract.
|
|
|
|
func Deploy(ic *interop.Context, _ *vm.VM) error {
|
|
|
|
if ic.Block.Index != 0 {
|
|
|
|
return errors.New("native contracts can be deployed only at 0 block")
|
|
|
|
}
|
2020-04-20 17:38:47 +00:00
|
|
|
|
2020-04-22 20:00:18 +00:00
|
|
|
for _, native := range ic.Natives {
|
|
|
|
if err := native.Initialize(ic); err != nil {
|
|
|
|
md := native.Metadata()
|
|
|
|
return fmt.Errorf("initializing %s native contract: %v", md.ServiceName, err)
|
|
|
|
}
|
2020-04-20 17:38:47 +00:00
|
|
|
}
|
2020-03-19 15:52:37 +00:00
|
|
|
return nil
|
|
|
|
}
|