Skip to content

Commit

Permalink
Merge DEV into LAC CHAIN (#333)
Browse files Browse the repository at this point in the history
* Document the wallet configuration proccess and the related hapi
env variables. refs #137

* Document the wallet configuration proccess and the related
hapi env variables. refs #137

* fix typos. refs #137

* fix typos. refs #137

* fix: add missing parameter. refs #137

* reduce final bundle size  (#293)

* chore: avoid load unused icons from ual-reactjs-renderer to reduce the final bundle size

* chore: update eslint config

* feat: add new actions for permissioning committee and entity account (#332)

Co-authored-by: kurono <kurono@riseup.net>
Co-authored-by: adriel <adriexnet@gmail.com>
  • Loading branch information
3 people authored Feb 22, 2021
1 parent 3309b9e commit 92e0c40
Show file tree
Hide file tree
Showing 13 changed files with 738 additions and 525 deletions.
2 changes: 1 addition & 1 deletion .env.jungle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HAPI_EOS_API_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910
HAPI_EOS_BASE_ACCOUNT=baseaccount
HAPI_EOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_EOS_MECHANICS_ACCOUNT=eosmechatero
HAPI_EOS_MECHANICS_PASSWORD=PW5KTjY7p5CE44vrJcdEwGTijo5Dc6bg4YFnKQqzcdAypatudb2cv
HAPI_EOS_MECHANICS_PASSWORD=PW...
HAPI_EOS_WALLET_URL=http://wallet:8888
HAPI_EOS_EXCHANGE_RATE_API=http://api.coinlayer.com/api/live?symbols=EOS&access_key=e7146e1015657fa7bc3495bdf6302052
HAPI_EOS_BP_JSON_ON_CHAIN=false
Expand Down
2 changes: 1 addition & 1 deletion .env.lacchain
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ HAPI_EOS_API_CHAIN_ID=5821525c6588037e2b066b992fcac34909a5b7f1ea8d5a393f6720fca3
HAPI_EOS_BASE_ACCOUNT=baseaccount
HAPI_EOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_EOS_MECHANICS_ACCOUNT=eosmechanics
HAPI_EOS_MECHANICS_PASSWORD=PW5Kd9uRABQEiaWZ3UZYTfiY8ZgJYKiELRUrRRtTeucGxpHx5obDZ
HAPI_EOS_MECHANICS_PASSWORD=PW...
HAPI_EOS_MECHANICS_INCLUDE_TRANSACTION={"account":"writer","name":"run","authorization":[{"actor":"costarica","permission":"writer"}],"data":{}}
HAPI_EOS_WALLET_URL=http://wallet:8888
HAPI_EOS_BP_JSON_ON_CHAIN=false
Expand Down
47 changes: 47 additions & 0 deletions docs/wallet-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Dashboard wallet creation and configuration

The EOSIO dashboard collects information from different networks but also
allows users to execute specific administrative actions on certain networks,
by EOSIO accounts and their respective keys. All this requires to use a
wallet that acts as an intermediary to sign transactions and interact with
permissioned actions in the networks.

Here we explain how to create and configure such a wallet for the EOSIO
dashboard. Inside the wallet pod, please execute the following commands:

```bash
# Create a default wallet
cleos --wallet-url http://localhost:8888 wallet create --to-console
# Create a wallet called eosmechanics
cleos --wallet-url http://localhost:8888 wallet create -n eosmechanics --to-console
```

The previews commands will create a default wallet and another wallet called
eosmechanics. The returned passwords (a string starting with PW...) should be
used to fulfill the following environment variables:

```bash
HAPI_EOS_BASE_ACCOUNT=eosmechanics
HAPI_EOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_EOS_MECHANICS_ACCOUNT=eosmechanics
HAPI_EOS_MECHANICS_PASSWORD=PW...
```

Let's make sure that the wallet was created correctly:

```bash
cleos -u https://jungle.eosio.cr --wallet-url http://localhost:8888 wallet list
```

If the wallet is present but locked, then execute the following command:

```bash
cleos -u https://jungle.eosio.cr --wallet-url http://localhost:8888 wallet unlock -n eosmechanics
```

Finally, we will import an EOSIO key for reading information about statistics of the block
producers called eosmechanics (Ask the admins about the key):

```bash
cleos -u https://jungle.eosio.cr --wallet-url http://localhost:8888 wallet import -n eosmechanics
```
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ start-hasura-cli:
start-webapp:
$(eval -include .env)
@until \
curl http://localhost:8585/healthz; \
curl -s -o /dev/null -w 'hasura status %{http_code}\n' http://localhost:8585/healthz; \
do echo "$(BLUE)$(STAGE)-$(APP_NAME)-webapp |$(RESET) waiting for hasura service"; \
sleep 5; done;
@echo "..."
@docker-compose up -d --build webapp
@cd webapp && yarn && yarn start:local | cat
@echo "done webapp"

start-logs:
@docker-compose logs -f hapi webapp
Expand Down
5 changes: 3 additions & 2 deletions webapp/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"extends": [
"standard",
"standard-react",
"plugin:prettier/recommended",
"prettier/react",
"prettier/standard"
"prettier/standard",
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"env": {
"jest": true,
Expand Down
5 changes: 3 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "react-app-rewired build",
"eject": "react-scripts eject",
"lint": "lint-staged",
"test": "react-app-rewired test --env=jsdom"
"test": "react-app-rewired test --env=jsdom",
"start:local": "env-cmd -f ../.env react-app-rewired start"
},
"husky": {
"hooks": {
Expand All @@ -23,6 +24,7 @@
"not op_mini all"
],
"dependencies": {
"@eoscostarica/ual-reactjs-renderer": "^0.3.1",
"@apollo/react-hooks": "^4.0.0",
"@date-io/core": "^2.10.6",
"@eoscostarica/eoscr-components": "^3.1.0",
Expand Down Expand Up @@ -80,7 +82,6 @@
"ual-ledger": "^0.3.0",
"ual-lynx": "^0.4.0",
"ual-meetone": "^0.1.1",
"ual-reactjs-renderer": "^0.3.1",
"ual-scatter": "^0.3.0",
"ual-token-pocket": "^0.3.0"
},
Expand Down
37 changes: 37 additions & 0 deletions webapp/src/components/ContractActionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LacchainAddEntityActionEntityTypeField from './LacchainAddEntityActionEnt
import LacchainAddValidatorActionEntityField from './LacchainAddValidatorActionEntityField'
import LacchainAddValidatorActionValidatorAuthorityField from './LacchainAddValidatorActionValidatorAuthorityField'
import LacchainSetScheduleActionValidatorsField from './LacchainSetScheduleActionValidatorsField'
import EOSIONewAccountAuthority from './EOSIONewAccountAuthority'

const useStyles = makeStyles((theme) => ({
formControl: {
Expand Down Expand Up @@ -164,6 +165,42 @@ const ContractActionForm = ({ accountName, action, abi, onSubmitAction }) => {
onChange={handleFieldChange(field.name)}
/>
)
case 'eosio.newaccount.owner':
return (
<EOSIONewAccountAuthority
key={`action-field-${field.name}`}
label={field.name}
variant="outlined"
className={classes.formControl}
value={payload[field.name] || ''}
onChange={handleFieldChange(field.name)}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Chip label="public_key" />
</InputAdornment>
)
}}
/>
)
case 'eosio.newaccount.active':
return (
<EOSIONewAccountAuthority
key={`action-field-${field.name}`}
label={field.name}
variant="outlined"
className={classes.formControl}
value={payload[field.name] || ''}
onChange={handleFieldChange(field.name)}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Chip label="public_key" />
</InputAdornment>
)
}}
/>
)
default:
return (
<TextField
Expand Down
56 changes: 56 additions & 0 deletions webapp/src/components/EOSIONewAccountAuthority.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint camelcase: 0 */
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import TextField from '@material-ui/core/TextField'

import getAuthoritTemplate from '../utils/get-authority-template'

const LacchainNewAccount = ({
value,
onChange,
label,
variant,
className,
...props
}) => {
const [internalValue, setInternalValue] = useState()

const handleOnFieldChange = (event) => {
onChange({
target: {
value: getAuthoritTemplate(event.target.value)
}
})
}

useEffect(() => {
if (!value) {
return
}

try {
setInternalValue(value?.keys[0]?.key || '')
} catch (error) {}
}, [value])

return (
<TextField
{...props}
className={className}
value={internalValue || ''}
onChange={handleOnFieldChange}
label={label}
variant={variant}
/>
)
}

LacchainNewAccount.propTypes = {
value: PropTypes.any,
onChange: PropTypes.func,
label: PropTypes.string,
variant: PropTypes.string,
className: PropTypes.string
}

export default LacchainNewAccount
2 changes: 1 addition & 1 deletion webapp/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { UALProvider, withUAL } from 'ual-reactjs-renderer'
import { UALProvider, withUAL } from '@eoscostarica/ual-reactjs-renderer'
import { ApolloProvider } from '@apollo/react-hooks'
import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles'
import { StylesProvider } from '@material-ui/styles'
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/language/en.lacchain.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"setentxinfoTitle": "Set extended entity info",
"setentxinfoTooltip": "Set extended entity info.",
"setnodexinfoTitle": "Set extended node info",
"setnodexinfoTooltip": "Set extended node info."
"setnodexinfoTooltip": "Set extended node info.",
"rmnodeTitle": "Remove Node",
"rmnodeTooltip": "Allow remove a Validator Node from the network.",
"rmentityTitle": "Remove Entity",
"rmentityTooltip": "Allow remove an entity from the network."
}
}
7 changes: 5 additions & 2 deletions webapp/src/routes/Lacchain/LacchainManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ const LacchainManagement = ({ ual }) => {
'netaddgroup',
'setram',
'setentxinfo',
'setnodexinfo'
'setnodexinfo',
'rmnode',
'rmentity'
]
}

Expand All @@ -144,7 +146,8 @@ const LacchainManagement = ({ ual }) => {
'addboot',
'addobserver',
'addwriter',
'addvalidator'
'addvalidator',
'rmnode'
]
}

Expand Down
23 changes: 23 additions & 0 deletions webapp/src/utils/get-authority-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { eosConfig } from '../config'

const getAuthoritTemplate = (key) => {
if (eosConfig.networkName === 'lacchain') {
return {
threshold: 2,
keys: [{ weight: 1, key: key || '' }],
accounts: [
{ weight: 1, permission: { actor: 'writer', permission: 'access' } }
],
waits: []
}
}

return {
threshold: 1,
keys: [{ weight: 1, key: key || '' }],
accounts: [],
waits: []
}
}

export default getAuthoritTemplate
Loading

0 comments on commit 92e0c40

Please sign in to comment.