Skip to main content

Python HTTP for Humans.

Project description

cngn-python-library

CNGnManager is a Python library for interacting with a CNGN API. It provides a simple interface for various operations such as checking balance, swapping between chains, depositing for redemption, creating virtual accounts, and more.

Table of Contents

Installation

To install CNGnManager and its dependencies, run:

pip install cngn-manager

Usage

First, import the CNGnManager class using it namespace WrappedCBDC\CNGNManager: and all necessary constants.

from cngn_manager import CNGnManager, Network, ProviderType

Then, create an instance of CNGnManager with your secrets:

import os

api_key = "cngn_live_sk**********"
encryption_key = "yourencryptionkey"
ssh_private_key = """-----BEGIN OPENSSH PRIVATE KEY-----
your ssh key
-----END OPENSSH PRIVATE KEY-----"""

# NOTE: You can also get your private key from a file using
# ssh_private_key = os.open("/path/to/sshkey.key").read()

manager = CNGnManager(api_key, ssh_private_key, encryption_key)
# Example: Get balance
balance = manager.get_balance()
print(balance)

Available Methods

Get Balance

balance = manager.get_balance()
print(balance)

Get Transaction History

transactions = manager.get_transaction_history()
print(transactions)

Swap Between Chains

swap_params = {
    "amount": 100,
    "address": "0x1234...",
    "network": Network.BSC
}

swap_result = manager.swap_between_chains(swap_params)
print(swap_result)

Deposit for Redemption

deposit_params = {
    "amount": 1000,
    "bank": "Example Bank",
    "accountNumber": "1234567890"
}

deposit_result = manager.deposit_for_redemption(deposit_params)
print(deposit_result)

Create Virtual Account

mint_params = {
    "provider": ProviderType.KORAPAY
}

virtual_account = manager.create_virtual_account(mint_params)
print(virtual_account)

Whitelist Address

whitelist_params = {
    "bscAddress": "0x1234...",
    "bankName": "Example Bank",
    "bankAccountNumber": "1234567890"
}

whitelist_result = manager.whitelist_address(whitelist_params)
print(whitelist_result)

Testing

This project uses Jest for testing. To run the tests, follow these steps:

  1. Run the test command:
python3 -m unittest discover tests

This will run all tests in the tests directory.

Test Structure

The tests are located in the tests directory. They cover various aspects of the CNGnManager class, including:

  • API calls for different endpoints (GET and POST requests)
  • Encryption and decryption of data
  • Error handling for various scenarios

Error Handling

The library uses a custom error handling mechanism. All API errors are caught and thrown as Error objects with descriptive messages.

Types

The library includes python definitions for all parameters and return types. Please refer to the type definitions in the source code for more details.

Security

This library uses AES encryption for request payloads and Ed25519 decryption for response data. Ensure that your encryptionKey and privateKey are kept secure.

Contributing

Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.

Support

If you have any questions or need help using the library, please open an issue in the GitHub repository.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cngn_manager-0.0.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cngn_manager-0.0.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file cngn_manager-0.0.4.tar.gz.

File metadata

  • Download URL: cngn_manager-0.0.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for cngn_manager-0.0.4.tar.gz
Algorithm Hash digest
SHA256 12a2df7b65abe46fe284b78c30ba441b9e5350b7f8c2d7899ff6b18537866a47
MD5 381e79e0b9344ca805eefef167bf617b
BLAKE2b-256 80223564a864c04b81a6a301c959d158db411a35e52241211ce9fa6ad93aa295

See more details on using hashes here.

File details

Details for the file cngn_manager-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: cngn_manager-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for cngn_manager-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 82172de7e7aaef54ec0b751f030c3138ae3c49a01860a4f8c9df433f4ae49c2f
MD5 a0466479474f1366148e6d7a21250cf1
BLAKE2b-256 16628ef77fa13cf7fb8fa88ee0e16cbb97058749468fc44d29e5876a7d4a5cce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page