From a97e0cc605351a33d80c325adf5ebeb8a323ee88 Mon Sep 17 00:00:00 2001 From: "diamondburned (Forefront)" Date: Wed, 11 Dec 2019 23:12:09 -0800 Subject: [PATCH 1/3] Temporary patch to 'Unsupported event' --- wctl/ws_accounts.go | 2 +- wctl/ws_consensus.go | 2 +- wctl/ws_contract.go | 2 +- wctl/ws_network.go | 2 +- wctl/ws_tx.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wctl/ws_accounts.go b/wctl/ws_accounts.go index 460eaa07..2e46f50b 100644 --- a/wctl/ws_accounts.go +++ b/wctl/ws_accounts.go @@ -26,7 +26,7 @@ func (c *Client) PollAccounts() (func(), error) { case "reward_updated": err = parseAccountRewardUpdated(c, o) default: - err = errInvalidEvent(o, ev) + // err = errInvalidEvent(o, ev) } if err != nil { diff --git a/wctl/ws_consensus.go b/wctl/ws_consensus.go index 0e1df1da..b1ded3e2 100644 --- a/wctl/ws_consensus.go +++ b/wctl/ws_consensus.go @@ -23,7 +23,7 @@ func (c *Client) pollConsensus() (func(), error) { case "finalized": err = parseConsensusFinalized(c, v) default: - err = errInvalidEvent(v, ev) + // err = errInvalidEvent(v, ev) } if err != nil { diff --git a/wctl/ws_contract.go b/wctl/ws_contract.go index ade447ba..c262e192 100644 --- a/wctl/ws_contract.go +++ b/wctl/ws_contract.go @@ -20,7 +20,7 @@ func (c *Client) PollContracts() (func(), error) { case "log": err = parseContractLog(c, o) default: - err = errInvalidEvent(o, ev) + // err = errInvalidEvent(o, ev) } if err != nil { diff --git a/wctl/ws_network.go b/wctl/ws_network.go index 96b970bc..bf63b961 100644 --- a/wctl/ws_network.go +++ b/wctl/ws_network.go @@ -19,7 +19,7 @@ func (c *Client) PollNetwork() (func(), error) { case "left": err = parsePeerLeave(c, v) default: - err = errInvalidEvent(v, ev) + // err = errInvalidEvent(v, ev) } if err != nil { diff --git a/wctl/ws_tx.go b/wctl/ws_tx.go index a30af4af..8b963c89 100644 --- a/wctl/ws_tx.go +++ b/wctl/ws_tx.go @@ -26,7 +26,7 @@ func (c *Client) PollTransactions() (func(), error) { case ev == "failed": err = parseTxFailed(c, o) default: - err = errInvalidEvent(o, ev) + // err = errInvalidEvent(o, ev) } if err != nil { From 48e8650a20098ddf84bdef586245cf5554a027ae Mon Sep 17 00:00:00 2001 From: diamondburned Date: Fri, 13 Dec 2019 08:17:14 -0800 Subject: [PATCH 2/3] Added TxRejected --- log.go | 1 + wctl/wctl.go | 1 + wctl/ws_accounts.go | 2 +- wctl/ws_callbacks.go | 9 +++++++++ wctl/ws_consensus.go | 2 +- wctl/ws_contract.go | 2 +- wctl/ws_network.go | 2 +- wctl/ws_tx.go | 29 ++++++++++++++++++++++++++++- 8 files changed, 43 insertions(+), 5 deletions(-) diff --git a/log.go b/log.go index 1c52d2b0..2ac31d05 100644 --- a/log.go +++ b/log.go @@ -129,6 +129,7 @@ func (c *CollapseResultsLogger) Log(results *collapseResults) { func (c *CollapseResultsLogger) addTx(mod, event []byte, timestamp time.Time, tag int, txID []byte, sender []byte, logError error) { + o := c.arena.NewObject() o.Set("mod", c.arena.NewStringBytes(mod)) diff --git a/wctl/wctl.go b/wctl/wctl.go index 33b3c9e2..f3ebff90 100644 --- a/wctl/wctl.go +++ b/wctl/wctl.go @@ -120,6 +120,7 @@ type Client struct { // PollTransactions OnTxApplied OnTxGossipError + OnTxRejected OnTxFailed OnMetrics diff --git a/wctl/ws_accounts.go b/wctl/ws_accounts.go index 2e46f50b..460eaa07 100644 --- a/wctl/ws_accounts.go +++ b/wctl/ws_accounts.go @@ -26,7 +26,7 @@ func (c *Client) PollAccounts() (func(), error) { case "reward_updated": err = parseAccountRewardUpdated(c, o) default: - // err = errInvalidEvent(o, ev) + err = errInvalidEvent(o, ev) } if err != nil { diff --git a/wctl/ws_callbacks.go b/wctl/ws_callbacks.go index a9eb6118..be906626 100644 --- a/wctl/ws_callbacks.go +++ b/wctl/ws_callbacks.go @@ -112,6 +112,15 @@ type ( } OnTxApplied = func(TxApplied) + TxRejected struct { + TxID [32]byte `json:"tx_id"` + SenderID [32]byte `json:"sender_id"` + Tag byte `json:"tag"` + Error string `json:"error,omitempty"` + Time time.Time `json:"time"` + } + OnTxRejected = func(TxRejected) + TxGossipError struct { Error string `json:"error"` Time time.Time `json:"time"` diff --git a/wctl/ws_consensus.go b/wctl/ws_consensus.go index b1ded3e2..0e1df1da 100644 --- a/wctl/ws_consensus.go +++ b/wctl/ws_consensus.go @@ -23,7 +23,7 @@ func (c *Client) pollConsensus() (func(), error) { case "finalized": err = parseConsensusFinalized(c, v) default: - // err = errInvalidEvent(v, ev) + err = errInvalidEvent(v, ev) } if err != nil { diff --git a/wctl/ws_contract.go b/wctl/ws_contract.go index c262e192..ade447ba 100644 --- a/wctl/ws_contract.go +++ b/wctl/ws_contract.go @@ -20,7 +20,7 @@ func (c *Client) PollContracts() (func(), error) { case "log": err = parseContractLog(c, o) default: - // err = errInvalidEvent(o, ev) + err = errInvalidEvent(o, ev) } if err != nil { diff --git a/wctl/ws_network.go b/wctl/ws_network.go index bf63b961..96b970bc 100644 --- a/wctl/ws_network.go +++ b/wctl/ws_network.go @@ -19,7 +19,7 @@ func (c *Client) PollNetwork() (func(), error) { case "left": err = parsePeerLeave(c, v) default: - // err = errInvalidEvent(v, ev) + err = errInvalidEvent(v, ev) } if err != nil { diff --git a/wctl/ws_tx.go b/wctl/ws_tx.go index 8b963c89..4bb1e2fb 100644 --- a/wctl/ws_tx.go +++ b/wctl/ws_tx.go @@ -25,8 +25,10 @@ func (c *Client) PollTransactions() (func(), error) { err = parseTxGossipError(c, o) case ev == "failed": err = parseTxFailed(c, o) + case ev == "rejected": + err = parseTxRejected(c, o) default: - // err = errInvalidEvent(o, ev) + err = errInvalidEvent(o, ev) } if err != nil { @@ -81,6 +83,31 @@ func parseTxGossipError(c *Client, v *fastjson.Value) error { return nil } +func parseTxRejected(c *Client, v *fastjson.Value) error { + var t TxRejected + + if err := jsonHex(v, t.TxID[:], "tx_id"); err != nil { + return err + } + + if err := jsonHex(v, t.SenderID[:], "sender_id"); err != nil { + return err + } + + t.Tag = byte(v.GetUint("tag")) + t.Error = jsonString(v, "error") + + if err := jsonTime(v, &t.Time, "time"); err != nil { + return err + } + + if c.OnTxRejected != nil { + c.OnTxRejected(t) + } + + return nil +} + func parseTxFailed(c *Client, v *fastjson.Value) error { var t TxFailed From 0704c234b70895323ca161ad701d4b059ff91326 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Fri, 13 Dec 2019 08:23:34 -0800 Subject: [PATCH 3/3] Added execute into ContractGas --- wctl/ws_contract.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wctl/ws_contract.go b/wctl/ws_contract.go index ade447ba..2e25f901 100644 --- a/wctl/ws_contract.go +++ b/wctl/ws_contract.go @@ -15,7 +15,7 @@ func (c *Client) PollContracts() (func(), error) { } switch ev := jsonString(o, "event"); ev { - case "gas": + case "gas", "execute": // tx_applier.go same structure err = parseContractGas(c, o) case "log": err = parseContractLog(c, o)