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

feat: Implement validation for token max order amount against provision bucket size #421

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sundayonah
Copy link
Collaborator

Description

This PR introduces validation for the provider's token max order amount in relation to the largest provision bucket size for their local currency. When updating a token's max order amount, the system now ensures that the amount, converted to the provider's local currency, does not exceed the size of the largest provision bucket. If the amount exceeds the largest bucket, or if no provision buckets exist for the provider's currency, the request is rejected with an appropriate error message.

References

closes #399

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this project has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main

@sundayonah sundayonah marked this pull request as draft February 7, 2025 07:04
@sundayonah sundayonah marked this pull request as ready for review February 7, 2025 14:50
Comment on lines 790 to 834
// t.Run("GetSenderProfile", func(t *testing.T) {
// testUser, err := test.CreateTestUser(map[string]interface{}{
// "email": "[email protected]",
// "scope": "sender",
// })
// assert.NoError(t, err)

// sender, err := test.CreateTestSenderProfile(map[string]interface{}{
// "domain_whitelist": []string{"mydomain.com"},
// "user_id": testUser.ID,
// })
// assert.NoError(t, err)

// apiKeyService := services.NewAPIKeyService()
// _, _, err = apiKeyService.GenerateAPIKey(
// context.Background(),
// nil,
// sender,
// nil,
// )
// assert.NoError(t, err)

// accessToken, _ := token.GenerateAccessJWT(testUser.ID.String(), "sender")
// headers := map[string]string{
// "Authorization": "Bearer " + accessToken,
// }
// res, err := test.PerformRequest(t, "GET", "/settings/sender", nil, headers, router)
// assert.NoError(t, err)

// // Assert the response body
// assert.Equal(t, http.StatusOK, res.Code)
// var response struct {
// Data types.SenderProfileResponse
// Message string
// }
// err = json.Unmarshal(res.Body.Bytes(), &response)
// assert.NoError(t, err)
// assert.Equal(t, "Profile retrieved successfully", response.Message)
// assert.NotNil(t, response.Data, "response.Data is nil")
// assert.Greater(t, len(response.Data.Tokens), 0)
// assert.Contains(t, response.Data.WebhookURL, "https://example.com")

// })

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment if not needed

Comment on lines 752 to 754
Network: "bitcoin",
Address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an evm network as example

polygon and a 0x.... address

Comment on lines 713 to 715
Network: "bitcoin",
Address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below

Comment on lines 675 to 677
Network: "bitcoin",
Address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below

Comment on lines 637 to 639
Network: "bitcoin",
Address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate Provider Token Max Order Amount Against Bucket Size
2 participants