feat: actors: Add bytecode getter

This commit is contained in:
Łukasz Magiera 2023-02-09 13:12:16 +01:00
parent 9339267e6e
commit 8d6aa2477c
4 changed files with 28 additions and 6 deletions

View File

@ -49,4 +49,7 @@ type State interface {
Nonce() (uint64, error)
GetState() interface{}
GetBytecodeCID() (cid.Cid, error)
GetBytecodeHash() ([32]byte, error)
}

View File

@ -49,4 +49,7 @@ type State interface {
Nonce() (uint64, error)
GetState() interface{}
GetBytecodeCID() (cid.Cid, error)
GetBytecodeHash() ([32]byte, error)
}

View File

@ -21,12 +21,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
func make{{.v}}(store adt.Store, bytecode cid.Cid) (State, error) {
out := state{{.v}}{store: store}
s, err := evm{{.v}}.ConstructState(store, bytecode)
if err != nil {
return nil, err
}
s, err := evm{{.v}}.ConstructState(store, bytecode)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -42,4 +42,12 @@ func (s *state{{.v}}) Nonce() (uint64, error) {
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
}
func (s *state{{.v}}) GetBytecodeCID() (cid.Cid, error) {
return s.State.Bytecode, nil
}
func (s *state{{.v}}) GetBytecodeHash() ([32]byte, error) {
return s.State.BytecodeHash, nil
}

View File

@ -43,3 +43,11 @@ func (s *state10) Nonce() (uint64, error) {
func (s *state10) GetState() interface{} {
return &s.State
}
func (s *state10) GetBytecodeCID() (cid.Cid, error) {
return s.State.Bytecode, nil
}
func (s *state10) GetBytecodeHash() ([32]byte, error) {
return s.State.BytecodeHash, nil
}