github.com/cryptohub-digital/blockbook@v0.3.5-0.20240403155730-99ab40b9104c/bchain/coins/xcb/xcb_types.go (about) 1 package xcb 2 3 import ( 4 "context" 5 "math/big" 6 7 "github.com/cryptohub-digital/blockbook/bchain" 8 ) 9 10 // RpcLog is returned by xcb_getLogs 11 type RpcLog struct { 12 Address string `json:"address"` 13 Topics []string `json:"topics"` 14 Data string `json:"data"` 15 } 16 17 // RpcLog is returned by xcb_getTransactionReceipt 18 type RpcReceipt struct { 19 EnergyUsed string `json:"energyUsed"` 20 Status string `json:"status"` 21 Logs []*RpcLog `json:"logs"` 22 } 23 24 // CoreCoinSpecificData contains data specific to Core Coin transactions 25 type CoreCoinSpecificData struct { 26 Tx *RpcTransaction `json:"tx"` 27 Receipt *RpcReceipt `json:"receipt,omitempty"` 28 } 29 30 // RpcTransaction is returned by xcb_getTransactionByHash 31 type RpcTransaction struct { 32 AccountNonce string `json:"nonce"` 33 EnergyPrice string `json:"energyPrice"` 34 EnergyLimit string `json:"energy"` 35 To string `json:"to"` // nil means contract creation 36 Value string `json:"value"` 37 Payload string `json:"input"` 38 Hash string `json:"hash"` 39 BlockNumber string `json:"blockNumber"` 40 BlockHash string `json:"blockHash,omitempty"` 41 From string `json:"from"` 42 TransactionIndex string `json:"transactionIndex"` 43 } 44 45 // CVMClient provides the necessary client functionality for cvm chain sync 46 type CVMClient interface { 47 NetworkID(ctx context.Context) (*big.Int, error) 48 HeaderByNumber(ctx context.Context, number *big.Int) (CVMHeader, error) 49 SuggestEnergyPrice(ctx context.Context) (*big.Int, error) 50 EstimateEnergy(ctx context.Context, msg interface{}) (uint64, error) 51 BalanceAt(ctx context.Context, addrDesc bchain.AddressDescriptor, blockNumber *big.Int) (*big.Int, error) 52 NonceAt(ctx context.Context, addrDesc bchain.AddressDescriptor, blockNumber *big.Int) (uint64, error) 53 } 54 55 // CVMRPCClient provides the necessary rpc functionality for cvm chain sync 56 type CVMRPCClient interface { 57 XcbSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (CVMClientSubscription, error) 58 CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error 59 Close() 60 } 61 62 // CVMHeader provides access to the necessary header data for cvm chain sync 63 type CVMHeader interface { 64 Hash() string 65 Number() *big.Int 66 Difficulty() *big.Int 67 } 68 69 // CVMHash provides access to the necessary hash data for cvm chain sync 70 type CVMHash interface { 71 Hex() string 72 } 73 74 // CVMClientSubscription provides interaction with an cvm client subscription 75 type CVMClientSubscription interface { 76 Err() <-chan error 77 Unsubscribe() 78 } 79 80 // CVMSubscriber provides interaction with a subscription channel 81 type CVMSubscriber interface { 82 Channel() interface{} 83 Close() 84 } 85 86 // CVMNewBlockSubscriber provides interaction with a new block subscription channel 87 type CVMNewBlockSubscriber interface { 88 CVMSubscriber 89 Read() (CVMHeader, bool) 90 } 91 92 // CVMNewBlockSubscriber provides interaction with a new tx subscription channel 93 type CVMNewTxSubscriber interface { 94 CVMSubscriber 95 Read() (CVMHash, bool) 96 } 97 98 // CoreCoinBlockSpecificData contain data specific for Ethereum block 99 type CoreCoinBlockSpecificData struct { 100 Contracts []bchain.ContractInfo 101 } 102 103 const ( 104 // cbc token type names 105 CBC20TokenType bchain.TokenTypeName = "CBC20" 106 CBC721TokenType bchain.TokenTypeName = "CBC721" 107 )