-
Notifications
You must be signed in to change notification settings - Fork 189
/
model.go
134 lines (117 loc) · 5.81 KB
/
model.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
// Copyright 2020 The klaytn Authors
// This file is part of the klaytn library.
//
// The klaytn library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The klaytn library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the klaytn library. If not, see <http://www.gnu.org/licenses/>.
package kas
import "time"
const (
TxTableName = "klay_transfers"
KctTransferTableName = "kct_transfers"
RevertedTxTableName = "reverted_transactions"
MetadataTableName = "fetcher_metadata"
ContractTableName = "contract"
KctFtMetadataTableName = "kct_ft_metadata"
KctNftMetadataTableName = "kct_nft_metadata"
)
type Tx struct {
TransactionId int64 `gorm:"column:transactionId;type:BIGINT;INDEX:idIdx;NOT NULL;PRIMARY_KEY"`
FromAddr []byte `gorm:"column:fromAddr;type:VARBINARY(20);INDEX:txFromAddrIdx"`
ToAddr []byte `gorm:"column:toAddr;type:VARBINARY(20);INDEX:txToAddrIdx"`
Value string `gorm:"column:value;type:VARCHAR(80)"`
TransactionHash []byte `gorm:"column:transactionHash;type:VARBINARY(32);INDEX:tHashIdx;NOT NULL"`
Status int `gorm:"column:status;type:SMALLINT"`
Timestamp int64 `gorm:"column:timestamp;type:INT(11)"`
TypeInt int `gorm:"column:typeInt;INDEX:tTypeIdx;NOT NULL"`
GasPrice uint64 `gorm:"column:gasPrice;type:BIGINT"`
GasUsed uint64 `gorm:"column:gasUsed;type:BIGINT"`
FeePayer []byte `gorm:"column:feePayer;type:VARBINARY(20)"`
FeeRatio uint `gorm:"column:feeRatio;type:INT"`
Internal bool `gorm:"column:internal;type:TINYINT(1);DEFAULT:0"`
}
func (Tx) TableName() string {
return TxTableName
}
type KCTTransfer struct {
ContractAddress []byte `gorm:"column:contractAddress;type:VARBINARY(20);INDEX:ttFromCompIdx,ttToCompIdx;NOT NULL"`
From []byte `gorm:"column:fromAddr;type:VARBINARY(20);INDEX:ttFromCompIdx,ttFromIdx"`
To []byte `gorm:"column:toAddr;type:VARBINARY(20);INDEX:ttToCompIdx,ttToIdx"`
TransactionLogId int64 `gorm:"column:transactionLogId;type:BIGINT;PRIMARY_KEY;INDEX:ttFromCompIdx,ttToCompIdx"`
Value string `gorm:"column:value;type:VARCHAR(80)"`
TransactionHash []byte `gorm:"column:transactionHash;type:VARBINARY(32);INDEX:ttHashIdx;NOT NULL"`
Timestamp int64 `gorm:"column:timestamp;type:INT(11)"`
}
func (KCTTransfer) TableName() string {
return KctTransferTableName
}
type RevertedTx struct {
TransactionHash []byte `gorm:"column:transactionHash;type:VARBINARY(32);NOT NULL;PRIMARY_KEY"`
BlockNumber int64 `gorm:"column:blockNumber;type:BIGINT"`
RevertMessage string `gorm:"column:revertMessage;type:VARCHAR(1024)"`
ContractAddress []byte `gorm:"column:contractAddress;type:VARBINARY(20);NOT NULL"`
Timestamp int64 `gorm:"column:timestamp;type:INT(11)"`
}
func (RevertedTx) TableName() string {
return RevertedTxTableName
}
type FetcherMetadata struct {
Key string `gorm:"column:key;type:VARCHAR(30);PRIMARY_KEY"`
Value int64 `gorm:"column:value;type:BIGINT"`
}
func (FetcherMetadata) TableName() string {
return MetadataTableName
}
type Contract struct {
Id int `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
Address []byte `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
}
func (Contract) TableName() string {
return ContractTableName
}
type FT struct {
Id int `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
Address []byte `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
Name string `gorm:"column:name;type:VARCHAR(30)"`
Symbol string `gorm:"column:symbol;type:VARCHAR(20)"`
Decimal int `gorm:"column:decimal;type:TINYINT"`
TotalSupply string `gorm:"column:totalSupply;type:VARCHAR(80)"`
SiteUrl string `gorm:"column:siteUrl;type:VARCHAR(200)"`
IconUrl string `gorm:"column:iconUrl;type:VARCHAR(200)"`
Disable bool `gorm:"column:disable;type:TINYINT(1);DEFAULT:0"`
Type int `gorm:"column:type;type:TINYINT;DEFAULT:0"`
Status int `gorm:"column:status;type:TINYINT;DEFAULT:0"`
ErrorLog string `gorm:"column:errorLog;type:VARCHAR(255);"`
CreatedAt *time.Time `gorm:"column:createdAt;type:DATETIME;DEFAULT:NULL"`
UpdatedAt *time.Time `gorm:"column:updatedAt;type:DATETIME;DEFAULT:NULL"`
DeletedAt *time.Time `gorm:"column:deletedAt;type:DATETIME;DEFAULT:NULL"`
}
func (FT) TableName() string {
return KctFtMetadataTableName
}
type NFT struct {
Id int `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
Address []byte `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
Name string `gorm:"column:name;type:VARCHAR(30)"`
Symbol string `gorm:"column:symbol;type:VARCHAR(20)"`
TotalSupply string `gorm:"column:totalSupply;type:VARCHAR(80)"`
Disable bool `gorm:"column:disable;type:TINYINT(1);DEFAULT:0"`
Type int `gorm:"column:type;type:TINYINT;DEFAULT:0"`
Status int `gorm:"column:status;type:TINYINT;DEFAULT:0"`
ErrorLog string `gorm:"column:errorLog;type:VARCHAR(255);"`
CreatedAt *time.Time `gorm:"column:createdAt;type:DATETIME;DEFAULT:NULL"`
UpdatedAt *time.Time `gorm:"column:updatedAt;type:DATETIME;DEFAULT:NULL"`
DeletedAt *time.Time `gorm:"column:deletedAt;type:DATETIME;DEFAULT:NULL"`
}
func (NFT) TableName() string {
return KctNftMetadataTableName
}