aboutsummaryrefslogtreecommitdiffstats
path: root/ethpipe/js_types.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethpipe/js_types.go')
-rw-r--r--ethpipe/js_types.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/ethpipe/js_types.go b/ethpipe/js_types.go
index e1743486b..0fb3a3876 100644
--- a/ethpipe/js_types.go
+++ b/ethpipe/js_types.go
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethcrypto"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
)
@@ -175,3 +176,33 @@ func NewJSReciept(contractCreation bool, creationAddress, hash, address []byte)
ethutil.Bytes2Hex(address),
}
}
+
+type JSMessage struct {
+ To string `json:"to"`
+ From string `json:"from"`
+ Input string `json:"input"`
+ Output string `json:"output"`
+ Path int32 `json:"path"`
+ Origin string `json:"origin"`
+ Timestamp int32 `json:"timestamp"`
+ Coinbase string `json:"coinbase"`
+ Block string `json:"block"`
+ Number int32 `json:"number"`
+ Value string `json:"value"`
+}
+
+func NewJSMessage(message *ethstate.Message) JSMessage {
+ return JSMessage{
+ To: ethutil.Bytes2Hex(message.To),
+ From: ethutil.Bytes2Hex(message.From),
+ Input: ethutil.Bytes2Hex(message.Input),
+ Output: ethutil.Bytes2Hex(message.Output),
+ Path: int32(message.Path),
+ Origin: ethutil.Bytes2Hex(message.Origin),
+ Timestamp: int32(message.Timestamp),
+ Coinbase: ethutil.Bytes2Hex(message.Origin),
+ Block: ethutil.Bytes2Hex(message.Block),
+ Number: int32(message.Number.Int64()),
+ Value: message.Value.String(),
+ }
+}