Merge pull request #203 from 67P/feature/rsk-testnet

Migrate/switch to RSK testnet
This commit was merged in pull request #203.
This commit is contained in:
Râu Cao
2022-11-11 17:01:36 +01:00
committed by GitHub
7 changed files with 3489 additions and 12345 deletions
+6 -12
View File
@@ -1,27 +1,21 @@
---
language: node_js
node_js:
- "10"
- "14"
- "16"
sudo: false
dist: xenial
dist: precise
notifications:
email:
on_success: never
on_failure: always
email: false
addons:
chrome: stable
env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1
cache:
npm: false
branches:
only:
- master
script:
- npm test
+6 -1
View File
@@ -3,7 +3,12 @@ import * as localforage from 'localforage';
import config from 'kredits-web/config/environment';
function createStore(name) {
const networkName = config.web3RequiredNetwork || 'custom';
let networkName;
if (config.web3RequiredNetworkName) {
networkName = config.web3RequiredNetworkName.toLocaleLowerCase().replace(' ', '-');
} else {
networkName = 'custom';
}
return localforage.createInstance({ name: `kredits:${networkName}:${name}` });
}
+8 -7
View File
@@ -1,5 +1,5 @@
import ethers from 'ethers';
import Kredits from 'kredits-contracts';
import Kredits from '@kredits/contracts';
import Service from '@ember/service';
import EmberObject from '@ember/object';
@@ -73,13 +73,12 @@ export default Service.extend({
}
async function instantiateWithAccount (web3Provider, context) {
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
console.debug('[kredits] Using user-provided Web3 instance, e.g. from Metamask');
ethProvider = new ethers.providers.Web3Provider(web3Provider);
const network = await ethProvider.getNetwork();
if (isPresent(config.web3RequiredNetwork) &&
network.name !== config.web3RequiredNetwork) {
window.alert(`Please switch your Ethereum wallet to the "${config.web3RequiredNetwork}" network before connecting your account.`);
if (isPresent(config.web3RequiredChainId) &&
network.chainId !== config.web3RequiredChainId) {
return instantiateWithoutAccount();
}
@@ -112,12 +111,14 @@ export default Service.extend({
},
async setup () {
const kredits = await this.getEthProvider().then((providerAndSigner) => {
const kredits = await this.getEthProvider().then(providerAndSigner => {
return new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, {
ipfsConfig: config.ipfs
}).init();
});
});
await kredits.init();
this.set('kredits', kredits);
this.set('currentBlock', await kredits.provider.getBlockNumber());
+4 -10
View File
@@ -25,8 +25,9 @@ module.exports = function(environment) {
// when it is created
},
web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9',
web3RequiredNetwork: 'rinkeby',
web3ProviderUrl: 'https://rsk-testnet.kosmos.org',
web3RequiredChainId: 31,
web3RequiredNetworkName: 'RSK Testnet',
githubConnectUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/connect/github',
githubSignupUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/github',
@@ -55,7 +56,6 @@ module.exports = function(environment) {
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.web3ProviderUrl = 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9';
ENV.githubConnectUrl = 'http://localhost:8888/kredits/signup/connect/github';
ENV.githubSignupUrl = 'http://localhost:8888/kredits/signup/github';
@@ -82,13 +82,7 @@ module.exports = function(environment) {
if (process.env.WEB3_PROVIDER_URL) {
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
ENV.web3RequiredNetwork = null;
}
if (process.env.KREDITS_DAO_ADDRESS) {
ENV.kreditsKernelAddress = process.env.KREDITS_DAO_ADDRESS;
}
if (process.env.KREDITS_APM_DOMAIN) {
ENV.kreditsApmDomain = process.env.KREDITS_APM_DOMAIN;
ENV.web3RequiredChainId = null;
}
return ENV;
+3462 -12312
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -31,6 +31,7 @@
"@ember/optional-features": "^1.3.0",
"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"@kredits/contracts": "^7.0.1",
"babel-preset-es2015": "^6.22.0",
"broccoli-asset-rev": "^3.0.0",
"ember-auto-import": "^1.12.1",
@@ -66,7 +67,6 @@
"eslint-plugin-node": "^11.1.0",
"ethers": "^5.4.7",
"fetch-mock": "^9.10.7",
"kredits-contracts": "github:67P/kredits-contracts#hardhat",
"loader.js": "^4.7.0",
"localforage": "^1.7.3",
"ndjson": "github:hugomrdias/ndjson#feat/readable-stream3",
+2 -2
View File
@@ -11,7 +11,7 @@ module('Unit | Service | browser-cache', function(hooks) {
test('creates kredits data stores', function(assert) {
let cache = this.owner.lookup('service:browser-cache');
assert.equal(cache.contributors._config.name, "kredits:rinkeby:contributors");
assert.equal(cache.contributions._config.name, "kredits:rinkeby:contributions");
assert.equal(cache.contributors._config.name, "kredits:rsk-testnet:contributors");
assert.equal(cache.contributions._config.name, "kredits:rsk-testnet:contributions");
});
});