sidan-gin 0.1.2__tar.gz → 0.1.6__tar.gz

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.

Files changed (27) hide show
  1. sidan_gin-0.1.6/PKG-INFO +63 -0
  2. sidan_gin-0.1.6/README.md +38 -0
  3. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/pyproject.toml +2 -2
  4. sidan_gin-0.1.6/src/sidan_gin/wallet/__init__.py +3 -0
  5. sidan_gin-0.1.6/src/sidan_gin/wallet/cli.py +13 -0
  6. sidan_gin-0.1.6/src/sidan_gin/wallet/derivation_indices.py +30 -0
  7. sidan_gin-0.1.6/src/sidan_gin/wallet/mnemonic.py +24 -0
  8. sidan_gin-0.1.6/src/sidan_gin/wallet/root_key.py +24 -0
  9. sidan_gin-0.1.6/src/sidan_gin/wallet/wallet.py +48 -0
  10. sidan_gin-0.1.2/PKG-INFO +0 -34
  11. sidan_gin-0.1.2/README.md +0 -9
  12. sidan_gin-0.1.2/src/sidan_gin/wallet/__init__.py +0 -3
  13. sidan_gin-0.1.2/src/sidan_gin/wallet/wallet.py +0 -40
  14. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/LICENSE +0 -0
  15. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/__init__.py +0 -0
  16. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/encryption/__init__.py +0 -0
  17. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/encryption/cipher.py +0 -0
  18. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/__init__.py +0 -0
  19. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/account_info.py +0 -0
  20. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/asset.py +0 -0
  21. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/asset_metadata.py +0 -0
  22. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/block_info.py +0 -0
  23. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/network.py +0 -0
  24. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/protocol.py +0 -0
  25. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/transaction_info.py +0 -0
  26. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/utxo.py +0 -0
  27. {sidan_gin-0.1.2 → sidan_gin-0.1.6}/src/sidan_gin/types/value.py +0 -0
@@ -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
+
@@ -0,0 +1,38 @@
1
+ <div align="center">
2
+ <hr />
3
+ <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>
4
+
5
+ [![Licence](https://img.shields.io/github/license/sidan-lab/gin)](https://github.com/sidan-lab/gin/blob/master/LICENSE)
6
+ [![Test](https://github.com/sidan-lab/gin/actions/workflows/build.yml/badge.svg)](https://github.com/sidan-lab/gin/actions/workflows/build.yml)
7
+ [![Publish](https://github.com/sidan-lab/bin/actions/workflows/publish.yml/badge.svg)](https://github.com/sidan-lab/bin/actions/workflows/publish.yml)
8
+
9
+ [![PyPi version](https://badgen.net/pypi/v/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
10
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
11
+ [![PyPI download month](https://img.shields.io/pypi/dm/sidan_gin)](https://pypi.python.org/pypi/sidan_gin/)
12
+
13
+ [![Twitter/X](https://img.shields.io/badge/Follow%20us-@sidan__lab-blue?logo=x&style=for-the-badge)](https://x.com/sidan_lab)
14
+
15
+ <hr/>
16
+ </div>
17
+
18
+ # gin
19
+
20
+ 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:
21
+
22
+ - Identical type system with Mesh and Whisky.
23
+ - Transaction signing
24
+ - Cipher data encryption and decryption
25
+
26
+ ## Installation
27
+
28
+ ```sh
29
+ pip install sidan_gin
30
+ ```
31
+
32
+ ## Getting Started
33
+
34
+ ## Documentation
35
+
36
+ - Coming soon
37
+
38
+ ![Alt](https://repobeats.axiom.co/api/embed/0446bd7a0e9d2cd208432845cda9182f263321cd.svg "Repobeats analytics image")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sidan-gin"
3
- version = "0.1.2"
3
+ version = "0.1.6"
4
4
  classifiers = [
5
5
  "Intended Audience :: Developers",
6
6
  "License :: OSI Approved :: Apache Software License",
@@ -19,9 +19,9 @@ license = "Apache-2.0"
19
19
  [tool.poetry.dependencies]
20
20
  python = ">3.11,<4.0.0"
21
21
  requests = "^2.25"
22
- cbor2 = "^5.6.5"
23
22
  pycardano = "^0.12.3"
24
23
  cryptography = "^44.0.2"
24
+ cardano-python-signing-module = "^0.1.0"
25
25
 
26
26
  [tool.poetry.group.dev.dependencies]
27
27
  pytest = "^8.2.0"
@@ -0,0 +1,3 @@
1
+ # flake8: noqa
2
+
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
+ )
@@ -0,0 +1,48 @@
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)
sidan_gin-0.1.2/PKG-INFO DELETED
@@ -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
-
sidan_gin-0.1.2/README.md DELETED
@@ -1,9 +0,0 @@
1
- # gin
2
-
3
- A python library for Cardano development, compatible with Mesh and Whisky types.
4
-
5
- ## Installation
6
-
7
- ```sh
8
- pip install sidan_gin
9
- ```
@@ -1,3 +0,0 @@
1
- # flake8: noqa
2
-
3
- from .wallet import *
@@ -1,40 +0,0 @@
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)
File without changes