Skip to content

Commit 501344c

Browse files
RuslanGlaznyovEvgenyKhlivetskyLiver-23
authored
Feat/v0.2 (#3)
feat: completely new app --------- Co-authored-by: EvgenyKhlivetsky <[email protected]> Co-authored-by: EvgenyKhlivetsky <[email protected]> Co-authored-by: Liver-23 <[email protected]>
1 parent 9f246c7 commit 501344c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1976
-4872
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TELEGRAM_BOT_TOKEN=your bot token here

.eslintrc.cjs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:prettier/recommended',
10+
],
11+
overrides: [
12+
{
13+
env: {
14+
node: true,
15+
},
16+
files: ['.eslintrc.{js,cjs}'],
17+
parserOptions: {
18+
sourceType: 'script',
19+
},
20+
},
21+
],
22+
parser: '@typescript-eslint/parser',
23+
parserOptions: {
24+
ecmaVersion: 'latest',
25+
sourceType: 'module',
26+
},
27+
plugins: ['@typescript-eslint'],
28+
rules: {},
29+
}

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "all",
6+
"printWidth": 80
7+
}

README.md

+99-22
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,104 @@
11
# janusbot
2-
Self hosted Bot to easy vote in cosmos ecosystem
32

3+
Self hosted Bot to easy vote in cosmos ecosystem
44

55
<img src="janus.jpeg" width="30%">
66

7-
There is no need to vote via cli or web UI, just setup a bot with your validator or wherever you want and get notifications with vote options and vote ***directly in telegram!***
7+
There is no need to vote via cli or web UI, just setup a bot with your validator or wherever you want and get notifications with vote options and vote **_directly in telegram!_**
8+
9+
<img src="work_bot_example.png" width="30%">
810

9-
<img src="work_bot_example.png" width="40%">
11+
# How to run a bot
12+
### Get the binary
13+
#### Download the latest release
1014

11-
## How to run a bot
12-
### Upload the latest release on your machine
13-
For example:
15+
First download the latest release:
1416
```
1517
wget https://github.com/MELLIFERA-Labs/janusbot/releases/download/v0.0.3/janusbot-linux-amd64
1618
```
17-
18-
### Add binary to bin
19+
#### Build from sources
20+
1. install bun (JavaScript runtime). Go to site and fallow instructions: https://bun.sh
21+
2. Run build commands in root of project
22+
3. Install dependencies
23+
```bash
24+
bun install
1925
```
20-
mv janusbot-linux-amd64 /usr/bin/janusbot
26+
4. Build binary
27+
```bash
28+
bun build ./src/cli/index.ts --compile --outfile janusbot
2129
```
22-
### Setup app config
30+
Now you have `janusbot` binary in root of project
31+
32+
## Initialize the bot:
2333
```
2434
janusbot init
2535
```
26-
Fill all forms step by step as in example:
36+
## Verify that config is created
37+
38+
```
39+
cat $HOME/.janus/config.toml
40+
```
41+
42+
## Configure environment variables
43+
Set env variables, see `.env.example` or you can specify path to .env file, e.g. `dotenv = '/Home/.janus/.env'`.
44+
45+
## Create telegram bot
46+
Open telegram and look for @BotFather, run command `/newbot` and follow instructions.
47+
In the end you should get token for your bot: something like `9999999:ASDjaiodsjioasoidj123123`.
48+
Set token environment variable, variable name is `TELEGRAM_BOT_TOKEN`, e.g: `TELEGRAM_BOT_TOKEN=9999999:ASDjaiodsjioasoidj123123`.
2749

