package rpcx import ( "context" "github.com/meshplus/bitxhub-kit/crypto" "github.com/meshplus/bitxhub-kit/types" "gitlab.33.cn/link33/sidecar/internal" "gitlab.33.cn/link33/sidecar/model/pb" ) type SubscriptionType int const ( SubscribeNewBlock SubscriptionType = iota ) //go:generate mockgen -destination mock_client/mock_client.go -package mock_client -source client.go type Client interface { internal.Launcher // Reset ecdsa key. SetPrivateKey(crypto.PrivateKey) // Send a readonly transaction to link33. If the transaction is writable, // this transaction will not be executed and error wil be returned. SendView(tx *pb.BxhTransaction) (*pb.Receipt, error) // Send a signed transaction to link33. If the signature is illegal, // the transaction hash will be obtained but the transaction receipt is illegal. SendTransaction(tx *pb.BxhTransaction, opts *TransactOpts) (string, error) // Send transaction to link33 and get the receipt. SendTransactionWithReceipt(tx *pb.BxhTransaction, opts *TransactOpts) (*pb.Receipt, error) // Get the receipt by transaction hash, // the status of the receipt is a sign of whether the transaction is successful. GetReceipt(hash string) (*pb.Receipt, error) // Get transaction from link33 by transaction hash. GetTransaction(hash string) (*pb.GetTransactionResponse, error) // Get the current blockchain situation of link33. GetChainMeta() (*pb.ChainMeta, error) // Get blocks of the specified block height range. GetBlocks(start uint64, end uint64) (*pb.GetBlocksResponse, error) // Obtain block information from link33. // The block header contains the basic information of the block, // and the block body contains all the transactions packaged. GetBlock(value string, blockType pb.GetBlockRequest_Type) (*pb.Block, error) // Get the status of the blockchain from link33, normal or abnormal. GetChainStatus() (*pb.Response, error) // Get the validators from link33. GetValidators() (*pb.Response, error) // Get the current network situation of link33. GetNetworkMeta() (*pb.Response, error) // Get account balance from link33 by address. GetAccountBalance(address string) (*pb.Response, error) // Get the missing block header from link33. GetBlockHeader(ctx context.Context, begin, end uint64, ch chan<- *pb.BlockHeader) error // Get the missing block header from link33. GetInterchainTxWrappers(ctx context.Context, pid string, begin, end uint64, ch chan<- *pb.InterchainTxWrappers) error // Subscribe to event notifications from link33. Subscribe(context.Context, pb.SubscriptionRequest_Type, []byte) (<-chan interface{}, error) // Deploy the contract, the contract address will be returned when the deployment is successful. DeployContract(contract []byte, opts *TransactOpts) (contractAddr *types.Address, err error) // GenerateContractTx generates signed transaction to invoke contract GenerateContractTx(vmType pb.TransactionData_VMType, address *types.Address, method string, args ...*pb.Arg) (*pb.BxhTransaction, error) // GenerateIBTPTx generates interchain tx with ibtp specified GenerateIBTPTx(ibtp *pb.IBTP) (*pb.BxhTransaction, error) // Call the contract according to the contract type, contract address, // contract method, and contract method parameters InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error) // Invoke the BVM contract, BVM is link33's blot contract. InvokeBVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error) // Invoke the XVM contract, XVM is WebAssembly contract. InvokeXVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error) // Get link33's signatures specified by id and type. GetMultiSigns(id string, typ pb.GetMultiSignsRequest_Type) (*pb.SignResponse, error) // GetPendingNonceByAccount returns the latest nonce of an account in the pending status, // and it should be the nonce for next transaction GetPendingNonceByAccount(account string) (uint64, error) HeartBeat(address string, index string) (*pb.Response, error) } type TransactOpts struct { From string Nonce uint64 } func New(opts ...Option) (Client, error) { panic("implement me") } type Interchain struct { ID string `json:"id"` InterchainCounter map[string]uint64 `json:"interchain_counter,omitempty"` ReceiptCounter map[string]uint64 `json:"receipt_counter,omitempty"` SourceReceiptCounter map[string]uint64 `json:"source_receipt_counter,omitempty"` }