mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
Add multi-mint swap to CLI and API (#212)
* Add multi-mint swap to CLI and API * Add confirmation prompt to CLI * Replace several assert statements * Define response for API endpoint swap * Adapt to latest changes on main * Fix: missing argument after latest changes on main * API: use local wallet for swap * Improve swap command * clean up cli swap * fix comment * clean up router * fix up * remove outgoing --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -21,16 +21,17 @@ from ...wallet.crud import get_keyset
|
||||
from ...wallet.wallet import Wallet as Wallet
|
||||
|
||||
|
||||
async def get_mint_wallet(ctx: Context):
|
||||
async def get_mint_wallet(ctx: Context, force_select: bool = False):
|
||||
"""
|
||||
Helper function that asks the user for an input to select which mint they want to load.
|
||||
Useful for selecting the mint that the user wants to send tokens from.
|
||||
"""
|
||||
# we load a dummy wallet so we can check the balance per mint
|
||||
wallet: Wallet = ctx.obj["WALLET"]
|
||||
await wallet.load_proofs(reload=True)
|
||||
mint_balances = await wallet.balance_per_minturl()
|
||||
|
||||
if ctx.obj["HOST"] not in mint_balances:
|
||||
if ctx.obj["HOST"] not in mint_balances and not force_select:
|
||||
mint_url = wallet.url
|
||||
elif len(mint_balances) > 1:
|
||||
# if we have balances on more than one mint, we ask the user to select one
|
||||
|
||||
Reference in New Issue
Block a user