Skip to content

Commit d7aab4e

Browse files
committed
Enhance CLI and contract functionality with new features and updates
- Added new commands for neuron management and network parameter updates in the CLI. - Enhanced README with detailed command usage for new features. - Introduced new functions in the SubnetManager ABI for network parameter management. - Improved staking and subnet commands with better output formatting and error handling. - Updated contract interactions to use new address configurations for AMM and staking. - Added support for retrieving network parameters and resetting network lock state.
1 parent d3fb094 commit d7aab4e

File tree

13 files changed

+1168
-39
lines changed

13 files changed

+1168
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
- New command to set configuration values
1515
- New command to reset configuration to default values
1616
- New command to create a new wallet with a specified name and password
17-
- New command to unlock a wallet with a password
17+
- New command to unlock a wallet with a password
18+
- Added new commands for neuron management and network parameter updates in the CLI.
19+
- Enhanced README with detailed command usage for new features.
20+
- Introduced new functions in the SubnetManager ABI for network parameter management.
21+
- Improved staking and subnet commands with better output formatting and error handling.
22+
- Updated contract interactions to use new address configurations for AMM and staking.
23+
- Added support for retrieving network parameters and resetting network lock state.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ You can install `hetucli` on your local machine directly from source or PyPI. **
4242
Run
4343
```bash
4444
pip install -U hetu-pycli
45+
hetucli --help
4546
```
4647

