/
types.go
70 lines (62 loc) · 1.89 KB
/
types.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
package types
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewPool creates a new project pool.
func NewPool(id uint64, description, sponsor string, sponsorAddress sdk.AccAddress, shieldLimit sdk.Int, shield sdk.Int) Pool {
return Pool{
Id: id,
Description: description,
Sponsor: sponsor,
SponsorAddr: sponsorAddress.String(),
ShieldLimit: shieldLimit,
Active: true,
Shield: shield,
}
}
// NewProvider creates a new provider object.
func NewProvider(addr sdk.AccAddress) Provider {
return Provider{
Address: addr.String(),
DelegationBonded: sdk.ZeroInt(),
Collateral: sdk.ZeroInt(),
TotalLocked: sdk.ZeroInt(),
Withdrawing: sdk.ZeroInt(),
}
}
// NewPurchase creates a new purchase object.
func NewPurchase(purchaseID uint64, protectionEndTime, deletionTime time.Time, description string, shield sdk.Int, serviceFees sdk.DecCoins) Purchase {
return Purchase{
PurchaseId: purchaseID,
ProtectionEndTime: protectionEndTime,
DeletionTime: deletionTime,
Description: description,
Shield: shield,
ServiceFees: serviceFees,
}
}
// NewPurchaseList creates a new purchase list.
func NewPurchaseList(poolID uint64, purchaser sdk.AccAddress, purchases []Purchase) PurchaseList {
return PurchaseList{
PoolId: poolID,
Purchaser: purchaser.String(),
Entries: purchases,
}
}
// NewWithdraw creates a new withdraw object.
func NewWithdraw(addr sdk.AccAddress, amount sdk.Int, completionTime time.Time) Withdraw {
return Withdraw{
Address: addr.String(),
Amount: amount,
CompletionTime: completionTime,
}
}
func NewShieldStaking(poolID uint64, purchaser sdk.AccAddress, amount sdk.Int) ShieldStaking {
return ShieldStaking{
PoolId: poolID,
Purchaser: purchaser.String(),
Amount: amount,
WithdrawRequested: sdk.NewInt(0),
}
}