code.vegaprotocol.io/vega@v0.79.0/wallet/service/v1/interfaces.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 v1
    17  
    18  import (
    19  	"context"
    20  
    21  	api "code.vegaprotocol.io/vega/protos/vega/api/v1"
    22  	commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1"
    23  	walletpb "code.vegaprotocol.io/vega/protos/vega/wallet/v1"
    24  	nodetypes "code.vegaprotocol.io/vega/wallet/api/node/types"
    25  	"code.vegaprotocol.io/vega/wallet/wallet"
    26  )
    27  
    28  // Generates mocks
    29  //go:generate go run github.com/golang/mock/mockgen -destination mocks/mocks.go -package mocks code.vegaprotocol.io/vega/wallet/service/v1 WalletHandler,Auth,NodeForward,RSAStore,SpamHandler
    30  
    31  //nolint:interfacebloat
    32  type WalletHandler interface {
    33  	CreateWallet(name, passphrase string) (string, error)
    34  	ImportWallet(name, passphrase, recoveryPhrase string, version uint32) error
    35  	LoginWallet(name, passphrase string) error
    36  	SecureGenerateKeyPair(name, passphrase string, meta []wallet.Metadata) (string, error)
    37  	GetPublicKey(name, pubKey string) (wallet.PublicKey, error)
    38  	ListPublicKeys(name string) ([]wallet.PublicKey, error)
    39  	SignTx(name string, req *walletpb.SubmitTransactionRequest, height uint64, chainID string) (*commandspb.Transaction, error)
    40  	SignAny(name string, inputData []byte, pubKey string) ([]byte, error)
    41  	VerifyAny(inputData, sig []byte, pubKey string) (bool, error)
    42  	TaintKey(name, pubKey, passphrase string) error
    43  	UpdateMeta(name, pubKey, passphrase string, meta []wallet.Metadata) error
    44  }
    45  
    46  type Auth interface {
    47  	NewSession(name string) (string, error)
    48  	VerifyToken(token string) (string, error)
    49  	Revoke(token string) (string, error)
    50  	RevokeAllToken()
    51  }
    52  
    53  type NodeForward interface {
    54  	SendTx(context.Context, *commandspb.Transaction, api.SubmitTransactionRequest_Type, int) (*api.SubmitTransactionResponse, error)
    55  	CheckTx(context.Context, *commandspb.Transaction, int) (*api.CheckTransactionResponse, error)
    56  	HealthCheck(context.Context) error
    57  	LastBlockHeightAndHash(context.Context) (*api.LastBlockHeightResponse, int, error)
    58  	SpamStatistics(context.Context, string) (*api.GetSpamStatisticsResponse, int, error)
    59  	Stop()
    60  }
    61  
    62  type RSAStore interface {
    63  	GetRsaKeys() (*RSAKeys, error)
    64  }
    65  
    66  type SpamHandler interface {
    67  	GenerateProofOfWork(pubKey string, stats *nodetypes.SpamStatistics) (*commandspb.ProofOfWork, error)
    68  	CheckSubmission(req *walletpb.SubmitTransactionRequest, stats *nodetypes.SpamStatistics) error
    69  }