WIP Allow users to zap photos
Working, basic implementation of zaps for photos. No fetching or rendering of receipts yet.
This commit is contained in:
@@ -100,10 +100,76 @@ export class MockNostrRelayService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
export class MockNostrZapService extends Service {
|
||||
@tracked _lightningAddress = 'user@example.com';
|
||||
@tracked _endpoint = {
|
||||
callback: 'https://example.com/callback',
|
||||
minSendable: 1000,
|
||||
maxSendable: 100_000_000,
|
||||
allowsNostr: true,
|
||||
nostrPubkey: 'c'.repeat(64),
|
||||
};
|
||||
@tracked _webLNAvailable = false;
|
||||
@tracked _zapResult = {
|
||||
invoice: 'lnbc1u1pjtestinvoice1234567890',
|
||||
zapRequest: { id: 'zap-req-1' },
|
||||
};
|
||||
@tracked _parsedInvoice = {
|
||||
amount: 1_000_000,
|
||||
expiry: 9_999_999_999,
|
||||
description: 'test zap',
|
||||
};
|
||||
|
||||
@tracked recipientRelays = null;
|
||||
|
||||
getLightningAddress() {
|
||||
return this._lightningAddress;
|
||||
}
|
||||
|
||||
async resolveLnurl() {
|
||||
if (!this._endpoint.allowsNostr) {
|
||||
throw new Error('This lightning address does not support Nostr zaps');
|
||||
}
|
||||
return this._endpoint;
|
||||
}
|
||||
|
||||
async loadRecipientRelays() {
|
||||
this.recipientRelays = ['wss://relay.test'];
|
||||
return this.recipientRelays;
|
||||
}
|
||||
|
||||
getZapRelays() {
|
||||
return (
|
||||
this.recipientRelays || [
|
||||
'wss://relay.damus.io',
|
||||
'wss://nos.lol',
|
||||
'wss://relay.primal.net',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
hasWebLN() {
|
||||
return this._webLNAvailable;
|
||||
}
|
||||
|
||||
async zap() {
|
||||
return this._zapResult;
|
||||
}
|
||||
|
||||
parseInvoice() {
|
||||
return this._parsedInvoice;
|
||||
}
|
||||
|
||||
async payWithWebln() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function setupNostrMocks(hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
this.owner.register('service:nostrAuth', MockNostrAuthService);
|
||||
this.owner.register('service:nostrData', MockNostrDataService);
|
||||
this.owner.register('service:nostrRelay', MockNostrRelayService);
|
||||
this.owner.register('service:nostrZap', MockNostrZapService);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user