From c374a59af8fa9394b39be2a815c43aa5f4bb5398 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 30 Mar 2017 00:48:18 -0400 Subject: [PATCH] Add access token and wallet address to GitHub reward --- ui/js/lbryio.js | 7 +------ ui/js/page/reward.js | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ui/js/lbryio.js b/ui/js/lbryio.js index c65767aaa..777f70f29 100644 --- a/ui/js/lbryio.js +++ b/ui/js/lbryio.js @@ -28,18 +28,13 @@ const mocks = { }; lbryio.call = function(resource, action, params, method='get') { - console.log('top of lbryio.call') return new Promise((resolve, reject) => { - console.log('top of promise handler') /* temp code for mocks */ if (`${resource}.${action}` in mocks) { - console.log(`found ${resource}.${action} in mocks`) resolve(mocks[`${resource}.${action}`](params)); - console.log('...resolved.'); return; - } else { - console.log(`did not find ${resource}.${action} in mocks`); } + /* end temp */ console.log('about to create xhr object'); diff --git a/ui/js/page/reward.js b/ui/js/page/reward.js index 8c148ad80..55562c8eb 100644 --- a/ui/js/page/reward.js +++ b/ui/js/page/reward.js @@ -13,34 +13,38 @@ const LinkGithubReward = React.createClass({ onClaimed: React.PropTypes.func, }, _launchLinkPage: function() { - const githubAuthParams = { + /* const githubAuthParams = { client_id: GITHUB_CLIENT_ID, redirect_uri: 'https://lbry.io/', scope: 'user:email,public_repo', allow_signup: false, } - shell.openExternal('https://github.com/login/oauth/authorize?' + querystring.stringify(githubAuthParams)); + shell.openExternal('https://github.com/login/oauth/authorize?' + querystring.stringify(githubAuthParams)); */ + shell.openExternal('https://lbry.io'); }, handleConfirmClicked: function() { this.setState({ confirming: true, }); - lbryio.call('reward', 'new', { - reward_type: 'new_developer', - access_token: 'token will go here', - }, 'post').then((response) => { - console.log('response:', response); + lbry.get_new_address().then((address) => { + lbryio.call('reward', 'new', { + reward_type: 'new_developer', + access_token: '**access token here**', + wallet_address: address, + }, 'post').then((response) => { + console.log('response:', response); - this.props.onClaimed(); // This will trigger another API call to show that we succeeded + this.props.onClaimed(); // This will trigger another API call to show that we succeeded - this.setState({ - confirming: false, - }); - }, (error) => { - console.log('failed with error:', error); - this.setState({ - confirming: false, + this.setState({ + confirming: false, + }); + }, (error) => { + console.log('failed with error:', error); + this.setState({ + confirming: false, + }); }); }); }, @@ -54,7 +58,7 @@ const LinkGithubReward = React.createClass({

-

This will open browser window where you can authorize GitHub to link your account to LBRY. This will record your email (no spam) and star the LBRY repo.

+

This will open a browser window where you can authorize GitHub to link your account to LBRY. This will record your email (no spam) and star the LBRY repo.

Once you're finished, you may confirm you've linked the account to receive your reward.