Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'Backup' into S01E05-live
Browse files Browse the repository at this point in the history
  • Loading branch information
xardass committed Nov 27, 2018
2 parents 8676f81 + b34f645 commit 998afc2
Show file tree
Hide file tree
Showing 30 changed files with 831 additions and 718 deletions.
Binary file added images/social_facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_riot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_slack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/social_youtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 88 additions & 78 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,82 +1,92 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>Swarm City</title>
<meta name="description" content="Swarm City">
<base href="/">
<link rel="icon" href="images/favicon.ico">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#EFD96F">
<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="Swarm City">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Swarm City">
<link href='https://fonts.googleapis.com/css?family=Montserrat:200,300,700' rel='stylesheet' type='text/css'>
<link rel="apple-touch-icon" href="images/manifest/icon-48x48.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png">
<link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png">
<link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png">
<link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png">
<meta name="msapplication-TileImage" content="images/manifest/icon-144x144.png">
<meta name="msapplication-TileColor" content="#3f51b5">
<meta name="msapplication-tap-highlight" content="no">
<script src='socket.io.js'></script>

<script>
if (!localStorage.getItem('SwarmCity')) {

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>Swarm City</title>
<meta name="description" content="Swarm City">
<base href="/">
<link rel="icon" href="images/favicon.ico">
<link rel="manifest" href="manifest.json">

<meta property="og:title" content="Swarm City">
<meta property="og:image" content="images/manifest/icon-48x48.png">
<meta property="og:description" content="Swarm City is a blockchain based marketplace with a built in reputation system. It uses blockchain technology and smart contracts to allow people to communicate and transact value, and earn contextual reputation.">
<meta property="og:url" content="https://swarm.city">
<meta name="twitter:card" content="images/manifest/icon-192x192.png">
<meta name="theme-color" content="#3f51b5">

<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="Swarm City">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Swarm City">
<link rel="apple-touch-icon" href="images/manifest/icon-48x48.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png">
<link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png">
<link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png">
<link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png">
<meta name="msapplication-TileImage" content="images/manifest/icon-144x144.png">
<meta name="msapplication-TileColor" content="#3f51b5">
<meta name="msapplication-tap-highlight" content="no">
<script src='socket.io.js'></script>
<script>
if (!localStorage.getItem('SwarmCity')) {
let storage = { // eslint-disable-line
user: {
language: 'en',
username: '',
location: '',
avatar: '[[importHref]]../../images/defaultavatar.png'},
keyStore: {},
};
localStorage.setItem('SwarmCity', JSON.stringify(storage));
}
window.Polymer = {rootPath: '/'};
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('service-worker.js', {
scope: Polymer.rootPath,
});
user: {
language: 'en',
username: '',
location: '',
avatar: '[[importHref]]../../images/defaultavatar.png'
},
keyStore: {},
};
localStorage.setItem('SwarmCity', JSON.stringify(storage));
}
window.Polymer = { rootPath: '/' };
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('service-worker.js', {
scope: Polymer.rootPath,
});
}
</script>
<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>
<link rel="import" href="src/swarm-city.html">
<style>
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,800');
body {
margin: 0;
padding: 0;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
letter-spacing: 0;
font-style: normal;
background-color: #F4F4F4;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-font-feature-settings: "liga" on;
-moz-font-feature-settings: "liga" on;
-ms-font-feature-settings: "liga" on;
font-feature-settings: "liga" on;
line-height: 1.4;
min-height: 100vh;
background-image: url("loading.png");
background-repeat: no-repeat;
background-position: center, center;
}
</style>
</head>
<body>
<swarm-city></swarm-city>
<noscript>
Please enable JavaScript to view this website.
</noscript>
<!-- Built with love -->
</body>
</html>
});
}
</script>
<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>
<link rel="import" href="src/swarm-city.html">
<style>
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,800');

body {
margin: 0;
padding: 0;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
letter-spacing: 0;
font-style: normal;
background-color: #F4F4F4;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-font-feature-settings: "liga"on;
-moz-font-feature-settings: "liga"on;
-ms-font-feature-settings: "liga"on;
font-feature-settings: "liga"on;
line-height: 1.4;
min-height: 100vh;
background-image: url("loading.png");
background-repeat: no-repeat;
background-position: center, center;
}
</style>
</head>

<body>
<swarm-city></swarm-city>
<noscript>
Please enable JavaScript to view this website.
</noscript>
<!-- Built with love -->
</body>

</html>
10 changes: 5 additions & 5 deletions src/data/data-simpledeal.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
// generate the itemHash
const itemHash = hdWallet.createItem(seeker.privateKey);

