Current Folder

This commit is contained in:
Luis Fernando Molina committed 2020-11-20 14:05:59 +01:00
1 parent 8b3382289b
commit cfcada880d
4379 files changed

No files matched your search

@@ -0,0 +1,53 @@
function newEthereumFunctionLibraryAccounts() {
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 newEthereumActionSwitch() {
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() {
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'
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1 @@
{"type":"Workspace","name":"Ethereum Integration Demo","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataMining":{"type":"Data Mining","name":"New Data Mining","project":"Superalgos","exchangeDataTasks":[{"type":"Exchange Data Tasks","name":"Binance","project":"Superalgos","marketDataTasks":[{"type":"Market Data Tasks","name":"Binance BTC/USDT","project":"Superalgos","dataMineTasks":[{"type":"Data Mine Tasks","name":"Masters","project":"Superalgos","taskManagers":[{"type":"Task Manager","name":"Masters","project":"Superalgos","tasks":[{"type":"Task","name":"Exchange Raw Data","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Exchange Raw Data","config":"{ \n\"startDate\": \"2017-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Exchange Raw Data Historic-OHLCVs","project":"Superalgos","id":"da7e6d2a-76d5-431c-ba48-aa98ebd2a907","savedPayload":{"position":{"x":23623.030015561097,"y":29888.16403283887},"targetPosition":{"x":23918.47234146476,"y":29836.06957953879},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Historic-OHLCVs","id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc"}}}],"id":"f9daa393-935e-4a9d-bdc5-706d97ac5530","savedPayload":{"position":{"x":23918.47234146476,"y":29836.06957953879},"targetPosition":{"x":24213.914667368423,"y":29783.97512623871},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"5827edbc-89f8-495a-953a-a568f2fca44e","savedPayload":{"position":{"x":24213.914667368423,"y":29783.97512623871},"targetPosition":{"x":24509.356993272086,"y":29731.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Candles Volumes","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Candles Volumes","config":"{}","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Market","project":"Superalgos","id":"243ecbf4-cb69-42e2-9acb-b03c7c481b79","savedPayload":{"position":{"x":23619.613932037235,"y":29653.83848916277},"targetPosition":{"x":23918.47234146476,"y":29627.69176633847},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"9f683143-a33f-42c1-9fa8-c601f01ee4e1"}}},{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Daily","project":"Superalgos","id":"c90cb0e5-3e49-40ba-b919-38b0e5f7fcee","savedPayload":{"position":{"x":23646.580005353764,"y":29500.906287816262},"targetPosition":{"x":23918.47234146476,"y":29627.69176633847},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Daily","id":"980ceb1d-7be6-454f-90d9-01ba1fd4a65d"}}}],"id":"ac31f04b-4d79-4e18-9262-1a9a933b6156","savedPayload":{"position":{"x":23918.47234146476,"y":29627.69176633847},"targetPosition":{"x":24213.914667368423,"y":29679.78621963855},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"46c3f665-a9e2-46dc-b569-2a928d2067af","savedPayload":{"position":{"x":24213.914667368423,"y":29679.78621963855},"targetPosition":{"x":24509.356993272086,"y":29731.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Bollinger Bands","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Bollinger Bands","config":"{}","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Bollinger Bands Multi-Period-Market","project":"Superalgos","id":"12498614-646b-411c-9c82-747bacb8d7a6","savedPayload":{"position":{"x":23699.9640031147,"y":29354.234959407873},"targetPosition":{"x":23989.74175100142,"y":29431.88067293863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"941a0543-0cc0-4a5d-a782-728d2835c100"}}},{"typeLine truncated
@@ -0,0 +1,690 @@
[
{
"type": "Ethereum Project",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Blockchain",
"relatedUiObject": "Ethereum Blockchain",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Decentralized Application",
"relatedUiObject": "Ethereum Decentralized Application",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Token Definitions",
"relatedUiObject": "Ethereum Token Definitions",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Wallet",
"relatedUiObject": "Ethereum Wallet",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"actionFunction": "payload.executeAction",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete"
}
],
"isProjectHead": true,
"isTitleAllwaysVisible": false,
"addLeftIcons": true,
"isPinned": true,
"positionLocked": true,
"icon": "ethereum"
},
{
"type": "Ethereum Wallet",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Client Reference",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "networkClientReference",
"relatedUiObject": "Network Client Reference",
"actionFunction": "payload.executeAction"
},
{
"action": "Create Wallet Account",
"actionProject": "Ethereum",
"label": "Add Wallet Account",
"relatedUiObject": "Wallet Account",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "networkClientReference",
"type": "node",
"childType": "Network Client Reference",
"autoAdd": true
},
{
"name": "walletAccounts",
"type": "array",
"childType": "Wallet Account"
}
],
"icon": "ethereum"
},
{
"type": "Network Client Reference",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"title": [
"Use Reference Parent Parent",
"Use Reference Parent"
],
"referenceAttachesTo": {
"compatibleTypes": "->Network Client->"
},
"addLeftIcons": true,
"level": 3,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Wallet->"
},
"propertyNameAtParent": "networkClientReference",
"icon": "ethereum"
},
{
"type": "Wallet Account",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Add UI Object",
"label": "Add ETH Balance",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "ethBalance",
"relatedUiObject": "ETH Balance",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"label": "Add Token Balance",
"relatedUiObject": "Token Balance",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"address\": \"\", \n\"privateKey\": \"\"\n}"
},
"addLeftIcons": true,
"level": 0,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Wallet->"
},
"propertyNameAtParent": "walletAccounts",
"properties": [
{
"name": "ethBalance",
"type": "node",
"childType": "ETH Balance"
},
{
"name": "tokenBalances",
"type": "array",
"childType": "Token Balance"
}
],
"icon": "ethereum",
"isPersonalData": true
},
{
"type": "ETH Balance",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 4,
"chainAttachesTo": {
"compatibleTypes": "->Wallet Account->"
},
"propertyNameAtParent": "ethBalance",
"icon": "ethereum"
},
{
"type": "Token Balance",
"menuItems": [
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"title": [
"Use Reference Parent"
],
"addLeftIcons": true,
"level": 4,
"referenceAttachesTo": {
"compatibleTypes": "->Ethereum Token->"
},
"chainAttachesTo": {
"compatibleTypes": "->Wallet Account->"
},
"propertyNameAtParent": "tokenBalances",
"icon": "ethereum"
},
{
"type": "Ethereum Token Definitions",
"menuItems": [
{
"action": "Add Missing Children",
"label": "Add Missing Children",
"relatedUiObject": "Ethereum Token Definitions",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "erc-20TokenType",
"type": "node",
"childType": "ERC-20 Token Type"
},
{
"name": "erc-223TokenType",
"type": "node",
"childType": "ERC-223 Token Type"
},
{
"name": "erc-721TokenType",
"type": "node",
"childType": "ERC-721 Token Type"
},
{
"name": "erc-777TokenType",
"type": "node",
"childType": "ERC-777 Token Type"
}
],
"icon": "ethereum"
},
{
"type": "ERC-20 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Ethereum Token",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-20TokenType",
"properties": [
{
"name": "ethereumTokens",
"type": "array",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-223 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Ethereum Token",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-223TokenType",
"properties": [
{
"name": "ethereumTokens",
"type": "array",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-721 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Ethereum Token",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-721TokenType",
"properties": [
{
"name": "ethereumTokens",
"type": "array",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "ERC-777 Token Type",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Ethereum Token",
"relatedUiObject": "Ethereum Token",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Token Definitions->"
},
"propertyNameAtParent": "erc-777TokenType",
"properties": [
{
"name": "ethereumTokens",
"type": "array",
"childType": "Ethereum Token"
}
],
"icon": "ethereum"
},
{
"type": "Ethereum Token",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Add UI Object",
"label": "Add Smart Contract",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "smartContract",
"relatedUiObject": "Smart Contract",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"codeName\": \"\"\n}"
},
"addLeftIcons": true,
"level": 2,
"chainAttachesTo": {
"compatibleTypes": "->ERC-20 Token Type->ERC-223 Token Type->ERC-721 Token Type->ERC-777 Token Type->"
},
"propertyNameAtParent": "ethereumTokens",
"properties": [
{
"name": "smartContracts",
"type": "node",
"childType": "Smart Contract"
}
],
"icon": "ethereum",
"alternativeIcons": [
{
"codeName": "USDT",
"iconName": "tether"
},
{
"codeName": "BNB",
"iconName": "binance-coin"
}
]
},
{
"type": "Ethereum Blockchain",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Blockchain Network",
"relatedUiObject": "Blockchain Network",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "blockchainNetworks",
"type": "array",
"childType": "Blockchain Network"
}
],
"icon": "ethereum"
},
{
"type": "Blockchain Network",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Network Client",
"relatedUiObject": "Network Client",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Ethereum Blockchain->"
},
"propertyNameAtParent": "blockchainNetworks",
"properties": [
{
"name": "networkClients",
"type": "array",
"childType": "Network Client"
}
],
"icon": "ethereum"
},
{
"type": "Network Client",
"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",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"referenceAttachesTo": {
"compatibleTypes": "->Network Node->"
},
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"host\": \"localhost\", \n\"httpPort\": \"8545\"\n}"
},
"addLeftIcons": true,
"level": 1,
"chainAttachesTo": {
"compatibleTypes": "->Blockchain Network->"
},
"propertyNameAtParent": "networkClients",
"icon": "ethereum"
},
{
"type": "Ethereum Decentralized Application",
"menuItems": [
{
"action": "Add UI Object",
"label": "Add Smart Contract",
"relatedUiObject": "Smart Contract",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"isHierarchyHead": true,
"addLeftIcons": true,
"level": 0,
"properties": [
{
"name": "smartContracts",
"type": "array",
"childType": "Smart Contract"
}
],
"icon": "ethereum"
},
{
"type": "Smart Contract",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Add UI Object",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "solidityCode",
"label": "Add Solidity Code",
"relatedUiObject": "Solidity Code",
"actionFunction": "payload.executeAction"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n\"address\": \"\"\n}"
},
"chainAttachesTo": {
"compatibleTypes": "->Token Definition->Ethereum Decentralized Application->"
},
"propertyNameAtParent": "smartContracts",
"addLeftIcons": true,
"level": 1,
"properties": [
{
"name": "solidityCode",
"type": "node",
"childType": "Solidity Code"
}
],
"icon": "ethereum"
},
{
"type": "Solidity Code",
"menuItems": [
{
"action": "Edit",
"actionFunction": "uiObject.codeEditor.activate",
"label": "Edit",
"iconPathOn": "ethereum",
"iconPathOff": "ethereum"
},
{
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"code": true
},
"initialValues": {
"code": "// Type your smart contract code here."
},
"chainAttachesTo": {
"compatibleTypes": "->Smart Contract->"
},
"propertyNameAtParent": "solidityCode",
"addLeftIcons": true,
"level": 2,
"icon": "ethereum"
}
]
@@ -0,0 +1,2 @@
[
]
@@ -0,0 +1,2 @@
[
]
@@ -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.getHierarchyHeadsByType('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() {
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
}
}
}