diff --git a/head.go b/head.go new file mode 100644 index 0000000..9843b1e --- /dev/null +++ b/head.go @@ -0,0 +1,24 @@ +package eosws + +import "time" + +func init() { + RegisterIncomingMessage("head_info", HeadInfo{}) + RegisterOutgoingMessage("get_head_info", GetHeadInfo{}) +} + +type HeadInfo struct { + CommonIn + Data struct{ + LastIrreversibleBlockNum uint32 `json:"last_irreversible_block_num"` + LastIrreversibleBlockId string `json:"last_irreversible_block_id"` + HeadBlockNum uint32 `json:"head_block_num"` + HeadBlockID string `json:"head_block_id"` + HeadBlockTime time.Time `json:"head_block_time"` + HeadBlockProducer string `json:"head_block_producer"` + } `json:"data"` +} + +type GetHeadInfo struct { + CommonOut +} \ No newline at end of file diff --git a/mdl/v1/block.go b/mdl/v1/block.go new file mode 100644 index 0000000..4a2ee58 --- /dev/null +++ b/mdl/v1/block.go @@ -0,0 +1,32 @@ +package mdl + +import ( + "time" +) + +type Block struct { + ID string `json:"id"` + Irreversible bool `json:"irreversible"` + Header *BlockHeader `json:"header"` + TransactionCount int `json:"transaction_count"` +} + +type BlockHeader struct { + Timestamp time.Time `json:"timestamp"` + Producer string `json:"producer"` + Confirmed uint16 `json:"confirmed"` + Previous string `json:"previous"` + TransactionMRoot string `json:"transaction_mroot"` + ActionMRoot string `json:"action_mroot"` + ScheduleVersion uint32 `json:"schedule_version"` + NewProducers *ProducerSchedule `json:"new_producers" eos:"optional"` +} + +type ProducerSchedule struct { + Version uint32 `json:"version"` + Producers []ProducerKey `json:"producers"` +} +type ProducerKey struct { + AccountName string `json:"producer_name"` + BlockSigningKey string `json:"block_signing_key"` +} diff --git a/mdl/v1/transaction.go b/mdl/v1/transaction.go index ccd5a32..f84fead 100644 --- a/mdl/v1/transaction.go +++ b/mdl/v1/transaction.go @@ -3,7 +3,7 @@ package mdl import ( "encoding/json" - eos "github.com/eoscanada/eos-go" + "github.com/eoscanada/eos-go" "github.com/eoscanada/eos-go/ecc" ) @@ -88,3 +88,8 @@ type ActionRef struct { TrxID string `json:"trx_id"` ActionIndex int `json:"action_index"` } + +type TransactionList struct { + NextCursor string `json:"next_cursor"` + Transactions []*TransactionLifecycle `json:"transactions"` +} diff --git a/transaction.go b/transaction.go new file mode 100644 index 0000000..0db5628 --- /dev/null +++ b/transaction.go @@ -0,0 +1,22 @@ +package eosws + +import "github.com/shrimpliu/eosws-go/mdl/v1" + +func init() { + RegisterOutgoingMessage("get_transaction_lifecycle", GetTrxLifecycle{}) + RegisterIncomingMessage("transaction_lifecycle", TrxLifecycle{}) +} + +type GetTrxLifecycle struct { + CommonOut + Data struct{ + ID string `json:"id"` + } +} + +type TrxLifecycle struct { + CommonIn + Data struct{ + Lifecycle *mdl.TransactionLifecycle `json:"lifecycle"` + } `json:"data"` +} \ No newline at end of file