web3 0.x to 1.0.x
This commit is contained in:
parent
51542e978e
commit
e9114d4582
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
function SHA3Encrypt(web3, str, cb) {
|
||||
var strEncode = web3.sha3(str);
|
||||
var strEncode = web3.utils.sha3(str);
|
||||
cb(strEncode);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
//check current network page is connected to. Alerts, if not Oracles network
|
||||
function checkNetworkVersion(web3, cb) {
|
||||
async function checkNetworkVersion(web3, cb) {
|
||||
var msgNotOracles = "You aren't connected to Oracles network. Please, switch on Oracles plugin and choose Oracles network. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.";
|
||||
web3.version.getNetwork(function(err, netId) {
|
||||
if (err)
|
||||
console.log(err);
|
||||
console.log("netId: " + netId);
|
||||
switch (netId) {
|
||||
case "1": {
|
||||
let config = await getConfig()
|
||||
web3.eth.net.getId().then(function(connectedNetworkID) {
|
||||
console.log("connectedNetworkID: " + connectedNetworkID);
|
||||
connectedNetworkID = parseInt(connectedNetworkID);
|
||||
switch (connectedNetworkID) {
|
||||
case 1: {
|
||||
console.log('This is mainnet');
|
||||
swal("Warning", msgNotOracles, "warning");
|
||||
cb(false);
|
||||
return false;
|
||||
} break;
|
||||
case "2": {
|
||||
case 2: {
|
||||
console.log('This is the deprecated Morden test network.');
|
||||
swal("Warning", msgNotOracles, "warning");
|
||||
cb(false);
|
||||
return false;
|
||||
} break;
|
||||
case "3": {
|
||||
case 3: {
|
||||
console.log('This is the ropsten test network.');
|
||||
swal("Warning", msgNotOracles, "warning");
|
||||
cb(false);
|
||||
return false;
|
||||
} break;
|
||||
case "12648430": {
|
||||
case config.networkID: {
|
||||
console.log('This is Oracles from Metamask');
|
||||
cb(true);
|
||||
return true;
|
||||
} break;
|
||||
default: {
|
||||
console.log('This is an unknown network.');
|
||||
swal("Warning", msgNotOracles, "warning");
|
||||
cb(false);
|
||||
return false;
|
||||
} break;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
//gets config file with address of Oracles contract
|
||||
function getConfig(cb) {
|
||||
$.getJSON("./assets/javascripts/config.json", function(config) {
|
||||
var contractAddress = config.Ethereum[config.environment].contractAddress;
|
||||
cb(contractAddress);
|
||||
});
|
||||
async function getConfig(cb) {
|
||||
let config = await $.getJSON("./assets/javascripts/config.json")
|
||||
let contractAddress = config.Ethereum[config.environment].contractAddress
|
||||
let abi = config.Ethereum[config.environment].abi
|
||||
let networkID = config.networkID
|
||||
let configJSON = {
|
||||
contractAddress,
|
||||
networkID,
|
||||
abi
|
||||
}
|
||||
if (cb) cb(configJSON)
|
||||
return configJSON;
|
||||
}
|
|
@ -15,8 +15,7 @@ function getWeb3(callback) {
|
|||
// new instance
|
||||
myWeb3.eth.defaultAccount = window.web3.eth.defaultAccount;
|
||||
|
||||
checkNetworkVersion(myWeb3, function(isOraclesNetwork) {
|
||||
callback(myWeb3, isOraclesNetwork);
|
||||
});
|
||||
let isOraclesNetwork = checkNetworkVersion(myWeb3)
|
||||
callback(myWeb3, isOraclesNetwork);
|
||||
}
|
||||
}
|
|
@ -8,10 +8,9 @@ function startDapp(web3, isOraclesNetwork) {
|
|||
var ballotsArrayFiltered = [];
|
||||
var votingKey;
|
||||
|
||||
getAccounts(function(accounts) {
|
||||
getConfig(function(contractAddress) {
|
||||
getConfigCallBack(web3, accounts, contractAddress);
|
||||
})
|
||||
getAccounts(async function(accounts) {
|
||||
let config = await getConfig()
|
||||
getConfigCallBack(web3, accounts, config.contractAddress);
|
||||
});
|
||||
|
||||
//getting of config callback
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"environment": "live",
|
||||
"networkID": 12648430,
|
||||
"Ethereum": {
|
||||
"live": {
|
||||
"contractAddress": "0xf472e0e43570b9afaab67089615080cf7c20018d"
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
|||
//=require jquery.min.js
|
||||
//=require web3.js
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,6 @@
|
|||
<!-- <meta property="og:image" content="https://www.notarycoin.com/assets/images/share.png"> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./assets/stylesheets/index.css">
|
||||
<link rel="stylesheet" type="text/css" href="./assets/stylesheets/sweetalert2.min.css">
|
||||
<link rel="apple-touch-icon" href="./favicons/favicon-192x192.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="./favicons/favicon-192x192.png">
|
||||
<link rel="mask-icon" color="#6151cc" href="./favicons/safari-pinned-tab.svg">
|
||||
|
@ -76,7 +75,7 @@
|
|||
<p class="footer-rights">2017 Oracles Network. All rights reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="./assets/javascripts/sweetalert2.min.js" type="text/javascript"></script>
|
||||
<script src="./assets/javascripts/application.js?v=1.71" type="text/javascript"></script>
|
||||
<script src="./assets/javascripts/modules.js?" type="text/javascript"></script>
|
||||
<script src="./assets/javascripts/application.js?v=1.72" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
let sweetalert2 = require("sweetalert2");
|
||||
let jquery = require("jquery");
|
||||
let Web3 = require("web3");
|
||||
|
||||
window.swal = sweetalert2;
|
||||
window.$ = jquery;
|
||||
window.Web3 = Web3;
|
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
|
@ -22,7 +22,7 @@
|
|||
"sass": "gulp sass",
|
||||
"coffee": "gulp javascript",
|
||||
"watch": "gulp watch",
|
||||
"start": "http-server -a localhost -p 8000"
|
||||
"start": "browserify modules.js -o assets/javascripts/modules.js && gulp javascript && gulp sass && http-server -a localhost -p 8000"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -31,5 +31,10 @@
|
|||
"keywords": [],
|
||||
"author": "oraclesorg",
|
||||
"license": "MIT",
|
||||
"homepage": "https://oracles.org/"
|
||||
}
|
||||
"homepage": "https://oracles.org/",
|
||||
"dependencies": {
|
||||
"jquery": "^3.2.1",
|
||||
"sweetalert2": "^7.0.3",
|
||||
"web3": "^1.0.0-beta.26"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue