getter.gno
1.25 Kb · 51 lines
1package impl
2
3import (
4 plimit "gno.land/p/gnoswap/order/limit/v0"
5 rotree "gno.land/p/nt/bptree/rotree/v0"
6)
7
8func (l *limitOrderImpl) GetConfig() *plimit.Config {
9 return l.store.GetConfig().Clone()
10}
11
12func (l *limitOrderImpl) GetNextOrderID() uint64 {
13 return l.store.GetNextOrderID()
14}
15
16func (l *limitOrderImpl) ExistsOrder(orderID uint64) bool {
17 return l.store.GetOrders().Has(plimit.OrderKey(orderID))
18}
19
20func (l *limitOrderImpl) GetOrder(orderID uint64) *plimit.Order {
21 value := l.store.GetOrders().Get(plimit.OrderKey(orderID))
22 if value == nil {
23 return nil
24 }
25
26 return value.(*plimit.Order).Clone()
27}
28
29func (l *limitOrderImpl) GetOrders() *rotree.ReadOnlyTree {
30 return rotree.Wrap(l.store.GetOrders(), cloneOrderEntry)
31}
32
33func (l *limitOrderImpl) GetOrdersByOwner() *rotree.ReadOnlyTree {
34 return rotree.Wrap(l.store.GetOrdersByOwner(), nil)
35}
36
37func (l *limitOrderImpl) GetPendingExecutionFeeAmount(tokenPath string) int64 {
38 return getPendingExecutionFeeAmount(l.store.GetPendingExecutionFees(), tokenPath)
39}
40
41func (l *limitOrderImpl) GetPendingExecutionFees() *rotree.ReadOnlyTree {
42 return rotree.Wrap(l.store.GetPendingExecutionFees(), nil)
43}
44
45func cloneOrderEntry(value any) any {
46 if value == nil {
47 return nil
48 }
49
50 return value.(*plimit.Order).Clone()
51}