/
task.go
53 lines (47 loc) · 1.02 KB
/
task.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 (
"encoding/json"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewTask returns a new task.
func NewTask(
contract string,
function string,
beginBlock int64,
bounty sdk.Coins,
description string,
expiration time.Time,
creator sdk.AccAddress,
closingBlock int64,
waitingBlocks int64,
) Task {
return Task{
Contract: contract,
Function: function,
BeginBlock: beginBlock,
Bounty: bounty,
Description: description,
Expiration: expiration,
Creator: creator.String(),
ClosingBlock: closingBlock,
WaitingBlocks: waitingBlocks,
Status: TaskStatusPending,
}
}
// NewResponse returns a new response.
func NewResponse(score sdk.Int, operator sdk.AccAddress) Response {
return Response{
Operator: operator.String(),
Score: score,
}
}
type Responses []Response
// String implements the Stringer interface.
func (r Responses) String() string {
jsonBytes, err := json.Marshal(r)
if err != nil {
return "[]"
}
return string(jsonBytes)
}