github.com/MetalBlockchain/metalgo@v1.11.9/vms/components/avax/asset.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package avax 5 6 import ( 7 "errors" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 "github.com/MetalBlockchain/metalgo/vms/components/verify" 11 ) 12 13 var ( 14 errNilAssetID = errors.New("nil asset ID is not valid") 15 errEmptyAssetID = errors.New("empty asset ID is not valid") 16 17 _ verify.Verifiable = (*Asset)(nil) 18 ) 19 20 type Asset struct { 21 ID ids.ID `serialize:"true" json:"assetID"` 22 } 23 24 // AssetID returns the ID of the contained asset 25 func (asset *Asset) AssetID() ids.ID { 26 return asset.ID 27 } 28 29 func (asset *Asset) Verify() error { 30 switch { 31 case asset == nil: 32 return errNilAssetID 33 case asset.ID == ids.Empty: 34 return errEmptyAssetID 35 default: 36 return nil 37 } 38 }