Code refactoring, contract update

This commit is contained in:
viktor 2017-07-21 16:06:09 +03:00
parent 305edde61f
commit 4cad317bfc
8 changed files with 390 additions and 516 deletions

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.11;
pragma solidity ^0.4.13;
contract ProofOfPhone {
struct PhoneAddr {
@ -13,10 +13,10 @@ contract ProofOfPhone {
tokens[token] = PhoneAddr({phone: phone, addr: msg.sender});
}
function activatePair(bytes32 token) {
if (tokens[token].addr != msg.sender) throw;
phoneAddressPair[tokens[token].phone] = tokens[token].addr;
addressPhonePair[tokens[token].addr] = tokens[token].phone;
function activatePair(uint code) {
require(tokens[sha3(code)].addr == msg.sender);
phoneAddressPair[tokens[sha3(code)].phone] = tokens[sha3(code)].addr;
addressPhonePair[tokens[sha3(code)].addr] = tokens[sha3(code)].phone;
}
function getPhoneByAddress(address addr) constant returns(uint) {

16
scripts/config.json Normal file
View File

@ -0,0 +1,16 @@
{
"environment": "live",
"Ethereum": {
"live": {
"rpc": "http://127.0.0.1:8540",
"account": "0x0000000000000000000000000000000000000000",
"contractAddress": "0x0000000000000000000000000000000000000000"
},
"contracts": {
"ProofOfPhone": {
"bin": "0x6060604052341561000f57600080fd5b5b6104568061001f6000396000f300606060405236156100805763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630367966681146100855780633404fe32146100b75780635fb3f3b5146100d257806371d01c73146100ea578063b958a5e11461011b578063ceaecc841461014c578063fe97ee881461017e575b600080fd5b341561009057600080fd5b61009b6004356101b1565b604051600160a060020a03909116815260200160405180910390f35b34156100c257600080fd5b6100d06004356024356101cf565b005b34156100dd57600080fd5b6100d060043561023b565b005b34156100f557600080fd5b610109600160a060020a03600435166103aa565b60405190815260200160405180910390f35b341561012657600080fd5b610109600160a060020a03600435166103bc565b60405190815260200160405180910390f35b341561015757600080fd5b61009b6004356103db565b604051600160a060020a03909116815260200160405180910390f35b341561018957600080fd5b61019d600160a060020a03600435166103f6565b604051901515815260200160405180910390f35b600081815260016020526040902054600160a060020a03165b919050565b604080519081016040908152838252600160a060020a0333166020808401919091526000848152600290915220815181556020820151600191909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055505b5050565b33600160a060020a031660026000836040519081526020016040519081900390208152602081019190915260400160002060010154600160a060020a03161461028357600080fd5b600260008260405190815260200160405180910390206000191660001916815260200190815260200160002060010160009054906101000a9004600160a060020a031660016000600260008560405190815260200160405180910390206000191660001916815260200190815260200160002060000154815260200190815260200160002060006101000a815481600160a060020a030219169083600160a060020a03160217905550600260008260405190815260200160405180910390206000191660001916815260200190815260200160002060000154600080600260008560405190815260200160405190819003902081526020808201929092526040908101600090812060010154600160a060020a031684529183019390935291019020555b50565b60006020819052908152604090205481565b600160a060020a0381166000908152602081905260409020545b919050565b600160205260009081526040902054600160a060020a031681565b600160a060020a0381166000908152602081905260408120541561041c575060016101ca565b5060006101ca565b5b9190505600a165627a7a7230582050345f78bdbfe2e76a3da18b5175077fc8d6cb5466ba9b133bec3e02d2ee22450029",
"abi": [{"constant":true,"inputs":[{"name":"phone","type":"uint256"}],"name":"getAddressByPhone","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"phone","type":"uint256"},{"name":"token","type":"bytes32"}],"name":"newToken","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"code","type":"uint256"}],"name":"activatePair","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"addressPhonePair","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"getPhoneByAddress","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"phoneAddressPair","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"hasPhone","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}]
}
}
}
}

View File

@ -14,8 +14,8 @@
}
},
"smartContract": {
"bin": "0x60606040525b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b6109438061003f6000396000f36060604052361561008a576000357c0100000000000000000000000000000000000000000000000000000000900480631f83f440146101ef57806341c0e1b51461021b5780634636a1591461022a578063a02b9aac1461024b578063b958a5e1146102cf578063e3ffc9a3146102fb578063f37306531461030a578063fe97ee881461034c5761008a565b6101ed5b6060604051908101604052806000815260200167016345785d8a0000340481526020016000368080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050815260200150600260005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005060008201518160000160005055602082015181600101600050556040820151816002016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061018957805160ff19168380011785556101ba565b828001600101855582156101ba579182015b828111156101b957825182600050559160200191906001019061019b565b5b5090506101e591906101c7565b808211156101e157600081815060009055506001016101c7565b5090565b50509050505b565b005b6102056004808035906020019091905050610378565b6040518082815260200191505060405180910390f35b61022860048050506103bc565b005b6102496004808035906020019091908035906020019091905050610455565b005b61026160048080359060200190919050506106b1565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102c15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102e5600480803590602001909190505061079f565b6040518082815260200191505060405180910390f35b61030860048050506107e3565b005b61032060048080359060200190919050506108ae565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61036260048080359060200190919050506108e6565b6040518082815260200191505060405180910390f35b6000600260005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000506001016000505490506103b7565b919050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561041857610453565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104b1576106ad565b6060604051908101604052808281526020016000815260200160016000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105635780601f1061053857610100808354040283529160200191610563565b820191906000526020600020905b81548152906001019060200180831161054657829003601f168201915b5050505050815260200150600260005060008473ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005060008201518160000160005055602082015181600101600050556040820151816002016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061060c57805160ff191683800117855561063d565b8280016001018555821561063d579182015b8281111561063c57825182600050559160200191906001019061061e565b5b509050610668919061064a565b80821115610664576000818150600090555060010161064a565b5090565b5050905050816003600050600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b5050565b6020604051908101604052806000815260200150600260005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000506002016000508054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561078e5780601f106107635761010080835404028352916020019161078e565b820191906000526020600020905b81548152906001019060200180831161077157829003601f168201915b5050505050905061079a565b919050565b6000600260005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000506000016000505490506107de565b919050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561083f576108ac565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660003073ffffffffffffffffffffffffffffffffffffffff1631604051809050600060405180830381858888f19350505050505b565b600360005060205280600052604060002060009150909054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006000600260005060008473ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005060000160005054141515610934576001905061093e5661093d565b6000905061093e565b5b91905056",
"ABI": [{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"getPaymentByAddress","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"},{"name":"phone","type":"uint256"}],"name":"newPhoneToAddr","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"getPaymentDataByAddress","outputs":[{"name":"","type":"bytes"}],"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"getPhoneByAddress","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"sendEtherToOwner","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"phones","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"hasPhone","outputs":[{"name":"","type":"bool"}],"type":"function"},{"inputs":[],"type":"constructor"}],
"bin": "0x6060604052341561000f57600080fd5b5b6104568061001f6000396000f300606060405236156100805763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630367966681146100855780633404fe32146100b75780635fb3f3b5146100d257806371d01c73146100ea578063b958a5e11461011b578063ceaecc841461014c578063fe97ee881461017e575b600080fd5b341561009057600080fd5b61009b6004356101b1565b604051600160a060020a03909116815260200160405180910390f35b34156100c257600080fd5b6100d06004356024356101cf565b005b34156100dd57600080fd5b6100d060043561023b565b005b34156100f557600080fd5b610109600160a060020a03600435166103aa565b60405190815260200160405180910390f35b341561012657600080fd5b610109600160a060020a03600435166103bc565b60405190815260200160405180910390f35b341561015757600080fd5b61009b6004356103db565b604051600160a060020a03909116815260200160405180910390f35b341561018957600080fd5b61019d600160a060020a03600435166103f6565b604051901515815260200160405180910390f35b600081815260016020526040902054600160a060020a03165b919050565b604080519081016040908152838252600160a060020a0333166020808401919091526000848152600290915220815181556020820151600191909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055505b5050565b33600160a060020a031660026000836040519081526020016040519081900390208152602081019190915260400160002060010154600160a060020a03161461028357600080fd5b600260008260405190815260200160405180910390206000191660001916815260200190815260200160002060010160009054906101000a9004600160a060020a031660016000600260008560405190815260200160405180910390206000191660001916815260200190815260200160002060000154815260200190815260200160002060006101000a815481600160a060020a030219169083600160a060020a03160217905550600260008260405190815260200160405180910390206000191660001916815260200190815260200160002060000154600080600260008560405190815260200160405190819003902081526020808201929092526040908101600090812060010154600160a060020a031684529183019390935291019020555b50565b60006020819052908152604090205481565b600160a060020a0381166000908152602081905260409020545b919050565b600160205260009081526040902054600160a060020a031681565b600160a060020a0381166000908152602081905260408120541561041c575060016101ca565b5060006101ca565b5b9190505600a165627a7a7230582050345f78bdbfe2e76a3da18b5175077fc8d6cb5466ba9b133bec3e02d2ee22450029",
"ABI": [{"constant":true,"inputs":[{"name":"phone","type":"uint256"}],"name":"getAddressByPhone","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"phone","type":"uint256"},{"name":"token","type":"bytes32"}],"name":"newToken","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"code","type":"uint256"}],"name":"activatePair","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"addressPhonePair","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"getPhoneByAddress","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"phoneAddressPair","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"hasPhone","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}],
"wallet": {
"test": "0x0000000000000000000000000000000000000000",
"live": "0x0000000000000000000000000000000000000000"

View File

@ -19,7 +19,7 @@
},
"repository": {
"type": "git",
"url": "https://gitlab.com/blocknotary/proofofphone"
"url": "https://github.com/blocknotary/proofofphone"
},
"keywords": [
"node",

View File

@ -40,24 +40,14 @@ function newTokenTX(web3, contract, sender, phoneNumber, token, cb) {
cb(err, result);
});
}
function showAlert(err, msg) {
if (!err) {
swal({
title: "Error",
text: msg,
type: "error"
});
}
else {
if (err.type != "REQUEST_REJECTED") {
console.log(err);
swal({
title: "Error",
text: msg,
type: "error"
});
}
}
function showAlert(err, msg, type) {
if (err) console.log(err);
if (err.type == "REQUEST_REJECTED") return;
swal({
title: type?capitalizeFirstLetter(type):"Error",
text: msg?msg:err.message,
type: type?type:"error"
});
}
function attachToContract(web3, config, cb) {
if(!web3.isConnected()) {
@ -101,17 +91,17 @@ function checkNetworkVersion(web3, cb) {
switch (netId) {
case "1": {
console.log('This is mainnet');
swal("Warning", msgNotOracles, "warning");
showAlert(null, msgNotOracles, "warning");
cb(false);
} break;
case "2": {
console.log('This is the deprecated Morden test network.');
swal("Warning", msgNotOracles, "warning");
showAlert(null, msgNotOracles, "warning");
cb(false);
} break;
case "3": {
console.log('This is the ropsten test network.');
swal("Warning", msgNotOracles, "warning");
showAlert(null, msgNotOracles, "warning");
cb(false);
} break;
case "12648430": {
@ -120,12 +110,37 @@ function checkNetworkVersion(web3, cb) {
} break;
default: {
console.log('This is an unknown network.');
swal("Warning", msgNotOracles, "warning");
showAlert(null, msgNotOracles, "warning");
cb(false);
} break;
}
})
}
const contractAddress = "0xf7e9626dbaeb1a6c8b3d02379eb54b81f16e785f"; // Oracles network ProofOfPhone contract address
const bottomMainText = `There is a smart contract deployed to the Oracles network. You can find it here:
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;">
<tbody class="copyTableBody">
<tr>
<td class="copyTableCellWalletValue2">` + contractAddress + `</td>
<td id="copyWallet3" data-clipboard-text="`+ contractAddress + `" class="copyTableCellCopyButton"></td>
</tr>
</tbody>
</table>
This contract has the following public method signature: hasPhone (address _addr).<br/>
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.`
const bottomCheckPageText = 'Enter a phone number or an Ethereum address to continue. <br/>' + bottomMainText;
const githubURL = "https://github.com/blocknotary/proofofphone";
const chooseAccountAlertText = "You haven't chosen any account in Oracles plugin. Please, choose your account in Oracles plugin and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.";
const addressCopiedToBufferText = "Address copied to buffer";
const URLCopiedToBufferText = "url copied to buffer";
const codeSuccessfullySentBySMSText = "Code was successfully sent by SMS";
const invalidCodeEnteredText = "Invalid code entered";
const walletIsNotSetText = "Phone wasn't set for this wallet yet";
const phoneIsNotSetText = "This phone wasn't set for any wallet yet";
const defaultStepTitleText = "Submit your phone number";
const secondStepTitleText = "Submit received code";
const secondStepTitleDescription = "Copy the code from the SMS to continue";
const thirdStepTitleText = "Success";
function deployContract(web3, config, sender) {
var contractABI = config.Ethereum.contracts.ProofOfPhone.abi;
var compiled = config.Ethereum.contracts.ProofOfPhone.bin;
@ -255,7 +270,7 @@ function getWeb3(callback) {
// no web3, use fallback
console.error("Please use a web3 browser");
var msgNotEthereum = "You aren't connected to Oracles Network. Please, switch on Oracles plugin and refresh the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.";
swal("Warning", msgNotEthereum, "warning");
showAlert(null, msgNotEthereum, "warning");
callback(myWeb3, false);
} else {
// window.web3 == web3 most of the time. Don't override the provided,
@ -271,13 +286,18 @@ function getWeb3(callback) {
});
}
}
//launches main application
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
//launches main proofofphone application
function startDapp(web3, isOraclesNetwork) {
console.log(web3);
var sender;
$(function() {
if (!isOraclesNetwork) return;
//gets accounts, chosen at Oracles plugin
getAccounts(function(accounts) {
//gets Ethereum config data
getConfig(function(config) {
getConfigCallBack(web3, accounts, config);
});
@ -305,11 +325,6 @@ function startDapp(web3, isOraclesNetwork) {
var bottomDesc = $('#bottomDesc');
var bottomDescAddition = $('#bottomDescAddition');
var bottomDescAddition2 = $('#bottomDescAddition2');
var copyTable = $('.copyTable');
var copyTableCellWalletValue1 = $('.copyTableCellWalletValue1');
copyTableCellWalletValue1.text("0xf7e9626dbaeb1a6c8b3d02379eb54b81f16e785f");
var copyTableCellWalletValue2 = $('.copyTableCellWalletValue2');
var POPTitleContainer = $('.POPTitleContainer');
var POPTitleContainerShortend = $('.POPTitleContainerShortend');
var POPDescContainer = $('.POPDescContainer');
@ -318,22 +333,15 @@ function startDapp(web3, isOraclesNetwork) {
var step1CopyTable = $('#step1CopyTable');
var step3CopyTable = $('#step3CopyTable');
var copyHashTable = $('#copyHashTable');
var checkboxContainer = $(".checkboxContainer");
var privacyPolicyCheckbox = $("#privacyPolicyCheckbox");
var addr = $("#addressVal").text();
$("#copyWallet").attr("data-clipboard-text",addr);
$("#copyWallet").attr("data-clipboard-text", addr);
function getConfigCallBack(web3, accounts, config) {
console.log(accounts);
if (accounts.length == 1) {
sender = accounts[0];
POPInputWallet.val(sender);
} else {
swal("Warning", "You haven't chosen any account in Oracles plugin. Please, choose your account in Oracles plugin and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.", "warning");
}
} else showAlert(null, chooseAccountAlertText, "warning");
var wallet = QueryString.wallet;
if (wallet) {
@ -352,36 +360,13 @@ function startDapp(web3, isOraclesNetwork) {
});
}
var copyWallet = document.getElementById('copyWallet');
var clientCopyWallet = new Clipboard( copyWallet );
clientCopyWallet.on( "success", function( event ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
var POPShare = document.getElementById('POPShare');
var clientShare = new Clipboard( POPShare );
clientShare.on( "success", function( event ) {
Materialize.toast('url copied to buffer', 3000, 'rounded');
});
buildCopyWalletControl("copyWallet");
buildCopyURLControl("POPShare");
phoneRadio.click(function(e) {
phoneRadioCheck();
});
$(".POPcheckbox").click(function(e) {
if ($(this).find(".POPcheckboxSelected")[0]) {
$(this).find(".POPcheckboxSelected").addClass("POPcheckboxUnselected");
$(this).find(".POPcheckboxSelected").removeClass("POPcheckboxSelected");
privacyPolicyCheckbox.prop( "checked", false );
} else {
$(this).find(".POPcheckboxUnselected").addClass("POPcheckboxSelected");
$(this).find(".POPcheckboxUnselected").removeClass("POPcheckboxUnselected");
privacyPolicyCheckbox.prop( "checked", true );
}
});
walletRadio.click(function(e) {
walletRadioCheck();
});
@ -395,7 +380,7 @@ function startDapp(web3, isOraclesNetwork) {
});
$('.githubRibbon').click(function(e) {
window.open("https://github.com/blocknotary/proofofphone", "_blank");
window.open(githubURL, "_blank");
});
$('.homeButton').click(function(e) {
@ -410,36 +395,21 @@ function startDapp(web3, isOraclesNetwork) {
submit(config, sender);
});
POPInputPhone.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
POPInputPhone.keypress(inputKeyPressEvent);
POPInputSMS.keypress(inputKeyPressEvent);
POPInputWallet.keypress(inputKeyPressEvent);
}
POPInputSMS.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
POPInputWallet.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
function inputKeyPressEvent(e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
}
function phoneRadioCheck() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
unselectPOPRadios();
phoneRadio.find('.POPRadioInner').removeClass('POPradioUnselected');
phoneRadio.find('.POPRadioInner').addClass('POPradioSelected');
POPInputPhone.removeClass('hide');
@ -449,10 +419,7 @@ function startDapp(web3, isOraclesNetwork) {
}
function walletRadioCheck() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
unselectPOPRadios();
walletRadio.find('.POPRadioInner').removeClass('POPradioUnselected');
walletRadio.find('.POPRadioInner').addClass('POPradioSelected');
POPInputWallet.removeClass('hide');
@ -464,106 +431,38 @@ function startDapp(web3, isOraclesNetwork) {
function submit(config, sender) {
var visibleInput = $('input:visible');
var curStepNum = parseInt(stepNum.val());
if (visibleInput.val() != "") {
middleMainContainerInner.fadeOut(500);
loader.removeClass('hide');
switch(curStepNum) {
case 1: {
var phoneNumber = parseInt(visibleInput.val());
sendCodeBySMS(phoneNumber, function(err, token) {
if (err) {
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return showAlert(err, err.message);
}
addToken(web3, config, sender, phoneNumber, token, function(err, txHash) {
if (err) {
showAlert(err, err.message);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
swal({
title: "Success",
text: "Code successfully sent by SMS",
type: "success"
});
});
}
});
});
} break;
case 2: {
var code = POPInputSMS.val();
var token = web3.sha3(code);
verifyCodeFromSMS(web3, config, sender, token, function(err, txHash) {
if (err) {
showAlert(null, "Invalid code entered");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
});
} break;
case 4:
{
var radioVal = $('input[name=radioCheck]:checked').val();
if (radioVal == "wallet") {
getPhoneByAddress(web3, config, sender, POPInputWallet.val(), function(err, phone) {
if (err) return showAlert(err, err.message);
console.log(phone);
if (phone != 0) {
POPInputPhone.val(phone);
changeStepNumber(null, 3);
} else {
swal({
title: "Warning",
text: "Phone wasn't set for this wallet yet",
type: "warning"
});
}
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
} else {
getAddressByPhone(web3, config, sender, POPInputPhone.val(), function(err, addr) {
if (err) return showAlert(err, err.message);
if (addr != "0x0000000000000000000000000000000000000000" && addr != "0x") {
POPInputWallet.val(addr);
changeStepNumber(null, 3);
} else {
swal({
title: "Warning",
text: "This phone wasn't set for any wallet yet",
type: "warning"
});
}
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
if (visibleInput.val() == "") return visibleInput.focus();
middleMainContainerInner.fadeOut(500);
loader.removeClass('hide');
switch(curStepNum) {
case 1: {
var phoneNumber = parseInt(visibleInput.val());
sendCodeBySMS(phoneNumber, sendCodeBySMSCallback);
} break;
case 2: {
var code = parseInt(POPInputSMS.val());
//var token = web3.sha3(code);
verifyCodeFromSMS(web3, config, sender, code, verifyCodeFromSMSCallback);
} break;
case 4:
{
var radioVal = $('input[name=radioCheck]:checked').val();
if (radioVal == "wallet") {
getPhoneByAddress(web3, config, sender, POPInputWallet.val(), getPhoneByAddressCallback);
} else {
getAddressByPhone(web3, config, sender, POPInputPhone.val(), getAddressByPhoneCallback);
}
break;
default:
{
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
break;
}
} else visibleInput.focus();
}
break;
default:
{
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
break;
}
}
function changeStepNumber(addition, absolute) {
@ -575,36 +474,10 @@ function startDapp(web3, isOraclesNetwork) {
stepLabel.text("Step " + newStepNum);
switch(newStepNum) {
case 1:
{
stepTitle.text("Submit your phone number");
bottomDesc.text("Enter a phone number you'd like to join with your Ethereum address. We will send you an SMS. After verification, we will ask you to deposit a service fee of 0.1 ether to a smart contract at the address");
stepLabel.removeClass("hide");
radioContainer.addClass("hide");
inputContainer.show();
POPBottomDescriptionContainer.show();
POPInputPhone.removeClass('hide');
POPInputPhone.focus();
POPInputSMS.addClass('hide');
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
copyTable.show();
step1CopyTable.removeClass("hide");
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.removeClass("hide");
}
break;
case 2:
{
stepTitle.text("Submit received code");
bottomDesc.text("Copy the code from the SMS to continue");
stepTitle.text(secondStepTitleText);
bottomDesc.text(secondStepTitleDescription);
stepLabel.removeClass("hide");
radioContainer.addClass("hide");
inputContainer.show();
@ -613,31 +486,23 @@ function startDapp(web3, isOraclesNetwork) {
POPInputSMS.removeClass('hide');
POPInputSMS.focus();
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.addClass("hide");
}
break;
case 3:
{
stepTitle.text("Success");
stepTitle.text(thirdStepTitleText);
stepLabel.addClass("hide");
POPBottomDescriptionContainer.hide();
bottomDescAddition2.html('There is a smart contract deployed to the Oracles network. You can find it here:\
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;"><tbody class="copyTableBody"><tr><td class="copyTableCellWalletValue2">'
+ copyTableCellWalletValue1.text() +
'</td><td id="copyWallet3" data-clipboard-text="'+ copyTableCellWalletValue1.text() + '" class="copyTableCellCopyButton"></td></tr></tbody></table>This contract has the following public method signature:\
hasPhone (address _addr).<br/>\
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.');
bottomDescAddition2.html(bottomMainText);
bottomDescAddition2.removeClass("hide");
$('.successTableCellWalletValue').text(POPInputWallet.val());
var host = "https://" + window.location.hostname;
var newUrl = host + "/?wallet=" + POPInputWallet.val().trim();
@ -646,36 +511,22 @@ function startDapp(web3, isOraclesNetwork) {
$('.successTableCellPhoneValue').text(POPInputPhone.val());
radioContainer.addClass("hide");
inputContainer.hide();
POPBottomDescriptionContainer.addClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.removeClass("hide");
copyHashTable.addClass("hide");
successContainer.removeClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.addClass("hide");
var copyWallet3 = document.getElementById('copyWallet3');
var clientCopyWallet3 = new Clipboard( copyWallet3 );
clientCopyWallet3.on( "success", function( readyEvent ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
buildCopyWalletControl("copyWallet3");
}
break;
case 4:
{
stepTitle.text("Check");
bottomDesc.html('Enter a phone number or an Ethereum address to continue. <br/>\
There is a smart contract deployed to the Oracles network. You can find it here:\
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;"><tbody class="copyTableBody"><tr><td class="copyTableCellWalletValue2">'
+ copyTableCellWalletValue1.text() +
'</td><td id="copyWallet2" data-clipboard-text="'+ copyTableCellWalletValue1.text() + '" class="copyTableCellCopyButton"></td></tr></tbody></table>This contract has the following public method signature:\
hasPhone (address _addr).<br/>\
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.');
bottomDesc.html(bottomCheckPageText);
stepLabel.addClass("hide");
phoneRadioCheck();
@ -686,42 +537,118 @@ function startDapp(web3, isOraclesNetwork) {
POPInputPhone.focus();
POPInputSMS.addClass('hide');
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainer.addClass("POPTitleContainerShortend");
POPTitleContainer.removeClass("POPTitleContainer");
POPDescContainer.addClass("POPDescContainerShortend");
POPDescContainer.removeClass("POPDescContainer");
var copyWallet2 = document.getElementById('copyWallet2');
var clientCopyWallet2 = new Clipboard(copyWallet2);
clientCopyWallet2.on( "success", function( readyEvent ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
checkboxContainer.addClass("hide");
buildCopyWalletControl("copyWallet2");
}
break;
default:
{
stepTitle.text("Submit your phone number");
stepTitle.text(defaultStepTitleText);
stepLabel.removeClass("hide");
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
POPBottomDescriptionContainer.show();
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
}
break;
}
}
function unselectPOPRadios() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
}
function sendCodeBySMSCallback(err, token) {
if (err) {
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return showAlert(err, err.message);
}
addToken(web3, config, sender, phoneNumber, token, function(err, txHash) {
if (err) {
showAlert(err, err.message);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
showAlert(null, codeSuccessfullySentBySMSText, "success");
});
}
});
}
function verifyCodeFromSMSCallback(err, txHash) {
if (err) {
showAlert(null, invalidCodeEnteredText);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
}
function getAddressByPhoneCallback(err, addr) {
if (err) return showAlert(err, err.message);
if (addr != "0x0000000000000000000000000000000000000000" && addr != "0x") {
POPInputWallet.val(addr);
changeStepNumber(null, 3);
} else showAlert(null, phoneIsNotSetText, "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
function getPhoneByAddressCallback(err, phone) {
if (err) return showAlert(err, err.message);
console.log(phone);
if (phone != 0) {
POPInputPhone.val(phone);
changeStepNumber(null, 3);
} else showAlert(null, walletIsNotSetText, "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
function buildCopyWalletControl(id) {
var copyWallet = document.getElementById(id);
var clientCopyWallet = new Clipboard(copyWallet);
clientCopyWallet.on( "success", function( readyEvent ) {
Materialize.toast(addressCopiedToBufferText, 3000, 'rounded');
});
}
function buildCopyURLControl(id) {
var POPShare = document.getElementById(id);
var clientShare = new Clipboard( POPShare );
clientShare.on( "success", function( event ) {
Materialize.toast(URLCopiedToBufferText, 3000, 'rounded');
});
}
});
}

View File

@ -0,0 +1,25 @@
const contractAddress = "0xf7e9626dbaeb1a6c8b3d02379eb54b81f16e785f"; // Oracles network ProofOfPhone contract address
const bottomMainText = `There is a smart contract deployed to the Oracles network. You can find it here:
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;">
<tbody class="copyTableBody">
<tr>
<td class="copyTableCellWalletValue2">` + contractAddress + `</td>
<td id="copyWallet3" data-clipboard-text="`+ contractAddress + `" class="copyTableCellCopyButton"></td>
</tr>
</tbody>
</table>
This contract has the following public method signature: hasPhone (address _addr).<br/>
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.`
const bottomCheckPageText = 'Enter a phone number or an Ethereum address to continue. <br/>' + bottomMainText;
const githubURL = "https://github.com/blocknotary/proofofphone";
const chooseAccountAlertText = "You haven't chosen any account in Oracles plugin. Please, choose your account in Oracles plugin and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.";
const addressCopiedToBufferText = "Address copied to buffer";
const URLCopiedToBufferText = "url copied to buffer";
const codeSuccessfullySentBySMSText = "Code was successfully sent by SMS";
const invalidCodeEnteredText = "Invalid code entered";
const walletIsNotSetText = "Phone wasn't set for this wallet yet";
const phoneIsNotSetText = "This phone wasn't set for any wallet yet";
const defaultStepTitleText = "Submit your phone number";
const secondStepTitleText = "Submit received code";
const secondStepTitleDescription = "Copy the code from the SMS to continue";
const thirdStepTitleText = "Success";

View File

@ -1,10 +1,12 @@
//launches main application
//launches main proofofphone application
function startDapp(web3, isOraclesNetwork) {
console.log(web3);
var sender;
$(function() {
if (!isOraclesNetwork) return;
//gets accounts, chosen at Oracles plugin
getAccounts(function(accounts) {
//gets Ethereum config data
getConfig(function(config) {
getConfigCallBack(web3, accounts, config);
});
@ -32,11 +34,6 @@ function startDapp(web3, isOraclesNetwork) {
var bottomDesc = $('#bottomDesc');
var bottomDescAddition = $('#bottomDescAddition');
var bottomDescAddition2 = $('#bottomDescAddition2');
var copyTable = $('.copyTable');
var copyTableCellWalletValue1 = $('.copyTableCellWalletValue1');
copyTableCellWalletValue1.text("0xf7e9626dbaeb1a6c8b3d02379eb54b81f16e785f");
var copyTableCellWalletValue2 = $('.copyTableCellWalletValue2');
var POPTitleContainer = $('.POPTitleContainer');
var POPTitleContainerShortend = $('.POPTitleContainerShortend');
var POPDescContainer = $('.POPDescContainer');
@ -45,26 +42,15 @@ function startDapp(web3, isOraclesNetwork) {
var step1CopyTable = $('#step1CopyTable');
var step3CopyTable = $('#step3CopyTable');
var copyHashTable = $('#copyHashTable');
var checkboxContainer = $(".checkboxContainer");
var privacyPolicyCheckbox = $("#privacyPolicyCheckbox");
var addr = $("#addressVal").text();
$("#copyWallet").attr("data-clipboard-text",addr);
$("#copyWallet").attr("data-clipboard-text", addr);
function getConfigCallBack(web3, accounts, config) {
console.log(accounts);
if (accounts.length == 1) {
sender = accounts[0];
POPInputWallet.val(sender);
} else {
showAlert(
null,
"You haven't chosen any account in Oracles plugin. Please, choose your account in Oracles plugin and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.",
"warning"
);
}
} else showAlert(null, chooseAccountAlertText, "warning");
var wallet = QueryString.wallet;
if (wallet) {
@ -83,36 +69,13 @@ function startDapp(web3, isOraclesNetwork) {
});
}
var copyWallet = document.getElementById('copyWallet');
var clientCopyWallet = new Clipboard( copyWallet );
clientCopyWallet.on( "success", function( event ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
var POPShare = document.getElementById('POPShare');
var clientShare = new Clipboard( POPShare );
clientShare.on( "success", function( event ) {
Materialize.toast('url copied to buffer', 3000, 'rounded');
});
buildCopyWalletControl("copyWallet");
buildCopyURLControl("POPShare");
phoneRadio.click(function(e) {
phoneRadioCheck();
});
$(".POPcheckbox").click(function(e) {
if ($(this).find(".POPcheckboxSelected")[0]) {
$(this).find(".POPcheckboxSelected").addClass("POPcheckboxUnselected");
$(this).find(".POPcheckboxSelected").removeClass("POPcheckboxSelected");
privacyPolicyCheckbox.prop( "checked", false );
} else {
$(this).find(".POPcheckboxUnselected").addClass("POPcheckboxSelected");
$(this).find(".POPcheckboxUnselected").removeClass("POPcheckboxUnselected");
privacyPolicyCheckbox.prop( "checked", true );
}
});
walletRadio.click(function(e) {
walletRadioCheck();
});
@ -126,7 +89,7 @@ function startDapp(web3, isOraclesNetwork) {
});
$('.githubRibbon').click(function(e) {
window.open("https://github.com/blocknotary/proofofphone", "_blank");
window.open(githubURL, "_blank");
});
$('.homeButton').click(function(e) {
@ -141,36 +104,21 @@ function startDapp(web3, isOraclesNetwork) {
submit(config, sender);
});
POPInputPhone.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
POPInputPhone.keypress(inputKeyPressEvent);
POPInputSMS.keypress(inputKeyPressEvent);
POPInputWallet.keypress(inputKeyPressEvent);
}
POPInputSMS.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
POPInputWallet.keypress(function (e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
});
function inputKeyPressEvent(e) {
var key = e.which;
if (key == 13) { // the enter key code
POPSubmit.click();
return false;
}
}
function phoneRadioCheck() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
unselectPOPRadios();
phoneRadio.find('.POPRadioInner').removeClass('POPradioUnselected');
phoneRadio.find('.POPRadioInner').addClass('POPradioSelected');
POPInputPhone.removeClass('hide');
@ -180,10 +128,7 @@ function startDapp(web3, isOraclesNetwork) {
}
function walletRadioCheck() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
unselectPOPRadios();
walletRadio.find('.POPRadioInner').removeClass('POPradioUnselected');
walletRadio.find('.POPRadioInner').addClass('POPradioSelected');
POPInputWallet.removeClass('hide');
@ -195,90 +140,38 @@ function startDapp(web3, isOraclesNetwork) {
function submit(config, sender) {
var visibleInput = $('input:visible');
var curStepNum = parseInt(stepNum.val());
if (visibleInput.val() != "") {
middleMainContainerInner.fadeOut(500);
loader.removeClass('hide');
switch(curStepNum) {
case 1: {
var phoneNumber = parseInt(visibleInput.val());
sendCodeBySMS(phoneNumber, function(err, token) {
if (err) {
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return showAlert(err, err.message);
}
addToken(web3, config, sender, phoneNumber, token, function(err, txHash) {
if (err) {
showAlert(err, err.message);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
showAlert(null, "Code successfully sent by SMS", "success");
});
}
});
});
} break;
case 2: {
var code = POPInputSMS.val();
var token = web3.sha3(code);
verifyCodeFromSMS(web3, config, sender, token, function(err, txHash) {
if (err) {
showAlert(null, "Invalid code entered");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
});
} break;
case 4:
{
var radioVal = $('input[name=radioCheck]:checked').val();
if (radioVal == "wallet") {
getPhoneByAddress(web3, config, sender, POPInputWallet.val(), function(err, phone) {
if (err) return showAlert(err, err.message);
console.log(phone);
if (phone != 0) {
POPInputPhone.val(phone);
changeStepNumber(null, 3);
} else showAlert(null, "Phone wasn't set for this wallet yet", "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
} else {
getAddressByPhone(web3, config, sender, POPInputPhone.val(), function(err, addr) {
if (err) return showAlert(err, err.message);
if (addr != "0x0000000000000000000000000000000000000000" && addr != "0x") {
POPInputWallet.val(addr);
changeStepNumber(null, 3);
} else showAlert(null, "This phone wasn't set for any wallet yet", "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
if (visibleInput.val() == "") return visibleInput.focus();
middleMainContainerInner.fadeOut(500);
loader.removeClass('hide');
switch(curStepNum) {
case 1: {
var phoneNumber = parseInt(visibleInput.val());
sendCodeBySMS(phoneNumber, sendCodeBySMSCallback);
} break;
case 2: {
var code = parseInt(POPInputSMS.val());
//var token = web3.sha3(code);
verifyCodeFromSMS(web3, config, sender, code, verifyCodeFromSMSCallback);
} break;
case 4:
{
var radioVal = $('input[name=radioCheck]:checked').val();
if (radioVal == "wallet") {
getPhoneByAddress(web3, config, sender, POPInputWallet.val(), getPhoneByAddressCallback);
} else {
getAddressByPhone(web3, config, sender, POPInputPhone.val(), getAddressByPhoneCallback);
}
break;
default:
{
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
break;
}
} else visibleInput.focus();
}
break;
default:
{
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
break;
}
}
function changeStepNumber(addition, absolute) {
@ -290,36 +183,10 @@ function startDapp(web3, isOraclesNetwork) {
stepLabel.text("Step " + newStepNum);
switch(newStepNum) {
case 1:
{
stepTitle.text("Submit your phone number");
bottomDesc.text("Enter a phone number you'd like to join with your Ethereum address. We will send you an SMS. After verification, we will ask you to deposit a service fee of 0.1 ether to a smart contract at the address");
stepLabel.removeClass("hide");
radioContainer.addClass("hide");
inputContainer.show();
POPBottomDescriptionContainer.show();
POPInputPhone.removeClass('hide');
POPInputPhone.focus();
POPInputSMS.addClass('hide');
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
copyTable.show();
step1CopyTable.removeClass("hide");
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.removeClass("hide");
}
break;
case 2:
{
stepTitle.text("Submit received code");
bottomDesc.text("Copy the code from the SMS to continue");
stepTitle.text(secondStepTitleText);
bottomDesc.text(secondStepTitleDescription);
stepLabel.removeClass("hide");
radioContainer.addClass("hide");
inputContainer.show();
@ -328,31 +195,23 @@ function startDapp(web3, isOraclesNetwork) {
POPInputSMS.removeClass('hide');
POPInputSMS.focus();
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.addClass("hide");
}
break;
case 3:
{
stepTitle.text("Success");
stepTitle.text(thirdStepTitleText);
stepLabel.addClass("hide");
POPBottomDescriptionContainer.hide();
bottomDescAddition2.html('There is a smart contract deployed to the Oracles network. You can find it here:\
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;"><tbody class="copyTableBody"><tr><td class="copyTableCellWalletValue2">'
+ copyTableCellWalletValue1.text() +
'</td><td id="copyWallet3" data-clipboard-text="'+ copyTableCellWalletValue1.text() + '" class="copyTableCellCopyButton"></td></tr></tbody></table>This contract has the following public method signature:\
hasPhone (address _addr).<br/>\
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.');
bottomDescAddition2.html(bottomMainText);
bottomDescAddition2.removeClass("hide");
$('.successTableCellWalletValue').text(POPInputWallet.val());
var host = "https://" + window.location.hostname;
var newUrl = host + "/?wallet=" + POPInputWallet.val().trim();
@ -361,36 +220,22 @@ function startDapp(web3, isOraclesNetwork) {
$('.successTableCellPhoneValue').text(POPInputPhone.val());
radioContainer.addClass("hide");
inputContainer.hide();
POPBottomDescriptionContainer.addClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.removeClass("hide");
copyHashTable.addClass("hide");
successContainer.removeClass("hide");
POPTitleContainerShortend.addClass("POPTitleContainer");
POPTitleContainerShortend.removeClass("POPTitleContainerShortend");
POPDescContainerShortend.addClass("POPDescContainer");
POPDescContainerShortend.removeClass("POPDescContainerShortend");
checkboxContainer.addClass("hide");
var copyWallet3 = document.getElementById('copyWallet3');
var clientCopyWallet3 = new Clipboard( copyWallet3 );
clientCopyWallet3.on( "success", function( readyEvent ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
buildCopyWalletControl("copyWallet3");
}
break;
case 4:
{
stepTitle.text("Check");
bottomDesc.html('Enter a phone number or an Ethereum address to continue. <br/>\
There is a smart contract deployed to the Oracles network. You can find it here:\
<table cellspacing="0" cellpadding="0" class="copyTable nomargin" style="display: table;"><tbody class="copyTableBody"><tr><td class="copyTableCellWalletValue2">'
+ copyTableCellWalletValue1.text() +
'</td><td id="copyWallet2" data-clipboard-text="'+ copyTableCellWalletValue1.text() + '" class="copyTableCellCopyButton"></td></tr></tbody></table>This contract has the following public method signature:\
hasPhone (address _addr).<br/>\
If the _addr is registered in the contract\'s Phone Registry, the hasPhone method returns true. Otherwise it returns false.');
bottomDesc.html(bottomCheckPageText);
stepLabel.addClass("hide");
phoneRadioCheck();
@ -401,42 +246,118 @@ function startDapp(web3, isOraclesNetwork) {
POPInputPhone.focus();
POPInputSMS.addClass('hide');
POPInputWallet.addClass('hide');
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
POPTitleContainer.addClass("POPTitleContainerShortend");
POPTitleContainer.removeClass("POPTitleContainer");
POPDescContainer.addClass("POPDescContainerShortend");
POPDescContainer.removeClass("POPDescContainer");
var copyWallet2 = document.getElementById('copyWallet2');
var clientCopyWallet2 = new Clipboard(copyWallet2);
clientCopyWallet2.on( "success", function( readyEvent ) {
Materialize.toast('Address copied to buffer', 3000, 'rounded');
});
checkboxContainer.addClass("hide");
buildCopyWalletControl("copyWallet2");
}
break;
default:
{
stepTitle.text("Submit your phone number");
stepTitle.text(defaultStepTitleText);
stepLabel.removeClass("hide");
POPBottomDescriptionContainer.removeClass("hide");
step1CopyTable.addClass("hide");
POPBottomDescriptionContainer.show();
step1CopyTable.hide();
step3CopyTable.addClass("hide");
bottomDescAddition.addClass("hide");
bottomDescAddition2.addClass("hide");
copyHashTable.addClass("hide");
successContainer.addClass("hide");
}
break;
}
}
function unselectPOPRadios() {
POPradios.each(function(e) {
$(this).find('.POPRadioInner').removeClass('POPradioSelected');
$(this).find('.POPRadioInner').addClass('POPradioUnselected');
});
}
function sendCodeBySMSCallback(err, token) {
if (err) {
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return showAlert(err, err.message);
}
addToken(web3, config, sender, phoneNumber, token, function(err, txHash) {
if (err) {
showAlert(err, err.message);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
showAlert(null, codeSuccessfullySentBySMSText, "success");
});
}
});
}
function verifyCodeFromSMSCallback(err, txHash) {
if (err) {
showAlert(null, invalidCodeEnteredText);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
return;
}
if (txHash) {
getTxCallBack(txHash, function() {
changeStepNumber(+1, null);
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
});
}
}
function getAddressByPhoneCallback(err, addr) {
if (err) return showAlert(err, err.message);
if (addr != "0x0000000000000000000000000000000000000000" && addr != "0x") {
POPInputWallet.val(addr);
changeStepNumber(null, 3);
} else showAlert(null, phoneIsNotSetText, "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
function getPhoneByAddressCallback(err, phone) {
if (err) return showAlert(err, err.message);
console.log(phone);
if (phone != 0) {
POPInputPhone.val(phone);
changeStepNumber(null, 3);
} else showAlert(null, walletIsNotSetText, "warning");
middleMainContainerInner.fadeIn(500);
loader.addClass('hide');
}
function buildCopyWalletControl(id) {
var copyWallet = document.getElementById(id);
var clientCopyWallet = new Clipboard(copyWallet);
clientCopyWallet.on( "success", function( readyEvent ) {
Materialize.toast(addressCopiedToBufferText, 3000, 'rounded');
});
}
function buildCopyURLControl(id) {
var POPShare = document.getElementById(id);
var clientShare = new Clipboard( POPShare );
clientShare.on( "success", function( event ) {
Materialize.toast(URLCopiedToBufferText, 3000, 'rounded');
});
}
});
}

View File

@ -56,25 +56,11 @@ html
input(id="POPInputSMS" placeholder="SMS code", type="number").POPInput.POPInputSMS.hide
input(id="POPInputWallet" placeholder="Ethereum wallet").POPInput.POPInputWallet.hide
button.POPButton#POPSubmit submit
//
div.checkboxContainer
div.checkboxInnerContainer
div.checkboxInnerContainerCell
div.POPcheckbox
div.POPcheckboxSelected
div.checkboxInnerContainerCell
span.POPCheckboxDesc I understand that this is a proof-of-concept, my phone number will be permanently stored unencrypted on the Ethereum blockchain and connected to my public key
input(type="checkbox", name="privacyPolicyCheckbox", id="privacyPolicyCheckbox", checked).hide
div.POPBottomDescriptionContainer
div.POPTitleContainer.marginBottom1
label.POPTitle2 How does it work?
div.POPDescContainer
label#bottomDesc.POPDesc Enter a phone number you'd like to join with your Ethereum address. We will send you an SMS. After verification, your address will be joined to your phone.
table#copyHashTable(cellspacing="0" cellpadding="0").copyTable.nomargin.hide
tbody.copyTableBody
tr
td#hashVal.copyTableCellWalletValue2
td#hashCopy.copyTableCellCopyButton2
div.someOuterContainer
div.someContainer
label#bottomDescAddition.POPDesc.hide
@ -103,7 +89,6 @@ html
div
label#bottomDescAddition2.POPDesc.hide
div.githubRibbon
//img(src="/img/loader.gif").loader.hide
div.loader.hide
div.loader-i.loader-i_left-top
div.loader-i.loader-i_right-top