stripping out avax stuff, no user handles
parent
81f5a372e4
commit
cb19eef03f
@ -1,236 +0,0 @@
|
||||
{% set is_user = current_user == user %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
{% include 'includes/head.html' %}
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
|
||||
{% include 'includes/navbar.html' %}
|
||||
|
||||
{% if user %}
|
||||
<div class="screen">
|
||||
<div class="columns">
|
||||
<div class="column is-full content">
|
||||
<h3>From Avalanche Blockchain</h3>
|
||||
<p>Handle: <strong><span id="userHandle" class="mr-4">?</span></strong></p>
|
||||
<p>Wownero Address: <strong><span id="wowneroAddress" class="mr-4 wrap">?</span></strong></p>
|
||||
<p>Profile IPFS Hash: <strong><span id="metadataIPFSHash">?</span></strong></p>
|
||||
<p>Tipped AVAX: <strong><span id="tippedAVAX">?</span></strong></p>
|
||||
<p>Tipped WOWX: <strong><span id="tippedWOWX">?</span></strong></p>
|
||||
<p>Tipped WOW: <strong><span id="tippedWOW">?</span></strong></p>
|
||||
|
||||
<h3>From Local Database</h3>
|
||||
{# Handle #}
|
||||
{% if is_user %}
|
||||
<div class="field">
|
||||
<label class="label">Handle</label>
|
||||
<div class="control columns">
|
||||
<div class="column is-two-thirds">
|
||||
<input id="handleInput" class="input" type="text" placeholder="{{ user.handle }}" value="{{ user.handle }}">
|
||||
<p class="help">The username/handle you want to be referenced by.</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a id="publishHandle" onclick="publishHandle()" class="publishAVAX button">Publish AVAX</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p><strong>Handle:</strong> {{ user.handle }}</p>
|
||||
{% endif %}
|
||||
|
||||
{# Wownero Address #}
|
||||
{% if is_user %}
|
||||
<div class="field">
|
||||
<label class="label">Wownero Address</label>
|
||||
<div class="control columns">
|
||||
<div class="column is-two-thirds">
|
||||
<input id="wowneroAddressInput" class="input" type="text" placeholder="{{ user.wownero_address or '' }}" value="{{ user.wownero_address or '' }}">
|
||||
<p class="help">The Wownero wallet address you want to receive tips on.</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a id="publishWowneroAddress" onclick="publishWowneroAddress()" class="publishAVAX button">Publish AVAX</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p><strong>Wownero Address:</strong> <span class="wrap">{{ user.wownero_address or '?' }}</span></p>
|
||||
{% endif %}
|
||||
|
||||
{# Metadata IPFS Hash #}
|
||||
{% if is_user %}
|
||||
<div class="field">
|
||||
<label class="label">Metadata IPFS Hash</label>
|
||||
<div class="control columns">
|
||||
<div class="column is-two-thirds">
|
||||
<input id="metadataIPFSHashInput" class="input" type="text" placeholder="{{ user.ipfs_hash or '' }}" value="{{ user.ipfs_hash or '' }}">
|
||||
<p class="help">The IPFS hash of your profile metadata.</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a id="publishMetadataIPFSHash" onclick="publishMetadataIPFSHash()" class="publishAVAX button">Publish AVAX</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p><strong>Metadata IPFS Hash:</strong> {{ user.ipfs_hash or '' }}</p>
|
||||
{% endif %}
|
||||
|
||||
<p><strong>Register Date: </strong> {{ user.register_date }} ({{ user.register_date | humanize }})</p>
|
||||
<p><strong>Last Login Date: </strong> {{ user.last_login_date }} ({{ user.last_login_date | humanize }})</p>
|
||||
<p><strong>Moderator: </strong> {{ user.is_moderator() }}</p>
|
||||
<p><strong>Verified: </strong> {{ user.verified }}</p>
|
||||
<p><strong>Memes Posted: </strong> {{ user.memes | length }}</p>
|
||||
{% if user.bio %}
|
||||
<p><strong>Bio: </strong> {{ user.bio }}</p>
|
||||
{% endif %}
|
||||
{% if user.website %}
|
||||
<p>Website: <a href="{{ user.website_url }}" target="_blank">{{ user.website_url }}</a></p>
|
||||
{% endif %}
|
||||
{% if is_user %}
|
||||
<p><a onclick="saveDB()" class="ml-2 button is-primary">Save DB</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</section>
|
||||
{% include 'includes/footer.html' %}
|
||||
|
||||
<script type="text/javascript">
|
||||
async function saveDB() {
|
||||
await fetch('{{ url_for("api.update_user" ) }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
'user_id': {{ user.id }},
|
||||
'handle': document.getElementById('handleInput').value,
|
||||
'wownero_address': document.getElementById('wowneroAddressInput').value,
|
||||
'ipfs_hash': document.getElementById('metadataIPFSHashInput').value,
|
||||
})
|
||||
})
|
||||
.then((resp) => resp.json())
|
||||
.then(function(data) {
|
||||
console.log(data)
|
||||
if (data['success']) {
|
||||
notif('Updated user information in this server\'s database.', 'success');
|
||||
notif('Publish to the Avalanche blockchain to make the data globally available.', 'info');
|
||||
} else {
|
||||
notif(data['message'], 'error');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
async function fetchUserProfile() {
|
||||
await addAvalancheNetwork();
|
||||
_walletAddress = w3.utils.toChecksumAddress('{{ user.public_address }}');
|
||||
const userProfile = await contract.methods.userProfile(_walletAddress).call();
|
||||
if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle};
|
||||
if (userProfile.wowneroAddress){document.getElementById('wowneroAddress').innerHTML = userProfile.wowneroAddress};
|
||||
if (userProfile.metadataIPFSHash){document.getElementById('metadataIPFSHash').innerHTML = userProfile.metadataIPFSHash};
|
||||
if (userProfile.tippedAVAX){document.getElementById('tippedAVAX').innerHTML = w3.utils.fromWei(userProfile.tippedAVAX)};
|
||||
if (userProfile.tippedWOWX){document.getElementById('tippedWOWX').innerHTML = w3.utils.fromWei(userProfile.tippedWOWX)};
|
||||
return
|
||||
}
|
||||
|
||||
async function publishHandle() {
|
||||
document.getElementById('publishHandle').classList.add('is-loading');
|
||||
const handle = document.getElementById('handleInput').value;
|
||||
if (handle == "") {
|
||||
notif('Cannot publish an empty value.', 'warning');
|
||||
document.getElementById('publishHandle').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
await addAvalancheNetwork();
|
||||
try {
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
notif(`Publishing user handle "${handle}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
|
||||
let res = await contract.methods.setUserHandle(handle).send({
|
||||
from: walletAddress,
|
||||
value: 0,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('publishHandle').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function publishWowneroAddress() {
|
||||
document.getElementById('publishWowneroAddress').classList.add('is-loading');
|
||||
const address = document.getElementById('wowneroAddressInput').value;
|
||||
if (address == "") {
|
||||
notif('Cannot publish an empty value.', 'warning');
|
||||
document.getElementById('publishWowneroAddress').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
await addAvalancheNetwork();
|
||||
try {
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
notif(`Publishing Wownero address "${address.slice(0, 6)}...${address.slice(-6)}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
|
||||
let res = await contract.methods.setUserWowneroAddress(address).send({
|
||||
from: walletAddress,
|
||||
value: 0,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('publishWowneroAddress').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function publishMetadataIPFSHash() {
|
||||
document.getElementById('publishMetadataIPFSHash').classList.add('is-loading');
|
||||
const _hash = document.getElementById('metadataIPFSHashInput').value;
|
||||
if (_hash == "") {
|
||||
notif('Cannot publish an empty value.', 'warning');
|
||||
document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
await addAvalancheNetwork();
|
||||
try {
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
notif(`Publishing user profile metadata IPFS hash "${_hash}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
|
||||
let res = await contract.methods.setUserMetadata(_hash).send({
|
||||
from: walletAddress,
|
||||
value: 0,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
fetchUserProfile();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue