Add SetMsgEcho to helloworld contract
This method is used to demonstrate returning values from tx handlers.
@@ -35,6 +35,16 @@ func (c *HelloWorld) SetMsg(ctx contract.Context, req *types.MapEntry) error {
return ctx.Set([]byte(req.Key), req)
}
+func (c *HelloWorld) SetMsgEcho(ctx contract.Context, req *types.MapEntry) (*types.MapEntry, error) {
+ if err := ctx.Set([]byte(req.Key), req); err != nil {
+ return nil, err
+ }
+ return &types.MapEntry{
+ Key: req.Key,
+ Value: req.Value,
+ }, nil
+}
+
func (c *HelloWorld) GetMsg(ctx contract.StaticContext, req *types.MapEntry) (*types.MapEntry, error) {
var result types.MapEntry
if err := ctx.Get([]byte(req.Key), &result); err != nil {
