format react with linter

This commit is contained in:
Jesse de Wit
2023-11-10 21:26:19 +01:00
committed by ok300
parent 48fe09ea98
commit 707a11c3fa
12 changed files with 207 additions and 207 deletions

View File

@@ -1,12 +1,12 @@
import { import {
buyBitcoin, buyBitcoin,
BuyBitcoinProvider BuyBitcoinProvider
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleBuyBtc = async () => { const exampleBuyBtc = async () => {
// ANCHOR: buy-btc // ANCHOR: buy-btc
const buyBitcoinResponse = await buyBitcoin({ const buyBitcoinResponse = await buyBitcoin({
provider: BuyBitcoinProvider.MOONPAY provider: BuyBitcoinProvider.MOONPAY
}) })
// ANCHOR_END: buy-btc // ANCHOR_END: buy-btc
} }

View File

@@ -1,15 +1,15 @@
import { connectLsp, lspId, lspInfo } from "@breeztech/react-native-breez-sdk" import { connectLsp, lspId, lspInfo } from '@breeztech/react-native-breez-sdk'
const exampleAutoConnect = async () => { const exampleAutoConnect = async () => {
// ANCHOR: get-lsp-info // ANCHOR: get-lsp-info
const id = await lspId() const id = await lspId()
const info = await lspInfo() const info = await lspInfo()
// ANCHOR_END: get-lsp-info // ANCHOR_END: get-lsp-info
} }
const exampleManualConnect = async () => { const exampleManualConnect = async () => {
// ANCHOR: connect-lsp // ANCHOR: connect-lsp
const id = "your selected lsp id" const id = 'your selected lsp id'
await connectLsp(id) await connectLsp(id)
// ANCHOR_END: connect-lsp // ANCHOR_END: connect-lsp
} }

View File

@@ -1,22 +1,22 @@
import { import {
listFiatCurrencies, listFiatCurrencies,
fetchFiatRates fetchFiatRates
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleListCurrencies = async () => { const exampleListCurrencies = async () => {
// ANCHOR: list-fiat-currencies // ANCHOR: list-fiat-currencies
const fiatCurrencies = await listFiatCurrencies() const fiatCurrencies = await listFiatCurrencies()
// ANCHOR_END: list-fiat-currencies // ANCHOR_END: list-fiat-currencies
} }
const exampleFetchRates = async () => { const exampleFetchRates = async () => {
// ANCHOR: fetch-fiat-rates // ANCHOR: fetch-fiat-rates
const fiatRates = await fetchFiatRates() const fiatRates = await fetchFiatRates()
// ANCHOR_END: fetch-fiat-rates // ANCHOR_END: fetch-fiat-rates
} }
const exampleListCurrenciesAndRates = async () => { const exampleListCurrenciesAndRates = async () => {
// ANCHOR: get-fiat-currencies-and-rates // ANCHOR: get-fiat-currencies-and-rates
// TODO // TODO
// ANCHOR_END: get-fiat-currencies-and-rates // ANCHOR_END: get-fiat-currencies-and-rates
} }

View File

@@ -1,47 +1,47 @@
import { import {
BreezEvent, type BreezEvent,
connect, connect,
defaultConfig, defaultConfig,
EnvironmentType, EnvironmentType,
mnemonicToSeed, mnemonicToSeed,
NodeConfig, type NodeConfig,
NodeConfigVariant, NodeConfigVariant,
nodeInfo nodeInfo
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleGettingStarted = async () => { const exampleGettingStarted = async () => {
// ANCHOR: init-sdk // ANCHOR: init-sdk
// SDK events listener // SDK events listener
const onBreezEvent = (e: BreezEvent) => { const onBreezEvent = (e: BreezEvent) => {
console.log(`Received event ${e.type}`) console.log(`Received event ${e.type}`)
}
// Create the default config
const seed = await mnemonicToSeed('<mnemonics words>')
const inviteCode = '<invite code>'
const apiKey = '<api key>'
const nodeConfig: NodeConfig = {
type: NodeConfigVariant.GREENLIGHT,
config: {
inviteCode
} }
}
// Create the default config const config = await defaultConfig(
const seed = await mnemonicToSeed("<mnemonics words>") EnvironmentType.PRODUCTION,
const inviteCode = "<invite code>" apiKey,
const apiKey = "<api key>" nodeConfig
const nodeConfig: NodeConfig = { )
type: NodeConfigVariant.GREENLIGHT,
config: {
inviteCode
}
}
const config = await defaultConfig( // Connect to the Breez SDK make it ready for use
EnvironmentType.PRODUCTION, await connect(config, seed, onBreezEvent)
apiKey, // ANCHOR_END: init-sdk
nodeConfig
)
// Connect to the Breez SDK make it ready for use
await connect(config, seed, onBreezEvent)
// ANCHOR_END: init-sdk
} }
const exampleFetchNodeInfo = async () => { const exampleFetchNodeInfo = async () => {
// ANCHOR: fetch-balance // ANCHOR: fetch-balance
const nodeState = await nodeInfo() const nodeState = await nodeInfo()
const balanceLn = nodeState.channelsBalanceMsat const balanceLn = nodeState.channelsBalanceMsat
const balanceOnchain = nodeState.onchainBalanceMsat const balanceOnchain = nodeState.onchainBalanceMsat
// ANCHOR_END: fetch-balance // ANCHOR_END: fetch-balance
} }

View File

@@ -1,25 +1,25 @@
import { import {
InputTypeVariant, InputTypeVariant,
lnurlAuth, lnurlAuth,
LnUrlCallbackStatusVariant, LnUrlCallbackStatusVariant,
parseInput parseInput
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleLnurlAuth = async () => { const exampleLnurlAuth = async () => {
// ANCHOR: lnurl-auth // ANCHOR: lnurl-auth
// Endpoint can also be of the form: // Endpoint can also be of the form:
// keyauth://domain.com/auth?key=val // keyauth://domain.com/auth?key=val
const lnurlAuthUrl = const lnurlAuthUrl =
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu" 'lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu'
const input = await parseInput(lnurlAuthUrl) const input = await parseInput(lnurlAuthUrl)
if (input.type === InputTypeVariant.LN_URL_AUTH) { if (input.type === InputTypeVariant.LN_URL_AUTH) {
const result = await lnurlAuth(input.data) const result = await lnurlAuth(input.data)
if (result.type === LnUrlCallbackStatusVariant.OK) { if (result.type === LnUrlCallbackStatusVariant.OK) {
console.log("Successfully authenticated") console.log('Successfully authenticated')
} else { } else {
console.log("Failed to authenticate") console.log('Failed to authenticate')
}
} }
// ANCHOR_END: lnurl-auth }
// ANCHOR_END: lnurl-auth
} }

View File

@@ -1,24 +1,24 @@
import { import {
InputTypeVariant, InputTypeVariant,
parseInput, parseInput,
payLnurl payLnurl
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleLnurlPay = async () => { const exampleLnurlPay = async () => {
// ANCHOR: lnurl-pay // ANCHOR: lnurl-pay
// Endpoint can also be of the // Endpoint can also be of the
// lnurlp://domain.com/lnurl-pay?key=val // lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf // lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
const lnurlPayUrl = "lightning@address.com" const lnurlPayUrl = 'lightning@address.com'
const input = await parseInput(lnurlPayUrl) const input = await parseInput(lnurlPayUrl)
if (input.type === InputTypeVariant.LN_URL_PAY) { if (input.type === InputTypeVariant.LN_URL_PAY) {
const amountMsat = input.data.minSendable const amountMsat = input.data.minSendable
const lnUrlPayResult = await payLnurl({ const lnUrlPayResult = await payLnurl({
data: input.data, data: input.data,
amountMsat, amountMsat,
comment: "comment" comment: 'comment'
}) })
} }
// ANCHOR_END: lnurl-pay // ANCHOR_END: lnurl-pay
} }

View File

@@ -1,24 +1,24 @@
import { import {
InputTypeVariant, InputTypeVariant,
parseInput, parseInput,
withdrawLnurl withdrawLnurl
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleLnurlWithdraw = async () => { const exampleLnurlWithdraw = async () => {
// ANCHOR: lnurl-withdraw // ANCHOR: lnurl-withdraw
// Endpoint can also be of the form: // Endpoint can also be of the form:
// lnurlw://domain.com/lnurl-withdraw?key=val // lnurlw://domain.com/lnurl-withdraw?key=val
const lnurlWithdrawUrl = const lnurlWithdrawUrl =
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk" 'lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk'
const input = await parseInput(lnurlWithdrawUrl) const input = await parseInput(lnurlWithdrawUrl)
if (input.type === InputTypeVariant.LN_URL_WITHDRAW) { if (input.type === InputTypeVariant.LN_URL_WITHDRAW) {
const amountMsat = input.data.minWithdrawable const amountMsat = input.data.minWithdrawable
const lnUrlWithdrawResult = await withdrawLnurl({ const lnUrlWithdrawResult = await withdrawLnurl({
data: input.data, data: input.data,
amountMsat, amountMsat,
description: "comment" description: 'comment'
}) })
} }
// ANCHOR_END: lnurl-withdraw // ANCHOR_END: lnurl-withdraw
} }

View File

@@ -1,52 +1,52 @@
import { import {
inProgressSwap, inProgressSwap,
listRefundables, listRefundables,
openChannelFee, openChannelFee,
receiveOnchain, receiveOnchain,
refund refund
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleReceiveOnchain = async () => { const exampleReceiveOnchain = async () => {
// ANCHOR: generate-receive-onchain-address // ANCHOR: generate-receive-onchain-address
const swapInfo = await receiveOnchain({}) const swapInfo = await receiveOnchain({})
// Send your funds to the below bitcoin address // Send your funds to the below bitcoin address
const address = swapInfo.bitcoinAddress const address = swapInfo.bitcoinAddress
// ANCHOR_END: generate-receive-onchain-address // ANCHOR_END: generate-receive-onchain-address
} }
const exampleInProgressSwap = async () => { const exampleInProgressSwap = async () => {
// ANCHOR: in-progress-swap // ANCHOR: in-progress-swap
const swapInfo = await inProgressSwap() const swapInfo = await inProgressSwap()
// ANCHOR_END: in-progress-swap // ANCHOR_END: in-progress-swap
} }
const exampleListRefundables = async () => { const exampleListRefundables = async () => {
// ANCHOR: list-refundables // ANCHOR: list-refundables
const refundables = await listRefundables() const refundables = await listRefundables()
// ANCHOR_END: list-refundables // ANCHOR_END: list-refundables
} }
const exampleRefund = async () => { const exampleRefund = async () => {
// ANCHOR: execute-refund // ANCHOR: execute-refund
const refundables = await listRefundables() const refundables = await listRefundables()
const toAddress = "..." const toAddress = '...'
const satPerVbyte = 5 const satPerVbyte = 5
const refundResponse = await refund({ const refundResponse = await refund({
swapAddress: refundables[0].bitcoinAddress, swapAddress: refundables[0].bitcoinAddress,
toAddress, toAddress,
satPerVbyte satPerVbyte
}) })
// ANCHOR_END: execute-refund // ANCHOR_END: execute-refund
} }
const exampleOpenChannelFee = async () => { const exampleOpenChannelFee = async () => {
// ANCHOR: get-channel-opening-fees // ANCHOR: get-channel-opening-fees
const amountMsat = 10000 const amountMsat = 10000
const openChannelFeeResponse = await openChannelFee({ const openChannelFeeResponse = await openChannelFee({
amountMsat: amountMsat amountMsat
}) })
// ANCHOR_END: get-channel-opening-fees // ANCHOR_END: get-channel-opening-fees
} }

View File

@@ -1,10 +1,10 @@
import { receivePayment } from "@breeztech/react-native-breez-sdk" import { receivePayment } from '@breeztech/react-native-breez-sdk'
const exampleReceiveLightningPayment = async () => { const exampleReceiveLightningPayment = async () => {
// ANCHOR: receive-payment // ANCHOR: receive-payment
const invoice = await receivePayment({ const invoice = await receivePayment({
amountMsat: 3000000, amountMsat: 3000000,
description: "Invoice for 3000 sats" description: 'Invoice for 3000 sats'
}) })
// ANCHOR_END: receive-payment // ANCHOR_END: receive-payment
} }

View File

@@ -1,49 +1,49 @@
import { import {
ReverseSwapPairInfo, type ReverseSwapPairInfo,
fetchReverseSwapFees, fetchReverseSwapFees,
inProgressReverseSwaps, inProgressReverseSwaps,
sendOnchain sendOnchain
} from "@breeztech/react-native-breez-sdk" } from '@breeztech/react-native-breez-sdk'
const exampleFetchReverseSwapFees = async () => { const exampleFetchReverseSwapFees = async () => {
// ANCHOR: estimate-current-reverse-swap-total-fees // ANCHOR: estimate-current-reverse-swap-total-fees
const currentFees = await fetchReverseSwapFees({ sendAmountSat: 50000 }) const currentFees = await fetchReverseSwapFees({ sendAmountSat: 50000 })
console.log( console.log(
`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}` `Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`
) )
// ANCHOR_END: estimate-current-reverse-swap-total-fees // ANCHOR_END: estimate-current-reverse-swap-total-fees
} }
const exampleListCurrentFees = (currentFees: ReverseSwapPairInfo) => { const exampleListCurrentFees = (currentFees: ReverseSwapPairInfo) => {
// ANCHOR: get-current-reverse-swap-min-max // ANCHOR: get-current-reverse-swap-min-max
console.log(`Minimum amount, in sats: ${currentFees.min}`) console.log(`Minimum amount, in sats: ${currentFees.min}`)
console.log(`Maximum amount, in sats: ${currentFees.max}`) console.log(`Maximum amount, in sats: ${currentFees.max}`)
// ANCHOR_END: get-current-reverse-swap-min-max // ANCHOR_END: get-current-reverse-swap-min-max
} }
const exampleSendOnchain = async (currentFees: ReverseSwapPairInfo) => { const exampleSendOnchain = async (currentFees: ReverseSwapPairInfo) => {
// ANCHOR: start-reverse-swap // ANCHOR: start-reverse-swap
const onchainRecipientAddress = "bc1.." const onchainRecipientAddress = 'bc1..'
const amountSat = currentFees.min const amountSat = currentFees.min
const satPerVbyte = 5 const satPerVbyte = 5
const reverseSwapInfo = await sendOnchain({ const reverseSwapInfo = await sendOnchain({
amountSat, amountSat,
onchainRecipientAddress, onchainRecipientAddress,
pairHash: currentFees.feesHash, pairHash: currentFees.feesHash,
satPerVbyte satPerVbyte
}) })
// ANCHOR_END: start-reverse-swap // ANCHOR_END: start-reverse-swap
} }
const exampleInProgressReverseSwaps = async () => { const exampleInProgressReverseSwaps = async () => {
// ANCHOR: check-reverse-swaps-status // ANCHOR: check-reverse-swaps-status
const swaps = await inProgressReverseSwaps() const swaps = await inProgressReverseSwaps()
for (const swap of swaps) { for (const swap of swaps) {
console.log( console.log(
`Reverse swap ${swap.id} in progress, status is ${swap.status}` `Reverse swap ${swap.id} in progress, status is ${swap.status}`
) )
} }
// ANCHOR_END: check-reverse-swaps-status // ANCHOR_END: check-reverse-swaps-status
} }

View File

@@ -1,12 +1,12 @@
import { sendSpontaneousPayment } from "@breeztech/react-native-breez-sdk" import { sendSpontaneousPayment } from '@breeztech/react-native-breez-sdk'
const exampleSendSpontaneousPayment = async () => { const exampleSendSpontaneousPayment = async () => {
// ANCHOR: send-spontaneous-payment // ANCHOR: send-spontaneous-payment
const nodeId = "..." const nodeId = '...'
const sendPaymentResponse = await sendSpontaneousPayment({ const sendPaymentResponse = await sendSpontaneousPayment({
nodeId, nodeId,
amountMsat: 3000000 amountMsat: 3000000
}) })
// ANCHOR_END: send-spontaneous-payment // ANCHOR_END: send-spontaneous-payment
} }

View File

@@ -1,7 +1,7 @@
import { staticBackup } from "@breeztech/react-native-breez-sdk" import { staticBackup } from '@breeztech/react-native-breez-sdk'
const exampleStaticBackup = async () => { const exampleStaticBackup = async () => {
// ANCHOR: static-channel-backup // ANCHOR: static-channel-backup
let backupData = await staticBackup({ workingDir: "<working directory>" }) const backupData = await staticBackup({ workingDir: '<working directory>' })
// ANCHOR_END: static-channel-backup // ANCHOR_END: static-channel-backup
} }