github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/txs/txstest/context.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package txstest
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/MetalBlockchain/metalgo/snow"
    10  	"github.com/MetalBlockchain/metalgo/vms/platformvm/config"
    11  	"github.com/MetalBlockchain/metalgo/vms/platformvm/txs"
    12  	"github.com/MetalBlockchain/metalgo/vms/platformvm/txs/fee"
    13  	"github.com/MetalBlockchain/metalgo/wallet/chain/p/builder"
    14  )
    15  
    16  func newContext(
    17  	ctx *snow.Context,
    18  	cfg *config.Config,
    19  	timestamp time.Time,
    20  ) *builder.Context {
    21  	var (
    22  		feeCalc         = fee.NewStaticCalculator(cfg.StaticFeeConfig, cfg.UpgradeConfig)
    23  		createSubnetFee = feeCalc.CalculateFee(&txs.CreateSubnetTx{}, timestamp)
    24  		createChainFee  = feeCalc.CalculateFee(&txs.CreateChainTx{}, timestamp)
    25  	)
    26  
    27  	return &builder.Context{
    28  		NetworkID:                     ctx.NetworkID,
    29  		AVAXAssetID:                   ctx.AVAXAssetID,
    30  		BaseTxFee:                     cfg.StaticFeeConfig.TxFee,
    31  		CreateSubnetTxFee:             createSubnetFee,
    32  		TransformSubnetTxFee:          cfg.StaticFeeConfig.TransformSubnetTxFee,
    33  		CreateBlockchainTxFee:         createChainFee,
    34  		AddPrimaryNetworkValidatorFee: cfg.StaticFeeConfig.AddPrimaryNetworkValidatorFee,
    35  		AddPrimaryNetworkDelegatorFee: cfg.StaticFeeConfig.AddPrimaryNetworkDelegatorFee,
    36  		AddSubnetValidatorFee:         cfg.StaticFeeConfig.AddSubnetValidatorFee,
    37  		AddSubnetDelegatorFee:         cfg.StaticFeeConfig.AddSubnetDelegatorFee,
    38  	}
    39  }