// 1. Encode the newItem method to be sent through approveAndCall
// 1. Encode the newItem method to be sent through transferAndCall
const simpleDealContract = new _web3.eth.Contract(simpleDeal.abi, hashtag.address);
const rawNewItem = simpleDealContract.methods.newItem(
itemHash,
itemBudgetWei,
metadataHash.bytes32
).encodeABI();
const tokenContract = new _web3.eth.Contract(kovSwtToken.abi, hashtag.tokenAddress);
const rawApproveAndCall = tokenContract.methods.approveAndCall(
const rawTransferAndCall = tokenContract.methods.transferAndCall(
hashtag.address, // spender
totalSum, // totalSum
rawNewItem, // next call data
Expand All @@ -59,7 +59,7 @@
gasPrice: 1000000000,
gasLimit: 3000000,
to: hashtag.tokenAddress,
data: rawApproveAndCall,
data: rawTransferAndCall,
chainId: 42,
});
tx.sign(new Buffer(seeker.privateKey, 'hex'));
Expand Down Expand Up @@ -161,7 +161,7 @@
item.hash
).encodeABI();
const tokenContract = new _web3.eth.Contract(kovSwtToken.abi, hashtag.tokenAddress);
const rawApproveAndCall = tokenContract.methods.approveAndCall(
const rawTransferAndCall = tokenContract.methods.transferAndCall(
hashtag.address, // spender
totalSum, // totalSum
rawFundItem, // next call data
Expand All @@ -177,7 +177,7 @@
gasPrice: 1000000000,
gasLimit: 3000000,
to: hashtag.tokenContractAddress,
data: rawApproveAndCall,
data: rawTransferAndCall,
chainId: 42,
});
tx.sign(new Buffer(provider.privateKey, 'hex'));
Expand Down
73 changes: 72 additions & 1 deletion src/data/data-transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Import libraries
const Tx = webpack.EthereumTx
const Buffer = webpack.Buffer.Buffer
const _web3 = window.web3Local
const _web3 = window.web3Kovan
const _web3Mainnet = window.web3Mainnet
const sha3 = webpack.sha3
const ipfs = window.ipfs

Expand Down Expand Up @@ -83,13 +84,83 @@
})
}


async function tokenMainTxAsync({
sender,
receiverAddress,
amount,
tokenContractAddress }) {

let tokens = _web3Mainnet.utils.toWei(amount.toString(), 'ether');

const tokenContract = new webpack.Contract(
kovSwtToken.abi,
tokenContractAddress);
let rawTokenTx = tokenContract.methods.transfer(
receiverAddress,
tokens
).encodeABI();

// 2. Get user's nonce
const nonce = await _web3Mainnet.eth.getTransactionCount(sender.address)

// 3. Generate tx object, sign and serialize
const tx = new Tx({
nonce: _web3Mainnet.utils.toHex(nonce),
from: sender.address,
gasPrice: 21000000000,
gasLimit: 1500000,
to: tokenContractAddress,
data: rawTokenTx,
chainId: 1,
});
tx.sign(new Buffer(sender.privateKey, 'hex'));
const serializedTx = tx.serialize();

// 4. Send transaction, await receipt.
// Extra line for clarity
const hash = await sendSignedTransactionMain('0x' + serializedTx.toString('hex'))
return hash
}

function sendSignedTransactionMain(tx) {
return new Promise((resolve, reject) => {
let _hash;
_web3Mainnet.eth.sendSignedTransaction(tx)
.once('transactionHash', (hash) => {
resolve(hash)
_hash = hash
})
.on('receipt', (receipt) => {
console.log('received receipt for txHash: ' + hash, receipt);
})
.on('error', (err, receipt) => {
if (err.message &&
err.message.startsWith('Failed to check for transaction receipt')
) {
console.log('Another complaint about the receipt ignored.');
} else {
if (receipt) {
console.error('We might be out of Gas: %j', receipt);
} else {
console.error(err);
}
reject(new Error('Transaction error: ' + err));
}
});
})
}

class DataTransaction extends Polymer.Element {
static get is() {
return 'data-transaction';
}
tokenTx(args) {
return tokenTxAsync(args)
}
tokenMainTx(args) {
return tokenMainTxAsync(args)
}
}
window.customElements.define(DataTransaction.is, DataTransaction);

Expand Down
35 changes: 18 additions & 17 deletions src/displays/display-backup.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,24 @@
* downloads account info, after success routs to download-success
*/
_download() {
let storage = JSON.parse(localStorage.getItem('SwarmCity'));
const filename = `SwarmCity - UTC KeyStore`;
storage.keyStore.avatar = storage.user.avatar;
storage.keyStore.username = storage.user.username;
const text = JSON.stringify(storage.keyStore);
const element = document.createElement('a');
element.setAttribute('href', `data:application/json;charset=utf-8,${encodeURIComponent(text)}`);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
if (this.route.path == '/make-backup/') {
this.path = 'download-success/';
} else {
this.path = 'download-success-profile/';
}
let storage = JSON.parse(localStorage.getItem('SwarmCity'));
const filename = 'SwarmCity - UTC KeyStore';
storage.keyStore.avatar = storage.user.avatar;
storage.keyStore.username = storage.user.username;
storage.keyStore.avatarHash = storage.user.avatarHash;
const text = JSON.stringify(storage.keyStore);
const element = document.createElement('a');
element.setAttribute('href', 'data:application/json;charset=utf-8,'
+ encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
if (this.route.path == '/make-backup/') {
this.path = 'download-success/';
} else {
this.path = 'download-success-profile/';
}
/**
* check for operating system for enable/disable the download backup file link
Expand Down
2 changes: 1 addition & 1 deletion src/displays/display-complete-transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
sender,
receiverAddress,
weiAmount,
tokenAddress: '0x0ADBc89464Cb7fa752ADCf3533514949A2547589',
tokenAddress: '0xf69ca736d959519a79f9075021444a8a0ee384d3',
}).then((serializedTx) => {
this.dispatch({
type: 'BROADCAST',
Expand Down
8 changes: 8 additions & 0 deletions src/displays/display-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
.container {
background-color: var(--sc-green);
@apply --titlepage-closed-container;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
min-width: 100vw;
min-height: 100vh;
z-index: 1;
}

.container .top {
Expand Down
Loading

0 comments on commit 998afc2

Please sign in to comment.