4748
### Install from source
@@ -112,7 +113,41 @@ Set the contract address
112113
hetucli c set whetu_address <address>
113114
hetucli c set staking_address <address>
114115
hetucli c set subnet_address <address>
115-
hetucli c set whetu_address <address>
116+
hetucli c set neuron_address <address>
117+
hetucli c set amm_address <address>
118+
```
119+
120+
### Main Process(New,Staking,Swap)
121+
122+
#### New A Subnet
123+
124+
```bash
125+
hetucli w import <private-key> --name test0
126+
hetucli whetu deposit --sender test0 --value 1000
127+
hetucli whetu balance-of test0
128+
hetucli subnet get-network-lock-cost
129+
hetucli whetu approve --spender <subnet_address> --value 100 --sender test0
130+
hetucli subnet update-network-params --network-min-lock 100000000000000000000 --network-rate-limit 1 --lock-reduction-interval 10000 --sender <address>
131+
hetucli subnet regist --sender test0 --name "AI Vision" --description "Computre vision and image processing network" --token-name "VISION" --token-symbol "VIS"
132+
```
133+
#### Staking and Participation
134+
135+
```bash
136+
hetucli whetu approve --spender <stake_address> --value 100 --sender test0
137+
hetucli stake add-stake --sender test0 --amount 100
138+
hetucli stake total-staked
139+
hetucli stake allocate-to-subnet --netuid 1 --sender test0 --amount 50
140+
hetucli neuron regist --sender test0 --netuid 1 --is-validator-role --axon-endpoint "http://my-node.com" --axon-port 8080 --prometheus-endpoint "http://my-metrics.com" --prometheus-port 9090
141+
```
142+
143+
#### Trading Subnet Tokens
144+
145+
```bash
146+
hetucli subnet subnet-info --netuid 1
147+
hetucli c set amm_address <amm_pool_address>
148+
hetucli amm pool-info
149+
hetucli whetu approve --spender 0xa16E02E87b7454126E5E10d957A927A7F5B5d2be --value 100 --sender test0
150+
hetucli amm swap-hetu-for-alpha --hetu-amount-in 100 --alpha-amount-out-min 0 --sender test0 --to <to-address>
116151
```
117152

118153
### WHETU

contracts/SubnetManager.abi

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,49 @@
324324
"stateMutability": "view",
325325
"type": "function"
326326
},
327+
{
328+
"inputs": [],
329+
"name": "getNetworkParams",
330+
"outputs": [
331+
{
332+
"internalType": "uint256",
333+
"name": "minLock",
334+
"type": "uint256"
335+
},
336+
{
337+
"internalType": "uint256",
338+
"name": "lastLock",
339+
"type": "uint256"
340+
},
341+
{
342+
"internalType": "uint256",
343+
"name": "lastLockBlock",
344+
"type": "uint256"
345+
},
346+
{
347+
"internalType": "uint256",
348+
"name": "rateLimit",
349+
"type": "uint256"
350+
},
351+
{
352+
"internalType": "uint256",
353+
"name": "reductionInterval",
354+
"type": "uint256"
355+
},
356+
{
357+
"internalType": "uint16",
358+
"name": "totalNets",
359+
"type": "uint16"
360+
},
361+
{
362+
"internalType": "uint16",
363+
"name": "nextId",
364+
"type": "uint16"
365+
}
366+
],
367+
"stateMutability": "view",
368+
"type": "function"
369+
},
327370
{
328371
"inputs": [],
329372
"name": "getNextNetuid",
@@ -1325,6 +1368,13 @@
13251368
"stateMutability": "nonpayable",
13261369
"type": "function"
13271370
},
1371+
{
1372+
"inputs": [],
1373+
"name": "resetNetworkLockState",
1374+
"outputs": [],
1375+
"stateMutability": "nonpayable",
1376+
"type": "function"
1377+
},
13281378
{
13291379
"inputs": [
13301380
{
@@ -1558,6 +1608,154 @@
15581608
"stateMutability": "nonpayable",
15591609
"type": "function"
15601610
},
1611+
{
1612+
"inputs": [
1613+
{
1614+
"internalType": "uint256",
1615+
"name": "_networkMinLock",
1616+
"type": "uint256"
1617+
},
1618+
{
1619+
"internalType": "uint256",
1620+
"name": "_networkRateLimit",
1621+
"type": "uint256"
1622+
},
1623+
{
1624+
"internalType": "uint256",
1625+
"name": "_lockReductionInterval",
1626+
"type": "uint256"
1627+
}
1628+
],
1629+
"name": "updateNetworkParams",
1630+
"outputs": [],
1631+
"stateMutability": "nonpayable",
1632+
"type": "function"
1633+
},
1634+
{
1635+
"inputs": [
1636+
{
1637+
"internalType": "uint16",
1638+
"name": "netuid",
1639+
"type": "uint16"
1640+
},
1641+
{
1642+
"components": [
1643+
{
1644+
"internalType": "uint16",
1645+
"name": "rho",
1646+
"type": "uint16"
1647+
},
1648+
{
1649+
"internalType": "uint16",
1650+
"name": "kappa",
1651+
"type": "uint16"
1652+
},
1653+
{
1654+
"internalType": "uint16",
1655+
"name": "immunityPeriod",
1656+
"type": "uint16"
1657+
},
1658+
{
1659+
"internalType": "uint16",
1660+
"name": "tempo",
1661+
"type": "uint16"
1662+
},
1663+
{
1664+
"internalType": "uint16",
1665+
"name": "maxValidators",
1666+
"type": "uint16"
1667+
},
1668+
{
1669+
"internalType": "uint16",
1670+
"name": "activityCutoff",
1671+
"type": "uint16"
1672+
},
1673+
{
1674+
"internalType": "uint16",
1675+
"name": "maxAllowedUids",
1676+
"type": "uint16"
1677+
},
1678+
{
1679+
"internalType": "uint16",
1680+
"name": "maxAllowedValidators",
1681+
"type": "uint16"
1682+
},
1683+
{
1684+
"internalType": "uint16",
1685+
"name": "minAllowedWeights",
1686+
"type": "uint16"
1687+
},
1688+
{
1689+
"internalType": "uint16",
1690+
"name": "maxWeightsLimit",
1691+
"type": "uint16"
1692+
},
1693+
{
1694+
"internalType": "uint256",
1695+
"name": "baseBurnCost",
1696+
"type": "uint256"
1697+
},
1698+
{
1699+
"internalType": "uint64",
1700+
"name": "currentDifficulty",
1701+
"type": "uint64"
1702+
},
1703+
{
1704+
"internalType": "uint16",
1705+
"name": "targetRegsPerInterval",
1706+
"type": "uint16"
1707+
},
1708+
{
1709+
"internalType": "uint16",
1710+
"name": "maxRegsPerBlock",
1711+
"type": "uint16"
1712+
},
1713+
{
1714+
"internalType": "uint64",
1715+
"name": "weightsRateLimit",
1716+
"type": "uint64"
1717+
},
1718+
{
1719+
"internalType": "bool",
1720+
"name": "registrationAllowed",
1721+
"type": "bool"
1722+
},
1723+
{
1724+
"internalType": "bool",
1725+
"name": "commitRevealEnabled",
1726+
"type": "bool"
1727+
},
1728+
{
1729+
"internalType": "uint64",
1730+
"name": "commitRevealPeriod",
1731+
"type": "uint64"
1732+
},
1733+
{
1734+
"internalType": "uint64",
1735+
"name": "servingRateLimit",
1736+
"type": "uint64"
1737+
},
1738+
{
1739+
"internalType": "uint16",
1740+
"name": "validatorThreshold",
1741+
"type": "uint16"
1742+
},
1743+
{
1744+
"internalType": "uint16",
1745+
"name": "neuronThreshold",
1746+
"type": "uint16"
1747+
}
1748+
],
1749+
"internalType": "struct SubnetTypes.SubnetHyperparams",
1750+
"name": "newHyperparams",
1751+
"type": "tuple"
1752+
}
1753+
],
1754+
"name": "updateSubnetHyperparams",
1755+
"outputs": [],
1756+
"stateMutability": "nonpayable",
1757+
"type": "function"
1758+
},
15611759
{
15621760
"inputs": [
15631761
{

contracts/SubnetManager.bin

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

hetu_pycli/cli.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
from hetu_pycli.src.hetu.staking import staking_app
1010
from hetu_pycli.src.hetu.subnet import subnet_app
1111
from hetu_pycli.src.hetu.amm import amm_app
12-
from hetu_pycli.config import load_config, ensure_config_file
12+
from hetu_pycli.src.hetu.neuron import neuron_app
13+
from hetu_pycli.config import load_config, ensure_config_file, _epilog
1314
from hetu_pycli.version import __version__
1415

1516
app = Typer(
1617
help="Hetu chain command line client",
1718
no_args_is_help=True,
19+
epilog=_epilog
1820
)
1921

2022
@app.callback()
@@ -60,20 +62,22 @@ def raise_exit():
6062
name="wallet",
6163
help="Wallet management",
6264
no_args_is_help=True,
65+
epilog=_epilog
6366
)
6467
app.add_typer(wallet_app, name="w", hidden=True, no_args_is_help=True)
65-
app.add_typer(tx_app, name="tx", help="Transfer & transaction", no_args_is_help=True)
68+
app.add_typer(tx_app, name="tx", help="Transfer & transaction", no_args_is_help=True, epilog=_epilog)
6669
app.add_typer(
67-
contract_app, name="contract", help="Contract operations", no_args_is_help=True
70+
contract_app, name="contract", help="Contract operations", no_args_is_help=True, epilog=_epilog
6871
)
69-
app.add_typer(config_app, name="config", help="Config management", no_args_is_help=True)
72+
app.add_typer(config_app, name="config", help="Config management", no_args_is_help=True, epilog=_epilog)
7073
app.add_typer(config_app, name="c", hidden=True, no_args_is_help=True)
7174
app.add_typer(config_app, name="conf", hidden=True, no_args_is_help=True)
72-
app.add_typer(erc20_app, name="erc20", help="ERC20 token operations", no_args_is_help=True)
73-
app.add_typer(whetu_app, name="whetu", help="WHETU contract operations", no_args_is_help=True)
74-
app.add_typer(staking_app, name="stake", help="Global staking operations", no_args_is_help=True)
75-
app.add_typer(subnet_app, name="subnet", help="Subnet manager operations", no_args_is_help=True)
76-
app.add_typer(amm_app, name="amm", help="Subnet AMM operations", no_args_is_help=True)
75+
app.add_typer(erc20_app, name="erc20", help="ERC20 token operations", no_args_is_help=True, epilog=_epilog)
76+
app.add_typer(whetu_app, name="whetu", help="WHETU contract operations", no_args_is_help=True, epilog=_epilog)
77+
app.add_typer(staking_app, name="stake", help="Global staking operations", no_args_is_help=True, epilog=_epilog)
78+
app.add_typer(subnet_app, name="subnet", help="Subnet manager operations", no_args_is_help=True, epilog=_epilog)
79+
app.add_typer(amm_app, name="amm", help="Subnet AMM operations", no_args_is_help=True, epilog=_epilog)
80+
app.add_typer(neuron_app, name="neuron", help="Neuron manager operations", no_args_is_help=True, epilog=_epilog)
7781

7882
if __name__ == "__main__":
7983
app()

hetu_pycli/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import yaml
33
from pathlib import Path
44

5+
_epilog = "Made with ❤️ by The Hetu protocol"
6+
57
DEFAULT_CONFIG_PATH = os.path.expanduser("~/.hetucli/config.yml")
68
DEFAULT_CONFIG = {
79
"chain": "ws://127.0.0.1:8545",
@@ -15,6 +17,7 @@
1517
"subnet_address": "0x0000000000000000000000000000000000000000",
1618
"staking_address": "0x0000000000000000000000000000000000000000",
1719
"amm_address": "0x0000000000000000000000000000000000000000",
20+
"neuron_address": "0x0000000000000000000000000000000000000000",
1821
"metagraph_cols": {
1922
"ACTIVE": True,
2023
"AXON": True,

0 commit comments

Comments
 (0)