forked from TrueCloudLab/frostfs-node
35 lines
705 B
Go
35 lines
705 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||
|
)
|
||
|
|
||
|
func (cs *ContractState) Parse() error {
|
||
|
nf, err := nef.FileFromBytes(cs.RawNEF)
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("can't parse NEF file: %w", err)
|
||
|
}
|
||
|
|
||
|
m := new(manifest.Manifest)
|
||
|
if err := json.Unmarshal(cs.RawManifest, m); err != nil {
|
||
|
return fmt.Errorf("can't parse manifest file: %w", err)
|
||
|
}
|
||
|
|
||
|
cs.NEF = &nf
|
||
|
cs.Manifest = m
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
type ContractState struct {
|
||
|
NEF *nef.File
|
||
|
RawNEF []byte
|
||
|
Manifest *manifest.Manifest
|
||
|
RawManifest []byte
|
||
|
Hash util.Uint160
|
||
|
}
|