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

Custom request implementation #93

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

minibits-cash
Copy link
Contributor

Implements: #92

Description

This change implements optional customRequest parameter to the CashuMint class and its methods. Every custom request implementation should follow the signature and types for default request method as defined in request.ts.

It then can be passed to the CashuMint class constructor, or optionally to its class methods (following the pattern that is already in place for mintUrl param).

Potential usage is a communication with the mints that might expose their API over other then TLS network connection, such as Tor.

Basic usage by the wallet:

import { CashuMint, } from '@cashu/cashu-ts'
import { torRequest } from '../services'

const getMint = function (mintUrl: string) {
    // ...
    if(mintUrl.includes('.onion')) {        
        const mint = new CashuMint(mintUrl, torRequest)        
    }
    // ...
}

Changes

  • Changes are limited to CashuMint class
  • Constructor accepts new optional param _customRequest
  • Static class methods accept new optional param customRequest
  • If custom method is passed it is used to make a request, otherwise default request implementation is used

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

@gandlafbtc
Copy link
Collaborator

Following up on this PR after merging a few other PRs. Sorry for the long wait! Should we rebase this branch and then review it?

@minibits-cash
Copy link
Contributor Author

Following up on this PR after merging a few other PRs. Sorry for the long wait! Should we rebase this branch and then review it?

I did the rebase of changes on top of the current main branch.

author misovan <[email protected]> 1696800460 +0200
committer misovan <[email protected]> 1705586653 +0100

parent 9338b18
author misovan <[email protected]> 1696800460 +0200
committer misovan <[email protected]> 1705586381 +0100

parent 6a881c3
author misovan <[email protected]> 1696800460 +0200
committer misovan <[email protected]> 1705581162 +0100

Add custom request option

Prettier
Copy link
Collaborator

@gandlafbtc gandlafbtc left a comment

Choose a reason for hiding this comment

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

great work! Maybe even worth to add a section on the readme about it. can be done later

@gandlafbtc gandlafbtc merged commit dec03df into cashubtc:main Jan 29, 2024
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.

3 participants