mirror of
https://github.com/jwinterm/tubbymemes.git
synced 2026-10-17 05:21:28 +02:00
stripping out avax stuff, no user handles
This commit is contained in:
@@ -29,7 +29,7 @@ def mod():
|
||||
if not current_user.is_authenticated:
|
||||
flash('You must be logged in and have MetaMask wallet connected.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
if not current_user.is_moderator():
|
||||
if not current_user.moderator:
|
||||
flash('You are not a moderator.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
memes = Meme.query.filter(
|
||||
@@ -43,9 +43,6 @@ def publish():
|
||||
if not current_user.is_authenticated:
|
||||
flash('You need to connect your wallet first.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
if not current_user.wownero_address:
|
||||
flash('You need to specify your Wownero wallet address first.', 'warning')
|
||||
return redirect(url_for('user.show', handle=current_user.handle))
|
||||
meme = None
|
||||
try:
|
||||
client = ipfsApi.Client('127.0.0.1', 5001)
|
||||
@@ -76,7 +73,7 @@ def publish():
|
||||
)
|
||||
db.session.add(meme)
|
||||
db.session.commit()
|
||||
if current_user.verified or current_user.is_moderator():
|
||||
if current_user.verified or current_user.moderator:
|
||||
res = upload_to_ipfs(meme.id)
|
||||
meme.meta_ipfs_hash = res[0]
|
||||
meme.meme_ipfs_hash = res[1]
|
||||
@@ -104,7 +101,7 @@ def show(meme_id):
|
||||
if not meme.approved and not current_user.is_authenticated:
|
||||
flash('You need to be logged in to view that meme.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
elif not meme.approved and not current_user.is_moderator():
|
||||
elif not meme.approved and not current_user.moderator:
|
||||
flash('You need to be a moderator to view that meme.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
return render_template('meme.html', meme=meme)
|
||||
@@ -115,7 +112,7 @@ def approve(meme_id, action):
|
||||
if not current_user.is_authenticated:
|
||||
flash('You need to be logged in to reach this page.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
if not current_user.is_moderator():
|
||||
if not current_user.moderator:
|
||||
flash('You need to be a moderator to reach this page.', 'warning')
|
||||
return redirect(url_for('meme.index'))
|
||||
meme = Meme.query.get(meme_id)
|
||||
|
||||
@@ -21,17 +21,14 @@
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
{% if meme.user.profile_image %}
|
||||
<figure class="image is-48x48">
|
||||
<img src="{{ url_for('meta.uploaded_file', filename=meme.user.profile_image) }}" alt="{{ meme.user.handle }} pfp">
|
||||
<img src="/static/img/logo.png" alt="{{ meme.user.id }} pfp">
|
||||
</figure>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<p class="title is-4">{{ meme.title }}</p>
|
||||
<p class="subtitle is-6">
|
||||
<a href="{{ url_for('user.show', handle=meme.user.handle) }}">{{ meme.user.handle }}</a>
|
||||
<a href="{{ meme.user.public_address | show_snowtrace }}" target="_blank">({{ meme.user.public_address | shorten_address }})</a>
|
||||
<a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">({{ meme.user.public_address | shorten_address }})</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
{% if request.path == '/' %}
|
||||
<a class="button is-secondary" href="{{ url_for('meta.about') }}" up-target=".container">About</a>
|
||||
{% if current_user.is_authenticated %}
|
||||
<a class="button is-secondary" href="{{ url_for('user.show', handle=current_user.handle) }}">Profile</a>
|
||||
<a class="button is-danger" href="{{ url_for('meta.disconnect') }}">Disconnect</a>
|
||||
{% if current_user.is_moderator() %}
|
||||
<a class="button is-warning" href="{{ url_for('meme.mod') }}" up-preload up-follow=".container">Mod</a>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script src="/static/js/vendor/noty-3.2.0.js"></script>
|
||||
<!-- <script src="/static/js/main.js"></script> -->
|
||||
<!-- <script src="/static/js/vendor/web3-1.3.6.min.js"></script> -->
|
||||
<script src="/static/js/vendor/metamask-onboarding-1.0.1.bundle.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
+41
-252
@@ -30,27 +30,16 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<br/>
|
||||
<p><strong>Meme ID:</strong> <code>{{ meme }}</code></p>
|
||||
<p><strong>Title:</strong> {{ meme.title }}</p>
|
||||
<p><strong>Description:</strong> {{ meme.description }}</p>
|
||||
<p><strong>Poster Address:</strong> <a href="{{ url_for('user.show', handle=meme.user.handle) }}">{{ meme.user.handle }}</a></p>
|
||||
{% if meme.user.wownero_address %}
|
||||
<p><strong>Wownero Address:</strong> <span style="word-wrap: break-word">{{ meme.user.wownero_address }}</p>
|
||||
{% endif %}
|
||||
<h1 class="title"><strong>{{ meme.title }}</strong></h1>
|
||||
<h1 class="subtitle"><strong>{{ meme.description }}</strong></h1>
|
||||
<hr>
|
||||
|
||||
<p><strong>Poster Address: </strong></br><span style="word-wrap: break-word"><a href="{{ meme.user.public_address | show_etherscan }}">{{ meme.user.public_address }}</a></span></p>
|
||||
{% if meme.meta_ipfs_hash %}
|
||||
<p><strong>Meta IPFS:</strong> <a href="{{ meta_url }}" target=_self>{{ meme.meta_ipfs_hash }}</a></p>
|
||||
<p><strong>Metadata IPFS:</strong></br><a href="{{ meta_url }}" target=_self>{{ meme.meta_ipfs_hash }}</a></p>
|
||||
{% endif %}
|
||||
{% if meme.meme_ipfs_hash %}
|
||||
<p><strong>Meme IPFS:</strong> <a href="{{ meme_url }}" target=_self>{{ meme.meme_ipfs_hash }}</a></p>
|
||||
{% endif %}
|
||||
{% if meme.minted %}
|
||||
<p>
|
||||
<strong>Tips Received:</strong>
|
||||
<span id="wowTips">?</span> WOW,
|
||||
<span id="wowxTips">?</span> WOWX,
|
||||
<span id="avaxTips">?</span> AVAX
|
||||
</p>
|
||||
<p><strong>Token ID:</strong> <span id="tokenId">? </span> <a href="{{ config.CONTRACT_ADDRESS | show_snowtrace }}">(contract)</a></p>
|
||||
<p><strong>Meme IPFS:</strong></br><a href="{{ meme_url }}" target=_self>{{ meme.meme_ipfs_hash }}</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% if not meme.approved %}
|
||||
@@ -65,86 +54,17 @@
|
||||
</div>
|
||||
{% else %}
|
||||
<br/>
|
||||
<div id="tipButtons" class="columns" style="display:none;">
|
||||
{% if meme.user.wownero_address %}
|
||||
<div class="column">
|
||||
<a class="button is-info is-12" onclick="tipWOW()" id="tipWOWButton" style="width:100%;">Tip via p2p WOW</a>
|
||||
<div id="tipButtons" class="columns">
|
||||
<div class="column is-one-quarter">
|
||||
<input class="input" type="number" step=".001" value="0.002" id="tipAmount">
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="column">
|
||||
<a class="button is-info is-12" onclick="tipSC()" id="tipSCButton" style="width:100%;">Tip via Smart Contract</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mintButtons" class="columns" style="display:none;">
|
||||
{% if meme.user.wownero_address %}
|
||||
<div class="column is-one-third">
|
||||
<a class="button is-info" onclick="tipWOW()" id="tipWOWButton" style="width:100%;">Tip via p2p WOW</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="column">
|
||||
<a class="button is-danger" onclick="mint()" id="mintButton" style="width:100%;">Mint to AVAX</a>
|
||||
<a class="button is-info is-12" id="tipButton" style="width:100%;">Tip this poster</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div id="tipWOWModal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Tip via WOW p2p</p>
|
||||
<button class="delete" aria-label="close" id="closeWOWModal"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
<p style="word-wrap: break-word;">
|
||||
<strong>Wownero Address (p2p):</strong>
|
||||
<span id="wowneroAddress">{{ meme.user.wownero_address | default('?') }}</span>
|
||||
</p>
|
||||
</br>
|
||||
<p>
|
||||
Funds sent to this address will not be tracked as they are a direct,
|
||||
p2p transaction on the anonymous, private Wownero network.
|
||||
Nobody will have visibility into these and will not be shown.
|
||||
</p>
|
||||
</br>
|
||||
<a href="https://wownero.org/#wallets" target="_blank">Wownero Wallets</a>
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tipSCModal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Tip via Smart Contract</p>
|
||||
<button class="delete" aria-label="close" id="closeSCModal"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
<p>
|
||||
Sending a tip via the <a href="{{ config.CONTRACT_ADDRESS | show_snowtrace }}" target="_blank">tubbymemes smart contract</a> will send a small amount to the
|
||||
publisher (the address that minted the meme) and the contract owner ({{ config.CONTRACT_OWNER }}), and the remainder is sent to the meme creator (whoever uploaded it). Everyone gets tipped for their contribution, but primarily the meme creator.
|
||||
</p>
|
||||
</br>
|
||||
<p>
|
||||
Input the amount of WOWX or AVAX you would like to send and click a button below to sign the transaction in MetaMask wallet.
|
||||
</p>
|
||||
</br>
|
||||
<div class="field">
|
||||
<label class="label">Tip Amount</label>
|
||||
<div class="control">
|
||||
<input id="tipSCAmount" class="input" type="text" placeholder=".042069">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button id="tipWOWXButton" class="button is-success" onclick="tipWOWX()">Tip WOWX</button>
|
||||
<button id="tipAVAXButton" class="button" onclick="tipAVAX()">Tip AVAX</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -152,170 +72,39 @@
|
||||
</section>
|
||||
{% include 'includes/footer.html' %}
|
||||
{% if meme.approved %}
|
||||
<script src="/static/js/vendor/web3-1.3.6.min.js"></script>
|
||||
<script src="/static/js/main.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
// Show buttons depending on if minted or not
|
||||
let minted = await isMinted('{{ meme.meta_ipfs_hash }}');
|
||||
if (minted) {
|
||||
document.getElementById('tipButtons').style.display = "flex";
|
||||
} else {
|
||||
document.getElementById('mintButtons').style.display = "flex";
|
||||
const w3 = new Web3(Web3.givenProvider);
|
||||
document.getElementById('tipButton').onclick = async () => {
|
||||
document.getElementById('tipButton').classList.add('is-loading');
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const tipAmount = document.getElementById('tipAmount').value;
|
||||
const tipAmountWei = w3.utils.toWei(tipAmount);
|
||||
const tipAmountHex = Number(tipAmountWei).toString(16);
|
||||
try {
|
||||
notif(`Tipping ${tipAmount} ETH to poster {{ meme.user.public_address | shorten_address }} for meme {{ meme.id }}.`, 'info');
|
||||
await ethereum.request({
|
||||
method: 'eth_sendTransaction',
|
||||
params: [
|
||||
{
|
||||
from: walletAddress,
|
||||
to: "{{ meme.user.public_address }}",
|
||||
value: tipAmountHex
|
||||
},
|
||||
],
|
||||
})
|
||||
.then((txHash) => {
|
||||
console.log(txHash);
|
||||
})
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('tipButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
// Show tip amounts
|
||||
try {
|
||||
const tokenId = await getTokenID('{{ meme.meta_ipfs_hash }}');
|
||||
const memeDeets = await contract.methods.tokenMeme(tokenId).call();
|
||||
document.getElementById('tokenId').innerHTML = tokenId;
|
||||
document.getElementById('wowxTips').innerHTML = await w3.utils.fromWei(memeDeets.creatorTipsWOWX);
|
||||
document.getElementById('avaxTips').innerHTML = await w3.utils.fromWei(memeDeets.creatorTipsAVAX);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
async function tipWOW() {
|
||||
document.getElementById('tipWOWButton').classList.add('is-loading');
|
||||
document.getElementById('tipWOWModal').classList.add('is-active');
|
||||
document.getElementById('closeWOWModal').onclick = () => {
|
||||
document.getElementById('tipWOWModal').classList.remove('is-active');
|
||||
document.getElementById('tipWOWButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function tipSC() {
|
||||
document.getElementById('tipSCButton').classList.add('is-loading');
|
||||
document.getElementById('tipSCModal').classList.add('is-active');
|
||||
document.getElementById('closeSCModal').onclick = () => {
|
||||
document.getElementById('tipSCModal').classList.remove('is-active');
|
||||
document.getElementById('tipSCButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function getTipAmount() {
|
||||
const amt = document.getElementById('tipSCAmount').value;
|
||||
if (isNaN(amt)) {
|
||||
notif('You must provide a number.', 'warning');
|
||||
return false;
|
||||
} else {
|
||||
return amt;
|
||||
}
|
||||
}
|
||||
|
||||
async function tipAVAX() {
|
||||
document.getElementById('tipAVAXButton').classList.add('is-loading');
|
||||
const tokenId = await getTokenID('{{ meme.meta_ipfs_hash }}');
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const tipAmount = await getTipAmount();
|
||||
if (!tipAmount) {
|
||||
document.getElementById('tipAVAXButton').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
const tipAmountWei = w3.utils.toWei(tipAmount);
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
try {
|
||||
const gasLimit = await contract.methods.tipAVAX(tokenId, tipAmountWei).estimateGas({from: walletAddress, value: tipAmountWei}, function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
notif(`Tipping ${tipAmount} AVAX to meme "{{ meme.id | shorten_address }}" by "{{ meme.user.handle }} ({{ meme.user.public_address | shorten_address }})" via the Avalanche blockchain.`, 'info');
|
||||
let res = await contract.methods.tipAVAX(tokenId, tipAmountWei).send({
|
||||
from: walletAddress,
|
||||
value: tipAmountWei,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('tipAVAXButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function approveWOWX(amountWei) {
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const allowanceWei = await wowxContract.methods.allowance(walletAddress, contractAddress).call();
|
||||
if (amountWei <= allowanceWei) {
|
||||
return true;
|
||||
}
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
const gasLimit = await wowxContract.methods.approve(contractAddress, amountWei).estimateGas({from: walletAddress}, function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
try {
|
||||
notif(`Approving usage of WOWX token.`, 'info');
|
||||
let res = await wowxContract.methods.approve(contractAddress, amountWei).send({
|
||||
from: walletAddress,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
return true;
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
async function tipWOWX() {
|
||||
document.getElementById('tipWOWXButton').classList.add('is-loading');
|
||||
const tipAmount = await getTipAmount();
|
||||
if (!tipAmount) {
|
||||
document.getElementById('tipWOWXButton').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
const tipAmountWei = w3.utils.toWei(tipAmount);
|
||||
const tokenId = await getTokenID('{{ meme.meta_ipfs_hash }}');
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const approved = await approveWOWX(tipAmountWei);
|
||||
if (!approved) {
|
||||
document.getElementById('tipWOWXButton').classList.remove('is-loading');
|
||||
return false;
|
||||
}
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
try {
|
||||
const gasLimit = await contract.methods.tipWOWX(tokenId, tipAmountWei).estimateGas({from: walletAddress}, function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
notif(`Tipping ${tipAmount} WOWX to meme "{{ meme.id | shorten_address }}" by "{{ meme.user.handle }} ({{ meme.user.public_address | shorten_address }})".`, 'info');
|
||||
let res = await contract.methods.tipWOWX(tokenId, tipAmountWei).send({
|
||||
from: walletAddress,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('tipWOWXButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
|
||||
async function mint() {
|
||||
if (await isMinted('{{ meme.meta_ipfs_hash }}')) {
|
||||
notif('Already minted!', 'warning');
|
||||
return
|
||||
}
|
||||
document.getElementById('mintButton').classList.add('is-loading');
|
||||
const walletAddress = await getMetamaskAccount();
|
||||
const gasPrice = await w3.eth.getGasPrice();
|
||||
const gasLimit = await contract.methods.mint("{{ meme.meta_ipfs_hash }}", "{{ meme.user.public_address }}").estimateGas({from: walletAddress}, function(err, gas){
|
||||
return gas;
|
||||
});
|
||||
try {
|
||||
notif(`Minting meme "{{ meme.id | shorten_address }}" by "{{ meme.user.handle }} ({{ meme.user.public_address | shorten_address }})" to the Avalanche blockchain.`, 'info');
|
||||
let res = await contract.methods.mint("{{ meme.meta_ipfs_hash }}", "{{ meme.user.public_address }}").send({
|
||||
from: walletAddress,
|
||||
value: 0,
|
||||
gasPrice: gasPrice,
|
||||
gas: gasLimit
|
||||
});
|
||||
console.log(res);
|
||||
window.location.href = "";
|
||||
} catch(e) {
|
||||
notif(e.message, 'warning');
|
||||
document.getElementById('mintButton').classList.remove('is-loading');
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
||||
@@ -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>
|
||||
@@ -25,14 +25,14 @@
|
||||
<div class="field">
|
||||
<label class="label">Title</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="Title of your meme" name="title">
|
||||
<input class="input" type="text" placeholder="Dank title" name="title">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Description</label>
|
||||
<div class="control">
|
||||
<textarea class="textarea" placeholder="Description..." name="description"></textarea>
|
||||
<textarea class="textarea" placeholder="Dank description" name="description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox">
|
||||
I agree to support the ongoing funding of exploratory meme missions
|
||||
I agree to be a based ass Tubby posting mfer 4 life
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user