Documentation ¶
Index ¶
- Constants
- Variables
- func BuildTx(opType string, matches []*parser.Match, payloadMetadata Metadata, ...) (*txs.Tx, []*types.AccountIdentifier, error)
- func GetTxDependenciesIDs(tx txs.UnsignedTx) ([]ids.ID, error)
- func ParseRosettaTxs(parserCfg TxParserConfig, txs []*txs.Tx, dependencyTxs BlockTxDependencies) ([]*types.Transaction, error)
- type BlockTxDependencies
- type ExportMetadata
- type ImportExportOptions
- type ImportMetadata
- type Metadata
- type OperationMetadata
- type SingleTxDependency
- type StakingMetadata
- type StakingOptions
- type TxParser
- type TxParserConfig
Constants ¶
const ( OpImportAvax = "IMPORT_AVAX" OpExportAvax = "EXPORT_AVAX" OpAddValidator = "ADD_VALIDATOR" OpAddPermissionlessValidator = "ADD_PERMISSIONLESS_VALIDATOR" OpAddDelegator = "ADD_DELEGATOR" OpAddPermissionlessDelegator = "ADD_PERMISSIONLESS_DELEGATOR" OpRewardValidator = "REWARD_VALIDATOR" OpCreateChain = "CREATE_CHAIN" OpCreateSubnet = "CREATE_SUBNET" OpAddSubnetValidator = "ADD_SUBNET_VALIDATOR" OpRemoveSubnetValidator = "REMOVE_SUBNET_VALIDATOR" OpTransformSubnetValidator = "TRANSFORM_SUBNET_VALIDATOR" OpAdvanceTime = "ADVANCE_TIME" OpBase = "BASE" OpTransferSubnetOwnership = "TRANSFER_SUBNET_OWNERSHIP" OpConvertSubnetToL1Tx = "CONVERT_SUBNET_TO_L1_TX" OpRegisterL1ValidatorTx = "REGISTER_L1_VALIDATOR_TX" OpIncreaseL1ValidatorBalanceTx = "INCREASE_L1_VALIDATOR_BALANCE_TX" OpSetL1ValidatorWeightTx = "SET_L1_VALIDATOR_WEIGHT_TX" OpDisableL1ValidatorTx = "DISABLE_L1_VALIDATOR_TX" OpTypeImport = "IMPORT" OpTypeExport = "EXPORT" OpTypeInput = "INPUT" OpTypeOutput = "OUTPUT" OpTypeStakeOutput = "STAKE" OpTypeReward = "REWARD" MetadataOpType = "type" MetadataTxType = "tx_type" MetadataStakingTxID = "staking_tx_id" MetadataValidatorNodeID = "validator_node_id" MetadataStakingStartTime = "staking_start_time" MetadataStakingEndTime = "staking_end_time" MetadataMessage = "message" MetadataSigner = "signer" MetadataBaseFee = "base_fee" MetadataMatches = "matches" MetadataValidatorRewards = "validator_rewards" MetadataValidatorRewardsOwner = "validator_rewards_owner" MetadataDelegationRewardsOwner = "delegation_rewards_owner" MetadataDelegatorRewardsOwner = "delegator_rewards_owner" MetadataDelegationRewards = "delegation_rewards" MetadataDelegationFeeRewards = "delegation_fee_rewards" MetadataSubnetID = "subnet_id" SubAccountTypeUnlocked = "unlocked" SubAccountTypeLockedStakeable = "locked_stakeable" SubAccountTypeLockedNotStakeable = "locked_not_stakeable" SubAccountTypeStaked = "staked" )
Variables ¶
var ( OperationTypes = []string{ OpImportAvax, OpExportAvax, OpAddValidator, OpAddDelegator, OpRewardValidator, OpCreateChain, OpCreateSubnet, OpAddSubnetValidator, OpRemoveSubnetValidator, OpTransformSubnetValidator, OpAddPermissionlessValidator, OpAddPermissionlessDelegator, } CallMethods = []string{} )
Functions ¶
func BuildTx ¶
func BuildTx( opType string, matches []*parser.Match, payloadMetadata Metadata, codec codec.Manager, avaxAssetID ids.ID, ) (*txs.Tx, []*types.AccountIdentifier, error)
BuildTx constructs a P-chain Tx based on the provided operation type, Rosetta matches and metadata This method is only used during construction.
func GetTxDependenciesIDs ¶ added in v0.1.42
func GetTxDependenciesIDs(tx txs.UnsignedTx) ([]ids.ID, error)
GetTxDependenciesIDs generates the list of transaction ids used in the inputs to given unsigned transaction this list is then used to fetch the dependency transactions in order to extract source addresses as this information is not part of the transaction objects on chain.
func ParseRosettaTxs ¶
func ParseRosettaTxs( parserCfg TxParserConfig, txs []*txs.Tx, dependencyTxs BlockTxDependencies, ) ([]*types.Transaction, error)
Types ¶
type BlockTxDependencies ¶
type BlockTxDependencies map[ids.ID]*SingleTxDependency
func (BlockTxDependencies) GetReferencedAccounts ¶
func (bd BlockTxDependencies) GetReferencedAccounts(hrp string) (map[string]*types.AccountIdentifier, error)
GetReferencedAccounts extracts destination accounts from given dependency transactions
type ExportMetadata ¶
type ExportMetadata struct { DestinationChain string `json:"destination_chain"` DestinationChainID ids.ID `json:"destination_chain_id"` }
ExportMetadata contain response fields returned by /construction/metadata for P-chain Export transactions
type ImportExportOptions ¶
type ImportExportOptions struct { SourceChain string `json:"source_chain"` DestinationChain string `json:"destination_chain"` }
ImportExportOptions contain response fields returned by /construction/preprocess for P-chain Import/Export transactions
type ImportMetadata ¶
ImportMetadata contain response fields returned by /construction/metadata for P-chain Import transactions
type Metadata ¶
type Metadata struct { NetworkID uint32 `json:"network_id"` BlockchainID ids.ID `json:"blockchain_id"` *ImportMetadata *ExportMetadata *StakingMetadata }
Metadata contains metadata values returned by /construction/metadata for P-chain transactions
type OperationMetadata ¶
type OperationMetadata struct { Type string `json:"type"` SigIndices []uint32 `json:"sig_indices,omitempty"` Locktime uint64 `json:"locktime"` Threshold uint32 `json:"threshold,omitempty"` Matches []*parser.Match `json:"matches,omitempty"` }
OperationMetadata contains metadata fields specific to individual Rosetta operations as opposed to transactions
func ParseOpMetadata ¶
func ParseOpMetadata(metadata map[string]interface{}) (*OperationMetadata, error)
ParseOpMetadata creates an OperationMetadata from given generic metadata map
type SingleTxDependency ¶
type SingleTxDependency struct { // [Tx] has some of its outputs spent as // input from a tx dependent on it Tx *txs.Tx // Staker txs are rewarded at the end of staking period // with some utxos appended to staker txs' ones. // [RewardUTXOs] collects those reward utxos RewardUTXOs []*avax.UTXO // contains filtered or unexported fields }
SingleTxDependency represents a single dependency of a give transaction
type StakingMetadata ¶
type StakingMetadata struct { NodeID string `json:"node_id"` BLSPublicKey string `json:"bls_public_key"` BLSProofOfPossession string `json:"bls_proof_of_possession"` ValidationRewardsOwners []string `json:"reward_addresses"` DelegationRewardsOwners []string `json:"delegator_reward_addresses"` Start uint64 `json:"start"` // TODO: Remove Post-Durango End uint64 `json:"end"` Subnet string `json:"subnet"` Locktime uint64 `json:"locktime"` Threshold uint32 `json:"threshold"` }
StakingMetadata contain response fields returned by /construction/metadata for P-chain AddValidator/AddDelegator transactions
type StakingOptions ¶
type StakingOptions struct { NodeID string `json:"node_id"` BLSPublicKey string `json:"bls_public_key"` BLSProofOfPossession string `json:"bls_proof_of_possession"` ValidationRewardsOwners []string `json:"reward_addresses"` DelegationRewardsOwners []string `json:"delegator_reward_addresses"` Start uint64 `json:"start"` // TODO: Remove Post-Durango End uint64 `json:"end"` Subnet string `json:"subnet"` Locktime uint64 `json:"locktime"` Threshold uint32 `json:"threshold"` }
StakingOptions contain response fields returned by /construction/preprocess for P-chain AddValidator/AddDelegator transactions
type TxParser ¶
type TxParser struct {
// contains filtered or unexported fields
}
TxParser parses P-chain transactions and generate corresponding Rosetta operations
func NewTxParser ¶
func NewTxParser( cfg TxParserConfig, inputTxAccounts map[string]*types.AccountIdentifier, dependencyTxs BlockTxDependencies, ) (*TxParser, error)
NewTxParser returns a new transaction parser
type TxParserConfig ¶
type TxParserConfig struct { // IsConstruction indicates if parsing is done as part of construction or /block endpoints IsConstruction bool // Hrp used for address formatting Hrp string // ChainIDs maps chain id to chain id alias mappings // ChainIDs may provided by TxParser called or lazily initialized, // as soon as pChainClient is ready to serve requests ChainIDs map[ids.ID]constants.ChainIDAlias // AvaxAssetID contains asset id for AVAX currency AvaxAssetID ids.ID // PChainClient holds a P-chain client, used to lookup asset descriptions for non-AVAX assets PChainClient client.PChainClient }