Package: tranquillo_staking_api
Tranquillo Staking Python SDKWelcome to the Tranquillo Staking Python SDK - your definitive toolkit for staking and delegation. This SDK provides a streamlined experience for initiating staking flows, handling delegation, and managing signed transactions, ensuring seamless and secure integration the POS networks.Tranquillo Staking Python SDKBuild the Tranquillo SDK ApplicationPrerequisites for Tranquillo SDKInstalling Tranquillo SDK DependenciesRunning the Tranquillo SDK ApplicationStarting the Tranquillo API ServerRunning SDKTestingToolUnderstanding SDK Output DataSDK Testing ProceduresTTesting Tranquillo SDK Server withcurlCommandsExecuting Automated Tests for the SDKRunning a Single Test FilePerforming Coverage Analysis for SDK TestsGenerating Test Coverage Reports for the SDKMongoDB Command Reference for Staking Data ManagementAccessing and Querying theStaking DatabaseBuilding and Deploying the Tranquillo SDKConfiguringpyproject.tomlfor Tranquillo SDKBuilding the Tranquillo SDK PackagePublishing the Tranquillo SDK to PyPIVersion Control Tagging for SDK ReleasesBuild the Tranquillo SDK ApplicationPrerequisites for Tranquillo SDKPython: Version 3.11 or higher.Poetry: Dependency management tool forPython.Installing Tranquillo SDK DependenciesBefore building the program, ensure you have the following prerequisites:Navigate to the project directory:cdpython_sdkSetup Environment:Create a virtual environment and activate it:python3.11-mvenvvenvsourcevenv/bin/activateInstall the necessary dependencies using Poetry:poetryinstallRunning the Tranquillo SDK ApplicationStarting the Tranquillo API ServerTo start the server and import validator keys using mnemonics, use the following command:poetryrunpythonpython_sdk/endpoint_server.pyRunning SDKTestingToolpoetryrunpythonpython_sdk/tester.pyUnderstanding SDK Output Datapoetry run python python_sdk/tester.pyFlowID:['2d514903-2a09-41d6-938d-65965c0d7507']DelegatedState:delegated
TransactionState:broadcastedSDK Testing ProceduresTTesting Tranquillo SDK Server withcurlCommandsTo test the API endpoints, you can use thecurlcommand-line tool. Here are some example commands:Test the Create Staking Flow Endpoint:curl-XPOST-H"Content-Type: application/json"\-d'{"flow": {"network_code": "cosmos", "chain_code": "testnet", "operation": "staking"}}'\http://127.0.0.1:5000/api/v1/flowsTest the Delegate Endpoint(Replace{flow_id}with the actual flow ID):curl-XPUT-H"Content-Type: application/json"\-d'{"name": "create_delegate_tx", "inputs": {"delegator_address": "your_address", "validator_address": "validator_address", "amount": 100}}'\http://127.0.0.1:5000/api/v1/flows/{flow_id}/nextTest the Signed Delegate Endpoint(Replace{flow_id}with the actual flow ID):curl-XPUT-H"Content-Type: application/json"\-d'{"name": "sign_delegate_tx", "inputs": {"transaction_payload": "your_payload"}, "signatures": ["signature1", "signature2"]}'\http://127.0.0.1:5000/api/v1/flows/{flow_id}/nextReplace placeholders likeyour_address,validator_address,your_payload, etc., with actual values when executing the commands.Executing Automated Tests for the SDKTo execute your tests, you can use the following command:poetryrunpytest# orpoetryrunpytesttests/test_tranquillo_client.pyOr, if you are using unittest and your test files are named in the pattern test_*.py, you can use:poetryrunpython-munittestdiscoverRunning a Single Test FileTo run a specific test file, simply provide the path to the file. For example:poetryrunpytesttests/test_my_feature.pyPerforming Coverage Analysis for SDK TestsRun tests with coverage using the following command:poetryrunpytest--cov=python_sdk/.Generating Test Coverage Reports for the SDKTerminal Report:poetryrunpytest--cov=python_sdk/.--cov-report=termCreate HTML Report:poetryrunpytest--cov=python_sdk/.--cov-report=xmlXML Report:poetryrunpytest--cov=your_package_name--cov-report=xmlMongoDB Command Reference for Staking Data ManagementThis section outlines the MongoDB commands used for querying thestakingdatabase, specifically within theflowscollection.Accessing and Querying theStaking DatabaseFirst, Start mongo cli:./mongoshSwitch to thestakingdatabase:usestakingRetrieve and Display All Documents in flows CollectionThis command fetches all documents from the flows collection and displays them in a formatted manner.db.flows.find().pretty()Find a Specific Document by Flow IDReplace your_flow_id with the actual ID of the flow you want to query.db.flows.find({"flow_id":"your_flow_id"}).pretty()Example using a specific flow ID:db.flows.find({"flow_id":"b2c4c9c9-a6ef-46f7-b1a4-e3aebd9ba84b"}).pretty()Drop the CollectionExample to drop the flows collection:db.flows.drop()Building and Deploying the Tranquillo SDKConfiguringpyproject.tomlfor Tranquillo SDKEnsure your pyproject.toml file is correctly set up with all necessary information. This includes the package name, version, description, dependencies, and any other relevant metadata. Here's an example template:[tool.poetry]name="tranquillo-sdk"version="0.1.0"description="A Python SDK for interacting with the Tranquillo API"authors=["Your Name <youremail@example.com>"][tool.poetry.dependencies]python="^3.11"[tool.poetry.dev-dependencies]pytest="^7.4.3"[build-system]requires=["poetry-core>=1.0.0"]build-backend="poetry.core.masonry.api"Building the Tranquillo SDK PackageTo build the package, execute the following command:poetrybuildThis command will generate a .tar.gz archive and a .whl file in the dist directory.Publishing the Tranquillo SDK to PyPITo publish your package to PyPI (Python Package Index), create a account on PyPI.Once the account is created, publish your package using:poetrypublishThis command will prompt you for your PyPI username and password. If you are using a CI/CD pipeline, you can also automate this step using API tokens.Version Control Tagging for SDK ReleasesAfter deploying your package, tag the commit and push the tag to your remote repository:gittag-av0.1.0-m"Release 0.1.0"gitpushoriginv0.1.0