Skip to content

Commit

Permalink
Add support for dYdX
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellocchia committed Jun 5, 2024
1 parent cd44936 commit 0ed7dc7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Supported BIP coins:
- Cosmos
- Dash (and related test net)
- Dogecoin (and related test net)
- dYdX
- eCash (and related test net)
- Elrond (MultiversX)
- EOS
Expand Down
1 change: 1 addition & 0 deletions bip_utils/bip/conf/bip44/bip44_coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Bip44Coins(BipCoins):
COSMOS = auto()
DASH = auto()
DOGECOIN = auto()
DYDX = auto()
ECASH = auto()
ELROND = auto()
EOS = auto()
Expand Down
15 changes: 15 additions & 0 deletions bip_utils/bip/conf/bip44/bip44_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,21 @@ class Bip44Conf:
},
)

# Configuration for dYdX
DYDX: BipCoinConf = BipCoinConf(
coin_names=CoinsConf.DYDX.CoinNames(),
coin_idx=Slip44.ATOM,
is_testnet=False,
def_path=DER_PATH_NON_HARDENED_FULL,
key_net_ver=_BIP44_BTC_KEY_NET_VER_MAIN,
wif_net_ver=None,
bip32_cls=Bip32Slip10Secp256k1,
addr_cls=AtomAddrEncoder,
addr_params={
"hrp": CoinsConf.DYDX.ParamByKey("addr_hrp"),
},
)

# Configuration for eCash main net
EcashMainNet: BipBitcoinCashConf = BipBitcoinCashConf(
coin_names=CoinsConf.EcashMainNet.CoinNames(),
Expand Down
1 change: 1 addition & 0 deletions bip_utils/bip/conf/bip44/bip44_conf_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Bip44ConfGetterConst:
Bip44Coins.DASH_TESTNET: Bip44Conf.DashTestNet,
Bip44Coins.DOGECOIN: Bip44Conf.DogecoinMainNet,
Bip44Coins.DOGECOIN_TESTNET: Bip44Conf.DogecoinTestNet,
Bip44Coins.DYDX: Bip44Conf.DYDX,
Bip44Coins.ECASH: Bip44Conf.EcashMainNet,
Bip44Coins.ECASH_TESTNET: Bip44Conf.EcashTestNet,
Bip44Coins.ELROND: Bip44Conf.Elrond,
Expand Down
8 changes: 8 additions & 0 deletions bip_utils/coin_conf/coins_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ class CoinsConf:
},
)

# Configuration for dYdX
DYDX: CoinConf = CoinConf(
coin_name=CoinNames("dYdX", "DYDX"),
params={
"addr_hrp": Slip173.DYDX,
},
)

# Configuration for eCash main net
EcashMainNet: CoinConf = CoinConf(
coin_name=CoinNames("eCash", "XEC"),
Expand Down
1 change: 1 addition & 0 deletions bip_utils/slip/slip173/slip173.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Slip173:
CHIHUAHUA: str = "chihuahua"
CELESTIA: str = "celestia"
COSMOS: str = "cosmos"
DYDX: str = "dydx"
ELROND: str = "erd"
FETCH_AI: str = "fetch"
HARMONY_ONE: str = "one"
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ certik
cosmos
dash
dogecoin
dydx
ecash
elrond
eos
Expand Down
1 change: 1 addition & 0 deletions readme/bip44.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Supported coins enumerative for BIP-0044:
|Cosmos|`Bip44Coins.COSMOS`|-|
|Dash|`Bip44Coins.DASH`|`Bip44Coins.DASH_TESTNET`|
|Dogecoin|`Bip44Coins.DOGECOIN`|`Bip44Coins.DOGECOIN_TESTNET`|
|dYdX|`Bip44Coins.DYDX`|-|
|eCash|`Bip44Coins.ECASH`|`Bip44Coins.ECASH_TESTNET`|
|Elrond (MultiversX)|`Bip44Coins.ELROND` or `Bip44Coins.MULTIVERSX`|-|
|EOS|`Bip44Coins.EOS`|-|
Expand Down
30 changes: 30 additions & 0 deletions tests/bip/bip44/test_bip44.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,30 @@
"DTdrvUHbk5oMyi62tM7LqrjAcXfqB7eaad",
],
},
# dYdX
{
"coin": Bip44Coins.DYDX,
"names": ("dYdX", "DYDX"),
"is_testnet": False,
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"ex_master": "xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu",
"wif_master": "",
"account": {
"ex_pub": "xpub6DGzViq8bmgMLYdVZ3xnLVEdKwzBnGdzzJZ4suG8kVb9TTLAbrwv8YdKBb8FWKdBNinaHKmBv7JpQvqBYx4rxch7WnHzNFzSVrMf8hQepTP",
"ex_priv": "xprv9zHe6DJEmQ8484Z2T2RmyMHtmv9hNov9d5dU5WrXCA4Aaf124KdfakJqLGnVYwvBvMP4ttqm7QL5vuPTepiJiEJREiJnhswKmj6zLttwCMu",
},
"chain_ext": {
"ex_pub": "xpub6EbeQ8h8S7mEGxYTn34gKedwvsmytMW61v51RAc8e6VzgMMLFkkNMN6sYtqvtZQ8TjBKswbxUTzxzj3nZfwr4pzFB7rySMaBUUCJnCuxu33",
"ex_priv": "xprvA1cHzdAEbkCw4UTzg1XfxWhDNqwVUtnEeh9QcnCX5ky1oZ2BiDS7oZnPhdgFNqWwGtB3BNebior1tS26wAtbQzCTe5Pty1BhkcwT8QfWQSP",
},
"addresses": [
"dydx19rl4cm2hmr8afy4kldpxz3fka4jguq0a4erelz",
"dydx1jrkmdcwgq94uaamx6zax2luewlhf7u4k4pg4k4",
"dydx1kng7tv83qesgvv2ze7hxlw4urfrjk8vqf20ydu",
"dydx1zuvk68xw4y9swp06796rx8zarjvvkrt6xraztg",
"dydx12ecyuddg4wlnhztusgju5zxxjgznkz7fes66kh",
],
},
# eCash
{
"coin": Bip44Coins.ECASH,
Expand Down Expand Up @@ -2411,6 +2435,12 @@
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"default_address": "DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC",
},
# dYdX
{
"coin": Bip44Coins.DYDX,
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"default_address": "dydx19rl4cm2hmr8afy4kldpxz3fka4jguq0a4erelz",
},
# eCash
{
"coin": Bip44Coins.ECASH,
Expand Down

0 comments on commit 0ed7dc7

Please sign in to comment.