-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from pavanjoshi914/format-sdk
format files with prettier
- Loading branch information
Showing
27 changed files
with
617 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import * as crypto from 'node:crypto'; // required in node.js | ||
import * as crypto from "node:crypto"; // required in node.js | ||
global.crypto = crypto; // required in node.js | ||
import 'websocket-polyfill' // required in node.js | ||
import "websocket-polyfill"; // required in node.js | ||
|
||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
import * as readline from "node:readline/promises"; | ||
import { stdin as input, stdout as output } from "node:process"; | ||
|
||
import { webln as providers } from "../../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const nwcUrl = await rl.question('Nostr Wallet Connect URL (nostrwalletconnect://...): '); | ||
const nwcUrl = await rl.question( | ||
"Nostr Wallet Connect URL (nostrwalletconnect://...): ", | ||
); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl }); | ||
const webln = new providers.NostrWebLNProvider({ | ||
nostrWalletConnectUrl: nwcUrl, | ||
}); | ||
await webln.enable(); | ||
const response = await webln.getBalance(); | ||
|
||
console.log(response); | ||
|
||
webln.close(); | ||
webln.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import * as crypto from 'node:crypto'; // required in node.js | ||
import * as crypto from "node:crypto"; // required in node.js | ||
global.crypto = crypto; // required in node.js | ||
import 'websocket-polyfill' // required in node.js | ||
import "websocket-polyfill"; // required in node.js | ||
|
||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
import * as readline from "node:readline/promises"; | ||
import { stdin as input, stdout as output } from "node:process"; | ||
|
||
import { webln as providers } from "../../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const nwcUrl = await rl.question('Nostr Wallet Connect URL (nostrwalletconnect://...): '); | ||
const nwcUrl = await rl.question( | ||
"Nostr Wallet Connect URL (nostrwalletconnect://...): ", | ||
); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl }); | ||
const webln = new providers.NostrWebLNProvider({ | ||
nostrWalletConnectUrl: nwcUrl, | ||
}); | ||
await webln.enable(); | ||
const response = await webln.makeInvoice({ | ||
amount: 100, | ||
defaultMemo: "NWC WebLN example" | ||
defaultMemo: "NWC WebLN example", | ||
}); | ||
|
||
console.log(response); | ||
|
||
webln.close(); | ||
webln.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import * as crypto from 'node:crypto'; // required in node.js | ||
import * as crypto from "node:crypto"; // required in node.js | ||
global.crypto = crypto; // required in node.js | ||
import 'websocket-polyfill' // required in node.js | ||
import "websocket-polyfill"; // required in node.js | ||
|
||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
import * as readline from "node:readline/promises"; | ||
import { stdin as input, stdout as output } from "node:process"; | ||
|
||
import { webln as providers } from "../../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const nwcUrl = await rl.question('Nostr Wallet Connect URL (nostrwalletconnect://...): '); | ||
const invoice = await rl.question('Lightning invoice: '); | ||
const nwcUrl = await rl.question( | ||
"Nostr Wallet Connect URL (nostrwalletconnect://...): ", | ||
); | ||
const invoice = await rl.question("Lightning invoice: "); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl }); | ||
const webln = new providers.NostrWebLNProvider({ | ||
nostrWalletConnectUrl: nwcUrl, | ||
}); | ||
await webln.enable(); | ||
const sendPaymentResponse = await webln.sendPayment(invoice); | ||
console.log(sendPaymentResponse); | ||
|
||
const getBalanceResponse = await webln.getBalance(); | ||
console.log(getBalanceResponse); | ||
|
||
webln.close(); | ||
webln.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
import * as readline from "node:readline/promises"; | ||
import { stdin as input, stdout as output } from "node:process"; | ||
|
||
import { auth, Client } from "../dist/index.module.js"; | ||
import { LightningAddress } from "alby-tools"; | ||
|
@@ -11,14 +11,18 @@ const authClient = new auth.OAuth2User({ | |
client_secret: process.env.CLIENT_SECRET, | ||
callback: "http://localhost:8080", | ||
scopes: ["payments:send"], | ||
token: { access_token: undefined, refresh_token: undefined, expires_at: undefined } // initialize with existing token | ||
token: { | ||
access_token: undefined, | ||
refresh_token: undefined, | ||
expires_at: undefined, | ||
}, // initialize with existing token | ||
}); | ||
|
||
console.log(`Open the following URL and authenticate the app:`); | ||
console.log(authClient.generateAuthURL()); | ||
console.log("----\n"); | ||
|
||
const code = await rl.question('Code: (localhost:8080?code=[THIS CODE]: '); | ||
const code = await rl.question("Code: (localhost:8080?code=[THIS CODE]: "); | ||
rl.close(); | ||
|
||
await authClient.requestAccessToken(code); | ||
|
@@ -29,7 +33,7 @@ const ln = new LightningAddress("[email protected]"); | |
// fetch the LNURL data | ||
await ln.fetch(); | ||
|
||
const invoice = await ln.requestInvoice({satoshi: 1000}); | ||
const invoice = await ln.requestInvoice({ satoshi: 1000 }); | ||
|
||
const response = await client.sendPayment({ invoice: invoice.paymentRequest }); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.