-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
models.go
135 lines (115 loc) · 3.32 KB
/
models.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package db
import (
"time"
"github.com/shopspring/decimal"
)
type Block struct {
ID uint
TimeStamp time.Time
Height int64 `gorm:"uniqueIndex:chainheight"`
BlockchainID uint `gorm:"uniqueIndex:chainheight"`
Chain Chain `gorm:"foreignKey:BlockchainID"`
Indexed bool
// TODO: Should block event indexing be split out or rolled up?
BlockEventsIndexed bool
}
type FailedBlock struct {
ID uint
Height int64 `gorm:"uniqueIndex:failedchainheight"`
BlockchainID uint `gorm:"uniqueIndex:failedchainheight"`
Chain Chain `gorm:"foreignKey:BlockchainID"`
}
type FailedEventBlock struct {
ID uint
Height int64 `gorm:"uniqueIndex:failedchaineventheight"`
BlockchainID uint `gorm:"uniqueIndex:failedchaineventheight"`
Chain Chain `gorm:"foreignKey:BlockchainID"`
}
type Chain struct {
ID uint `gorm:"primaryKey"`
ChainID string `gorm:"uniqueIndex"` // e.g. osmosis-1
Name string // e.g. Osmosis
}
type Tx struct {
ID uint
Hash string `gorm:"uniqueIndex"`
Code uint32
BlockID uint
Block Block
SignerAddressID *uint // *int allows foreign key to be null
SignerAddress Address
Fees []Fee
}
type Fee struct {
ID uint `gorm:"primaryKey"`
TxID uint `gorm:"uniqueIndex:txDenomFee"`
Amount decimal.Decimal `gorm:"type:decimal(78,0);"`
DenominationID uint `gorm:"uniqueIndex:txDenomFee"`
Denomination Denom `gorm:"foreignKey:DenominationID"`
PayerAddressID uint `gorm:"index:idx_payer_addr"`
PayerAddress Address `gorm:"foreignKey:PayerAddressID"`
}
// dbTypes.Address{Address: currTx.FeePayer().String()}
type Address struct {
ID uint
Address string `gorm:"uniqueIndex"`
}
type MessageType struct {
ID uint `gorm:"primaryKey"`
MessageType string `gorm:"uniqueIndex;not null"`
}
type Message struct {
ID uint
TxID uint `gorm:"index:idx_txid_typeid"`
Tx Tx
MessageTypeID uint `gorm:"foreignKey:MessageTypeID,index:idx_txid_typeid"`
MessageType MessageType
MessageIndex int
}
const (
OsmosisRewardDistribution uint = iota
TendermintLiquidityDepositCoinsToPool
TendermintLiquidityDepositPoolCoinReceived
TendermintLiquiditySwapTransactedCoinIn
TendermintLiquiditySwapTransactedCoinOut
TendermintLiquiditySwapTransactedFee
TendermintLiquidityWithdrawPoolCoinSent
TendermintLiquidityWithdrawCoinReceived
TendermintLiquidityWithdrawFee
OsmosisProtorevDeveloperRewardDistribution
)
type Denom struct {
ID uint
Base string `gorm:"uniqueIndex"`
Name string
Symbol string
}
type DenomUnit struct {
ID uint
DenomID uint `gorm:"uniqueIndex:,composite:denom_id_name"`
Denom Denom
Exponent uint
Name string `gorm:"uniqueIndex:,composite:denom_id_name"`
}
// Store transactions with their messages for easy database creation
type TxDBWrapper struct {
Tx Tx
SignerAddress Address
Messages []MessageDBWrapper
}
type MessageDBWrapper struct {
Message Message
}
type DenomDBWrapper struct {
Denom Denom
DenomUnits []DenomUnitDBWrapper
}
type DenomUnitDBWrapper struct {
DenomUnit DenomUnit
}
type IBCDenom struct {
ID uint
Hash string `gorm:"uniqueIndex"`
Path string
BaseDenom string
}