28-
<img src="fill_init_example.png" width="90%">
50+
## Retrieve chat_id
51+
Now we need chat_id, so our bot knows where to send messages. It may be either group or private chat. In telegram look for `@username_to_id_bot`, or any other way you prefer to get chat_id.
52+
Add chat_id to config.toml, e.g: `chat_id = 123456789`.
53+
Update `key` in config.toml, string and no spaces, e.g: `key = 'telegram_cosmos_proposals'`.
54+
Currently we support only telegram, so `type = 'telegram'`.
55+
56+
## Configure bot
57+
### Keys management
58+
Now let's proceed with keys setup. These keys will be used to vote for proposals.
59+
If you want to create new wallet run:
60+
61+
```
62+
janusbot keys add WALLET_NAME
63+
```
64+
If you want to import existing one run:
65+
```
66+
janusbot keys add WALLET_NAME --recover
67+
```
68+
Follow instructions.
69+
70+
### Setup network
71+
Currently we have initial values for cosmos network, edit those for your preferred network.
72+
`transport` is your transport key, we added before: `telegram_cosmos_proposals` in our case.
73+
Here is a [complete example](./config.example.toml) of config.toml you should have in the end.
74+
#### Lava integration
75+
> [Lava](https://lavanet.xyz) is a modular data network for scaling access to any blockchain. The network can flexibly support any RPC and API, and node providers compete to offer the fastest and most reliable service
76+
77+
If you want to use RPC with Lava network, you can add `lava` section to config.toml, e.g:
78+
```toml
79+
[[network]]
80+
#...
81+
lava = { chain = 'COS5' }
82+
```
83+
It's also require `LAVA_PRIV_KEY` environment variable to be set. Set it in .env or in any other way you prefer.
84+
To get `LAVA_PRIV_KEY` look at [lava doc](https://docs.lavanet.xyz/sdk-backend/#%EF%B8%8F-recommended-flow).
85+
86+
## Run the bot
87+
```
88+
janusbot run start
89+
```
90+
And that's it! The bot will check for new proposals every five minutes and send you a message if there are any.
91+
92+
## Setup service file
93+
94+
1. Create service file
2995

30-
### Setup service file
31-
1. Create service file
3296
```
3397
touch /etc/systemd/system/janusbot.service
3498
```
99+
35100
2. Fill service file:
101+
36102
```
37103
cat <<EOF >> /etc/systemd/system/janusbot.service
38104
[Unit]
@@ -41,7 +107,7 @@ After=network-online.target
41107
42108
[Service]
43109
User=<USER>
44-
ExecStart=/usr/bin/janusbot start
110+
ExecStart=/usr/bin/janusbot run start
45111
Restart=on-failure
46112
RestartSec=3
47113
LimitNOFILE=4096
@@ -50,22 +116,33 @@ LimitNOFILE=4096
50116
WantedBy=multi-user.target
51117
EOF
52118
```
53-
3. Reload systemctl
119+
120+
3. Reload systemctl
121+
54122
```
55123
systemctl daemon-reload
56124
```
125+
57126
4. Start service
127+
58128
```
59129
systemctl start janusbot.service
60130
```
131+
61132
4. In order to watch the service run, you can do the following:
62-
```
63-
journalctl -u janusbot.service -f
64-
```
65-
### VIDEO GUIDES
66-
- EN - https://www.youtube.com/watch?v=U3DSN1M8tQM
67-
- RU - https://www.youtube.com/watch?v=LDzwrBmEOS0
133+
134+
```
135+
journalctl -u janusbot.service -f
136+
```
137+
## Well tested networks
138+
139+
- Cosmos Hub
140+
- Lava Network
141+
- Osmosis
142+
- May work for many others cosmos SDK based networks, but not tested yet.
143+
68144
## SUPPORT US
145+
69146
- COSMOS: `cosmos1qcual5kgmw3gqc9q22hlp0aluc3t7rnsprewgy`
70147
- JUNO: `juno1qcual5kgmw3gqc9q22hlp0aluc3t7rnsh3640c`
71148
- OSMOSIS: `osmo1qcual5kgmw3gqc9q22hlp0aluc3t7rnsfc277k`

bun.lockb

391 KB
Binary file not shown.

config.example.toml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# options parameter for file with env variables. Remove if you don't need it
2+
dotenv = '.env'
3+
# transports configuration
4+
[[transport]]
5+
# The unique name of the transport
6+
key = 'telegram_cosmos_proposals'
7+
# transport type
8+
type = 'telegram'
9+
# telegram chat id. Put your chat id here. Can be channel or your id for direct messages
10+
chat-id = '<id>'
11+
12+
# Networks configuration
13+
[[network]]
14+
# The unique name of the network (Required)
15+
key = 'cosmos_mainnet'
16+
# The chain id (Required)
17+
chain-id = 'cosmoshub-4'
18+
# The coin type (Required). This default value for most cosmos based networks. Check the your network docs to provide the correct value
19+
hd-path = "m/44'/118'/0'/0/0"
20+
# denom (Required)
21+
denom = 'uatom'
22+
# Address prefix (Required)
23+
prefix = 'cosmos'
24+
# Decimals (Required)
25+
decimals = 6
26+
wallet-key = ['my_wallet']
27+
# RPC endpoints (Optional)
28+
net = { rpc = ['https://rpc.cosmos.directory/cosmoshub'] }
29+
# Lava protocol configuration (Optinal)
30+
lava = { chain = "COS5" }
31+
# `lava` or `net`.One of this configuration is required
32+
# This will be used to create links to the block explorer. Links to proposals and trx result
33+
explorer = { proposal = 'https://www.mintscan.io/cosmos/proposals/:id', trx = 'https://www.mintscan.io/cosmos/txs/:hash' }
34+
# Specify the transport to send notifications. Which is defined above (Required)
35+
transport = 'telegram_cosmos_proposals'

fill_init_example.png

-81.7 KB
Binary file not shown.

index.js

-144
This file was deleted.

0 commit comments

Comments
 (0)