Package: colossus_sdk
Colossus Staking Python SDKWelcome to the Colossus 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 to the POS networks.Colossus Staking Python SDKBuild the Colossus SDK ApplicationPrerequisites for Colossus SDKInstalling Colossus SDK DependenciesRunning the Colossus SDK ApplicationStarting the Colossus API ServerRunning SDKTestingToolUnderstanding SDK Output DataSDK Testing ProceduresTesting Colossus 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 Colossus SDKConfiguringpyproject.tomlfor Colossus SDKBuilding the Colossus SDK PackagePublishing the Colossus SDK to PyPIVersion Control Tagging for SDK ReleasesUsing Poetry's Built-in Authentication:Environment Variables:Keyring Support:Build the Colossus SDK ApplicationPrerequisites for Colossus SDKPython: Version 3.11 or higher.Poetry: Dependency management tool forPython.Installing Colossus SDK DependenciesBefore building the program, ensure you have the following prerequisites:Navigate to the project directory:cdcolossus_sdkSetup Environment:Create a virtual environment and activate it:python3.11-mvenvvenvsourcevenv/bin/activateInstall the necessary dependencies using Poetry:poetryinstallRunning the Colossus SDK ApplicationStarting the Colossus API ServerTo start the server and import validator keys using mnemonics, use the following command:poetryrunpythoncolossus_sdk/endpoint_server.pyRunning SDKTestingToolpoetryrunpythoncolossus_sdk/tester.pyUnderstanding SDK Output Datapoetry run python colossus_sdk/tester.pyFlowID:['2d514903-2a09-41d6-938d-65965c0d7507']DelegatedState:delegated
TransactionState:broadcastedSDK Testing ProceduresTesting Colossus 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_colossus_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=colossus_sdk/.Generating Test Coverage Reports for the SDKTerminal Report:poetryrunpytest--cov=colossus_sdk/.--cov-report=termCreate HTML Report:poetryrunpytest--cov=colossus_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 Colossus SDKConfiguringpyproject.tomlfor Colossus 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="colossus-sdk"version="0.1.0"description="A Python SDK for interacting with the Colossus 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 Colossus 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 Colossus 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.0Using Poetry's Built-in Authentication:Runpoetry config http-basic.pypi username passwordin your terminal.This command stores your credentials securely in Poetry's configuration.Replace username and password with your actual PyPI credentials. If you're using a token, your username will betoken, and your password will be the token value.Environment Variables:You can also set your credentials as environment variables.
For example,set POETRY_PYPI_TOKEN_PYPIto your PyPI token.
This is a secure way to handle credentials, especially in CI/CD pipelines.Keyring Support:Poetry can integrate with the system's keyring to store credentials securely.
First, install a keyring backend if you don't have one (like keyring package in Python).
Store your credentials in the keyring, and Poetry will automatically use them when needed.