mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package x
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/node/wallet/chain/x/builder"
|
|
"github.com/luxfi/sdk/info"
|
|
)
|
|
|
|
func NewContextFromURI(ctx context.Context, uri string, utxoAssetID ids.ID, baseTxFee uint64, createAssetTxFee uint64) (*builder.Context, error) {
|
|
infoClient := info.NewClient(uri)
|
|
return NewContextFromClients(ctx, infoClient, utxoAssetID, baseTxFee, createAssetTxFee)
|
|
}
|
|
|
|
func NewContextFromClients(
|
|
ctx context.Context,
|
|
infoClient *info.Client,
|
|
utxoAssetID ids.ID,
|
|
baseTxFee uint64,
|
|
createAssetTxFee uint64,
|
|
) (*builder.Context, error) {
|
|
networkID, err := infoClient.GetNetworkID(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
chainID, err := infoClient.GetBlockchainID(ctx, builder.Alias)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &builder.Context{
|
|
NetworkID: networkID,
|
|
BlockchainID: chainID,
|
|
UTXOAssetID: utxoAssetID,
|
|
BaseTxFee: baseTxFee,
|
|
CreateAssetTxFee: createAssetTxFee,
|
|
}, nil
|
|
}
|