From ba4a5ccf62deff4c320de3c238e1ca241d2666b9 Mon Sep 17 00:00:00 2001
From: klim0v <klim0v-sergey@yandex.ru>
Date: Thu, 13 May 2021 01:02:26 +0300
Subject: [PATCH 1/2] fixes txs api responses

---
 CHANGELOG.md                         | 9 +++++++++
 api/v2/service/send_transaction.go   | 3 ++-
 coreV2/transaction/buy_swap_pool.go  | 3 +--
 coreV2/transaction/sell_swap_pool.go | 2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f1378732..9b5f53ab5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
 # Changelog
 
+## [v2.2.1](https://github.com/MinterTeam/minter-go-node/tree/v2.2.1)
+
+[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.2.0...v2.2.1)
+
+### Fixed
+
+- Swap pool tx tags *coin_to_sell* and *coin_to_buy*
+- Hash of the transaction in send API response
+
 ## [v2.2.0](https://github.com/MinterTeam/minter-go-node/tree/v2.2.0)
 
 [Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.1.0...v2.2.0)
diff --git a/api/v2/service/send_transaction.go b/api/v2/service/send_transaction.go
index 8c5c85de3..f3526939b 100644
--- a/api/v2/service/send_transaction.go
+++ b/api/v2/service/send_transaction.go
@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"encoding/hex"
+	"fmt"
 	"github.com/MinterTeam/minter-go-node/coreV2/code"
 	pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
 	abci "github.com/tendermint/tendermint/abci/types"
@@ -36,7 +37,7 @@ func (s *Service) SendTransaction(ctx context.Context, req *pb.SendTransactionRe
 	return &pb.SendTransactionResponse{
 		Code: uint64(result.Code),
 		Log:  result.Log,
-		Hash: "Mt" + strings.ToLower(result.Hash.String()),
+		Hash: "Mt" + strings.ToLower(fmt.Sprintf("%x", result.Hash)),
 	}, nil
 }
 
diff --git a/coreV2/transaction/buy_swap_pool.go b/coreV2/transaction/buy_swap_pool.go
index 48ae95d41..98b963190 100644
--- a/coreV2/transaction/buy_swap_pool.go
+++ b/coreV2/transaction/buy_swap_pool.go
@@ -185,7 +185,6 @@ func (data BuySwapPoolData) Run(tx *Transaction, context state.Interface, reward
 		rewardPool.Add(rewardPool, commissionInBaseCoin)
 
 		coinToBuy := data.Coins[0]
-		resultCoin := data.Coins[len(data.Coins)-1]
 		valueToBuy := data.ValueToBuy
 
 		var poolIDs tagPoolsChange
@@ -223,7 +222,7 @@ func (data BuySwapPoolData) Run(tx *Transaction, context state.Interface, reward
 			{Key: []byte("tx.commission_conversion"), Value: []byte(isGasCommissionFromPoolSwap.String()), Index: true},
 			{Key: []byte("tx.commission_amount"), Value: []byte(commission.String())},
 			{Key: []byte("tx.coin_to_buy"), Value: []byte(data.Coins[0].String()), Index: true},
-			{Key: []byte("tx.coin_to_sell"), Value: []byte(resultCoin.String()), Index: true},
+			{Key: []byte("tx.coin_to_sell"), Value: []byte(data.Coins[len(data.Coins)-1].String()), Index: true},
 			{Key: []byte("tx.return"), Value: []byte(amountIn.String())},
 			{Key: []byte("tx.pools"), Value: []byte(poolIDs.string())},
 		}
diff --git a/coreV2/transaction/sell_swap_pool.go b/coreV2/transaction/sell_swap_pool.go
index 9eb0ecb68..9e9dfc11b 100644
--- a/coreV2/transaction/sell_swap_pool.go
+++ b/coreV2/transaction/sell_swap_pool.go
@@ -204,7 +204,7 @@ func (data SellSwapPoolData) Run(tx *Transaction, context state.Interface, rewar
 			{Key: []byte("tx.commission_in_base_coin"), Value: []byte(commissionInBaseCoin.String())},
 			{Key: []byte("tx.commission_conversion"), Value: []byte(isGasCommissionFromPoolSwap.String()), Index: true},
 			{Key: []byte("tx.commission_amount"), Value: []byte(commission.String())},
-			{Key: []byte("tx.coin_to_buy"), Value: []byte(data.Coins[lastIteration].String()), Index: true},
+			{Key: []byte("tx.coin_to_buy"), Value: []byte(data.Coins[len(data.Coins)-1].String()), Index: true},
 			{Key: []byte("tx.coin_to_sell"), Value: []byte(data.Coins[0].String()), Index: true},
 			{Key: []byte("tx.return"), Value: []byte(amountOut.String())},
 			{Key: []byte("tx.pools"), Value: []byte(poolIDs.string())},

From 4919d606718c30a727b3d57a561111c8029658f8 Mon Sep 17 00:00:00 2001
From: klim0v <klim0v-sergey@yandex.ru>
Date: Mon, 17 May 2021 15:10:03 +0300
Subject: [PATCH 2/2] update version

---
 version/version.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/version/version.go b/version/version.go
index 42ac71985..e42c39862 100755
--- a/version/version.go
+++ b/version/version.go
@@ -7,7 +7,7 @@ const (
 
 var (
 	// Version must be a string because scripts like dist.sh read this file.
-	Version = "2.2.0"
+	Version = "2.2.1"
 
 	// GitCommit is the current HEAD set using ldflags.
 	GitCommit string