make cleos wallet accessable
This commit is contained in:
+1
-2
@@ -1,5 +1,4 @@
|
||||
node_modules/
|
||||
lerna-debug.log
|
||||
components/controller/graph.png
|
||||
wallet-data/
|
||||
blockchain-data/
|
||||
blockchain-data/
|
||||
|
||||
@@ -80,6 +80,34 @@ pnpm run dev:backend
|
||||
pnpm run dev:desktop
|
||||
```
|
||||
|
||||
### Кошелёк
|
||||
Для работы с кошельком блокчейна используется утилита cleos, которая позволяет извлекать таблицы смарт-контрактов и отправлять транзакции в блокчейн если это требуется.
|
||||
|
||||
Для работы с командным кошельком `cleos` локально необходимо разблокировать его:
|
||||
|
||||
```
|
||||
|
||||
pnpm run unlock
|
||||
```
|
||||
|
||||
В кошельке уже находится дефолтный ключ для работы с локальной средой. Этот ключ зашифрован паролем. Пароль хранится в .env и используется автоматически при разблокировке.
|
||||
|
||||
Для получения полного списка команд кошелька вводим:
|
||||
```
|
||||
pnpm run cli cleos
|
||||
```
|
||||
|
||||
Далее вызываем команду:
|
||||
```
|
||||
pnpm run cli cleos -- <cmd>
|
||||
```
|
||||
|
||||
Например, для получения информации о текущем состоянии блокчейна:
|
||||
```
|
||||
pnpm run cli cleos -- get info
|
||||
```
|
||||
|
||||
|
||||
## Лицензия
|
||||
|
||||
Продукт Потребительского Кооператива "ВОСХОД" распространяется по лицензии BY-NC-SA 4.0.
|
||||
|
||||
@@ -2,7 +2,7 @@ EOSIO_PUB_KEY=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
|
||||
EOSIO_PRV_KEY=5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
|
||||
DATADIR=blockchain-data
|
||||
BPACCOUNT=eosio
|
||||
PASSWORD=PASSWORD
|
||||
PASSWORD=PW5JGe4WsTPGrjnMzkGd4wfVdzoHCEySgbyq2WBWGAxSfevbXqAG4
|
||||
SERVER_SECRET=SECRET
|
||||
SERVER_URL=http://127.0.0.1:2998
|
||||
MONGO_URI=mongodb://127.0.0.1:27017/cooperative-x
|
||||
|
||||
@@ -11,4 +11,6 @@ node_modules
|
||||
temp
|
||||
.env
|
||||
blockchain-data/*
|
||||
wallet-data/*
|
||||
wallet-data/keosd.sock=
|
||||
wallet-data/wallet.lock
|
||||
wallet-data/production.wallet
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
"scripts": {
|
||||
"enter": "./scripts/enter.sh",
|
||||
"cli": "esno src/index.ts",
|
||||
"cleos": "esno src/index.ts cleos",
|
||||
"unlock": "esno src/index.ts unlock",
|
||||
"boot": "esno src/index.ts boot",
|
||||
"clear": "esno src/index.ts clear",
|
||||
"start": "./scripts/restart.sh",
|
||||
|
||||
@@ -3,19 +3,23 @@ import { promisify } from 'node:util'
|
||||
|
||||
const execAsync = promisify(exec)
|
||||
|
||||
export async function execCommand(command: string[]): Promise<string> {
|
||||
const fullCmd = ['docker', 'compose', 'exec', '-T', 'node', ...command].join(' ')
|
||||
export async function execCommand(command: string[]): Promise<void> {
|
||||
const fullCmd = ['docker', 'compose', 'exec', 'node', ...command].join(' ')
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line node/prefer-global/process
|
||||
const { stdout, stderr } = await execAsync(fullCmd, { env: process.env })
|
||||
if (stderr) {
|
||||
console.error(stderr)
|
||||
}
|
||||
return stdout.trim()
|
||||
if (stdout)
|
||||
console.log(stdout.trim())
|
||||
if (stderr)
|
||||
console.error(stderr.trim())
|
||||
}
|
||||
catch (error: any) {
|
||||
console.error('Command failed:', error.stderr || error)
|
||||
throw error
|
||||
catch (err: any) {
|
||||
if (err.stdout)
|
||||
console.log(err.stdout.trim())
|
||||
if (err.stderr)
|
||||
console.error(err.stderr.trim())
|
||||
// опционально:
|
||||
// console.error(`Command failed with code ${err.code}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,17 +31,11 @@ program.version('0.1.0')
|
||||
|
||||
// Команда для запуска команды в контейнере
|
||||
program
|
||||
.command('cleos <cmd...>')
|
||||
.command('cleos [cmd...]')
|
||||
.description('Execute a cleos command in a Node container')
|
||||
.allowUnknownOption()
|
||||
.action(async (cmd: string[]) => {
|
||||
try {
|
||||
console.log(cmd)
|
||||
await execCommand(['cleos', ...cmd])
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Command execution failed:', error)
|
||||
}
|
||||
.action(async (cmd: string[] = []) => {
|
||||
await execCommand(['cleos', ...cmd])
|
||||
})
|
||||
|
||||
// Команда для запуска команды в контейнере
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# The filename (relative to data-dir) to create a unix socket for HTTP RPC; set blank to disable. (eosio::http_plugin)
|
||||
# unix-socket-path = keosd.sock
|
||||
|
||||
# The local IP and port to listen for incoming http connections; setting to http-category-address to enable http-category-address option. leave blank to disable. (eosio::http_plugin)
|
||||
# http-server-address =
|
||||
|
||||
# Specify the Access-Control-Allow-Origin to be returned on each request (eosio::http_plugin)
|
||||
# access-control-allow-origin =
|
||||
|
||||
# Specify the Access-Control-Allow-Headers to be returned on each request (eosio::http_plugin)
|
||||
# access-control-allow-headers =
|
||||
|
||||
# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin)
|
||||
# access-control-max-age =
|
||||
|
||||
# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
|
||||
# access-control-allow-credentials = false
|
||||
|
||||
# The maximum body size in bytes allowed for incoming RPC requests (eosio::http_plugin)
|
||||
# max-body-size = 2097152
|
||||
|
||||
# Maximum size in megabytes http_plugin should use for processing http requests. -1 for unlimited. 503 error response when exceeded. (eosio::http_plugin)
|
||||
# http-max-bytes-in-flight-mb = 500
|
||||
|
||||
# Maximum number of requests http_plugin should use for processing http requests. 503 error response when exceeded. (eosio::http_plugin)
|
||||
# http-max-in-flight-requests = -1
|
||||
|
||||
# Maximum time on main thread for processing a request, -1 for unlimited (eosio::http_plugin)
|
||||
# http-max-response-time-ms = 15
|
||||
|
||||
# Append the error log to HTTP responses (eosio::http_plugin)
|
||||
# verbose-http-errors = false
|
||||
|
||||
# If set to false, then any incoming "Host" header is considered valid (eosio::http_plugin)
|
||||
# http-validate-host = true
|
||||
|
||||
# Additionally acceptable values for the "Host" header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default. (eosio::http_plugin)
|
||||
# http-alias =
|
||||
|
||||
# Number of worker threads in http thread pool (eosio::http_plugin)
|
||||
# http-threads = 2
|
||||
|
||||
# If set to false, do not keep HTTP connections alive, even if client requests. (eosio::http_plugin)
|
||||
# http-keep-alive = true
|
||||
|
||||
# The path of the wallet files (absolute path or relative to application data dir) (eosio::wallet_plugin)
|
||||
# wallet-dir = "."
|
||||
|
||||
# Timeout for unlocked wallet in seconds (default 900 (15 minutes)). Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin)
|
||||
# unlock-timeout = 900
|
||||
|
||||
# Plugin(s) to enable, may be specified multiple times
|
||||
# plugin =
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cipher_keys": "710a43f09ece89ed7baf387cc1ae3127cb90d9fc16cffda660c71c75678d1fe4d8b22e1fd0476e232581a37e3c3beda3e25b873ae0a9d43c274f30b4d9ea394f4c583234a6d0715540163edc28db22de98b0aa7e9431ebfc6f28b1eaf665326d7456b55f1fa776e7eac61d90264871e6a58b3ebbd8dec377e05ef7fec64b348aef02459329f49d1384bf2af32fd02ce1"
|
||||
}
|
||||
@@ -22,6 +22,8 @@
|
||||
"setup": "lerna run setup --scope @coopenomics/setup",
|
||||
"boot": "lerna run boot --scope @coopenomics/boot",
|
||||
"clear": "lerna run clear --scope @coopenomics/boot",
|
||||
"unlock": "lerna run unlock --scope @coopenomics/boot",
|
||||
"cleos": "lerna run cleos --scope @coopenomics/boot",
|
||||
"build:lib": "lerna run build --scope @coopenomics/factory --scope @coopenomics/cooptypes",
|
||||
"build:contracts:all": "lerna run build:all --scope @coopenomics/contracts",
|
||||
"build:contract": "lerna run build:one --scope @coopenomics/contracts --",
|
||||
|
||||
Reference in New Issue
Block a user