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

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,