Merge branch 'develop' of https://github.com/Superalgos/Superalgos into develop
This commit is contained in:
commit
928e611b85
6 files changed
+825
-501
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -29,7 +29,7 @@
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
"config": "{\n \"consumer_key\": \"TWITTER_CONSUMER_KEY\"\n \"consumer_secret\": \"TWITTER_CONSUMER_SECRET\"\n \"access_token_key\": \"TWITTER_ACCESS_TOKEN_KEY\"\n \"access_token_secret\": \"TWITTER_ACCESS_TOKEN_SECRET\"\n}"
|
||||
"config": "{\n \"consumer_key\": \"TWITTER_CONSUMER_KEY\",\n \"consumer_secret\": \"TWITTER_CONSUMER_SECRET\",\n \"access_token_key\": \"TWITTER_ACCESS_TOKEN_KEY\",\n \"access_token_secret\": \"TWITTER_ACCESS_TOKEN_SECRET\"\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
|
||||
@@ -186,41 +186,49 @@ function newFoundationsFunctionLibrarySocialBotsFunctions() {
|
||||
}
|
||||
|
||||
function sendTwitterTestMessage(node, callBackFunction) {
|
||||
var Twitter = SA.nodeModules.twitter
|
||||
|
||||
let consumer_key = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'consumer_key')
|
||||
let consumer_secret = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'consumer_secret')
|
||||
let access_token_key = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'access_token_key')
|
||||
let access_token_secret = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'access_token_secret')
|
||||
|
||||
if (process.env.TWITTER_CONSUMER_KEY) {
|
||||
consumer_key = process.env.TWITTER_CONSUMER_KEY
|
||||
}
|
||||
if (process.env.TWITTER_CONSUMER_SECRET) {
|
||||
consumer_secret = process.env.TWITTER_CONSUMER_SECRET
|
||||
}
|
||||
if (process.env.TWITTER_ACCESS_TOKEN_KEY) {
|
||||
access_token_key = process.env.TWITTER_ACCESS_TOKEN_KEY
|
||||
}
|
||||
if (process.env.TWITTER_ACCESS_TOKEN_SECRET) {
|
||||
access_token_secret = process.env.TWITTER_ACCESS_TOKEN_SECRET
|
||||
}
|
||||
let message = JSON.stringify({text: "Test message from Superalgos!"})
|
||||
let url = "https://api.twitter.com/1.1/statuses/update.json"
|
||||
|
||||
var twitterclient = new Twitter({
|
||||
consumer_key: consumer_key,
|
||||
consumer_secret: consumer_secret,
|
||||
access_token_key: access_token_key,
|
||||
access_token_secret: access_token_secret
|
||||
});
|
||||
|
||||
let message = JSON.stringify({status: "Test message from Superalgos!"})
|
||||
httpRequestJSON(message, url, onResponse)
|
||||
|
||||
twitterclient.post('statuses/update', message, function(error, tweet, response) {
|
||||
if(error) {
|
||||
callBackFunction({ result: "Fail", message: error })
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setInfoMessage('Twitter status update sent.')
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage('Could not send Twitter status update. Error Response: ' + err.message)
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
console.log(tweet); // Tweet body.
|
||||
console.log(response); // Raw response object.
|
||||
});
|
||||
}
|
||||
|
||||
function httpRequestJSON(pContentToSend, pPath, callBackFunction) {
|
||||
let xmlHttpRequest = new XMLHttpRequest();
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xmlHttpRequest.responseText);
|
||||
return;
|
||||
} else if (this.readyState === 4 && (this.status === 404 || this.status === 401 || this.status === 400)) {
|
||||
callBackFunction({
|
||||
result: "Fail",
|
||||
message: xmlHttpRequest.responseText
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (pContentToSend === undefined) {
|
||||
xmlHttpRequest.open("GET", pPath, true);
|
||||
xmlHttpRequest.send();
|
||||
} else {
|
||||
try {
|
||||
let blob = new Blob([pContentToSend]);
|
||||
xmlHttpRequest.open("POST", pPath, true);
|
||||
xmlHttpRequest.send(blob);
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] callServer -> err.message = " & err.message); }
|
||||
callBackFunction({ result: "Fail", message: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -121,11 +121,15 @@ 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 }
|
||||
|
||||
if (transfer.to === '0x9F25cc5f3e70b907269CebbB45D812313b3e9143'.toLowerCase()) {
|
||||
console.log(JSON.stringify(transfer))
|
||||
}
|
||||
let currentReputation = Number(transfer.value) / UI.projects.governance.globals.saToken.SA_TOKEN_BSC_DECIMAL_FACTOR
|
||||
let previousReputation = reputationByAddress.get(transfer.to)
|
||||
let previousReputation = reputationByAddress.get(transfer.to.toLowerCase())
|
||||
let newReputation = previousReputation | 0 + currentReputation
|
||||
reputationByAddress.set(transfer.to, newReputation)
|
||||
reputationByAddress.set(transfer.to.toLowerCase(), newReputation)
|
||||
}
|
||||
console.log('[INFO] tokenTransfers = ' + JSON.stringify(tokenTransfers))
|
||||
if (tokenTransfers.length > 9000) {
|
||||
console.log('[WARN] The total amount of BSC SA Token transfers is above 9000. After 10k this method will need pagination or otherwise users will not get their reputation calculated correctly.')
|
||||
} else {
|
||||
@@ -408,7 +412,7 @@ function newGovernanceUserProfileSpace() {
|
||||
}
|
||||
|
||||
function getBlockchainTokens(userProfile, blockchainAccount) {
|
||||
console.log('blockchainAccount ', blockchainAccount)
|
||||
console.log('User Profile Name: ', userProfile.name, 'blockchainAccount: ', blockchainAccount)
|
||||
const url = "https://api.bscscan.com/api?module=account&action=tokenbalance&contractaddress=" + UI.projects.governance.globals.saToken.SA_TOKEN_BSC_CONTRACT_ADDRESS + "&address=" + blockchainAccount + "&tag=latest&apikey=YourApiKeyToken"
|
||||
|
||||
fetch(url).then(function (response) {
|
||||
|
||||
Reference in new issue
Block a user