/
types.go
87 lines (72 loc) · 2.45 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/anathatech/project-anatha/config"
"time"
)
type NameInfo struct {
Name string `json:"name" yaml:"name"`
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
Price sdk.Coins `json:"price" yaml:"price"`
CreationTime time.Time `json:"creation_time" yaml:"creation_time"`
ExpiryTime time.Time `json:"expiry_time" yaml:"expiry_time"`
}
func NewNameInfo(name string) NameInfo {
return NameInfo{
Name: name,
Owner: nil,
Price: sdk.NewCoins(sdk.NewInt64Coin(config.DefaultDenom, 0)),
CreationTime: time.Time{},
ExpiryTime: time.Time{},
}
}
func (h NameInfo) String() string {
return fmt.Sprintf(`Name: %s
Owner: %s
Price: %s
Creation time: %s
Expiry time: %s`, h.Name, h.Owner, h.Price, h.CreationTime, h.ExpiryTime)
}
type BlockchainAddressRecordInfo struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
BlockchainAddressInfo BlockchainAddressInfo `json:"blockchain_address_info" yaml:"blockchain_address_info"`
}
func NewBlockchainAddressRecordInfo(address sdk.AccAddress, blockchainAddress BlockchainAddressInfo) BlockchainAddressRecordInfo {
return BlockchainAddressRecordInfo{
Address: address,
BlockchainAddressInfo: blockchainAddress,
}
}
func (a BlockchainAddressRecordInfo) String() string {
return fmt.Sprintf(`Address: %s
Blockchain address: %s`, a.Address, a.BlockchainAddressInfo)
}
type BlockchainAddressInfo struct {
BlockchainId string `json:"blockchain_id" yaml:"blockchain_id"`
Index string `json:"index" yaml:"index"`
BlockchainAddress string`json:"blockchain_address" yaml:"blockchain_address"`
}
func NewBlockchainAddressInfo(blockchainId string, index string, blockchainAddress string) BlockchainAddressInfo {
return BlockchainAddressInfo{
BlockchainId: blockchainId,
Index: index,
BlockchainAddress: blockchainAddress,
}
}
func (a BlockchainAddressInfo) String() string {
return fmt.Sprintf(`BlockchainId: %s
Index: %s
BlockchainAddress: %s`, a.BlockchainId, a.Index, a.BlockchainAddress)
}
type AddressCreditsInfo struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Credits sdk.Int `json:"credits" yaml:"credits"`
}
func NewAddressCreditsInfo(address sdk.AccAddress, credits sdk.Int) AddressCreditsInfo {
return AddressCreditsInfo{Address:address,Credits:credits}
}
func (a AddressCreditsInfo) String() string {
return fmt.Sprintf(`Address: %s
Credits: %s`, a.Address, a.Credits)
}