-
Notifications
You must be signed in to change notification settings - Fork 6
/
smartContractResult.go
71 lines (59 loc) · 1.82 KB
/
smartContractResult.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. smartContractResult.proto
package smartContractResult
import (
"math/big"
"github.com/ElrondNetwork/elrond-go-core/data"
)
var _ = data.TransactionHandler(&SmartContractResult{})
// IsInterfaceNil verifies if underlying object is nil
func (scr *SmartContractResult) IsInterfaceNil() bool {
return scr == nil
}
// SetValue sets the value of the smart contract result
func (scr *SmartContractResult) SetValue(value *big.Int) {
scr.Value = value
}
// SetData sets the data of the smart contract result
func (scr *SmartContractResult) SetData(data []byte) {
scr.Data = data
}
// SetRcvAddr sets the receiver address of the smart contract result
func (scr *SmartContractResult) SetRcvAddr(addr []byte) {
scr.RcvAddr = addr
}
// SetSndAddr sets the sender address of the smart contract result
func (scr *SmartContractResult) SetSndAddr(addr []byte) {
scr.SndAddr = addr
}
// GetRcvUserName returns the receiver user name from the smart contract result
func (_ *SmartContractResult) GetRcvUserName() []byte {
return nil
}
// TrimSlicePtr creates a copy of the provided slice without the excess capacity
func TrimSlicePtr(in []*SmartContractResult) []*SmartContractResult {
if len(in) == 0 {
return []*SmartContractResult{}
}
ret := make([]*SmartContractResult, len(in))
copy(ret, in)
return ret
}
// CheckIntegrity checks for not nil fields and negative value
func (scr *SmartContractResult) CheckIntegrity() error {
if len(scr.RcvAddr) == 0 {
return data.ErrNilRcvAddr
}
if len(scr.SndAddr) == 0 {
return data.ErrNilSndAddr
}
if scr.Value == nil {
return data.ErrNilValue
}
if scr.Value.Sign() < 0 {
return data.ErrNegativeValue
}
if len(scr.PrevTxHash) == 0 {
return data.ErrNilTxHash
}
return nil
}