/*SET CONTRACTS UP HERE*/ var GlobalChannelString = "ethoFSPinningChannel_alpha11"; var GlobalControllerContractAddress = "0xc38B47169950D8A28bC77a6Fa7467464f25ADAFc"; var GlobalControllerABI = JSON.parse('[ { "constant": true, "inputs": [], "name": "last_completed_migration", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address", "value": "0x" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": false, "inputs": [ { "name": "completed", "type": "uint256" } ], "name": "setCompleted", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "new_address", "type": "address" } ], "name": "upgrade", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "pinToAdd", "type": "string" }, { "name": "pinSize", "type": "uint32" } ], "name": "PinAdd", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "pin", "type": "string" } ], "name": "PinRemove", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": false, "inputs": [], "name": "deleteContract", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "set", "type": "address" } ], "name": "SetAccountCollectionAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "hostingCost", "type": "uint256" } ], "name": "SetHostingCost", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "pinStorageAddress", "type": "address" } ], "name": "SetPinStorageAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "ethoFSDashboardAddress", "type": "address" } ], "name": "SetEthoFSDashboardAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "ethoFSHostingContractsAddress", "type": "address" } ], "name": "SetEthoFSHostingContractsAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" }, { "name": "AccountName", "type": "string" } ], "name": "AddNewUserOwner", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "AccountName", "type": "string" } ], "name": "AddNewUserPublic", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "RemoveUserOwner", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "RemoveUserPublic", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "MainContentHash", "type": "string" }, { "name": "HostingContractName", "type": "string" }, { "name": "HostingContractDuration", "type": "uint32" }, { "name": "TotalContractSize", "type": "uint32" }, { "name": "pinSize", "type": "uint32" }, { "name": "ContentHashString", "type": "string" }, { "name": "ContentPathString", "type": "string" } ], "name": "AddNewContract", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" }, { "name": "MainContentHash", "type": "string" } ], "name": "RemoveHostingContract", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" }, { "name": "HostingContractExtensionDuration", "type": "uint32" } ], "name": "ExtendContract", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [], "name": "ScrubHostingContracts", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountName", "outputs": [ { "name": "value", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountActiveContractCount", "outputs": [ { "name": "value", "type": "uint32", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountTotalContractCount", "outputs": [ { "name": "value", "type": "uint32", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "UserAddress", "type": "address" }, { "name": "ArrayKey", "type": "uint256" } ], "name": "GetHostingContractAddress", "outputs": [ { "name": "value", "type": "address", "value": "0x" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "CheckAccountExistence", "outputs": [ { "name": "", "type": "bool", "value": false } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetMainContentHash", "outputs": [ { "name": "MainContentHash", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetContentHashString", "outputs": [ { "name": "ContentHashString", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetContentPathString", "outputs": [ { "name": "ContentPathString", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractDeployedBlockHeight", "outputs": [ { "name": "value", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractExpirationBlockHeight", "outputs": [ { "name": "value", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractStorageUsed", "outputs": [ { "name": "value", "type": "uint32", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractName", "outputs": [ { "name": "value", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "newOperator", "type": "address" } ], "name": "changeOperator", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "set", "type": "address" } ], "name": "SetAccountCollectionAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" }, { "name": "AccountName", "type": "string" } ], "name": "AddNewUser", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "RemoveUser", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newContractAddress", "type": "address" }, { "name": "UserAddress", "type": "address" }, { "name": "HostingContractName", "type": "string" }, { "name": "HostingContractDuration", "type": "uint32" }, { "name": "TotalContractSize", "type": "uint32" } ], "name": "AddHostingContract", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" }, { "name": "HostingContractAddress", "type": "address" } ], "name": "RemoveHostingContract1", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountAddress", "outputs": [ { "name": "value", "type": "address" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountName", "outputs": [ { "name": "value", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountActiveContractCount", "outputs": [ { "name": "value", "type": "uint32" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "GetUserAccountTotalContractCount", "outputs": [ { "name": "value", "type": "uint32" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" }, { "name": "ArrayKey", "type": "uint256" } ], "name": "GetHostingContractAddress", "outputs": [ { "name": "value", "type": "address" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "UserAddress", "type": "address" } ], "name": "CheckAccountExistence", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "ScrubContractList", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "set", "type": "uint256" } ], "name": "SetHostingContractCost", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" }, { "name": "HostingContractExtensionDuration", "type": "uint32" } ], "name": "ExtendHostingContract", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetMainContentHash", "outputs": [ { "name": "MainContentHash", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetContentHashString", "outputs": [ { "name": "ContentHashString", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetContentPathString", "outputs": [ { "name": "ContentPathString", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractDeployedBlockHeight", "outputs": [ { "name": "value", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractExpirationBlockHeight", "outputs": [ { "name": "value", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractStorageUsed", "outputs": [ { "name": "value", "type": "uint32" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "HostingContractAddress", "type": "address" } ], "name": "GetHostingContractName", "outputs": [ { "name": "value", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "MainContentHash", "type": "string" }, { "name": "HostingContractName", "type": "string" }, { "name": "HostingContractDuration", "type": "uint32" }, { "name": "TotalContractSize", "type": "uint32" }, { "name": "ContentHashString", "type": "string" }, { "name": "ContentPathString", "type": "string" } ], "name": "AddHostingContract", "outputs": [ { "name": "value", "type": "address" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "CustomerAddress", "type": "address" }, { "name": "HostingContractAddress", "type": "address" }, { "name": "AccountCollectionAddress", "type": "address" } ], "name": "RemoveHostingContract2", "outputs": [ { "name": "value", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "AccountCollectionAddress", "type": "address" } ], "name": "SetAccountCollectionAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" } ]'); /*END OF CONTRACT SETUP*/ const $miningMessage = document.querySelector('.mining-message') /*START OF MISC GLOBAL VARIABLES*/ var privateKeyLogin = false; var GlobalPrivateKey; var minimumContractCost = 10000000000000000; var GlobalUploadName = ""; var GlobalUserAddress = ""; var GlobalHostingCost = 1.0; var GlobalHostingCostWei = GlobalHostingCost * 1000000000000000000; var GlobalUploadSize = 0; var GlobalHashArray = new Array(); var GlobalSizeArray = new Array(); var GlobalPathArray = new Array(); var GlobalMainHashArray = new Array(); var GlobalMainPathArray = new Array(); var GlobalMainContentHash = ""; var GlobalUploadHash = ""; var GlobalUploadPath = ""; var GlobalContractDuration = ""; var GlobalHostingContractArray = new Array(); var GlobalTotalContractCount = 0; var GlobalHostingContractDetailArray = new Array(); var GlobalExtensionDuration; /*END OF MISC GLOBAL VARIABLES*/ fetch('https://api.coinmarketcap.com/v2/ticker/3452/').then(response => { return response.json(); }).then(data => { var ethoPriceUSD = data.data.quotes.USD.price; document.getElementById("ethoprice").textContent = round(ethoPriceUSD, 4); }).catch(err => {}); if (typeof web3 == 'undefined') { var web3 = new Web3() web3.setProvider(new Web3.providers.HttpProvider('https://rpc.ether1.org')) $('#ethofsLoginModal').modal('show'); } else { ethofsLogin(""); } function ethofsLogin(privateKey) { $('#ethofsLoginModal').modal('hide'); $('#ethofsRegistrationModal').modal('hide'); //CREATE ETHER-1 CHAIN CONNECTION AND LOOK FOR EXISTING USER ACCOUNT if (privateKey != "") { GlobalPrivateKey = privateKey; privateKeyLogin = true; web3.eth.net.isListening() .then(function() { console.log('ethoFS is connected') let account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey); console.log(account); web3.eth.accounts.wallet.add(account) web3.eth.defaultAccount = account.address; startEthofs() }) } else { privateKeyLogin = false; window.web3 = new Web3(window.web3.currentProvider); web3.eth.getAccounts(function(err, accounts) { if (err != null) { console.error("An error occurred: " + err); outputNoAddressContractTable(); } else if (accounts.length == 0) { $('#ethofsLoginModal').modal('show'); console.log("User is not logged in"); document.getElementById("welcome-name").textContent = "Access to Ether-1 Blockchain Not Found - Make Sure You Are Using Metamask or The Ether-1 Browser Extension"; document.getElementById("accountaddress").textContent = "Address Not Found"; outputNoAddressContractTable(); } else { console.log("User is logged in"); web3.eth.defaultAccount = accounts[0]; startEthofs(); } }); } } function startEthofs() { console.log("Starting ethoFS"); GlobalUserAddress = web3.eth.defaultAccount; var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); ethoFSAccounts.methods.CheckAccountExistence(GlobalUserAddress).call(function(error, result) { if (!error) { if (result) { document.getElementById("accountaddress").textContent = web3.eth.defaultAccount; ethoFSAccounts.methods.GetUserAccountName(GlobalUserAddress).call(function(error, result) { if (!error) { if (result) { getBlockHeight(web3); getBalance(web3); document.getElementById("welcome-name").textContent = "Welcome Back " + result; updateContractTable(); window.startApplication(); } } else { console.log("Error getting user account name"); } }); } else { document.getElementById("welcome-name").textContent = "User Not Found"; document.getElementById("accountaddress").textContent = "Address Not Found"; console.log("User Not Found"); $('#ethofsRegistrationModal').modal('show'); } } else { document.getElementById("welcome-name").textContent = "Access to Ether-1 Blockchain Not Found - Make Sure You Are Using Metamask or The Ether-1 Browser Extension"; document.getElementById("accountaddress").textContent = "Address Not Found"; console.log("Blockchain Access Error"); } }); } /*************************************************************************************************************/ function AddNewUser(userName) { console.log("Initiating New User Addition... " + userName); var controller = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); if (privateKeyLogin == true) { const tx = { to: GlobalControllerContractAddress, from: GlobalUserAddress, gas: 4000000, data: controller.methods.AddNewUserPublic(userName).encodeABI() }; var privateKey = '0x' + GlobalPrivateKey; web3.eth.accounts.signTransaction(tx, privateKey) .then(function(signedTransactionData) { web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) { if (!error) { if (result) { $('#minedBlockTrackerModal').modal('show'); waitForReceipt(result, function(receipt) { console.log("Transaction Has Been Mined: " + receipt); $('#minedBlockTrackerModal').modal('hide'); ethofsLogin(GlobalPrivateKey); }); } else { console.log("There was a problem adding new contract"); } } else { console.error(error); } }); }); } else { controller.methods.AddNewUserPublic(userName).send(function(error, result) { if (!error) { if (result) { document.getElementById("wait").innerHTML = 'Waiting For Add User Confirmation.'; $('#minedBlockTrackerModal').modal('show'); waitForReceipt(result, function(receipt) { console.log("Transaction Has Been Mined: " + receipt); $('#minedBlockTrackerModal').modal('hide'); ethofsLogin(""); }); } else { console.log("There was a problem adding new user"); $('#ethofsLoginModal').modal('show'); } } else { console.error(error); $('#ethofsLoginModal').modal('show'); } }); } } /*************************************************************************************************************/ function getBlockHeight(web3) { console.log("Starting Block Height Detection.."); web3.eth.getBlockNumber(function(err, data) { document.getElementById("blocknumber").textContent = data; console.log("ETHO Block Number: " + data); }); } /*************************************************************************************************************/ function getBalance(web3) { console.log("Starting Balance Detection.."); web3.eth.getBalance(web3.eth.defaultAccount, function(err, data) { var balance = "ETHO Balance: " + Number(web3.utils.fromWei(data, "ether")).toFixed(2); document.getElementById("ethobalance").textContent = balance; console.log("ETHO Balance: " + data); }); } /*************************************************************************************************************/ //CALCULATE AMOUNT TO BE SENT function calculateCost(contractSize, contractDuration, hostingCost) { var cost = ((((contractSize / 1048576) * hostingCost) * (contractDuration / 46522))); if (cost < minimumContractCost) { cost = minimumContractCost; } return cost; } /*************************************************************************************************************/ //CHECK FOR TX - BLOCK TO BE MINED function waitForReceipt(hash, cb) { web3.eth.getTransactionReceipt(hash, function(err, receipt) { document.getElementById("mining-status-message").textContent = "In Progress"; $miningMessage.innerText = "Waiting For Transaction Confirmation"; web3.eth.getBlock('latest', function(e, res) { if (!e) { document.getElementById("block-height").textContent = res.number; } }); if (err) { error(err); $miningMessage.innerText = "Error Conneting To Ether-1 Network"; } if (receipt !== null) { $miningMessage.innerText = "Transaction Confirmed"; document.getElementById("mining-status-message").textContent = "Complete"; if (cb) { cb(receipt); } } else { window.setTimeout(function() { waitForReceipt(hash, cb); }, 10000); } }); } /*************************************************************************************************************/ //CREATE ETHER-1 CHAIN CONNECTION AND REMOVE CONTRACT function RemoveContract(hostingAddress, contentHash) { var pinRemoving = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); if (privateKeyLogin == true) { const tx = { to: GlobalControllerContractAddress, from: GlobalUserAddress, gas: 4000000, data: pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).encodeABI() }; var privateKey = '0x' + GlobalPrivateKey; console.log("Private Key: " + privateKey); web3.eth.accounts.signTransaction(tx, privateKey) .then(function(signedTransactionData) { console.log("Signed TX Data: " + signedTransactionData.rawTransaction); web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) { if (!error) { if (result) { $('#minedBlockTrackerModal').modal('show'); waitForReceipt(result, function(receipt) { console.log("Transaction Has Been Mined: " + receipt); $('#minedBlockTrackerModal').modal('hide'); updateContractTable(); }); } else { console.log("There was a problem adding new contract"); } } else { console.error(error); } }); }); } else { const tx = { to: GlobalControllerContractAddress, from: GlobalUserAddress, }; pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).send(tx, function(error, result) { if (!error) { if (result) { $('#minedBlockTrackerModal').modal('show'); waitForReceipt(result, function(receipt) { console.log("Transaction Has Been Mined: " + receipt); $('#minedBlockTrackerModal').modal('hide'); updateContractTable(); }); } else { console.log("There was a problem removing contract"); } } else { console.error(error); } }); } } function updateContractTable() { /*************************************************************************************************************/ //CREATE ETHER-1 CHAIN CONNECTION AND GET USER ACCOUNT & CONTRACTS var ethoFSHostingContracts = new Array(); var hostingContracts = ""; var TotalContractCount = 0; var blockHeight = 0; web3.eth.getBlockNumber(function(error, result) { if (!error) { blockHeight = result; } else console.error(error); }); var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); ethoFSAccounts.methods.GetUserAccountTotalContractCount(web3.eth.defaultAccount).call(function(error, result) { TotalContractCount = result; GlobalTotalContractCount = result; const getContractData = async (ethoFSAccounts, account, TotalContractCount) => { if (TotalContractCount == 0) { outputNoAddressContractTableWithButton(); } for (i = 0; i < TotalContractCount; i++) { const promisify = (inner) => new Promise((resolve, reject) => inner((err, res) => { if (err) { reject(err); } else { resolve(res); } }) ); counter = i; GlobalHostingContractArray[counter] = new Array(); ethoFSHostingContractAddress = promisify(cb => ethoFSAccounts.methods.GetHostingContractAddress(account, counter).call(cb)); await Promise.all([getAdditionalContractData(await ethoFSHostingContractAddress, counter, ethoFSAccounts)]); async function getAdditionalContractData(ethoFSHostingContractAddress, counter, ethoFSAccounts) { const promisify = (inner) => new Promise((resolve, reject) => inner((err, res) => { if (err) { reject(err); } else { resolve(res); } }) ); ethoFSHostingContractCost = counter; ethoFSHostingContractName = promisify(cb => ethoFSAccounts.methods.GetHostingContractName(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractMainHash = promisify(cb => ethoFSAccounts.methods.GetMainContentHash(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractHashString = promisify(cb => ethoFSAccounts.methods.GetContentHashString(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractPathString = promisify(cb => ethoFSAccounts.methods.GetContentPathString(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractStorage = promisify(cb => ethoFSAccounts.methods.GetHostingContractStorageUsed(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractStartBlock = promisify(cb => ethoFSAccounts.methods.GetHostingContractDeployedBlockHeight(ethoFSHostingContractAddress).call(cb)); ethoFSHostingContractEndBlock = promisify(cb => ethoFSAccounts.methods.GetHostingContractExpirationBlockHeight(ethoFSHostingContractAddress).call(cb)); GlobalHostingContractArray[counter]['address'] = await ethoFSHostingContractAddress; GlobalHostingContractArray[counter]['name'] = await ethoFSHostingContractName; GlobalHostingContractArray[counter]['mainhash'] = await ethoFSHostingContractMainHash; GlobalHostingContractArray[counter]['hashstring'] = await ethoFSHostingContractHashString; GlobalHostingContractArray[counter]['pathstring'] = await ethoFSHostingContractPathString; GlobalHostingContractArray[counter]['storage'] = await ethoFSHostingContractStorage; GlobalHostingContractArray[counter]['startblock'] = await ethoFSHostingContractStartBlock; GlobalHostingContractArray[counter]['endblock'] = await ethoFSHostingContractEndBlock; GlobalHostingContractArray[counter]['hash'] = new Array(); GlobalHostingContractArray[counter]['path'] = new Array(); ContractHashArray = new Array(); ContractPathArray = new Array(); var splitHashArray = await Promise.all([splitString(await ethoFSHostingContractHashString, ":")]); var splitPathArray = await Promise.all([splitString(await ethoFSHostingContractPathString, ":")]); function splitString(stringToSplit, splitDelimeter) { return stringToSplit.split(splitDelimeter); } await Promise.all([loopSplitStrings(await splitHashArray[0], await splitPathArray[0], counter)]); function loopSplitStrings(splitHashArray, splitPathArray, counter) { for (j = 1; j < splitHashArray.length; j++) { GlobalHostingContractArray[counter]['hash'][j] = splitHashArray[j]; GlobalHostingContractArray[counter]['path'][j] = splitPathArray[j]; } } await Promise.all([addNewTableEntry(await ethoFSHostingContractAddress, await ethoFSHostingContractMainHash, await ethoFSHostingContractName, await ethoFSHostingContractAddress, await ethoFSHostingContractStorage, await ethoFSHostingContractStartBlock, await ethoFSHostingContractEndBlock, await ethoFSHostingContractCost, await counter, await blockHeight)]); } } //END GET ADDITIONAL CONTACT DATA }; getContractData(ethoFSAccounts, web3.eth.defaultAccount, TotalContractCount); function addNewTableEntry(ethoFSHostingContractAddress, ethoFSHostingContractMainHash, ethoFSHostingContractName, ethoFSHostingContractHash, ethoFSHostingContractStorage, ethoFSHostingContractStartBlock, ethoFSHostingContractEndBlock, ethoFSHostingContractCost, counter, blockHeight) { if (blockHeight > ethoFSHostingContractEndBlock) { ethoFSHostingContractStatus = "Expired"; hostingContracts += '
'; } else { ethoFSHostingContractStatus = "Active"; hostingContracts += '