ensure user switches to avax network

main
lza_menace 3 years ago
parent 0505a1eded
commit 5c3948f5ed

@ -83,6 +83,7 @@
} }
async function getTokenID(ipfsHash) { async function getTokenID(ipfsHash) {
await addAvalancheNetwork();
if (ipfsHash != '') { if (ipfsHash != '') {
const tokenId = await contract.methods.metadataTokenId(ipfsHash).call(); const tokenId = await contract.methods.metadataTokenId(ipfsHash).call();
return tokenId; return tokenId;
@ -90,6 +91,7 @@
} }
async function isMinted(ipfsHash) { async function isMinted(ipfsHash) {
await addAvalancheNetwork();
if (ipfsHash != '') { if (ipfsHash != '') {
const tokenId = await getTokenID(ipfsHash) const tokenId = await getTokenID(ipfsHash)
if (tokenId == 0) { if (tokenId == 0) {

@ -99,6 +99,7 @@
async function fetchUserProfile() { async function fetchUserProfile() {
await addAvalancheNetwork();
_walletAddress = w3.utils.toChecksumAddress('{{ user.public_address }}'); _walletAddress = w3.utils.toChecksumAddress('{{ user.public_address }}');
const userProfile = await contract.methods.userProfile(_walletAddress).call(); const userProfile = await contract.methods.userProfile(_walletAddress).call();
if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle}; if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle};
@ -114,6 +115,7 @@
if (handle == "") { if (handle == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
} }
await addAvalancheNetwork();
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){
@ -139,6 +141,7 @@
if (address == "") { if (address == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
} }
await addAvalancheNetwork();
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){
@ -164,6 +167,7 @@
if (_hash == "") { if (_hash == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
} }
await addAvalancheNetwork();
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){

Loading…
Cancel
Save