-
Notifications
You must be signed in to change notification settings - Fork 17
/
contract.go
53 lines (49 loc) · 1.11 KB
/
contract.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
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
type ContractManager interface {
PrepareCommit(
ctx sdk.Context,
txID TxID,
txIndex TxIndex,
tx ResolvedContractTransaction,
) (*ContractCallResult, error)
CommitImmediately(
ctx sdk.Context,
txID TxID,
txIndex TxIndex,
tx ResolvedContractTransaction,
) (*ContractCallResult, error)
Commit(
ctx sdk.Context,
txID TxID,
txIndex TxIndex,
) (*ContractCallResult, error)
Abort(
ctx sdk.Context,
txID TxID,
txIndex TxIndex,
) error
}
// GetData returns Data
func (res *ContractCallResult) GetData() []byte {
if res == nil {
return nil
} else {
return res.Data
}
}
// GetEvents converts Events to sdk.Events
func (res *ContractCallResult) GetEvents() sdk.Events {
if res == nil {
return nil
}
events := make(sdk.Events, 0, len(res.Events))
for _, ev := range res.Events {
attrs := make([]sdk.Attribute, 0, len(ev.Attributes))
for _, attr := range ev.Attributes {
attrs = append(attrs, sdk.NewAttribute(string(attr.Key), string(attr.Value)))
}
events = append(events, sdk.NewEvent(ev.Type, attrs...))
}
return events
}