github.com/klaytn/klaytn@v1.10.2/datasync/chaindatafetcher/kas/model.go (about)

     1  // Copyright 2020 The klaytn Authors
     2  // This file is part of the klaytn library.
     3  //
     4  // The klaytn library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The klaytn library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the klaytn library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package kas
    18  
    19  import "time"
    20  
    21  const (
    22  	TxTableName             = "klay_transfers"
    23  	KctTransferTableName    = "kct_transfers"
    24  	RevertedTxTableName     = "reverted_transactions"
    25  	MetadataTableName       = "fetcher_metadata"
    26  	ContractTableName       = "contract"
    27  	KctFtMetadataTableName  = "kct_ft_metadata"
    28  	KctNftMetadataTableName = "kct_nft_metadata"
    29  )
    30  
    31  type Tx struct {
    32  	TransactionId   int64  `gorm:"column:transactionId;type:BIGINT;INDEX:idIdx;NOT NULL;PRIMARY_KEY"`
    33  	FromAddr        []byte `gorm:"column:fromAddr;type:VARBINARY(20);INDEX:txFromAddrIdx"`
    34  	ToAddr          []byte `gorm:"column:toAddr;type:VARBINARY(20);INDEX:txToAddrIdx"`
    35  	Value           string `gorm:"column:value;type:VARCHAR(80)"`
    36  	TransactionHash []byte `gorm:"column:transactionHash;type:VARBINARY(32);INDEX:tHashIdx;NOT NULL"`
    37  	Status          int    `gorm:"column:status;type:SMALLINT"`
    38  	Timestamp       int64  `gorm:"column:timestamp;type:INT(11)"`
    39  	TypeInt         int    `gorm:"column:typeInt;INDEX:tTypeIdx;NOT NULL"`
    40  	GasPrice        uint64 `gorm:"column:gasPrice;type:BIGINT"`
    41  	GasUsed         uint64 `gorm:"column:gasUsed;type:BIGINT"`
    42  	FeePayer        []byte `gorm:"column:feePayer;type:VARBINARY(20)"`
    43  	FeeRatio        uint   `gorm:"column:feeRatio;type:INT"`
    44  	Internal        bool   `gorm:"column:internal;type:TINYINT(1);DEFAULT:0"`
    45  }
    46  
    47  func (Tx) TableName() string {
    48  	return TxTableName
    49  }
    50  
    51  type KCTTransfer struct {
    52  	ContractAddress  []byte `gorm:"column:contractAddress;type:VARBINARY(20);INDEX:ttFromCompIdx,ttToCompIdx;NOT NULL"`
    53  	From             []byte `gorm:"column:fromAddr;type:VARBINARY(20);INDEX:ttFromCompIdx,ttFromIdx"`
    54  	To               []byte `gorm:"column:toAddr;type:VARBINARY(20);INDEX:ttToCompIdx,ttToIdx"`
    55  	TransactionLogId int64  `gorm:"column:transactionLogId;type:BIGINT;PRIMARY_KEY;INDEX:ttFromCompIdx,ttToCompIdx"`
    56  	Value            string `gorm:"column:value;type:VARCHAR(80)"`
    57  	TransactionHash  []byte `gorm:"column:transactionHash;type:VARBINARY(32);INDEX:ttHashIdx;NOT NULL"`
    58  	Timestamp        int64  `gorm:"column:timestamp;type:INT(11)"`
    59  }
    60  
    61  func (KCTTransfer) TableName() string {
    62  	return KctTransferTableName
    63  }
    64  
    65  type RevertedTx struct {
    66  	TransactionHash []byte `gorm:"column:transactionHash;type:VARBINARY(32);NOT NULL;PRIMARY_KEY"`
    67  	BlockNumber     int64  `gorm:"column:blockNumber;type:BIGINT"`
    68  	RevertMessage   string `gorm:"column:revertMessage;type:VARCHAR(1024)"`
    69  	ContractAddress []byte `gorm:"column:contractAddress;type:VARBINARY(20);NOT NULL"`
    70  	Timestamp       int64  `gorm:"column:timestamp;type:INT(11)"`
    71  }
    72  
    73  func (RevertedTx) TableName() string {
    74  	return RevertedTxTableName
    75  }
    76  
    77  type FetcherMetadata struct {
    78  	Key   string `gorm:"column:key;type:VARCHAR(30);PRIMARY_KEY"`
    79  	Value int64  `gorm:"column:value;type:BIGINT"`
    80  }
    81  
    82  func (FetcherMetadata) TableName() string {
    83  	return MetadataTableName
    84  }
    85  
    86  type Contract struct {
    87  	Id      int    `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
    88  	Address []byte `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
    89  }
    90  
    91  func (Contract) TableName() string {
    92  	return ContractTableName
    93  }
    94  
    95  type FT struct {
    96  	Id          int        `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
    97  	Address     []byte     `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
    98  	Name        string     `gorm:"column:name;type:VARCHAR(30)"`
    99  	Symbol      string     `gorm:"column:symbol;type:VARCHAR(20)"`
   100  	Decimal     int        `gorm:"column:decimal;type:TINYINT"`
   101  	TotalSupply string     `gorm:"column:totalSupply;type:VARCHAR(80)"`
   102  	SiteUrl     string     `gorm:"column:siteUrl;type:VARCHAR(200)"`
   103  	IconUrl     string     `gorm:"column:iconUrl;type:VARCHAR(200)"`
   104  	Disable     bool       `gorm:"column:disable;type:TINYINT(1);DEFAULT:0"`
   105  	Type        int        `gorm:"column:type;type:TINYINT;DEFAULT:0"`
   106  	Status      int        `gorm:"column:status;type:TINYINT;DEFAULT:0"`
   107  	ErrorLog    string     `gorm:"column:errorLog;type:VARCHAR(255);"`
   108  	CreatedAt   *time.Time `gorm:"column:createdAt;type:DATETIME;DEFAULT:NULL"`
   109  	UpdatedAt   *time.Time `gorm:"column:updatedAt;type:DATETIME;DEFAULT:NULL"`
   110  	DeletedAt   *time.Time `gorm:"column:deletedAt;type:DATETIME;DEFAULT:NULL"`
   111  }
   112  
   113  func (FT) TableName() string {
   114  	return KctFtMetadataTableName
   115  }
   116  
   117  type NFT struct {
   118  	Id          int        `gorm:"column:id;type:INT AUTO_INCREMENT;PRIMARY_KEY"`
   119  	Address     []byte     `gorm:"column:address;type:VARBINARY(20);UNIQUE_INDEX;NOT NULL"`
   120  	Name        string     `gorm:"column:name;type:VARCHAR(30)"`
   121  	Symbol      string     `gorm:"column:symbol;type:VARCHAR(20)"`
   122  	TotalSupply string     `gorm:"column:totalSupply;type:VARCHAR(80)"`
   123  	Disable     bool       `gorm:"column:disable;type:TINYINT(1);DEFAULT:0"`
   124  	Type        int        `gorm:"column:type;type:TINYINT;DEFAULT:0"`
   125  	Status      int        `gorm:"column:status;type:TINYINT;DEFAULT:0"`
   126  	ErrorLog    string     `gorm:"column:errorLog;type:VARCHAR(255);"`
   127  	CreatedAt   *time.Time `gorm:"column:createdAt;type:DATETIME;DEFAULT:NULL"`
   128  	UpdatedAt   *time.Time `gorm:"column:updatedAt;type:DATETIME;DEFAULT:NULL"`
   129  	DeletedAt   *time.Time `gorm:"column:deletedAt;type:DATETIME;DEFAULT:NULL"`
   130  }
   131  
   132  func (NFT) TableName() string {
   133  	return KctNftMetadataTableName
   134  }