Merge pull request #1494 from Luis-Fernando-Molina/develop

Contribution: Governance: Token Distribution command gov.pay implemented and tested.
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-08-19 13:26:20 -04:00
commit 0c83eb95db
15 files changed
+387 -71

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ process.on('uncaughtException', function (err) {
process.on('unhandledRejection', (reason, p) => {
// Signal user that a necissary node module is missing
if (reason.code == 'MODULE_NOT_FOUND') {
console.log("[ERROR] Node Modules not found. Running the node setup command and then restart")
console.log("[ERROR] Dependency library not found. Please try running the 'node setup' command and then restart the Client.")
console.log('[ERROR] Client -> client-> reason = ' + JSON.stringify(reason))
process.exit(1)
}
+4 -1
View File
@@ -1102,7 +1102,10 @@ exports.newHttpInterface = function newHttpInterface(
case 'payContributors': {
let serverResponse = await WEB3_SERVER.payContributors(
params.signature
params.contractAddress,
params.contractAbi,
params.paymentsArray,
params.mnemonic
)
respondWithContent(JSON.stringify(serverResponse), httpResponse)
+30
View File
@@ -1397,6 +1397,36 @@
"setimmediate": "^1.0.5"
}
},
"ethereumjs-common": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz",
"integrity": "sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA=="
},
"ethereumjs-tx": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz",
"integrity": "sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw==",
"requires": {
"ethereumjs-common": "^1.5.0",
"ethereumjs-util": "^6.0.0"
},
"dependencies": {
"ethereumjs-util": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
"integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
"requires": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "0.1.6",
"rlp": "^2.2.3"
}
}
}
},
"ethereumjs-util": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.0.tgz",
+2
View File
@@ -10,6 +10,8 @@
"@octokit/rest": "^18.9.0",
"ccxt": "^1.51.98",
"child_process": "^1.0.2",
"ethereumjs-common": "^1.5.2",
"ethereumjs-tx": "^2.1.2",
"ethers": "^5.4.4",
"lookpath": "^1.2.2",
"node-fetch": "2.6.1",
+81 -3
View File
@@ -8,7 +8,8 @@ exports.newWeb3Server = function newWeb3Server() {
getWalletBalances: getWalletBalances,
signData: signData,
recoverAddress: recoverAddress,
mnemonicToPrivateKey: mnemonicToPrivateKey,
mnemonicToPrivateKey: mnemonicToPrivateKey,
payContributors: payContributors,
initialize: initialize,
finalize: finalize,
run: run
@@ -245,13 +246,13 @@ exports.newWeb3Server = function newWeb3Server() {
if (wallet.privateKey !== undefined) {
return {
address: wallet.address,
address: wallet.address,
privateKey: wallet.privateKey,
result: 'Ok'
}
} else {
return {
address: undefined,
address: undefined,
privateKey: undefined,
result: 'Fail'
}
@@ -260,6 +261,83 @@ exports.newWeb3Server = function newWeb3Server() {
} catch (err) {
return { error: 'Could not convert to Private Key. ' + err.stack }
}
}
async function payContributors(contractAddress, contractAbi, paymentsArray, mnemonic) {
try {
let response = await mnemonicToPrivateKey(mnemonic)
let privateKey = response.privateKey
for (let i = 0; i < paymentsArray.length; i++) {
await CL.projects.foundations.utilities.asyncFunctions.sleep(10000)
let payment = paymentsArray[i]
sendTokens(
i + 1,
payment.userProfile,
payment.from,
payment.to,
payment.amount
)
}
async function sendTokens(number, userProfile, fromAddress, toAddress, tokenAmount) {
try {
console.log('')
console.log('---------------------------------------------------------------------------------------------------------------------------------------------------')
console.log(' Payment # ' + number + ' - User Profile: ' + userProfile + ' - SA Tokens Amount: ' + tokenAmount / 1000000000000000000 + ' - Address: ' + toAddress)
console.log('---------------------------------------------------------------------------------------------------------------------------------------------------')
console.log('')
const Tx = require('ethereumjs-tx').Transaction;
const web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org/'))
const amount = web3.utils.toHex(tokenAmount)
privateKey = privateKey.replace('0x', '')
const privateKeyBuffer = Buffer.from(privateKey, 'hex')
const contractAbiObject = JSON.parse(contractAbi)
const contract = new web3.eth.Contract(contractAbiObject, contractAddress, { from: fromAddress })
const Common = require('ethereumjs-common').default
const BSC_FORK = Common.forCustomChain(
'mainnet',
{
name: 'Binance Smart Chain Mainnet',
networkId: 56,
chainId: 56,
url: 'https://bsc-dataseed.binance.org/'
},
'istanbul',
);
const nonce = await web3.eth.getTransactionCount(fromAddress);
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(),
"nonce": web3.utils.toHex(nonce)
};
const transaction = new Tx(rawTransaction, { 'common': BSC_FORK })
transaction.sign(privateKeyBuffer)
console.log('Transaction:', rawTransaction)
const result = await web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))
console.log('Result:', result)
return result
} catch (err) {
console.log('[ERROR] web3Server -> sendTokens -> err.stack = ' + err.stack)
}
}
return {
address: wallet.address,
privateKey: wallet.privateKey,
result: 'Ok'
}
} catch (err) {
return { error: 'Could not convert to Private Key. ' + err.stack }
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@@ -9,6 +9,14 @@
"propertyToCheckFor": "githubAPI",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Web3 API",
"relatedUiObject": "Web3 API",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "web3API",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
@@ -27,6 +35,11 @@
"name": "githubAPI",
"type": "node",
"childType": "Github API"
},
{
"name": "web3API",
"type": "node",
"childType": "Web3 API"
}
],
"isPersonalData": true
@@ -0,0 +1,35 @@
{
"type": "Web3 API",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"token\": \"\", \n\"mnemonic\": \"\"\n}"
},
"addLeftIcons": true,
"level": 1,
"attachingRules": {
"compatibleTypes": "->APIs->"
},
"propertyNameAtParent": "web3API",
"isPersonalData": true
}
@@ -1,7 +1,7 @@
{
"type": "Pools",
"name": "Superalgos",
"config": "{\n \"tokens\": \"60000000\",\n \"codeName\": \"Superalgos\"\n}",
"config": "{\"tokens\":\"60000000\",\"codeName\":\"Superalgos\"}",
"project": "Governance",
"poolClasses": [
{
@@ -12031,27 +12031,39 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"DEXs",
"Asset Class"
"Asset Class",
"Governance",
"90e0c410-b1e7-4f0a-9dec-99c597a7956d"
],
[
"First Listing",
"Asset Class"
"Asset Class",
"Governance",
"54f70f64-029a-4f2f-8847-5208c2fa94a1"
],
[
" Pancakeswap SA/WBTC",
"Asset Class"
"Asset Class",
"Governance",
"cc6e34d9-d58a-4aa7-9049-250ea90a8430"
],
[
"SA Liquidity",
"Asset"
"Asset",
"Governance",
"2e59edc7-7e37-40e3-808f-9ab3c7c5f0b3"
]
]
}
@@ -12091,27 +12103,39 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"DEXs",
"Asset Class"
"Asset Class",
"Governance",
"90e0c410-b1e7-4f0a-9dec-99c597a7956d"
],
[
"First Listing",
"Asset Class"
"Asset Class",
"Governance",
"54f70f64-029a-4f2f-8847-5208c2fa94a1"
],
[
" Pancakeswap SA/WBTC",
"Asset Class"
"Asset Class",
"Governance",
"cc6e34d9-d58a-4aa7-9049-250ea90a8430"
],
[
"WBTC Liquidity",
"Asset"
"Asset",
"Governance",
"117afaed-83bd-4b0c-be12-40b8c8dd3a34"
]
]
}
@@ -12148,23 +12172,33 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"DEXs",
"Asset Class"
"Asset Class",
"Governance",
"90e0c410-b1e7-4f0a-9dec-99c597a7956d"
],
[
"First Listing",
"Asset Class"
"Asset Class",
"Governance",
"54f70f64-029a-4f2f-8847-5208c2fa94a1"
],
[
" Pancakeswap SA/WBTC",
"Asset Class"
"Asset Class",
"Governance",
"cc6e34d9-d58a-4aa7-9049-250ea90a8430"
]
]
}
@@ -12203,19 +12237,27 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"DEXs",
"Asset Class"
"Asset Class",
"Governance",
"90e0c410-b1e7-4f0a-9dec-99c597a7956d"
],
[
"First Listing",
"Asset Class"
"Asset Class",
"Governance",
"54f70f64-029a-4f2f-8847-5208c2fa94a1"
]
]
}
@@ -12254,15 +12296,21 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"DEXs",
"Asset Class"
"Asset Class",
"Governance",
"90e0c410-b1e7-4f0a-9dec-99c597a7956d"
]
]
}
@@ -12315,23 +12363,33 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"CEXs",
"Asset Class"
"Asset Class",
"Governance",
"ec0ab4b8-e3cc-47e6-94e7-6d181e1008f4"
],
[
"Open Negotiations",
"Asset Class"
"Asset Class",
"Governance",
"144ad412-94fc-4b80-8dd9-2520f64edfcc"
],
[
"Bittrex",
"Asset"
"Asset",
"Governance",
"548dd163-9991-4de3-9e68-9e8a9a051a2f"
]
]
}
@@ -12370,23 +12428,33 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"CEXs",
"Asset Class"
"Asset Class",
"Governance",
"ec0ab4b8-e3cc-47e6-94e7-6d181e1008f4"
],
[
"Open Negotiations",
"Asset Class"
"Asset Class",
"Governance",
"144ad412-94fc-4b80-8dd9-2520f64edfcc"
],
[
"LBank",
"Asset"
"Asset",
"Governance",
"e4e7addb-a840-4ce9-9e01-74c7e57c24ad"
]
]
}
@@ -12425,23 +12493,33 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"CEXs",
"Asset Class"
"Asset Class",
"Governance",
"ec0ab4b8-e3cc-47e6-94e7-6d181e1008f4"
],
[
"Open Negotiations",
"Asset Class"
"Asset Class",
"Governance",
"144ad412-94fc-4b80-8dd9-2520f64edfcc"
],
[
"Probit",
"Asset"
"Asset",
"Governance",
"6b27f708-c243-42e9-874b-ceceea7db21f"
]
]
}
@@ -12478,19 +12556,27 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"CEXs",
"Asset Class"
"Asset Class",
"Governance",
"ec0ab4b8-e3cc-47e6-94e7-6d181e1008f4"
],
[
"Open Negotiations",
"Asset Class"
"Asset Class",
"Governance",
"144ad412-94fc-4b80-8dd9-2520f64edfcc"
]
]
}
@@ -12529,15 +12615,21 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
],
[
"CEXs",
"Asset Class"
"Asset Class",
"Governance",
"ec0ab4b8-e3cc-47e6-94e7-6d181e1008f4"
]
]
}
@@ -12576,11 +12668,15 @@
"referenceParentCombinedNodePath": [
[
"Superalgos-Exchanges",
"Assets"
"Assets",
"Governance",
"2cefeb95-9fde-418b-a35b-6178a97cac9d"
],
[
"SA Token Listings Rewards",
"Asset Class"
"Asset Class",
"Governance",
"492669d5-223f-426d-845a-f26dd1ae251e"
]
]
}
+3 -1
View File
@@ -1,7 +1,9 @@
function newGovernanceGlobalsSaToken() {
let thisObject = {
SA_TOKEN_BSC_CONTRACT_ADDRESS: '0xfb981ed9a92377ca4d75d924b9ca06df163924fd',
SA_TOKEN_BSC_TREASURY_ACCOUNT_ADDRESS: '0x8d4d2557ce99f83f658adf61eef3e61e04c2ac2c'
SA_TOKEN_BSC_CONTRACT_ABI: '[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"account","type":"address"},{"name":"amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"listAddress","type":"address"},{"name":"isBlackListed","type":"bool"}],"name":"blackListAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint256"},{"name":"_supply","type":"uint256"},{"name":"tokenOwner","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"blackListed","type":"address"},{"indexed":false,"name":"value","type":"bool"}],"name":"Blacklist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value",Line truncated
SA_TOKEN_BSC_TREASURY_ACCOUNT_ADDRESS: '0x8d4d2557ce99f83f658adf61eef3e61e04c2ac2c',
SA_TOKEN_BSC_DECIMAL_FACTOR: 1000000000000000000
}
return thisObject
}
@@ -33,7 +33,7 @@ function newGovernanceReportsCommmandInterface() {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov PRs Command')
return
}
if (command.indexOf('gov.prs') !== 0 ) { return 'Not PRs Commands' }
if (command.indexOf('gov.prs') !== 0) { return 'Not PRs Commands' }
/* Set up the commit message */
let message = command.trim().substring(command.indexOf(' ') + 1, command.length)
@@ -127,28 +127,83 @@ function newGovernanceReportsCommmandInterface() {
}
if (command.indexOf('gov.pay') !== 0) { return 'Not Pay Commands' }
httpRequest(undefined, 'Gov/Pay/' + UI.projects.education.spaces.docsSpace.currentBranch, onResponse)
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Paying to Contributors')
return
/*
Let's create a list of payments to be made.
*/
let paymentsArray = []
/*
Here we get from the workspace all User Profiles.
*/
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
/*
Transform the result array into table records.
*/
for (let j = 0; j < userProfiles.length; j++) {
let userProfile = userProfiles[j]
if (userProfile.payload === undefined) { continue }
if (userProfile.tokensMined === undefined) { continue }
if (userProfile.tokensMined.payload === undefined) { continue }
if (userProfile.tokensMined.payload.tokensMined === undefined) { continue }
let payment = {
"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
}
paymentsArray.push(payment)
}
/* Let's get the Mnemonic */
let web3API = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('APIs')[0].web3API
let mnemonic = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(web3API.payload, 'mnemonic')
/* Lets execute this command against the Client */
let params = {
method: 'payContributors',
contractAddress: UI.projects.governance.globals.saToken.SA_TOKEN_BSC_CONTRACT_ADDRESS,
contractAbi: UI.projects.governance.globals.saToken.SA_TOKEN_BSC_CONTRACT_ABI,
paymentsArray: paymentsArray,
mnemonic: mnemonic
}
let url = 'GOV' // We will access the default Client GOV endpoint.
httpRequest(JSON.stringify(params), url, onResponse)
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
data = JSON.parse(data)
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.CUSTOM_OK_RESPONSE.result) {
if (data.message.summary.changes + data.message.summary.deletions + data.message.summary.insertions > 0) {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Pay Done')
} else {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Pay Failed')
}
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('[ERROR] Call via HTTP Interface failed.' + err.stack)
console.log('[ERROR] Params = ' + JSON.stringify(params))
return
}
let response = JSON.parse(data)
/* Lets check the result of the method call */
if (response.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('[ERROR] Call to Client Github Server failed.' + err.stack)
console.log('[ERROR] Params = ' + JSON.stringify(params))
}
/* Successful Call */
if (response.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Contribution Payments Processed')
} else {
UI.projects.education.spaces.docsSpace.navigateTo(
data.docs.project,
data.docs.category,
data.docs.type,
data.docs.anchor,
response.docs.project,
response.docs.category,
response.docs.type,
response.docs.anchor,
undefined,
data.docs.placeholder
response.docs.placeholder
)
}
}
@@ -77,6 +77,7 @@ function newGovernanceReportsDelegation() {
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
if (program.payload[programPropertyName] === undefined) { continue }
if (program.payload[programPropertyName].bonus === undefined) { continue }
let tableRecord = {
"name": userProfile.name,
@@ -88,7 +88,7 @@ function newGovernanceUserProfileSpace() {
if (transfer.contractAddress !== UI.projects.governance.globals.saToken.SA_TOKEN_BSC_CONTRACT_ADDRESS) { continue }
if (transfer.from !== UI.projects.governance.globals.saToken.SA_TOKEN_BSC_TREASURY_ACCOUNT_ADDRESS) { continue }
let currentReputation = Number(transfer.value) / 1000000000000000000
let currentReputation = Number(transfer.value) / UI.projects.governance.globals.saToken.SA_TOKEN_BSC_DECIMAL_FACTOR
let previousReputation = reputationByAddress.get(transfer.to)
let newReputation = previousReputation | 0 + currentReputation
reputationByAddress.set(transfer.to, newReputation)
@@ -91,6 +91,7 @@ function newGovernanceUtilitiesDecendentTables() {
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
if (program.payload[programPropertyName] === undefined) { continue }
if (program.payload[programPropertyName].bonus === undefined) { continue }
let tableRecord = {
"name": userProfile.name,