Skip to content

Commit

Permalink
fix transfer and roll edit fees, fix roll side
Browse files Browse the repository at this point in the history
  • Loading branch information
Thykof committed Nov 9, 2023
1 parent f48cad0 commit c8a611f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 3 additions & 9 deletions internal/handler/wallet/rolls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand All @@ -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())

Expand All @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions internal/handler/wallet/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit c8a611f

Please sign in to comment.