-
Notifications
You must be signed in to change notification settings - Fork 8
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 #95 from breez/ci-react-native
Ci react native
- Loading branch information
Showing
21 changed files
with
1,933 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true | ||
}, | ||
extends: [ | ||
'standard-with-typescript', | ||
'plugin:react/recommended' | ||
], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true | ||
}, | ||
files: [ | ||
'.eslintrc.{js,cjs}' | ||
], | ||
parserOptions: { | ||
sourceType: 'script' | ||
} | ||
} | ||
], | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: [ | ||
'./tsconfig.json' | ||
] | ||
}, | ||
plugins: [ | ||
'react' | ||
], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off' | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect' | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Steps to compile the snippets locally | ||
1. Build a react native package | ||
- By running the publish-all-platforms CI in the breez-sdk repository (use dummy binaries) | ||
2. Download the react-native-{VERSION} artifact | ||
3. Unzip the artifact and put the `sdk-react-native.tgz` file in the `snippets/react-native/packages` folder | ||
4. Run `yarn` to install the package. | ||
5. happy coding |
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,12 +1,12 @@ | ||
import { | ||
buyBitcoin, | ||
BuyBitcoinProvider | ||
} from "@breeztech/react-native-breez-sdk" | ||
buyBitcoin, | ||
BuyBitcoinProvider | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleBuyBtc = async () => { | ||
// ANCHOR: buy-btc | ||
const buyBitcoinResponse = await buyBitcoin({ | ||
provider: BuyBitcoinProvider.MOONPAY | ||
}) | ||
// ANCHOR_END: buy-btc | ||
// ANCHOR: buy-btc | ||
const buyBitcoinResponse = await buyBitcoin({ | ||
provider: BuyBitcoinProvider.MOONPAY | ||
}) | ||
// ANCHOR_END: buy-btc | ||
} |
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,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 () => { | ||
// ANCHOR: get-lsp-info | ||
const id = await lspId() | ||
const info = await lspInfo() | ||
// ANCHOR_END: get-lsp-info | ||
// ANCHOR: get-lsp-info | ||
const id = await lspId() | ||
const info = await lspInfo() | ||
// ANCHOR_END: get-lsp-info | ||
} | ||
|
||
const exampleManualConnect = async () => { | ||
// ANCHOR: connect-lsp | ||
const id = "your selected lsp id" | ||
await connectLsp(id) | ||
// ANCHOR_END: connect-lsp | ||
// ANCHOR: connect-lsp | ||
const id = 'your selected lsp id' | ||
await connectLsp(id) | ||
// ANCHOR_END: connect-lsp | ||
} |
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,22 +1,22 @@ | ||
import { | ||
listFiatCurrencies, | ||
fetchFiatRates | ||
} from "@breeztech/react-native-breez-sdk" | ||
listFiatCurrencies, | ||
fetchFiatRates | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleListCurrencies = async () => { | ||
// ANCHOR: list-fiat-currencies | ||
const fiatCurrencies = await listFiatCurrencies() | ||
// ANCHOR_END: list-fiat-currencies | ||
// ANCHOR: list-fiat-currencies | ||
const fiatCurrencies = await listFiatCurrencies() | ||
// ANCHOR_END: list-fiat-currencies | ||
} | ||
|
||
const exampleFetchRates = async () => { | ||
// ANCHOR: fetch-fiat-rates | ||
const fiatRates = await fetchFiatRates() | ||
// ANCHOR_END: fetch-fiat-rates | ||
// ANCHOR: fetch-fiat-rates | ||
const fiatRates = await fetchFiatRates() | ||
// ANCHOR_END: fetch-fiat-rates | ||
} | ||
|
||
const exampleListCurrenciesAndRates = async () => { | ||
// ANCHOR: get-fiat-currencies-and-rates | ||
// TODO | ||
// ANCHOR_END: get-fiat-currencies-and-rates | ||
// ANCHOR: get-fiat-currencies-and-rates | ||
// TODO | ||
// ANCHOR_END: get-fiat-currencies-and-rates | ||
} |
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,47 +1,47 @@ | ||
import { | ||
BreezEvent, | ||
connect, | ||
defaultConfig, | ||
EnvironmentType, | ||
mnemonicToSeed, | ||
NodeConfig, | ||
NodeConfigVariant, | ||
nodeInfo | ||
} from "@breeztech/react-native-breez-sdk" | ||
type BreezEvent, | ||
connect, | ||
defaultConfig, | ||
EnvironmentType, | ||
mnemonicToSeed, | ||
type NodeConfig, | ||
NodeConfigVariant, | ||
nodeInfo | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleGettingStarted = async () => { | ||
// ANCHOR: init-sdk | ||
// SDK events listener | ||
const onBreezEvent = (e: BreezEvent) => { | ||
console.log(`Received event ${e.type}`) | ||
} | ||
// ANCHOR: init-sdk | ||
// SDK events listener | ||
const onBreezEvent = (e: BreezEvent) => { | ||
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 seed = await mnemonicToSeed('<mnemonics words>') | ||
const inviteCode = '<invite code>' | ||
const apiKey = '<api key>' | ||
const nodeConfig: NodeConfig = { | ||
type: NodeConfigVariant.GREENLIGHT, | ||
config: { | ||
inviteCode | ||
} | ||
} | ||
|
||
const config = await defaultConfig( | ||
EnvironmentType.PRODUCTION, | ||
apiKey, | ||
nodeConfig | ||
) | ||
const config = await defaultConfig( | ||
EnvironmentType.PRODUCTION, | ||
apiKey, | ||
nodeConfig | ||
) | ||
|
||
// Connect to the Breez SDK make it ready for use | ||
await connect(config, seed, onBreezEvent) | ||
// ANCHOR_END: init-sdk | ||
// Connect to the Breez SDK make it ready for use | ||
await connect(config, seed, onBreezEvent) | ||
// ANCHOR_END: init-sdk | ||
} | ||
|
||
const exampleFetchNodeInfo = async () => { | ||
// ANCHOR: fetch-balance | ||
const nodeState = await nodeInfo() | ||
const balanceLn = nodeState.channelsBalanceMsat | ||
const balanceOnchain = nodeState.onchainBalanceMsat | ||
// ANCHOR_END: fetch-balance | ||
// ANCHOR: fetch-balance | ||
const nodeState = await nodeInfo() | ||
const balanceLn = nodeState.channelsBalanceMsat | ||
const balanceOnchain = nodeState.onchainBalanceMsat | ||
// ANCHOR_END: fetch-balance | ||
} |
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,20 +1,20 @@ | ||
import { | ||
listPayments, | ||
PaymentTypeFilter | ||
} from "@breeztech/react-native-breez-sdk" | ||
listPayments, | ||
PaymentTypeFilter | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleListPayments = async () => { | ||
// ANCHOR: list-payments | ||
const payments = listPayments({ filter: PaymentTypeFilter.ALL }) | ||
// ANCHOR_END: list-payments | ||
// ANCHOR: list-payments | ||
const payments = listPayments({ filter: PaymentTypeFilter.ALL }) | ||
// ANCHOR_END: list-payments | ||
} | ||
|
||
const exampleListPaymentsFiltered = async () => { | ||
// ANCHOR: list-payments-filtered | ||
const payments = listPayments({ | ||
filter: PaymentTypeFilter.SENT, | ||
fromTimestamp: 1696880000, | ||
includeFailures: true | ||
}) | ||
// ANCHOR_END: list-payments-filtered | ||
// ANCHOR: list-payments-filtered | ||
const payments = listPayments({ | ||
filter: PaymentTypeFilter.SENT, | ||
fromTimestamp: 1696880000, | ||
includeFailures: true | ||
}) | ||
// ANCHOR_END: list-payments-filtered | ||
} |
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,25 +1,25 @@ | ||
import { | ||
InputTypeVariant, | ||
lnurlAuth, | ||
LnUrlCallbackStatusVariant, | ||
parseInput | ||
} from "@breeztech/react-native-breez-sdk" | ||
InputTypeVariant, | ||
lnurlAuth, | ||
LnUrlCallbackStatusVariant, | ||
parseInput | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleLnurlAuth = async () => { | ||
// ANCHOR: lnurl-auth | ||
// Endpoint can also be of the form: | ||
// keyauth://domain.com/auth?key=val | ||
const lnurlAuthUrl = | ||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu" | ||
// ANCHOR: lnurl-auth | ||
// Endpoint can also be of the form: | ||
// keyauth://domain.com/auth?key=val | ||
const lnurlAuthUrl = | ||
'lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu' | ||
|
||
const input = await parseInput(lnurlAuthUrl) | ||
if (input.type === InputTypeVariant.LN_URL_AUTH) { | ||
const result = await lnurlAuth(input.data) | ||
if (result.type === LnUrlCallbackStatusVariant.OK) { | ||
console.log("Successfully authenticated") | ||
} else { | ||
console.log("Failed to authenticate") | ||
} | ||
const input = await parseInput(lnurlAuthUrl) | ||
if (input.type === InputTypeVariant.LN_URL_AUTH) { | ||
const result = await lnurlAuth(input.data) | ||
if (result.type === LnUrlCallbackStatusVariant.OK) { | ||
console.log('Successfully authenticated') | ||
} else { | ||
console.log('Failed to authenticate') | ||
} | ||
// ANCHOR_END: lnurl-auth | ||
} | ||
// ANCHOR_END: lnurl-auth | ||
} |
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,24 @@ | ||
import { | ||
InputTypeVariant, | ||
parseInput, | ||
payLnurl | ||
} from "@breeztech/react-native-breez-sdk" | ||
InputTypeVariant, | ||
parseInput, | ||
payLnurl | ||
} from '@breeztech/react-native-breez-sdk' | ||
|
||
const exampleLnurlPay = async () => { | ||
// ANCHOR: lnurl-pay | ||
// Endpoint can also be of the | ||
// lnurlp://domain.com/lnurl-pay?key=val | ||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf | ||
const lnurlPayUrl = "[email protected]" | ||
// ANCHOR: lnurl-pay | ||
// Endpoint can also be of the | ||
// lnurlp://domain.com/lnurl-pay?key=val | ||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf | ||
const lnurlPayUrl = '[email protected]' | ||
|
||
const input = await parseInput(lnurlPayUrl) | ||
if (input.type === InputTypeVariant.LN_URL_PAY) { | ||
const amountMsat = input.data.minSendable | ||
const lnUrlPayResult = await payLnurl({ | ||
data: input.data, | ||
amountMsat, | ||
comment: "comment" | ||
}) | ||
} | ||
// ANCHOR_END: lnurl-pay | ||
const input = await parseInput(lnurlPayUrl) | ||
if (input.type === InputTypeVariant.LN_URL_PAY) { | ||
const amountMsat = input.data.minSendable | ||
const lnUrlPayResult = await payLnurl({ | ||
data: input.data, | ||
amountMsat, | ||
comment: 'comment' | ||
}) | ||
} | ||
// ANCHOR_END: lnurl-pay | ||
} |
Oops, something went wrong.