code.vegaprotocol.io/vega@v0.79.0/core/assets/builtin/builtin.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package builtin
    17  
    18  import (
    19  	"fmt"
    20  
    21  	"code.vegaprotocol.io/vega/core/assets/common"
    22  	"code.vegaprotocol.io/vega/core/types"
    23  	proto "code.vegaprotocol.io/vega/protos/vega"
    24  )
    25  
    26  type Builtin struct {
    27  	asset *types.Asset
    28  }
    29  
    30  func New(id string, asset *types.AssetDetails) *Builtin {
    31  	return &Builtin{
    32  		asset: &types.Asset{
    33  			ID:      id,
    34  			Details: asset,
    35  			Status:  types.AssetStatusProposed,
    36  		},
    37  	}
    38  }
    39  
    40  func (e *Builtin) SetValid() {}
    41  
    42  func (e *Builtin) SetPendingListing() {
    43  	e.asset.Status = types.AssetStatusPendingListing
    44  }
    45  
    46  func (e *Builtin) SetRejected() {
    47  	e.asset.Status = types.AssetStatusRejected
    48  }
    49  
    50  func (e *Builtin) SetEnabled() {
    51  	e.asset.Status = types.AssetStatusEnabled
    52  }
    53  
    54  func (b *Builtin) ProtoAsset() *proto.Asset {
    55  	return b.asset.IntoProto()
    56  }
    57  
    58  func (b Builtin) Type() *types.Asset {
    59  	return b.asset.DeepClone()
    60  }
    61  
    62  func (b *Builtin) GetAssetClass() common.AssetClass {
    63  	return common.Builtin
    64  }
    65  
    66  func (b *Builtin) IsValid() bool {
    67  	return true
    68  }
    69  
    70  func (b *Builtin) SignBridgeWhitelisting() ([]byte, []byte, error) {
    71  	return nil, nil, nil
    72  }
    73  
    74  func (b *Builtin) ValidateWithdrawal() error {
    75  	return nil
    76  }
    77  
    78  func (b *Builtin) SignWithdrawal() ([]byte, error) {
    79  	return nil, nil
    80  }
    81  
    82  func (b *Builtin) ValidateDeposit() error {
    83  	return nil
    84  }
    85  
    86  func (b *Builtin) String() string {
    87  	return fmt.Sprintf("id(%v) name(%v) symbol(%v) decimals(%v)",
    88  		b.asset.ID, b.asset.Details.Name, b.asset.Details.Symbol,
    89  		b.asset.Details.Decimals)
    90  }