-
Notifications
You must be signed in to change notification settings - Fork 2
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 #214 from 67P/chore/remove_last_ethereum_bits
Remove mentions of Ethereum from UI and code, refactor wallet connect
- Loading branch information
Showing
22 changed files
with
334 additions
and
218 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 |
---|---|---|
@@ -1,45 +1,37 @@ | ||
import Component from '@ember/component'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { computed } from '@ember/object'; | ||
import { action } from '@ember/object'; | ||
import { isPresent } from '@ember/utils'; | ||
|
||
export default Component.extend({ | ||
export default class TopbarAccountPanelComponent extends Component { | ||
@service router; | ||
@service kredits; | ||
|
||
tagName: '', | ||
@tracked setupInProgress = false; | ||
|
||
kredits: service(), | ||
router: service(), | ||
get userHasWallet () { | ||
return isPresent(window.ethereum); | ||
} | ||
|
||
setupInProgress: false, | ||
get walletConnected () { | ||
return this.userHasWallet && this.kredits.hasAccounts; | ||
} | ||
|
||
userHasEthereumWallet: computed(function() { | ||
return isPresent(window.ethereum); | ||
}), | ||
|
||
showConnectButton: computed('userHasEthereumWallet', | ||
'kredits.hasAccounts', function() { | ||
return this.userHasEthereumWallet && | ||
!this.kredits.hasAccounts; | ||
}), | ||
|
||
actions: { | ||
|
||
signup() { | ||
this.router.transitionTo('signup'); | ||
}, | ||
|
||
async connectAccount() { | ||
try { | ||
await window.ethereum.enable(); | ||
this.set('setupInProgress', true); | ||
await this.kredits.setup(); | ||
this.set('setupInProgress', false); | ||
} catch (error) { | ||
this.set('setupInProgress', false); | ||
console.log('Opening Ethereum wallet failed:', error); | ||
} | ||
} | ||
get walletDisconnected () { | ||
return this.userHasWallet && !this.kredits.hasAccounts; | ||
} | ||
|
||
@action | ||
signup () { | ||
this.router.transitionTo('signup'); | ||
} | ||
|
||
@action | ||
async connectWallet () { | ||
this.setupInProgress = true; | ||
await this.kredits.connectWallet(); | ||
this.setupInProgress = false; | ||
} | ||
|
||
}); | ||
} |
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,50 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import config from 'kredits-web/config/environment'; | ||
import { isAddress } from 'web3-utils'; | ||
|
||
export default class AccountController extends Controller { | ||
@service kredits; | ||
|
||
@tracked accountAddress = null; | ||
|
||
get isValidEthAccount () { | ||
return isAddress(this.accountAddress); | ||
} | ||
|
||
get signupButtonDisabled () { | ||
return !this.isValidEthAccount; | ||
} | ||
|
||
@action | ||
completeSignup () { | ||
const payload = { | ||
accessToken: this.kredits.githubAccessToken, | ||
account: this.accountAddress | ||
} | ||
|
||
fetch(config.githubSignupUrl, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(payload) | ||
}) | ||
.then(res => res.json()) | ||
.then(data => { | ||
if (data.error) { | ||
alert('Creating profile failed. We have been notified about this error and will take a look soon. Sorry!'); | ||
console.warn('Creating contributor profile failed:', | ||
JSON.parse(data.error.body).error.message) | ||
return false; | ||
} else { | ||
console.log('[signup/account] Created contributor:', data); | ||
|
||
this.kredits.githubAccessToken = null; | ||
this.accountAddress = null; | ||
|
||
this.transitionToRoute('signup.complete'); | ||
} | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
import config from 'kredits-web/config/environment'; | ||
|
||
export default Controller.extend({ | ||
|
||
actions: { | ||
|
||
connectGithub () { | ||
window.location = config.githubConnectUrl; | ||
} | ||
export default class IndexController extends Controller { | ||
|
||
@action | ||
connectGithub () { | ||
window.location = config.githubConnectUrl; | ||
} | ||
|
||
}); | ||
} |
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,23 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import { isEmpty } from '@ember/utils'; | ||
|
||
export default class SignupAccountRoute extends Route { | ||
@service kredits; | ||
|
||
async setupController (controller) { | ||
if (!window.ethereum) return; | ||
|
||
if (this.kredits.hasAccounts) { | ||
controller.accountAddress = this.kredits.currentUserAccounts.firstObject; | ||
} else { | ||
return this.kredits.connectWallet(); | ||
} | ||
} | ||
|
||
redirect () { | ||
if (isEmpty(this.kredits.githubAccessToken)) { | ||
this.transitionTo('signup.index'); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.