diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index cbe0d20aa..7d5aa0db5 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -1067,7 +1067,7 @@ exports.newHttpInterface = function newHttpInterface() { ) SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(serverResponse), httpResponse) - + setInterval( PL.servers.GITHUB_SERVER.mergePullRequests, 60000, @@ -1075,19 +1075,24 @@ exports.newHttpInterface = function newHttpInterface() { params.username, params.token ) - + return } case 'payContributors': { + console.log('----------------------------------------------------------------------------------------------') + console.log('DISTRIBUTION PROCESS STARTED') + console.log('----------------------------------------------------------------------------------------------') - let serverResponse = await PL.servers.WEB3_SERVER.payContributors( + SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) + + + await PL.servers.WEB3_SERVER.payContributors( params.contractAddress, params.contractAbi, params.paymentsArray, params.mnemonic ) - SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(serverResponse), httpResponse) return } default: { @@ -1106,7 +1111,7 @@ exports.newHttpInterface = function newHttpInterface() { } try { SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(error), httpResponse) - } catch(err) { + } catch (err) { // we just try to reponnd to the web app, but maybe the response has already been sent. } } diff --git a/Platform/Client/web3Server.js b/Platform/Client/web3Server.js index 354853cc7..80cf149e3 100644 --- a/Platform/Client/web3Server.js +++ b/Platform/Client/web3Server.js @@ -285,10 +285,14 @@ exports.newWeb3Server = function newWeb3Server() { let response = await mnemonicToPrivateKey(mnemonic) let privateKey = response.privateKey + console.log('----------------------------------------------------------------------------------------------') + console.log('PAYING CONTRIBUTORS') + console.log('----------------------------------------------------------------------------------------------') + for (let i = 0; i < paymentsArray.length; i++) { await PL.projects.foundations.utilities.asyncFunctions.sleep(10000) let payment = paymentsArray[i] - sendTokens( + await sendTokens( i + 1, payment.userProfile, payment.from, @@ -299,15 +303,31 @@ exports.newWeb3Server = function newWeb3Server() { async function sendTokens(number, userProfile, fromAddress, toAddress, tokenAmount) { try { + + tokenAmount = Math.trunc(tokenAmount / 1000000000000000000) + console.log('') console.log('---------------------------------------------------------------------------------------------------------------------------------------------------') - console.log(' Payment # ' + number + ' - User Profile: ' + userProfile + ' - SA Tokens Amount: ' + tokenAmount / 1000000000000000000 + ' - Address: ' + toAddress) + console.log(' Payment # ' + number + ' - User Profile: ' + userProfile + ' - SA Tokens Amount: ' + parseFloat(tokenAmount).toLocaleString('en') + ' - Address: ' + toAddress) console.log('---------------------------------------------------------------------------------------------------------------------------------------------------') console.log('') + if (tokenAmount === 0) { + console.log('No need to send a transaction in this case.') + return + } + const Tx = SA.nodeModules.ethereumjsTx.Transaction; const web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org/')) - const amount = web3.utils.toHex(tokenAmount) + /* + Token Amount + */ + + tokenAmount = web3.utils.toWei(tokenAmount.toString(), 'ether') + var amountBigNumber = web3.utils.toBN(tokenAmount) + + //const amount = web3.utils.toHex(tokenAmount) + if (privateKey === undefined) { privateKey = 'No Privete Key - Just Testing' } privateKey = privateKey.replace('0x', '') const privateKeyBuffer = Buffer.from(privateKey, 'hex') const contractAbiObject = JSON.parse(contractAbi) @@ -325,13 +345,14 @@ exports.newWeb3Server = function newWeb3Server() { ); const nonce = await web3.eth.getTransactionCount(fromAddress); + console.log('Nonce:', nonce) const rawTransaction = { "from": fromAddress, "gasPrice": web3.utils.toHex(5000000000), "gasLimit": web3.utils.toHex(210000), "to": contractAddress, "value": "0x0", - "data": contract.methods.transfer(toAddress, amount).encodeABI(), + "data": contract.methods.transfer(toAddress, amountBigNumber).encodeABI(), "nonce": web3.utils.toHex(nonce) }; @@ -340,6 +361,10 @@ exports.newWeb3Server = function newWeb3Server() { console.log('Transaction:', rawTransaction) const result = await web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex')) + .catch(err => { + console.log('[ERROR] sendSignedTransaction -> err =' + JSON.stringify(err)) + }) + console.log('Result:', result) return result } catch (err) { diff --git a/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js b/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js index f7eb10614..1b3d121cc 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js @@ -152,7 +152,7 @@ function newGovernanceReportsCommmandInterface() { "userProfile": userProfile.name, "from": UI.projects.governance.globals.saToken.SA_TOKEN_BSC_TREASURY_ACCOUNT_ADDRESS, "to": userProfile.payload.blockchainAccount, - "amount": 1 * UI.projects.governance.globals.saToken.SA_TOKEN_BSC_DECIMAL_FACTOR //(userProfile.tokensMined.payload.tokensMined.total | 0) * UI.projects.governance.globals.saToken.SA_TOKEN_BSC_DECIMAL_FACTOR + "amount": (userProfile.tokensMined.payload.tokensMined.total | 0) * UI.projects.governance.globals.saToken.SA_TOKEN_BSC_DECIMAL_FACTOR } paymentsArray.push(payment)