forked from stellar/go
/
claim_atom.go
72 lines (65 loc) · 1.66 KB
/
claim_atom.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
package xdr
import "fmt"
func (a ClaimAtom) OfferId() Int64 {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return a.V0.OfferId
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.OfferId
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}
func (a ClaimAtom) SellerId() AccountId {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return AccountId{
Type: PublicKeyTypePublicKeyTypeEd25519,
Ed25519: &a.V0.SellerEd25519,
}
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.SellerId
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}
func (a ClaimAtom) AssetBought() Asset {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return a.V0.AssetBought
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.AssetBought
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}
func (a ClaimAtom) AmountBought() Int64 {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return a.V0.AmountBought
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.AmountBought
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}
func (a ClaimAtom) AssetSold() Asset {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return a.V0.AssetSold
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.AssetSold
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}
func (a ClaimAtom) AmountSold() Int64 {
switch a.Type {
case ClaimAtomTypeClaimAtomTypeV0:
return a.V0.AmountSold
case ClaimAtomTypeClaimAtomTypeOrderBook:
return a.OrderBook.AmountSold
default:
panic(fmt.Errorf("Unknown ClaimAtom type: %v", a.Type))
}
}