sidan-gin 0.1.2__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sidan-gin might be problematic. Click here for more details.
- sidan_gin/wallet/__init__.py +1 -1
- sidan_gin/wallet/cli.py +13 -0
- sidan_gin/wallet/derivation_indices.py +30 -0
- sidan_gin/wallet/mnemonic.py +24 -0
- sidan_gin/wallet/root_key.py +24 -0
- sidan_gin/wallet/wallet.py +48 -40
- sidan_gin-0.1.6.dist-info/METADATA +63 -0
- {sidan_gin-0.1.2.dist-info → sidan_gin-0.1.6.dist-info}/RECORD +10 -6
- {sidan_gin-0.1.2.dist-info → sidan_gin-0.1.6.dist-info}/WHEEL +1 -1
- sidan_gin-0.1.2.dist-info/METADATA +0 -34
- {sidan_gin-0.1.2.dist-info → sidan_gin-0.1.6.dist-info}/LICENSE +0 -0
sidan_gin/wallet/__init__.py
CHANGED
sidan_gin/wallet/cli.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class DerivationIndices:
|
|
2
|
+
@classmethod
|
|
3
|
+
def default(cls):
|
|
4
|
+
"""Default derivation indices (payment with index 0)"""
|
|
5
|
+
return DerivationIndices.payment(0, 0)
|
|
6
|
+
|
|
7
|
+
@classmethod
|
|
8
|
+
def payment(cls, account_index: int, key_index: int):
|
|
9
|
+
"""Creates derivation indices for payment accounts"""
|
|
10
|
+
return DerivationIndices.raw_path(
|
|
11
|
+
["1852'", "1815'", f"{str(account_index)}'", str(0), str(key_index)]
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def stake(cls, account_index: int, key_index: int):
|
|
16
|
+
"""Creates derivation indices for stake accounts"""
|
|
17
|
+
return DerivationIndices.raw_path(
|
|
18
|
+
["1852'", "1815'", f"{str(account_index)}'", str(2), str(key_index)]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def drep(cls, account_index: int, key_index: int):
|
|
23
|
+
"""Creates derivation indices for drep accounts"""
|
|
24
|
+
return DerivationIndices.raw_path(
|
|
25
|
+
["1852'", "1815'", f"{str(account_index)}'", str(3), str(key_index)]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def raw_path(derivation_indices: list[str]):
|
|
29
|
+
"""Creates a raw path from derivation indices"""
|
|
30
|
+
return f"m/{'/'.join(derivation_indices)}"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import CardanoSigner
|
|
2
|
+
from sidan_gin.wallet.derivation_indices import DerivationIndices
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MnemonicWallet:
|
|
6
|
+
def __init__(self, mnemonic_phrase: str):
|
|
7
|
+
self.mnemonic_phrase = mnemonic_phrase
|
|
8
|
+
self.derivation_indices = DerivationIndices.default()
|
|
9
|
+
|
|
10
|
+
def payment_account(self, account_index: int, key_index: int):
|
|
11
|
+
self.derivation_indices = DerivationIndices.payment(account_index, key_index)
|
|
12
|
+
|
|
13
|
+
def stake_account(self, account_index: int, key_index: int):
|
|
14
|
+
self.derivation_indices = DerivationIndices.stake(account_index, key_index)
|
|
15
|
+
|
|
16
|
+
def drep_account(self, account_index: int, key_index: int):
|
|
17
|
+
self.derivation_indices = DerivationIndices.drep(account_index, key_index)
|
|
18
|
+
|
|
19
|
+
def sign_tx(self, tx_hex: str) -> str:
|
|
20
|
+
return CardanoSigner.sign_mnemonic(
|
|
21
|
+
self.mnemonic_phrase,
|
|
22
|
+
self.derivation_indices,
|
|
23
|
+
tx_hex,
|
|
24
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import CardanoSigner
|
|
2
|
+
from sidan_gin.wallet.derivation_indices import DerivationIndices
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RootKeyWallet:
|
|
6
|
+
def __init__(self, root_key: str):
|
|
7
|
+
self.root_key = root_key
|
|
8
|
+
self.derivation_indices = DerivationIndices.default()
|
|
9
|
+
|
|
10
|
+
def payment_account(self, account_index: int, key_index: int):
|
|
11
|
+
self.derivation_indices = DerivationIndices.payment(account_index, key_index)
|
|
12
|
+
|
|
13
|
+
def stake_account(self, account_index: int, key_index: int):
|
|
14
|
+
self.derivation_indices = DerivationIndices.stake(account_index, key_index)
|
|
15
|
+
|
|
16
|
+
def drep_account(self, account_index: int, key_index: int):
|
|
17
|
+
self.derivation_indices = DerivationIndices.drep(account_index, key_index)
|
|
18
|
+
|
|
19
|
+
def sign_tx(self, tx_hex: str) -> str:
|
|
20
|
+
return CardanoSigner.sign_bech32(
|
|
21
|
+
self.root_key,
|
|
22
|
+
self.derivation_indices,
|
|
23
|
+
tx_hex,
|
|
24
|
+
)
|
sidan_gin/wallet/wallet.py
CHANGED
|
@@ -1,40 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class
|
|
10
|
-
def __init__(self,
|
|
11
|
-
self.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
from sidan_gin.wallet.cli import CliWallet
|
|
4
|
+
from sidan_gin.wallet.mnemonic import MnemonicWallet
|
|
5
|
+
from sidan_gin.wallet.root_key import RootKeyWallet
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Main Wallet class that users will interact with
|
|
9
|
+
class Wallet:
|
|
10
|
+
def __init__(self, wallet_type: Union[MnemonicWallet, RootKeyWallet, CliWallet]):
|
|
11
|
+
self.wallet_type = wallet_type
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def new_mnemonic(cls, mnemonic_phrase: str) -> "Wallet":
|
|
15
|
+
"""Create a new wallet from a mnemonic phrase"""
|
|
16
|
+
return cls(MnemonicWallet(mnemonic_phrase))
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def new_root_key(cls, root_key: str) -> "Wallet":
|
|
20
|
+
"""Create a new wallet from a root key"""
|
|
21
|
+
return cls(RootKeyWallet(root_key))
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def new_cli(cls, cli_skey: str) -> "Wallet":
|
|
25
|
+
"""Create a new wallet that uses CLI signing"""
|
|
26
|
+
return cls(CliWallet(cli_skey))
|
|
27
|
+
|
|
28
|
+
def payment_account(self, account_index: int, key_index: int) -> "Wallet":
|
|
29
|
+
"""Configure for payment account operations"""
|
|
30
|
+
if isinstance(self.wallet_type, (MnemonicWallet, RootKeyWallet)):
|
|
31
|
+
self.wallet_type.payment_account(account_index, key_index)
|
|
32
|
+
return self
|
|
33
|
+
|
|
34
|
+
def stake_account(self, account_index: int, key_index: int) -> "Wallet":
|
|
35
|
+
"""Configure for stake account operations"""
|
|
36
|
+
if isinstance(self.wallet_type, (MnemonicWallet, RootKeyWallet)):
|
|
37
|
+
self.wallet_type.stake_account(account_index, key_index)
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
def drep_account(self, account_index: int, key_index: int) -> "Wallet":
|
|
41
|
+
"""Configure for drep account operations"""
|
|
42
|
+
if isinstance(self.wallet_type, (MnemonicWallet, RootKeyWallet)):
|
|
43
|
+
self.wallet_type.drep_account(account_index, key_index)
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def sign_tx(self, tx_hex: str) -> str:
|
|
47
|
+
"""Sign a transaction using the configured wallet"""
|
|
48
|
+
return self.wallet_type.sign_tx(tx_hex)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: sidan-gin
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: A python library for Cardano development, compatible with Mesh and Whisky types.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Keywords: cardano
|
|
7
|
+
Author: HinsonSIDAN
|
|
8
|
+
Author-email: wongkahinhinson@gmail.com
|
|
9
|
+
Requires-Python: >3.11,<4.0.0
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Dist: cardano-python-signing-module (>=0.1.0,<0.2.0)
|
|
18
|
+
Requires-Dist: cryptography (>=44.0.2,<45.0.0)
|
|
19
|
+
Requires-Dist: pycardano (>=0.12.3,<0.13.0)
|
|
20
|
+
Requires-Dist: requests (>=2.25,<3.0)
|
|
21
|
+
Project-URL: Documentation, https://github.com/sidan-lab/gin
|
|
22
|
+
Project-URL: Homepage, https://github.com/sidan-lab/gin
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
<hr />
|
|
27
|
+
<h2 align="center" style="border-bottom: none"><img style="position: relative; top: 0.25rem;" src="https://raw.githubusercontent.com/sidan-lab/brand_assets/main/sidan_s_square.png" alt="Whisky" height="30" /> Gin - Cardano Python SDK</h2>
|
|
28
|
+
|
|
29
|
+
[](https://github.com/sidan-lab/gin/blob/master/LICENSE)
|
|
30
|
+
[](https://github.com/sidan-lab/gin/actions/workflows/build.yml)
|
|
31
|
+
[](https://github.com/sidan-lab/bin/actions/workflows/publish.yml)
|
|
32
|
+
|
|
33
|
+
[](https://pypi.python.org/pypi/sidan_gin/)
|
|
34
|
+
[](https://pypi.python.org/pypi/sidan_gin/)
|
|
35
|
+
[](https://pypi.python.org/pypi/sidan_gin/)
|
|
36
|
+
|
|
37
|
+
[](https://x.com/sidan_lab)
|
|
38
|
+
|
|
39
|
+
<hr/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
# gin
|
|
43
|
+
|
|
44
|
+
Gin is a Python library for Cardano development, compatible with Mesh and Whisky types. It also re-export core logics implemented in Whisky to support stable serialization in Python. Supported features:
|
|
45
|
+
|
|
46
|
+
- Identical type system with Mesh and Whisky.
|
|
47
|
+
- Transaction signing
|
|
48
|
+
- Cipher data encryption and decryption
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pip install sidan_gin
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Getting Started
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
- Coming soon
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
@@ -11,9 +11,13 @@ sidan_gin/types/protocol.py,sha256=MxC2TLtQVrQao6csvPx459JwIpM98XNwBYK05d-JRA8,5
|
|
|
11
11
|
sidan_gin/types/transaction_info.py,sha256=c7rh7I38uTksnyDgAZKPdLlw0zVeQHfIVWrcWw-IwrA,220
|
|
12
12
|
sidan_gin/types/utxo.py,sha256=HvnAJXxyLm0KUBnrqprMm8Pc8H2ebxGW339pFLKo7K4,452
|
|
13
13
|
sidan_gin/types/value.py,sha256=cGFqxk15FrG2zy6PB5zMRq1vOBYfBQbMWbuqiCTEgRg,3345
|
|
14
|
-
sidan_gin/wallet/__init__.py,sha256=
|
|
15
|
-
sidan_gin/wallet/
|
|
16
|
-
sidan_gin
|
|
17
|
-
sidan_gin
|
|
18
|
-
sidan_gin
|
|
19
|
-
sidan_gin
|
|
14
|
+
sidan_gin/wallet/__init__.py,sha256=y_6mQqlePwnC0LPbCM0Il4XfkAzG0aqJLOdGRrSgljg,43
|
|
15
|
+
sidan_gin/wallet/cli.py,sha256=R-Q2Sq_K2j7ctkvZ57iB0z1dlqsqSe8zSqR11OZEPzE,290
|
|
16
|
+
sidan_gin/wallet/derivation_indices.py,sha256=NbxUEJfPgUCq6ACJtSbF4Zq8DtAO0vtjski7KtwvE9U,1139
|
|
17
|
+
sidan_gin/wallet/mnemonic.py,sha256=o7QWszzm-bNhv62rm4YvCTss2XNis4e-dB16uF7rOTs,907
|
|
18
|
+
sidan_gin/wallet/root_key.py,sha256=9fFBUlUcvBngE5mUitvMa5j7tnTRfzKTorlYxDUm6Bs,876
|
|
19
|
+
sidan_gin/wallet/wallet.py,sha256=XXBF4AVgXZGhleKZNkUqR5610Qe8Ey03C44fd19KxYI,1920
|
|
20
|
+
sidan_gin-0.1.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
21
|
+
sidan_gin-0.1.6.dist-info/METADATA,sha256=LHcj5blne0S4-vtj-mnLTz8mbg0dtV_eNIyIEdRY0nk,2660
|
|
22
|
+
sidan_gin-0.1.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
23
|
+
sidan_gin-0.1.6.dist-info/RECORD,,
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: sidan-gin
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: A python library for Cardano development, compatible with Mesh and Whisky types.
|
|
5
|
-
License: Apache-2.0
|
|
6
|
-
Keywords: cardano
|
|
7
|
-
Author: HinsonSIDAN
|
|
8
|
-
Author-email: wongkahinhinson@gmail.com
|
|
9
|
-
Requires-Python: >3.11,<4.0.0
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Requires-Dist: cbor2 (>=5.6.5,<6.0.0)
|
|
18
|
-
Requires-Dist: cryptography (>=44.0.2,<45.0.0)
|
|
19
|
-
Requires-Dist: pycardano (>=0.12.3,<0.13.0)
|
|
20
|
-
Requires-Dist: requests (>=2.25,<3.0)
|
|
21
|
-
Project-URL: Documentation, https://github.com/sidan-lab/gin
|
|
22
|
-
Project-URL: Homepage, https://github.com/sidan-lab/gin
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
|
|
25
|
-
# gin
|
|
26
|
-
|
|
27
|
-
A python library for Cardano development, compatible with Mesh and Whisky types.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
pip install sidan_gin
|
|
33
|
-
```
|
|
34
|
-
|
|
File without changes
|