Skip to content

Conversation

@turukawa
Copy link

@turukawa turukawa commented Dec 5, 2025

This is a fairly substantial pull request to get to a working version of the SDK. The updates can be divided into the following components:

  1. Model refactoring and fixes: generated code resulted in models that don't return data, or duplications and deeply-nested RootModels much of which could be deleted and simplified.
  2. New convenience functions: testing the API effectively requires building a full purchase workflow, but such a workflow is also useful to developers using the SDK. The README in the process folder details the main objectives and roadmap, and this update implements the simplest possible payments workflow for purchase and sale.
  3. Updated tests: all the tests should be refactored, especially as private endpoints have been committed to the repo. Tests for the convenience functions run through a complete workflow, and use the new environment variables to safely do a real-world test on the Rafiki test server.

I have commented the code I've introduced, with references, and hope this is straightforward to read.

All tests green. To run your own tests, please review the .env.example and add your own values.

`http-sfv` is deprecated in favour of `http-sf`. Replaced accordingly.
`classmethod` must return the value holding class data.
Optional fields are optional and not always returned.
These take in a variety of fixes:

- Row alignment and spacing
- Correct dependency import path

Note that this is only the most basic of fixes and much more needs to be done to fix duplicate functions and inefficient models.
It is good practice to place all environment variables - even demo ones used in 'test' - into a `.env` file that is excluded in the `.gitignore`. This commit adds:

- `pydantic-settings` to import environment variables from a `.env`
- `.env.example` for others to add their own settings
- `config.py` to import the settings and make them available in tests.
There are numerous changes:

- Removal of all unnecessary `RootModel` classes and refactoring for simple inheritence.
- Removal of duplicated `WalletAddress` class from `resource.py` and `auth.py`.
- Simplification of bizarre duplication of `LimitsOutgoing1`, `LimitsOutgoing2`, etc into a single class.

And multiple other quality of life fixes and improves. I have no doubt this could be improved further, but this is significantly easier to navigate and read.
The parser is useful for:

- Normalising wallet addresses from the form `$ilp.` to `https://ilp`.
- Converting stored private keys back to PEM format.
- Verifying payment response hash to validate buyer authentication.
This is the simplest function for processing a one-off payment between a purchaser and seller.

Includes:

- Pydantic models defining a seller account, and a pending incoming payment transaction that can be used to store stateless interactions (i.e. generate approval link -> third-party approval -> redirect for transaction completion)
- One-time payment process workflow.

A README covers the context and future functionality for this feature.
New dev dependencies required: `selenium` for authenticating purchase transactions via web, and `jupyterlab` for dev testing of code.

the `.env` requires a test wallet login and password to test the purchase approval workflow.
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.

1 participant