-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JS project scaffolding + web -> RN changes
- Loading branch information
Showing
55 changed files
with
34,299 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
dist/ | ||
|
||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# XDE | ||
.expo/ | ||
|
||
# VSCode | ||
.vscode/ | ||
jsconfig.json | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.idea | ||
.gradle | ||
local.properties | ||
android.iml | ||
|
||
# Cocoapods | ||
# | ||
example/ios/Pods | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore | ||
|
||
# Expo | ||
.expo/* | ||
|
||
# generated by bob | ||
**/**/*.swp |
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,10 @@ | ||
.github/** | ||
demos/** | ||
dist/** | ||
lib/types/** | ||
package-lock.json | ||
package.json | ||
README.md | ||
test/** | ||
tsconfig.json | ||
tslint.json |
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 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 4, | ||
"semi": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": true | ||
} |
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,3 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
}; |
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,34 @@ | ||
import LNC from '../lnc'; | ||
import { subscriptionMethods } from '../types/proto/schema'; | ||
|
||
// capitalize the first letter in the string | ||
const capitalize = (s: string) => s && s[0].toUpperCase() + s.slice(1); | ||
|
||
/** | ||
* Creates a typed Proxy object which calls the WASM request or | ||
* subscribe methods depending on which function is called on the object | ||
*/ | ||
export function createRpc<T extends object>(packageName: string, lnc: LNC): T { | ||
const rpc = {}; | ||
return new Proxy(rpc, { | ||
get(target, key, c) { | ||
const methodName = capitalize(key.toString()); | ||
// the full name of the method (ex: lnrpc.Lightning.OpenChannel) | ||
const method = `${packageName}.${methodName}`; | ||
|
||
if (subscriptionMethods.includes(method)) { | ||
// call subscribe for streaming methods | ||
return (request: object): string => { | ||
return lnc.subscribe(method, request); | ||
}; | ||
} else { | ||
// call request for unary methods | ||
return async (request: object): Promise<any> => { | ||
return await lnc.request(method, request); | ||
}; | ||
} | ||
} | ||
}) as T; | ||
} | ||
|
||
export default createRpc; |
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,17 @@ | ||
import LNC from '../lnc'; | ||
import { FaradayServer } from '../types/proto/faraday/faraday'; | ||
import { serviceNames as sn } from '../types/proto/schema'; | ||
import { createRpc } from './createRpc'; | ||
|
||
/** | ||
* An API wrapper to communicate with the Faraday node via GRPC | ||
*/ | ||
class FaradayApi { | ||
faradayServer: FaradayServer; | ||
|
||
constructor(lnc: LNC) { | ||
this.faradayServer = createRpc(sn.frdrpc.FaradayServer, lnc); | ||
} | ||
} | ||
|
||
export default FaradayApi; |
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,4 @@ | ||
export { default as LndApi } from './lnd'; | ||
export { default as LoopApi } from './loop'; | ||
export { default as PoolApi } from './pool'; | ||
export { default as FaradayApi } from './faraday'; |
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,44 @@ | ||
import LNC from '../lnc'; | ||
import { Autopilot } from '../types/proto/lnd/autopilotrpc/autopilot'; | ||
import { ChainNotifier } from '../types/proto/lnd/chainrpc/chainnotifier'; | ||
import { Invoices } from '../types/proto/lnd/invoicesrpc/invoices'; | ||
import { Lightning } from '../types/proto/lnd/lightning'; | ||
import { Router } from '../types/proto/lnd/routerrpc/router'; | ||
import { Signer } from '../types/proto/lnd/signrpc/signer'; | ||
import { WalletKit } from '../types/proto/lnd/walletrpc/walletkit'; | ||
import { WalletUnlocker } from '../types/proto/lnd/walletunlocker'; | ||
import { Watchtower } from '../types/proto/lnd/watchtowerrpc/watchtower'; | ||
import { WatchtowerClient } from '../types/proto/lnd/wtclientrpc/wtclient'; | ||
import { serviceNames as sn } from '../types/proto/schema'; | ||
import { createRpc } from './createRpc'; | ||
|
||
/** | ||
* An API wrapper to communicate with the LND node via GRPC | ||
*/ | ||
class LndApi { | ||
autopilot: Autopilot; | ||
chainNotifier: ChainNotifier; | ||
invoices: Invoices; | ||
lightning: Lightning; | ||
router: Router; | ||
signer: Signer; | ||
walletKit: WalletKit; | ||
walletUnlocker: WalletUnlocker; | ||
watchtower: Watchtower; | ||
watchtowerClient: WatchtowerClient; | ||
|
||
constructor(lnc: LNC) { | ||
this.autopilot = createRpc(sn.autopilotrpc.Autopilot, lnc); | ||
this.chainNotifier = createRpc(sn.chainrpc.ChainNotifier, lnc); | ||
this.invoices = createRpc(sn.invoicesrpc.Invoices, lnc); | ||
this.lightning = createRpc(sn.lnrpc.Lightning, lnc); | ||
this.router = createRpc(sn.routerrpc.Router, lnc); | ||
this.signer = createRpc(sn.signrpc.Signer, lnc); | ||
this.walletKit = createRpc(sn.walletrpc.WalletKit, lnc); | ||
this.walletUnlocker = createRpc(sn.lnrpc.WalletUnlocker, lnc); | ||
this.watchtower = createRpc(sn.watchtowerrpc.Watchtower, lnc); | ||
this.watchtowerClient = createRpc(sn.wtclientrpc.WatchtowerClient, lnc); | ||
} | ||
} | ||
|
||
export default LndApi; |
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,20 @@ | ||
import LNC from '../lnc'; | ||
import { SwapClient } from '../types/proto/loop/client'; | ||
import { Debug } from '../types/proto/loop/debug'; | ||
import { serviceNames as sn } from '../types/proto/schema'; | ||
import { createRpc } from './createRpc'; | ||
|
||
/** | ||
* An API wrapper to communicate with the Loop node via GRPC | ||
*/ | ||
class LoopApi { | ||
swapClient: SwapClient; | ||
debug: Debug; | ||
|
||
constructor(lnc: LNC) { | ||
this.swapClient = createRpc(sn.looprpc.SwapClient, lnc); | ||
this.debug = createRpc(sn.looprpc.Debug, lnc); | ||
} | ||
} | ||
|
||
export default LoopApi; |
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,23 @@ | ||
import LNC from '../lnc'; | ||
import { ChannelAuctioneer } from '../types/proto/pool/auctioneerrpc/auctioneer'; | ||
import { HashMail } from '../types/proto/pool/auctioneerrpc/hashmail'; | ||
import { Trader } from '../types/proto/pool/trader'; | ||
import { serviceNames as sn } from '../types/proto/schema'; | ||
import { createRpc } from './createRpc'; | ||
|
||
/** | ||
* An API wrapper to communicate with the Pool node via GRPC | ||
*/ | ||
class PoolApi { | ||
trader: Trader; | ||
channelAuctioneer: ChannelAuctioneer; | ||
hashmail: HashMail; | ||
|
||
constructor(lnc: LNC) { | ||
this.trader = createRpc(sn.poolrpc.Trader, lnc); | ||
this.channelAuctioneer = createRpc(sn.poolrpc.ChannelAuctioneer, lnc); | ||
this.hashmail = createRpc(sn.poolrpc.HashMail, lnc); | ||
} | ||
} | ||
|
||
export default PoolApi; |
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 @@ | ||
import LNC from './lnc'; | ||
|
||
export type { LncConfig, CredentialStore } from './types/lnc'; | ||
export { camelKeysToSnake, snakeKeysToCamel } from './util/objects'; | ||
export * from './types/proto'; | ||
|
||
export default LNC; |
Oops, something went wrong.