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:
sihamon
2023-06-23 20:04:28 +02:00
committed by GitHub
parent 25385f1f16
commit a0df47f13a
5 changed files with 103 additions and 3 deletions

View File

@@ -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