- Inspect Ethereum transactions
+ Inspect Rootstock transactions
{{#if this.model.ipfsHash}}
Inspect IPFS profile
{{/if}}
diff --git a/app/templates/signup/account.hbs b/app/templates/signup/account.hbs
new file mode 100644
index 0000000..8e934db
--- /dev/null
+++ b/app/templates/signup/account.hbs
@@ -0,0 +1,30 @@
+
+ Complete your contributor profile
+
+
+
+ Kredits allow you to to earn rewards for your contributions, in the form of
+ dynamic open-source grants. As a regular contributor, you can also take
+ part in the community's project governance and finances.
+
+
+ In order to interact with the system you will need a
+ Rootstock
+ wallet/account.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/templates/signup/complete.hbs b/app/templates/signup/complete.hbs
index 3fa98ac..082543b 100644
--- a/app/templates/signup/complete.hbs
+++ b/app/templates/signup/complete.hbs
@@ -7,7 +7,8 @@
Why not say hi to your fellow contributors
- in one of our chat rooms?.
+ in one of our chat rooms?.
Return to dashboard
diff --git a/app/templates/signup/eth-account.hbs b/app/templates/signup/eth-account.hbs
deleted file mode 100644
index 4c232e0..0000000
--- a/app/templates/signup/eth-account.hbs
+++ /dev/null
@@ -1,24 +0,0 @@
-
- Complete your contributor profile
-
-
-
- Kredits allow you to take part in project governance, and to earn rewards for
- your contributions. For both, you will need an Ethereum wallet/account.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/utils/switch-network.js b/app/utils/switch-network.js
new file mode 100644
index 0000000..5e22c55
--- /dev/null
+++ b/app/utils/switch-network.js
@@ -0,0 +1,29 @@
+import config from 'kredits-web/config/environment';
+
+export default async function () {
+ const networkName = config.web3NetworkName;
+ const chainId = config.web3ChainId;
+ const chainIdHex = `0x${Number(chainId).toString(16)}`;
+
+ try {
+ await window.ethereum.request({
+ method: 'wallet_switchEthereumChain',
+ params: [{ chainId: chainIdHex }]
+ });
+ } catch (err) {
+ // This error code indicates that the chain has not been added to MetaMask
+ if (err.code === 4902) {
+ await window.ethereum.request({
+ method: 'wallet_addEthereumChain',
+ params: [{
+ chainId: chainIdHex,
+ chainName: networkName,
+ rpcUrls: [ config.web3ProviderUrl ],
+ nativeCurrency: { name: 'tRBTC', symbol: 'tRBTC', decimals: 18 }
+ }]
+ });
+ } else {
+ console.warn('Failed to switch chains:', err.message);
+ }
+ }
+}
diff --git a/config/environment.js b/config/environment.js
index dcd354d..15321bf 100644
--- a/config/environment.js
+++ b/config/environment.js
@@ -26,11 +26,11 @@ module.exports = function(environment) {
},
web3ProviderUrl: 'https://rsk-testnet.kosmos.org',
- web3RequiredChainId: 31,
- web3RequiredNetworkName: 'RSK Testnet',
+ web3ChainId: 31,
+ web3NetworkName: 'RSK Testnet',
- githubConnectUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/connect/github',
- githubSignupUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/github',
+ githubConnectUrl: 'https://hal8000.kosmos.chat/kredits/signup/connect/github',
+ githubSignupUrl: 'https://hal8000.kosmos.chat/kredits/signup/github',
ipfs: {
host: 'ipfs.kosmos.org',
@@ -82,7 +82,12 @@ module.exports = function(environment) {
if (process.env.WEB3_PROVIDER_URL) {
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
- ENV.web3RequiredChainId = null;
+ }
+ if (process.env.WEB3_CHAIN_ID) {
+ ENV.web3ChainId = parseInt(process.env.WEB3_CHAIN_ID);
+ }
+ if (process.env.WEB3_NETWORK_NAME) {
+ ENV.web3NetworkName = process.env.WEB3_NETWORK_NAME;
}
return ENV;
diff --git a/package.json b/package.json
index 6ba8540..c3bfdea 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"start": "ember serve",
"test": "npm-run-all lint:* test:*",
"test:ember": "ember test",
- "start:local": "WEB3_PROVIDER_URL=http://localhost:8545 ember serve",
+ "start:local": "WEB3_PROVIDER_URL=http://localhost:8545 WEB3_CHAIN_ID=1337 WEB3_NETWORK_NAME='Hardhat Devchain' ember serve",
"build": "ember build --environment=production",
"build-prod": "rm -rf release/* && ember build -prod --output-path release",
"preversion": "npm test",
diff --git a/tests/integration/components/topbar-account-panel/component-test.js b/tests/integration/components/topbar-account-panel/component-test.js
index 251c7ed..457280d 100644
--- a/tests/integration/components/topbar-account-panel/component-test.js
+++ b/tests/integration/components/topbar-account-panel/component-test.js
@@ -3,37 +3,90 @@ import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
+function stubWalletApi () {
+ window.ethereum = {
+ on: function() { return true; },
+ request: function() { return Promise.resolve(); }
+ }
+}
+
module('Integration | Component | topbar-account-panel', function(hooks) {
setupRenderingTest(hooks);
- test('unknown user without wallet (or no permission to get wallet/account info)', async function(assert) {
+ test('Unknown user without wallet', async function(assert) {
await render(hbs`
`);
- assert.ok(this.element.textContent.trim().match(/^Anonymous/));
+ assert.ok(
+ this.element.textContent.trim().match(/^Anonymous/),
+ 'shows current user as anonymous'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#signup').length, 1,
+ 'signup button is visible'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#connect').length, 0,
+ 'connect button is not visible'
+ );
});
- test('unknown user with Ethereum wallet', async function(assert) {
+ test('Unknown user with disconnected wallet', async function(assert) {
+ stubWalletApi();
+ let service = this.owner.lookup('service:kredits');
+ service.set('currentUserAccounts', []);
+ await render(hbs`
`);
+
+ assert.ok(
+ this.element.textContent.trim().match(/^Anonymous/),
+ 'shows current user as anonymous'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#signup').length, 1,
+ 'signup button is visible'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#connect').length, 1,
+ 'connect button is visible'
+ );
+ });
+
+ test('Unknown user with connected wallet', async function(assert) {
+ stubWalletApi();
let service = this.owner.lookup('service:kredits');
service.set('currentUserAccounts', [{ foo: 'bar' }]);
await render(hbs`
`);
- assert.ok(this.element.textContent.trim().match(/^Anonymous/));
+ assert.ok(
+ this.element.textContent.trim().match(/^Anonymous/),
+ 'shows current user as anonymous'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#signup').length, 1,
+ 'signup button is visible'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#connect').length, 0,
+ 'connect button is not visible'
+ );
});
- test('known contributor', async function(assert) {
+ test('Known contributor', async function(assert) {
+ stubWalletApi();
let service = this.owner.lookup('service:kredits');
service.set('currentUserAccounts', [{ foo: 'bar' }]);
- service.set('currentUser', {
- name: 'Dorian Nakamoto',
- isCore: false
- });
+ service.set('currentUser', { name: 'Dorian Nakamoto', isCore: false });
await render(hbs`
`);
- assert.dom(this.element).hasText('Dorian Nakamoto');
-
- service.set('currentUser.isCore', true);
- await render(hbs`
`);
-
- assert.equal(this.element.querySelectorAll('span.core-flag').length, 1);
+ assert.dom(this.element).hasText(
+ 'Dorian Nakamoto', 'shows current user\'s name'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#signup').length, 0,
+ 'signup button is not visible'
+ );
+ assert.equal(
+ this.element.querySelectorAll('button#connect').length, 0,
+ 'connect button is not visible'
+ );
});
});
diff --git a/tests/unit/routes/signup/eth-account-test.js b/tests/unit/routes/signup/account-test.js
similarity index 57%
rename from tests/unit/routes/signup/eth-account-test.js
rename to tests/unit/routes/signup/account-test.js
index 4c4f714..0c0adb6 100644
--- a/tests/unit/routes/signup/eth-account-test.js
+++ b/tests/unit/routes/signup/account-test.js
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
-module('Unit | Route | signup/eth-account', function(hooks) {
+module('Unit | Route | signup/account', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
- let route = this.owner.lookup('route:signup/eth-account');
+ let route = this.owner.lookup('route:signup/account');
assert.ok(route);
});
});