@@ -16,8 +16,8 @@ import NDK, { NDKEvent, NDKKind, NDKPrivateKeySigner, NDKRelaySet, NDKUser } fro
1616import { NDKCashuDeposit } from "../deposit.js" ;
1717import createDebug from "debug" ;
1818import type { MintUrl } from "../mint/utils.js" ;
19- import type { CashuWallet , MintKeys , Proof , SendResponse } from "@cashu/cashu-ts" ;
20- import { getDecodedToken } from "@cashu/cashu-ts" ;
19+ import type { CashuWallet , GetInfoResponse , MintKeys , Proof , SendResponse } from "@cashu/cashu-ts" ;
20+ import { CashuMint , getDecodedToken } from "@cashu/cashu-ts" ;
2121import { consolidateTokens } from "../validate.js" ;
2222import { NDKWallet , NDKWalletBalance , NDKWalletEvents , NDKWalletStatus } from "../../index.js" ;
2323import { EventEmitter } from "tseep" ;
@@ -36,7 +36,6 @@ export type WalletWarning = {
3636import { PaymentHandler , PaymentWithOptionalZapInfo } from "./payment.js" ;
3737import { createInTxEvent , createOutTxEvent } from "./txs.js" ;
3838import { WalletState } from "./state/index.js" ;
39- import { MintInfo } from "@cashu/cashu-ts/dist/lib/es5/model/MintInfo.js" ;
4039
4140/**
4241 * This class tracks state of a NIP-60 wallet
@@ -79,12 +78,12 @@ export class NDKCashuWallet extends EventEmitter<NDKWalletEvents & {
7978 * Called when the wallet needs to load mint info. Use this
8079 * to load mint info from a database or other source.
8180 */
82- public onMintInfoNeeded ?: ( mint : string ) => Promise < MintInfo | undefined > ;
81+ public onMintInfoNeeded ?: ( mint : string ) => Promise < GetInfoResponse | undefined > ;
8382
8483 /**
8584 * Called when the wallet has loaded mint info.
8685 */
87- public onMintInfoLoaded ?: ( mint : string , info : MintInfo ) => void ;
86+ public onMintInfoLoaded ?: ( mint : string , info : GetInfoResponse ) => void ;
8887
8988 /**
9089 * Called when the wallet needs to load mint keys. Use this
@@ -412,12 +411,16 @@ export class NDKCashuWallet extends EventEmitter<NDKWalletEvents & {
412411 async cashuWallet ( mint : string ) : Promise < CashuWallet > {
413412 if ( this . wallets . has ( mint ) ) return this . wallets . get ( mint ) as CashuWallet ;
414413
415- const mintInfo = await this . onMintInfoNeeded ?.( mint ) ;
414+ let mintInfo = await this . onMintInfoNeeded ?.( mint ) ;
416415 const mintKeys = await this . onMintKeysNeeded ?.( mint ) ;
417416
417+ if ( ! mintInfo && this . onMintInfoLoaded ) {
418+ mintInfo = await CashuMint . getInfo ( mint ) ;
419+ this . onMintInfoLoaded ?.( mint , mintInfo ) ;
420+ }
421+
418422 const w = await walletForMint ( mint , { mintInfo, mintKeys } ) ;
419423
420- if ( w ?. mintInfo ) this . onMintInfoLoaded ?.( mint , w . mintInfo ) ;
421424 if ( w ?. keys ) this . onMintKeysLoaded ?.( mint , w . keys ) ;
422425
423426 if ( ! w ) throw new Error ( "unable to load wallet for mint " + mint ) ;
0 commit comments