-
Notifications
You must be signed in to change notification settings - Fork 4
/
helper.go
54 lines (41 loc) · 943 Bytes
/
helper.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
package parliament
import (
"context"
"github.com/fox-one/pando/pkg/uuid"
)
func (s *parliament) fetchAssetSymbol(ctx context.Context, assetID string) string {
if uuid.IsNil(assetID) {
return "ALL"
}
coin, err := s.assetz.Find(ctx, assetID)
if err != nil {
return "NULL"
}
return coin.Symbol
}
func (s *parliament) fetchUserName(ctx context.Context, userID string) string {
user, err := s.userz.Find(ctx, userID)
if err != nil {
return "NULL"
}
return user.Name
}
func (s *parliament) fetchCatName(ctx context.Context, id string) string {
if uuid.IsNil(id) {
return "ALL"
}
c, err := s.collaterals.Find(ctx, id)
if err != nil {
return "NULL"
}
return c.Name
}
func (s *parliament) fetchCatGemDai(ctx context.Context, id string) (gem, dai string) {
c, err := s.collaterals.Find(ctx, id)
if err != nil {
return
}
gem = s.fetchAssetSymbol(ctx, c.Gem)
dai = s.fetchAssetSymbol(ctx, c.Dai)
return
}