Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pablof7z committed Nov 26, 2024
1 parent ec7bb98 commit aee2abd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ndk-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"homepage": "https://github.com/nostr-dev-kit/ndk",
"dependencies": {
"@cashu/cashu-ts": "2.0.0-rc1",
"@cashu/cashu-ts": "2.0.0-rc4",
"@getalby/sdk": "^3.6.1",
"@nostr-dev-kit/ndk": "workspace:*",
"debug": "^4.3.4",
Expand Down
2 changes: 0 additions & 2 deletions ndk-wallet/src/cashu/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const debug = createDebug("ndk-wallet:cashu:decrypt");
* Decrypts an NDKEvent using nip44, and if that fails, using nip04.
*/
export async function decrypt(event: NDKEvent) {
console.log("decrypting with the nip44/nip04 implementation");

try {
await event.decrypt(undefined, undefined, "nip44");
return;
Expand Down
8 changes: 4 additions & 4 deletions ndk-wallet/src/cashu/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ export class NDKCashuDeposit extends EventEmitter<{
async finalize() {
if (!this.quoteId) throw new Error("No quoteId set.");

let ret: { proofs: Array<Proof> };
let proofs: Array<Proof>;

try {
d("Checking for minting status of %s", this.quoteId);
this._wallet ??= await this.wallet.walletForMint(this.mint);
ret = await this._wallet.mintProofs(this.amount, this.quoteId);
if (!ret?.proofs) return;
proofs = await this._wallet.mintProofs(this.amount, this.quoteId);
if (proofs.length === 0) return;
} catch (e: any) {
if (e.message.match(/not paid/i)) return;
d(e.message);
Expand All @@ -133,7 +133,7 @@ export class NDKCashuDeposit extends EventEmitter<{
this.finalized = true;

const tokenEvent = new NDKCashuToken(this.wallet.ndk);
tokenEvent.proofs = ret.proofs;
tokenEvent.proofs = proofs;
tokenEvent.mint = this.mint;
tokenEvent.wallet = this.wallet;

Expand Down
3 changes: 1 addition & 2 deletions ndk-wallet/src/cashu/pay/nut.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Proof } from "@cashu/cashu-ts";
import { CashuMint, CashuWallet } from "@cashu/cashu-ts";
import type { MintUrl } from "../mint/utils";
import type { NDKCashuPay } from "../pay";
import { chooseProofsForAmount, chooseProofsForAmounts, rollOverProofs } from "../proofs";
Expand Down Expand Up @@ -79,7 +78,7 @@ async function payNutWithMintTransfer(

const wallet = await pay.wallet.walletForMint(mint);

const { proofs } = await wallet.mintProofs(amount, quote.quote, {
const proofs = await wallet.mintProofs(amount, quote.quote, {
pubkey: p2pk,
});

Expand Down
2 changes: 1 addition & 1 deletion ndk-wallet/src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class NDKWalletService extends EventEmitter<{
/**
* Starts monitoring changes for the user's wallets
*/
public start({ user, walletEvent }: { user?: NDKUser; walletEvent?: NDKEvent }) {
public start({ user, walletEvent }: { user?: NDKUser; walletEvent?: NDKEvent } = {}) {
// todo: check NIP-78 configuration for webln/nwc/nip-61 settings
this.lifecycle = new NDKWalletLifecycle(this.ndk, user ?? this.ndk.activeUser!);
this.lifecycle.on("mintlist:ready", (mintList: NDKCashuMintList) => {
Expand Down

0 comments on commit aee2abd

Please sign in to comment.