Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix transfer and roll edit fees, fix roll side #838

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/handler/wallet/rolls.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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 +115,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
4 changes: 2 additions & 2 deletions internal/handler/wallet/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (t *transferCoin) Handle(params operations.TransferCoinParams) middleware.R
promptRequest := prompt.PromptRequest{
Action: walletapp.Sign,
Data: PromptRequestSignData{
Fees: string(params.Body.Fee),
Fees: strconv.FormatUint(fee, 10),
WalletAddress: address,
Nickname: acc.Nickname,
OperationType: int(transaction.OpType),
Expand All @@ -87,7 +87,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
11 changes: 11 additions & 0 deletions internal/handler/wallet/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ func Test_transfer_handler(t *testing.T) {
assert.Equal(t, http.StatusNotFound, resp.Result().StatusCode)
})

t.Run("Transfer with invalid fee", func(t *testing.T) {
resp, err := handleHTTPRequest(handler, "POST", fmt.Sprintf("/api/accounts/%s/transfer", nickname), `{
"fee": "none",
"amount": "5",
"recipientAddress": "AU1eQkRhZZBa5VNc24fCejxgFDpe1FHChpwiUksQB9StNb3rWm6i"
}`)

assert.NoError(t, err)
assert.Equal(t, http.StatusBadRequest, resp.Result().StatusCode)
})

t.Run("Transfer with invalid amount", func(t *testing.T) {
resp, err := handleHTTPRequest(handler, "POST", fmt.Sprintf("/api/accounts/%s/transfer", nickname), `{
"fee": "1",
Expand Down
Loading