Merge pull request #1060 from Luis-Fernando-Molina/next-version
Contribution: Governance Project setup
No files matched your search
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 18 KiB |
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"type": "Assets Structure",
|
||||
"type": "Assets",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset Class",
|
||||
"relatedUiObject": "Project Asset Class"
|
||||
"label": "Add Asset Class",
|
||||
"relatedUiObject": "Asset Class"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset",
|
||||
"relatedUiObject": "Project Asset"
|
||||
"label": "Add Asset",
|
||||
"relatedUiObject": "Asset"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -31,15 +31,15 @@
|
||||
},
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectAssetClasses",
|
||||
"name": "assetClasses",
|
||||
"type": "array",
|
||||
"childType": "Project Asset Class",
|
||||
"childType": "Asset Class",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "projectAssets",
|
||||
"name": "assets",
|
||||
"type": "array",
|
||||
"childType": "Project Asset",
|
||||
"childType": "Asset",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
@@ -34,7 +34,7 @@
|
||||
"compatibleTypes": "->Software Contributions->"
|
||||
},
|
||||
"referencingRules": {
|
||||
"compatibleTypes": "->Project Asset->"
|
||||
"compatibleTypes": "->Asset->"
|
||||
},
|
||||
"propertyNameAtParent": "contributedAssets",
|
||||
"icon": "tron"
|
||||
@@ -19,7 +19,8 @@
|
||||
}
|
||||
],
|
||||
"title": [
|
||||
"Use Reference Parent"
|
||||
"Use Reference Parent",
|
||||
"Use Reference Parent Parent"
|
||||
],
|
||||
"editors": {
|
||||
"config": true
|
||||
@@ -33,7 +34,7 @@
|
||||
"compatibleTypes": "->Governance Contributions->"
|
||||
},
|
||||
"referencingRules": {
|
||||
"compatibleTypes": "->Project Rank->"
|
||||
"compatibleTypes": "->Ranking Position->"
|
||||
},
|
||||
"propertyNameAtParent": "contributedTimes",
|
||||
"icon": "dogecoin"
|
||||
@@ -11,8 +11,8 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset",
|
||||
"relatedUiObject": "Project Asset"
|
||||
"label": "Add Asset",
|
||||
"relatedUiObject": "Asset"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -33,14 +33,14 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Assets Structure->Project Asset->"
|
||||
"compatibleTypes": "->Assets->Asset->"
|
||||
},
|
||||
"propertyNameAtParent": "softwareContributions",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectAssetClass",
|
||||
"name": "assetClass",
|
||||
"type": "array",
|
||||
"childType": "Project Asset",
|
||||
"childType": "Asset",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"type": "Governance Project",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Assets",
|
||||
"relatedUiObject": "Assets",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Ranking",
|
||||
"relatedUiObject": "Ranking",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add User Contributions",
|
||||
"relatedUiObject": "User Contributions",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity"
|
||||
}
|
||||
],
|
||||
"isProjectHead": true,
|
||||
"isTitleAllwaysVisible": false,
|
||||
"addLeftIcons": true,
|
||||
"isPinned": true,
|
||||
"positionLocked": true,
|
||||
"icon": "bitcoin",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectDefinition",
|
||||
"type": "node",
|
||||
"childType": "Project Definition",
|
||||
"project": "Superalgos",
|
||||
"autoAdd": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"type": "Governance Structure",
|
||||
"type": "Ranking",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Project Rank",
|
||||
"relatedUiObject": "Project Rank",
|
||||
"label": "Add Ranking Position",
|
||||
"relatedUiObject": "Ranking Position",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
@@ -23,9 +23,9 @@
|
||||
"level": 0,
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectRanks",
|
||||
"name": "rankingPositions",
|
||||
"type": "array",
|
||||
"childType": "Project Rank",
|
||||
"childType": "Ranking Position",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "Project Asset Class",
|
||||
"type": "Asset Class",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
@@ -11,14 +11,14 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset Class",
|
||||
"relatedUiObject": "Project Asset Class"
|
||||
"label": "Add Asset Class",
|
||||
"relatedUiObject": "Asset Class"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset",
|
||||
"relatedUiObject": "Project Asset"
|
||||
"label": "Add Asset",
|
||||
"relatedUiObject": "Asset"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -39,23 +39,23 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Assets Structure->Project Asset Class->"
|
||||
"compatibleTypes": "->Assets->Asset Class->"
|
||||
},
|
||||
"referencingRules": {
|
||||
"compatibleTypes": "->Team->Project Rank->"
|
||||
"compatibleTypes": "->Team->Ranking Position->"
|
||||
},
|
||||
"propertyNameAtParent": "projectAssetClasses",
|
||||
"propertyNameAtParent": "assetClasses",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectAssetClasses",
|
||||
"name": "assetClasses",
|
||||
"type": "array",
|
||||
"childType": "Project Asset Class",
|
||||
"childType": "Asset Class",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "projectAssets",
|
||||
"name": "assets",
|
||||
"type": "array",
|
||||
"childType": "Project Asset",
|
||||
"childType": "Asset",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "Project Asset",
|
||||
"type": "Asset",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
@@ -11,14 +11,14 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset Class",
|
||||
"relatedUiObject": "Project Asset Class"
|
||||
"label": "Add Asset Class",
|
||||
"relatedUiObject": "Asset Class"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Asset",
|
||||
"relatedUiObject": "Project Asset"
|
||||
"label": "Add Asset",
|
||||
"relatedUiObject": "Asset"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -39,23 +39,23 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Project Asset Class->Project Asset->"
|
||||
"compatibleTypes": "->Asset Class->Asset->"
|
||||
},
|
||||
"referencingRules": {
|
||||
"compatibleTypes": "->Team->Project Rank->"
|
||||
"compatibleTypes": "->Team->Ranking Position->"
|
||||
},
|
||||
"propertyNameAtParent": "projectAssets",
|
||||
"propertyNameAtParent": "assets",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectAssetClasses",
|
||||
"name": "assetClasses",
|
||||
"type": "array",
|
||||
"childType": "Project Asset Class",
|
||||
"childType": "Asset Class",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "projectAssets",
|
||||
"name": "assets",
|
||||
"type": "array",
|
||||
"childType": "Project Asset",
|
||||
"childType": "Asset",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "Project Rank",
|
||||
"type": "Ranking Position",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
@@ -11,8 +11,8 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Rank",
|
||||
"relatedUiObject": "Project Rank"
|
||||
"label": "Add Ranking Position",
|
||||
"relatedUiObject": "Ranking Position"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
@@ -39,14 +39,14 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Governance Structure->Project Rank->Team->"
|
||||
"compatibleTypes": "->Ranking->Ranking Position->Team->"
|
||||
},
|
||||
"propertyNameAtParent": "projectRanks",
|
||||
"propertyNameAtParent": "rankingPositions",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectRanks",
|
||||
"name": "rankingPositions",
|
||||
"type": "array",
|
||||
"childType": "Project Rank",
|
||||
"childType": "Ranking Position",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
@@ -11,8 +11,8 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Project Rank",
|
||||
"relatedUiObject": "Project Rank"
|
||||
"label": "Add Ranking Position",
|
||||
"relatedUiObject": "Ranking Position"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
@@ -39,14 +39,14 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Project Rank->Team->"
|
||||
"compatibleTypes": "->Ranking Position->Team->"
|
||||
},
|
||||
"propertyNameAtParent": "teams",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "projectRanks",
|
||||
"name": "rankingPositions",
|
||||
"type": "array",
|
||||
"childType": "Project Rank",
|
||||
"childType": "Ranking Position",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
@@ -0,0 +1,53 @@
|
||||
function newEthereumFunctionLibraryAccounts() {
|
||||
let thisObject = {
|
||||
createWalletAccount: createWalletAccount
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function createWalletAccount(node) {
|
||||
|
||||
let walletAccountNode = UI.projects.superalgos.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Wallet Account')
|
||||
|
||||
let params = {
|
||||
method: 'createWalletAccount',
|
||||
entropy: walletAccountNode.id
|
||||
}
|
||||
|
||||
let url = 'WEB3' // we don't need to ask this to any specific superalgos node.
|
||||
|
||||
httpRequest(JSON.stringify(params), url, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Call via HTTP Interface failed.')
|
||||
walletAccountNode.payload.uiObject.menu.internalClick('Delete UI Object')
|
||||
walletAccountNode.payload.uiObject.menu.internalClick('Delete UI Object')
|
||||
return
|
||||
}
|
||||
|
||||
let response = JSON.parse(data)
|
||||
|
||||
/* Lets check the result of the method call */
|
||||
if (response.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Call to WEB3 Server failed. ' + response.error)
|
||||
walletAccountNode.payload.uiObject.menu.internalClick('Delete UI Object')
|
||||
walletAccountNode.payload.uiObject.menu.internalClick('Delete UI Object')
|
||||
return
|
||||
}
|
||||
|
||||
let config = {
|
||||
address: response.address,
|
||||
privateKey: response.privateKey
|
||||
}
|
||||
|
||||
walletAccountNode.config = JSON.stringify(config, null, 4)
|
||||
walletAccountNode.name =
|
||||
response.address[response.address.length - 4] +
|
||||
response.address[response.address.length - 3] +
|
||||
response.address[response.address.length - 2] +
|
||||
response.address[response.address.length - 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
function newGovernanceActionSwitch() {
|
||||
|
||||
let thisObject = {
|
||||
executeAction: executeAction,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
/* Nothing to initialize since a Function Library does not hold any state. */
|
||||
}
|
||||
|
||||
async function executeAction(action) {
|
||||
switch (action.name) {
|
||||
case 'Create Wallet Account': {
|
||||
UI.projects.ethereum.functionLibraries.accounts.createWalletAccount(action.node)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
function newEthereumGlobalsChainIds() {
|
||||
let thisObject = {
|
||||
chainNameById: chainNameById
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function chainNameById(chainId) {
|
||||
switch(chainId) {
|
||||
case 1: return 'Ethereum Mainnet'
|
||||
case 3: return 'Ethereum Ropsten'
|
||||
case 4: return 'Ethereum Rinkeby'
|
||||
case 42: return 'Ethereum Kovan'
|
||||
case 61: return 'Ethereum Classic Mainnet'
|
||||
case 62: return 'Ethereum Classic Morden'
|
||||
default: return 'Unknown Network'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
function newEthereumBlockchainSpace() {
|
||||
const MODULE_NAME = 'Blockchain Space'
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
finalize: finalize,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
|
||||
let lastTryToReconnectDatetime
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
clientMap = undefined
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function physics() {
|
||||
networkClientStatusPhysics()
|
||||
}
|
||||
|
||||
async function networkClientStatusPhysics() {
|
||||
|
||||
/* We will query the node only every 3 seconds */
|
||||
if (lastTryToReconnectDatetime === undefined) {
|
||||
checkStatus()
|
||||
lastTryToReconnectDatetime = (new Date()).valueOf()
|
||||
} else {
|
||||
let now = (new Date()).valueOf()
|
||||
if (now - lastTryToReconnectDatetime > 3000) {
|
||||
checkStatus()
|
||||
lastTryToReconnectDatetime = now
|
||||
}
|
||||
}
|
||||
|
||||
async function checkStatus() {
|
||||
try {
|
||||
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
|
||||
|
||||
let blockchain = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadByNodeType('Ethereum Blockchain')
|
||||
if (blockchain === undefined) { return }
|
||||
for (let i = 0; i < blockchain.blockchainNetworks.length; i++) {
|
||||
let blockchainNetwork = blockchain.blockchainNetworks[i]
|
||||
for (let j = 0; j < blockchainNetwork.networkClients.length; j++) {
|
||||
let networkClient = blockchainNetwork.networkClients[j]
|
||||
|
||||
let route = UI.projects.ethereum.utilities.routeToClient.buildRouteToClient(networkClient)
|
||||
|
||||
if (route === undefined) { continue } // something went wrong building the route.
|
||||
|
||||
route.params.method = 'getNetworkClientStatus'
|
||||
|
||||
httpRequest(JSON.stringify(route.params), route.url, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Call via HTTP Interface failed.')
|
||||
return
|
||||
}
|
||||
|
||||
let status = JSON.parse(data)
|
||||
|
||||
/* Lets check the result of the method call */
|
||||
if (status.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Call to WEB3 Server failed. ' + status.error)
|
||||
return
|
||||
}
|
||||
|
||||
showStatus(status)
|
||||
}
|
||||
|
||||
async function showStatus(status) {
|
||||
const ANNIMATION_CYCLES_TO_LAST = 300
|
||||
|
||||
networkClient.payload.uiObject.resetErrorMessage()
|
||||
|
||||
if (status.isSyncing === false && status.chainId === 0) {
|
||||
networkClient.payload.uiObject.setStatus('Client is looking for peers...', ANNIMATION_CYCLES_TO_LAST)
|
||||
return
|
||||
}
|
||||
|
||||
if (status.chainId > 0) {
|
||||
let networkName = UI.projects.ethereum.globals.chainIds.chainNameById(status.chainId)
|
||||
networkClient.payload.uiObject.setStatus('Connected to ' + networkName + ' via the ' + route.params.interface + ' interface, through ' + networkClient.payload.referenceParent.name + ' Network Node.', ANNIMATION_CYCLES_TO_LAST)
|
||||
|
||||
networkClient.payload.uiObject.valueAtAngle = false
|
||||
networkClient.payload.uiObject.setValue(
|
||||
'Current Block Number ' + splitLargeNumber(status.currentBlockNumber)
|
||||
, 200)
|
||||
networkClient.payload.uiObject.setPercentage('100.00', ANNIMATION_CYCLES_TO_LAST)
|
||||
return
|
||||
}
|
||||
|
||||
/* If it is not syncing, then we have the current block and the highets block too */
|
||||
let percentage = (status.isSyncing.currentBlock * 100 / status.isSyncing.highestBlock).toFixed(4)
|
||||
let extraStatus = ''
|
||||
if (status.isSyncing.highestBlock - status.isSyncing.currentBlock < 300) {
|
||||
extraStatus = 'Block Download Phase Finished. Downloading Trie Data Structure.'
|
||||
} else {
|
||||
extraStatus = 'Block Download Phase.'
|
||||
networkClient.payload.uiObject.setPercentage(percentage, ANNIMATION_CYCLES_TO_LAST)
|
||||
}
|
||||
|
||||
networkClient.payload.uiObject.valueAtAngle = false
|
||||
networkClient.payload.uiObject.setValue(
|
||||
'Block ' + splitLargeNumber(status.isSyncing.currentBlock) +
|
||||
' from ' + splitLargeNumber(status.isSyncing.highestBlock) +
|
||||
'. State ' + splitLargeNumber(status.isSyncing.pulledStates) +
|
||||
' from ' + splitLargeNumber(status.isSyncing.knownStates)
|
||||
, 200)
|
||||
|
||||
if (status.isSyncing.currentBlock !== status.isSyncing.highestBlock) {
|
||||
networkClient.payload.uiObject.setStatus('Connected via http. Client is Syncing... ' + extraStatus, ANNIMATION_CYCLES_TO_LAST)
|
||||
}
|
||||
|
||||
function splitLargeNumber(number) {
|
||||
let label = number.toString()
|
||||
let result = label
|
||||
switch (label.length) {
|
||||
case 4: {
|
||||
return label[0] + ',' + label[1] + label[2] + label[3]
|
||||
}
|
||||
case 5: {
|
||||
return label[0] + label[1] + ',' + label[2] + label[3] + label[4]
|
||||
}
|
||||
case 6: {
|
||||
return label[0] + label[1] + label[2] + ',' + label[3] + label[4] + label[5]
|
||||
}
|
||||
case 7: {
|
||||
return label[0] + ',' + label[1] + label[2] + label[3] + ',' + label[4] + label[5] + label[6]
|
||||
}
|
||||
case 8: {
|
||||
return label[0] + label[1] + ',' + label[2] + label[3] + label[4] + ',' + label[5] + label[6] + label[7]
|
||||
}
|
||||
case 9: {
|
||||
return label[0] + label[1] + label[2] + ',' + label[3] + label[4] + label[5] + ',' + label[6] + label[7] + label[8]
|
||||
}
|
||||
case 10: {
|
||||
return label[0] + ',' + label[1] + label[2] + label[3] + ',' + label[4] + label[5] + label[6] + ',' + label[7] + label[8] + label[9]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('[ERROR] checkStatus -> err = ' + err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
thisObject.container.space = MODULE_NAME
|
||||
return thisObject.container
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
function newEthereumWalletSpace() {
|
||||
const MODULE_NAME = 'Wallet Space'
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
finalize: finalize,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
|
||||
let lastTryToReconnectDatetime
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function physics() {
|
||||
walletBalancesPhysics()
|
||||
}
|
||||
|
||||
async function walletBalancesPhysics() {
|
||||
|
||||
/* We will query the node only every 3 seconds */
|
||||
if (lastTryToReconnectDatetime === undefined) {
|
||||
checkBalances()
|
||||
lastTryToReconnectDatetime = (new Date()).valueOf()
|
||||
} else {
|
||||
let now = (new Date()).valueOf()
|
||||
if (now - lastTryToReconnectDatetime > 3000) {
|
||||
checkBalances()
|
||||
lastTryToReconnectDatetime = now
|
||||
}
|
||||
}
|
||||
|
||||
async function checkBalances() {
|
||||
try {
|
||||
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
|
||||
|
||||
let wallets = []
|
||||
let hierarchyHeads = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeads()
|
||||
for (let i = 0; i < hierarchyHeads.length; i++) {
|
||||
let hierarchyHead = hierarchyHeads[i]
|
||||
if (hierarchyHead.type === 'Ethereum Wallet') {
|
||||
wallets.push(hierarchyHead)
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < wallets.length; i++) {
|
||||
let wallet = wallets[i]
|
||||
|
||||
if (wallet.networkClientReference === undefined) {
|
||||
wallet.payload.uiObject.setWarningMessage('A Network Client Reference is needed in order to fetch Account Balances from a Network Client.')
|
||||
continue
|
||||
}
|
||||
|
||||
if (wallet.networkClientReference.payload === undefined) {
|
||||
// node exists without payload, probably has been deleted.
|
||||
continue
|
||||
}
|
||||
|
||||
if (wallet.networkClientReference.payload.referenceParent === undefined) {
|
||||
wallet.networkClientReference.payload.uiObject.setWarningMessage('A reference to a Network Client is needed in order to fetch Account Balances from a Network Client.')
|
||||
continue
|
||||
}
|
||||
|
||||
let networkClient = wallet.networkClientReference.payload.referenceParent
|
||||
|
||||
let route = UI.projects.ethereum.utilities.routeToClient.buildRouteToClient(networkClient)
|
||||
|
||||
if (route === undefined) { continue } // something went wrong building the route.
|
||||
|
||||
route.params.method = 'getWalletBalances'
|
||||
|
||||
let lightingPath = '' +
|
||||
'Ethereum Wallet->' +
|
||||
'Wallet Account->' +
|
||||
'ETH Balance->' +
|
||||
'Token Balance->' +
|
||||
'Ethereum Token->Smart Contract->' +
|
||||
'ERC-20 Token Type->ERC-223 Token Type->ERC-721 Token Type->ERC-777 Token Type->'
|
||||
|
||||
route.params.walletDefinition = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(wallet, false, true, true, false, false, lightingPath)
|
||||
|
||||
httpRequest(JSON.stringify(route.params), route.url, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Call via HTTP Interface failed.')
|
||||
return
|
||||
}
|
||||
|
||||
let response = JSON.parse(data)
|
||||
|
||||
/* Lets check the result of the method call */
|
||||
if (response.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Call to WEB3 Server failed. ' + response.error)
|
||||
return
|
||||
}
|
||||
|
||||
showBalances(response.walletDefinition)
|
||||
}
|
||||
|
||||
function showBalances(walletDefinition) {
|
||||
for (let i = 0; i < walletDefinition.walletAccounts.length; i++) {
|
||||
let walletAccount = walletDefinition.walletAccounts[i]
|
||||
|
||||
if (walletAccount.ethBalance !== undefined) {
|
||||
|
||||
let uiObject = wallet.walletAccounts[i].ethBalance.payload.uiObject
|
||||
|
||||
if (walletAccount.error !== undefined) {
|
||||
uiObject.setErrorMessage(walletAccount.error)
|
||||
} else {
|
||||
let value = walletAccount.ethBalance.value / 1000000000000000000
|
||||
uiObject.valueAtAngle = false
|
||||
uiObject.setValue(value + ' ETH')
|
||||
}
|
||||
}
|
||||
|
||||
for (let j = 0; j < walletAccount.tokenBalances.length; j++) {
|
||||
let tokenBalance = walletAccount.tokenBalances[j]
|
||||
let uiObject = wallet.walletAccounts[i].tokenBalances[j].payload.uiObject
|
||||
let value = tokenBalance.value / 1000000000000000000
|
||||
uiObject.valueAtAngle = false
|
||||
uiObject.setValue(value + ' ' + tokenBalance.referenceParent.config.codeName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('[ERROR] checkBalances -> err = ' + err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
thisObject.container.space = MODULE_NAME
|
||||
return thisObject.container
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
function newEthereumUtilitiesRouteToClient() {
|
||||
let thisObject = {
|
||||
buildRouteToClient: buildRouteToClient
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function buildRouteToClient(networkClient) {
|
||||
let config = JSON.parse(networkClient.config)
|
||||
if (config.host === undefined) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Property host not defined at node config.')
|
||||
return
|
||||
}
|
||||
if (config.httpPort === undefined && config.webSocketsPort === undefined) {
|
||||
networkClient.payload.uiObject.setErrorMessage('Property httpPort or webSocketsPort must be defined at node config.')
|
||||
return
|
||||
}
|
||||
|
||||
/* Web Sockets would be the default protocol */
|
||||
let clientPort
|
||||
let clientInterface
|
||||
if (config.webSocketsPort !== undefined) {
|
||||
clientInterface = 'ws'
|
||||
clientPort = config.webSocketsPort
|
||||
} else {
|
||||
clientInterface = 'http'
|
||||
clientPort = config.httpPort
|
||||
}
|
||||
|
||||
let params = {
|
||||
host: config.host,
|
||||
port: clientPort,
|
||||
interface: clientInterface
|
||||
}
|
||||
|
||||
/*
|
||||
Next, we will check which Superalgos Network Node we need as a gateway
|
||||
to the Ethereum Client. We will use the current node reference parent for that.
|
||||
*/
|
||||
if (networkClient.payload.referenceParent === undefined) {
|
||||
networkClient.payload.uiObject.setErrorMessage('You need to reference a Superalgos Network Node so that it acts as a gateway to the Ethereum Client.')
|
||||
return
|
||||
}
|
||||
|
||||
let networkNodeConfig = JSON.parse(networkClient.payload.referenceParent.config)
|
||||
let url = 'http://' + networkNodeConfig.host + ':' + networkNodeConfig.webPort + '/' + 'WEB3'
|
||||
|
||||
return {
|
||||
params: params,
|
||||
url: url
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -982,5 +982,62 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Governance",
|
||||
"propertyName": "governance",
|
||||
"UI": {
|
||||
"globals": [
|
||||
{
|
||||
"name": "ChainIds",
|
||||
"propertyName": "chainIds",
|
||||
"functionName": "newEthereumGlobalsChainIds"
|
||||
}
|
||||
],
|
||||
"functionLibraries": [
|
||||
{
|
||||
"name": "Accounts",
|
||||
"propertyName": "accounts",
|
||||
"functionName": "newEthereumFunctionLibraryAccounts"
|
||||
}
|
||||
],
|
||||
"utilities": [
|
||||
{
|
||||
"name": "Route To Client",
|
||||
"propertyName": "routeToClient",
|
||||
"functionName": "newEthereumUtilitiesRouteToClient"
|
||||
}
|
||||
],
|
||||
"spaces": [
|
||||
{
|
||||
"name": "Blockchain Space",
|
||||
"folderName": "Blockchain-Space",
|
||||
"propertyName": "blockchainSpace",
|
||||
"functionName": "newEthereumBlockchainSpace",
|
||||
"initializationIndex": 0,
|
||||
"animationPhysicsIndex": 0,
|
||||
"animationDrawIndex": 0,
|
||||
"onMouseWheelIndex": 0,
|
||||
"onMouseOverIndex": 0,
|
||||
"onMouseClickIndex": 0,
|
||||
"onMouseDownIndex": 0
|
||||
},
|
||||
{
|
||||
"name": "Wallet Space",
|
||||
"folderName": "Wallet-Space",
|
||||
"propertyName": "walletSpace",
|
||||
"functionName": "newEthereumWalletSpace",
|
||||
"initializationIndex": 1,
|
||||
"animationPhysicsIndex": 1,
|
||||
"animationDrawIndex": 1,
|
||||
"onMouseWheelIndex": 1,
|
||||
"onMouseOverIndex": 1,
|
||||
"onMouseClickIndex": 1,
|
||||
"onMouseDownIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"TS": {},
|
||||
"CL": {}
|
||||
}
|
||||
]
|
||||
@@ -31,24 +31,6 @@
|
||||
"relatedUiObject": "API Map",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Assets Structure",
|
||||
"relatedUiObject": "Assets Structure",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Governance Structure",
|
||||
"relatedUiObject": "Governance Structure",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add User Contributions",
|
||||
"relatedUiObject": "User Contributions",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
|
||||