code.vegaprotocol.io/vega@v0.79.0/core/txn/command.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 txn
    17  
    18  // Command ...
    19  type Command byte
    20  
    21  // Custom blockchain command encoding, lighter-weight than proto.
    22  const (
    23  	// SubmitOrderCommand ...
    24  	SubmitOrderCommand Command = 0x40
    25  	// CancelOrderCommand ...
    26  	CancelOrderCommand Command = 0x41
    27  	// AmendOrderCommand ...
    28  	AmendOrderCommand Command = 0x42
    29  	// WithdrawCommand ...
    30  	WithdrawCommand Command = 0x44
    31  	// ProposeCommand ...
    32  	ProposeCommand Command = 0x45
    33  	// VoteCommand ...
    34  	VoteCommand Command = 0x46
    35  	// AnnounceNodeCommand ...
    36  	AnnounceNodeCommand Command = 0x47
    37  	// NodeVoteCommand ...
    38  	NodeVoteCommand Command = 0x48
    39  	// NodeSignatureCommand ...
    40  	NodeSignatureCommand Command = 0x49
    41  	// LiquidityProvisionCommand ...
    42  	LiquidityProvisionCommand Command = 0x4A
    43  	// CancelLiquidityProvisionCommand ...
    44  	CancelLiquidityProvisionCommand Command = 0x52
    45  	// AmendLiquidityProvisionCommand ...
    46  	AmendLiquidityProvisionCommand Command = 0x53
    47  	// ChainEventCommand ...
    48  	ChainEventCommand Command = 0x4B
    49  	// SubmitOracleDataCommand ...
    50  	SubmitOracleDataCommand Command = 0x4C
    51  	// DelegateCommand ...
    52  	DelegateCommand Command = 0x4D
    53  	// UndelegateCommand ...
    54  	UndelegateCommand Command = 0x4E
    55  	// RotateKeySubmissionCommand ...
    56  	RotateKeySubmissionCommand Command = 0x50
    57  	// StateVariableProposalCommand ...
    58  	StateVariableProposalCommand Command = 0x51
    59  	// TransferFundsCommand ...
    60  	TransferFundsCommand Command = 0x54
    61  	// CancelTransferFundsCommand ...
    62  	CancelTransferFundsCommand Command = 0x55
    63  	// ValidatorHeartbeatCommand ...
    64  	ValidatorHeartbeatCommand Command = 0x56
    65  	// RotateEthereumKeySubmissionCommand ...
    66  	RotateEthereumKeySubmissionCommand Command = 0x57
    67  	// ProtocolUpgradeCommand Command ...
    68  	ProtocolUpgradeCommand Command = 0x58
    69  	// IssueSignatures Command ...
    70  	IssueSignatures Command = 0x59
    71  	// BatchMarketInstructions Command ...
    72  	BatchMarketInstructions Command = 0x5A
    73  	// StopOrdersSubmissionCommand ...
    74  	StopOrdersSubmissionCommand Command = 0x5B
    75  	// StopOrdersCancellationCommand ...
    76  	StopOrdersCancellationCommand Command = 0x5C
    77  	// CreateReferralSetCommand ...
    78  	CreateReferralSetCommand Command = 0x5D
    79  	// UpdateReferralSetCommand ...
    80  	UpdateReferralSetCommand Command = 0x5E
    81  	// ApplyReferralCodeCommand ...
    82  	ApplyReferralCodeCommand Command = 0x5F
    83  	// UpdateMarginModeCommand ...
    84  	UpdateMarginModeCommand Command = 0x60
    85  	// JoinTeamCommand ...
    86  	JoinTeamCommand Command = 0x61
    87  	// BatchProposeCommand ...
    88  	BatchProposeCommand Command = 0x62
    89  	// UpdatePartyProfileCommand ...
    90  	UpdatePartyProfileCommand Command = 0x63
    91  	// SubmitAMMCommand ...
    92  	SubmitAMMCommand Command = 0x64
    93  	// AmendAMMCommand ...
    94  	AmendAMMCommand Command = 0x65
    95  	// CancelAMMCommand ...
    96  	CancelAMMCommand Command = 0x66
    97  	// DelayedTransactionsWrapper ...
    98  	DelayedTransactionsWrapper Command = 0x67
    99  )
   100  
   101  var commandName = map[Command]string{
   102  	SubmitOrderCommand:                 "Submit Order",
   103  	CancelOrderCommand:                 "Cancel Order",
   104  	AmendOrderCommand:                  "Amend Order",
   105  	WithdrawCommand:                    "Withdraw",
   106  	ProposeCommand:                     "Proposal",
   107  	VoteCommand:                        "Vote on Proposal",
   108  	AnnounceNodeCommand:                "Register New Node",
   109  	NodeVoteCommand:                    "Node Vote",
   110  	NodeSignatureCommand:               "Node Signature",
   111  	LiquidityProvisionCommand:          "Liquidity Provision Order",
   112  	CancelLiquidityProvisionCommand:    "Cancel Liquidity Provision Order",
   113  	AmendLiquidityProvisionCommand:     "Amend Liquidity Provision Order",
   114  	ChainEventCommand:                  "Chain Event",
   115  	SubmitOracleDataCommand:            "Submit Oracle Data",
   116  	DelegateCommand:                    "Delegate",
   117  	UndelegateCommand:                  "Undelegate",
   118  	RotateKeySubmissionCommand:         "Key Rotate Submission",
   119  	StateVariableProposalCommand:       "State Variable Proposal",
   120  	TransferFundsCommand:               "Transfer Funds",
   121  	CancelTransferFundsCommand:         "Cancel Transfer Funds",
   122  	ValidatorHeartbeatCommand:          "Validator Heartbeat",
   123  	RotateEthereumKeySubmissionCommand: "Ethereum Key Rotate Submission",
   124  	ProtocolUpgradeCommand:             "Protocol Upgrade",
   125  	IssueSignatures:                    "Issue Signatures",
   126  	BatchMarketInstructions:            "Batch Market Instructions",
   127  	StopOrdersSubmissionCommand:        "Stop Orders Submission",
   128  	StopOrdersCancellationCommand:      "Stop Orders Cancellation",
   129  	CreateReferralSetCommand:           "Create Referral Set",
   130  	UpdateReferralSetCommand:           "Update Referral Set",
   131  	ApplyReferralCodeCommand:           "Apply Referral Code",
   132  	UpdateMarginModeCommand:            "Update Margin Mode",
   133  	JoinTeamCommand:                    "Join Team",
   134  	BatchProposeCommand:                "Batch Proposal",
   135  	UpdatePartyProfileCommand:          "Update Party Profile",
   136  	SubmitAMMCommand:                   "Submit AMM",
   137  	AmendAMMCommand:                    "Amend AMM",
   138  	CancelAMMCommand:                   "Cancel AMM",
   139  	DelayedTransactionsWrapper:         "Delayed Transactions Wrapper",
   140  }
   141  
   142  func (cmd Command) IsValidatorCommand() bool {
   143  	switch cmd {
   144  	case DelayedTransactionsWrapper, NodeSignatureCommand, ChainEventCommand, NodeVoteCommand, ValidatorHeartbeatCommand, RotateKeySubmissionCommand, StateVariableProposalCommand, RotateEthereumKeySubmissionCommand:
   145  		return true
   146  	default:
   147  		return false
   148  	}
   149  }
   150  
   151  // String return the.
   152  func (cmd Command) String() string {
   153  	s, ok := commandName[cmd]
   154  	if ok {
   155  		return s
   156  	}
   157  	return ""
   158  }