Skip to content

Commit

Permalink
Merge pull request #137 from ElrondNetwork/new-vmcommon-fixes
Browse files Browse the repository at this point in the history
return error for empty code
  • Loading branch information
sasurobert authored Jun 25, 2020
2 parents e1eff4e + e3af342 commit 8d37d04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arwen/contexts/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ func (context *blockchainContext) GetCodeHash(addr []byte) ([]byte, error) {

func (context *blockchainContext) GetCode(address []byte) ([]byte, error) {
account, err := context.blockChainHook.GetUserAccount(address)
if err != nil || arwen.IfNil(account) {
if arwen.IfNil(account) {
return nil, arwen.ErrInvalidAccount
}
if err != nil {
return nil, err
}

code := account.GetCode()
if len(code) == 0 {
return nil, arwen.ErrContractNotFound
}

return account.GetCode(), nil
}

Expand Down
2 changes: 2 additions & 0 deletions arwen/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ var ErrShiftNegative = errors.New("bitwise shift operations only allowed on posi
var ErrAsyncContextDoesNotExist = errors.New("async context was not created yet")

var ErrAsync = errors.New("invalid gas percentage provided for async call")

var ErrInvalidAccount = errors.New("account does not exist")

0 comments on commit 8d37d04

Please sign in to comment.