From c8a611f2c6e8148e93fa16a7927b975e8ae5eb17 Mon Sep 17 00:00:00 2001 From: Nathan Seva Date: Thu, 9 Nov 2023 08:47:22 -0500 Subject: [PATCH] fix transfer and roll edit fees, fix roll side --- internal/handler/wallet/rolls.go | 12 +++--------- internal/handler/wallet/transfer.go | 8 +------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/internal/handler/wallet/rolls.go b/internal/handler/wallet/rolls.go index 8d3725401..095c14a76 100644 --- a/internal/handler/wallet/rolls.go +++ b/internal/handler/wallet/rolls.go @@ -40,12 +40,6 @@ func (t *tradeRolls) Handle(params operations.TradeRollsParams) middleware.Respo return newErrorResponse("Error during amount conversion", errorTradeRoll, http.StatusBadRequest) } - // convert fee to uint64 - fee, err := strconv.ParseUint(string(params.Body.Fee), 10, 64) - if err != nil { - return newErrorResponse("Error during fee conversion", errorTradeRoll, http.StatusBadRequest) - } - addressBytes, err := acc.Address.MarshalText() if err != nil { return newErrorResponse("failed to marshal address", errorGetAccount, http.StatusInternalServerError) @@ -62,7 +56,7 @@ func (t *tradeRolls) Handle(params operations.TradeRollsParams) middleware.Respo promptRequest := prompt.PromptRequest{ Action: walletapp.Sign, Data: PromptRequestSignData{ - Fees: strconv.FormatUint(fee, 10), + Fees: string(params.Body.Fee), WalletAddress: string(addressBytes), Nickname: acc.Nickname, OperationType: int(opType), @@ -88,7 +82,7 @@ func (t *tradeRolls) Handle(params operations.TradeRollsParams) middleware.Respo password := output.Password - operation, err := doTradeRolls(acc, password, amount, fee, opType, t.massaClient) + operation, err := doTradeRolls(acc, password, amount, output.Fees, opType, t.massaClient) if err != nil { msg := fmt.Sprintf("error %sing rolls coin: %v", *params.Body.Side, err.Error()) @@ -115,7 +109,7 @@ func doTradeRolls( massaClient network.NodeFetcherInterface, ) (*sendOperation.OperationResponse, error) { var operation sendOperation.Operation - if opType == sellrolls.OpType { + if opType == buyrolls.OpType { operation = buyrolls.New(amount) } else { operation = sellrolls.New(amount) diff --git a/internal/handler/wallet/transfer.go b/internal/handler/wallet/transfer.go index 3ad4411d2..5209d755d 100644 --- a/internal/handler/wallet/transfer.go +++ b/internal/handler/wallet/transfer.go @@ -40,12 +40,6 @@ func (t *transferCoin) Handle(params operations.TransferCoinParams) middleware.R return newErrorResponse("Error during amount conversion", errorTransferCoin, http.StatusBadRequest) } - // convert fee to uint64 - fee, err := strconv.ParseUint(string(params.Body.Fee), 10, 64) - if err != nil { - return newErrorResponse("Error during fee conversion", errorTransferCoin, http.StatusBadRequest) - } - addressBytes, err := acc.Address.MarshalText() if err != nil { return newErrorResponse(err.Error(), errorGetAccount, http.StatusInternalServerError) @@ -87,7 +81,7 @@ func (t *transferCoin) Handle(params operations.TransferCoinParams) middleware.R password := output.Password // create the transaction and send it to the network - operation, err := doTransfer(acc, password, amount, fee, *params.Body.RecipientAddress, t.massaClient) + operation, err := doTransfer(acc, password, amount, output.Fees, *params.Body.RecipientAddress, t.massaClient) if err != nil { msg := fmt.Sprintf("error transferring coin: %v", err.Error())