github.com/condensat/bank-core@v0.1.0/database/model/assetinfo.go (about)

     1  // Copyright 2020 Condensat Tech. All rights reserved.
     2  // Use of this source code is governed by a MIT
     3  // license that can be found in the LICENSE file.
     4  
     5  package model
     6  
     7  import (
     8  	"time"
     9  )
    10  
    11  // AssetInfo from https://assets.blockstream.info/
    12  type AssetInfo struct {
    13  	AssetID    AssetID   `gorm:"unique_index;not null"`         // [FK] Reference to Asset table
    14  	LastUpdate time.Time `gorm:"index;not null;type:timestamp"` // Last update timestamp
    15  	Domain     string    `gorm:"index;not null;size:253"`       // AssetDomaine name (RFC 1053)
    16  	Name       string    `gorm:"index;not null;size:255"`       // Asset unique asset name
    17  	Ticker     string    `gorm:"index;not null;size:5"`         // Asset unique ticker name
    18  	Precision  uint8     `gorm:"default:0;not null"`            // Asset precision [0, 8]
    19  }
    20  
    21  func (p *AssetInfo) Valid() bool {
    22  	return p.AssetID > 0 &&
    23  		len(p.Domain) > 0 &&
    24  		len(p.Domain) <= 253 &&
    25  		len(p.Name) >= 2 && len(p.Name) <= 255 &&
    26  		len(p.Ticker) >= 3 && len(p.Ticker) <= 5 &&
    27  		p.Precision <= 8
    28  }