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.

@@ -1,3 +1,3 @@
1
1
  # flake8: noqa
2
2
 
3
- from .wallet import *
3
+ from .wallet import Wallet
@@ -0,0 +1,13 @@
1
+ import CardanoSigner
2
+
3
+
4
+ class CliWallet:
5
+ def __init__(self, cli_skey: str):
6
+ self.cli_skey = cli_skey
7
+
8
+ def sign_tx(self, tx_hex: str) -> str:
9
+ # Implement CLI-based signing
10
+ return CardanoSigner.sign_cli(
11
+ self.cli_skey,
12
+ tx_hex,
13
+ )
@@ -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
+ )
@@ -1,40 +1,48 @@
1
- # flake8: noqa: E501
2
-
3
- from cbor2 import dumps, loads
4
- from nacl.encoding import RawEncoder
5
- from nacl.hash import blake2b
6
- from pycardano import crypto, key
7
-
8
-
9
- class HDWallet:
10
- def __init__(self, mnemonic):
11
- self.mnemonic = mnemonic
12
- self.hd_wallet = crypto.HDWallet.from_mnemonic(self.mnemonic).derive_from_path(
13
- "m/1852'/1815'/0'/0/0"
14
- )
15
- self.signing_key = key.ExtendedSigningKey.from_hdwallet(self.hd_wallet)
16
- self.verification_key = self.signing_key.to_verification_key()
17
-
18
- def sign_tx(self, tx_hex):
19
- raw_decoded_cbor = loads(bytes.fromhex(tx_hex))
20
- raw_tx_body = raw_decoded_cbor[0]
21
- signature = self.sign(blake2b(dumps(raw_tx_body), 32, encoder=RawEncoder))
22
- raw_witness_set = raw_decoded_cbor[1]
23
- if 0 in raw_witness_set:
24
- raw_vkeys = raw_witness_set[0]
25
- raw_vkeys.append(
26
- [self.verification_key.to_non_extended().to_cbor()[2::], signature]
27
- )
28
- raw_witness_set[0] = raw_vkeys
29
- else:
30
- raw_witness_set[0] = [
31
- [self.verification_key.to_non_extended().to_cbor()[2::], signature]
32
- ]
33
- raw_decoded_cbor[1] = raw_witness_set
34
- return dumps(raw_decoded_cbor).hex()
35
-
36
- def sign_message_hex(self, message_hex):
37
- return self.sign(bytes.fromhex(message_hex))
38
-
39
- def sign(self, message):
40
- return self.signing_key.sign(message)
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
+ [![Licence](https://img.shields.io/github/license/sidan-lab/gin)](https://github.com/sidan-lab/gin/blob/master/LICENSE)
30
+ [![Test](https://github.com/sidan-lab/gin/actions/workflows/build.yml/badge.svg)](https://github.com/sidan-lab/gin/actions/workflows/build.yml)
31
+ [![Publish](https://github.com/sidan-lab/bin/actions/workflows/publish.yml/badge.svg)](https://github.com/sidan-lab/bin/actions/workflows/publish.yml)
32
+
33
+ [![PyPi version](https://badgen.net/pypi/v/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
34
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
35
+ [![PyPI download month](https://img.shields.io/pypi/dm/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
36
+
37
+ [![Twitter/X](https://img.shields.io/badge/Follow%20us-@sidan__lab-blue?logo=x&style=for-the-badge)](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
+ ![Alt](https://repobeats.axiom.co/api/embed/0446bd7a0e9d2cd208432845cda9182f263321cd.svg "Repobeats analytics image")
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=_ylJyQIxP_-knJYHUxgDVYWSWG3MMhd_xiI9CH0sFmA,38
15
- sidan_gin/wallet/wallet.py,sha256=ijZ2ICI91E8MPc73ueytqV5s-6bbj3O3hJs8RBnuljw,1442
16
- sidan_gin-0.1.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- sidan_gin-0.1.2.dist-info/METADATA,sha256=xAecfFzR9ZMNb4lIiN4CMD3ROej70nxuQ9Nlvf5HNQ4,1083
18
- sidan_gin-0.1.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
19
- sidan_gin-0.1.2.dist-info/RECORD,,
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,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.2
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -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
-