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
}
}
}
}