Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oscar #59

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Get familiar with the **setlife** folder structure
|-- /web/ # Application source code
|-- /components/ # React components
|-- /constants/ # Any constant variable used throughout the app
|-- /reducers/ # Redux Reducers + Redux Actions in the same file
|-- /ducks/ # [Redux Reducers + Redux Actions in the same file](https://github.com/erikras/ducks-modular-redux)
|-- /scripts/ # Functions for API calls, data formatters, validators, etc
|-- /styles/ # All .less stylesheets
```
Expand Down
12 changes: 12 additions & 0 deletions api/config/credentials.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/modules/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var apiModules = module.exports = (function() {
return {
authentication: require('./authentication'),
lightningNode: require('./lightningNode'),
payments: require('./payments'),
schedule: require('./schedule'),
team: require('./team')
Expand Down
51 changes: 51 additions & 0 deletions api/modules/lightningNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const lightningNode = module.exports = (() => {
const lnService = require('ln-service');
const {
PORTS,
MACAROONS,
TLS_CERTS
} = require('../config/credentials')

return {
getUserWalletInfo: (params) => {
return new Promise((resolve, reject) => {
const { lnd } = lnService.authenticatedLndGrpc({
cert: TLS_CERTS[params.user],
macaroon: MACAROONS[params.user],
socket: `127.0.0.1:${PORTS[params.user]}`
});

lnService.getWalletInfo({ lnd }, (error, result) => {
console.log(error);
console.log(result);
resolve(result)
});
})

},
subscribeToChainAddress: (params) => {
return new Promise((resolve, reject) => {
const { lnd } = lnService.authenticatedLndGrpc({
cert: TLS_CERTS[params.user],
macaroon: MACAROONS[params.user],
socket: `127.0.0.1:${PORTS[params.user]}`
});

const subscription = lnService.subscribeToChainAddress({
lnd,
bech32_address: process.env.ALICE_ADDRESS
})

subscription.on('confirmation', ({ block, transaction }) => {
console.log('confirmation block')
console.log(block)
// Fetch transaction amount
// Fetch next setblock for memberId: process.env.MEMBER_ID
// If setblock.amount < transaction.amount + setblock.paidAmount, fund block then and emit
// Else add amount to setblock.paidAmount
})
})

}
}
})()
1 change: 1 addition & 0 deletions api/modules/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var schedule = module.exports = (function () {
let updatedFieldData = {}
Object.keys(updatedFields).map(k => {
if (k == 'blockFraction') updatedFieldData['Blocks'] = updatedFields[k]
if (k == 'funded') updatedFieldData['Funded'] = updatedFields[k]
if (k == 'issueUrl') updatedFieldData['Issue'] = updatedFields[k]
if (k == 'description') updatedFieldData['Description'] = updatedFields[k]
})
Expand Down
3 changes: 3 additions & 0 deletions api/types/SetblockInputType.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var SetblockInputType = module.exports = new g.GraphQLInputObjectType({
blockFraction: {
type: g.GraphQLFloat
},
funded: {
type: g.GraphQLString
},
issueUrl: {
type: g.GraphQLString
},
Expand Down
4 changes: 4 additions & 0 deletions api/types/SetblockType.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ var SetblockType = module.exports = new g.GraphQLObjectType({
type: g.GraphQLFloat,
description: 'Must be either 1.0 or 0.5'
},
funded: {
type: g.GraphQLString,
description: 'Whether or not this Setblock has a confirmed payment sent to the Team Member that scheduled it'
},
issueUrl: {
type: g.GraphQLString,
description: 'A reference to the GitHub isssue being worked on during this setblock'
Expand Down
1 change: 1 addition & 0 deletions api/types/TeamMemberType.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var TeamMemberType = module.exports = new g.GraphQLObjectType({
date: r.fields.Date,
blockTime: r.fields.Blocktime,
blockFraction: r.fields.Blocks,
funded: r.fields.Funded,
issueUrl: r.fields.Issue,
description: r.fields.Description
})
Expand Down
2 changes: 1 addition & 1 deletion api/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ var types = module.exports = (function() {
UserType: require('./UserType'),
graphql: require('./graphql')
};
})();
})();
2 changes: 1 addition & 1 deletion config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = {
appRoot: path.resolve(__dirname, '..'),
components: resolve('web/components'),
config: resolve('config'),
ducks: resolve('web/ducks'),
htmlRoot: resolve('web/index.html'),
nodeModules: resolve('node_modules'),
pages: resolve('web/pages'),
public: resolve('public'),
reducers: resolve('web/reducers'),
scripts: resolve('web/scripts'),
source: resolve('web'),
styles: resolve('web/styles'),
Expand Down
15 changes: 14 additions & 1 deletion config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
require('dotenv').config()
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');

const paths = require('./paths')

console.log('process.env')
console.log(process.env.WEB_ROOT)

module.exports = {
// where webpack resolves files relative to
context: paths.appRoot,
Expand Down Expand Up @@ -34,7 +39,7 @@ module.exports = {
components: paths.components,
pages: paths.pages,
public: paths.public,
reducers: paths.reducers
ducks: paths.ducks
}
},
optimization: {
Expand Down Expand Up @@ -80,6 +85,14 @@ module.exports = {
new ManifestPlugin({
fileName: 'asset-manifest.json', // Not to confuse with manifest.json
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
GITHUB_CLIENT_ID: JSON.stringify(process.env.GITHUB_CLIENT_ID),
BTC_ADDRESS: JSON.stringify(process.env.BTC_ADDRESS),
STREAM_LINK: JSON.stringify(process.env.STREAM_LINK)
}
})
// SW plugin configuration
// The following option parameters and configuration are directly taken from react-create-app
// as it's a production ready configuration that works pretty well for our needs.
Expand Down
8 changes: 1 addition & 7 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ module.exports = merge(common, {
pathinfo: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
GITHUB_CLIENT_ID: JSON.stringify('a4868a77fd455c344822')
}
})
new webpack.HotModuleReplacementPlugin()
]
})
8 changes: 1 addition & 7 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ module.exports = merge(common, {
new CompressionPlugin({
test: /\.(js|css|html)$/,
deleteOriginalAssets: false
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
GITHUB_CLIENT_ID: JSON.stringify('88ee5c32729990ca3a14')
}
}),
})

// Progressive web app in progress
// new ManifestPlugin({
Expand Down
Loading