From 1f83fb5d3345fb0a237d1906dd871b584be3d30a Mon Sep 17 00:00:00 2001 From: "nadine.loepfe" Date: Tue, 26 Nov 2024 13:16:26 +0000 Subject: [PATCH] changing env load setup --- .github/workflows/test.yml | 1 + src/client/network.py | 4 ++++ test.py | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9289b89..415186a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,5 +37,6 @@ jobs: OPERATOR_ID: ${{ steps.solo.outputs.accountId }} OPERATOR_KEY: ${{ steps.solo.outputs.privateKey }} PUBLIC_KEY: ${{ steps.solo.outputs.publicKey }} + NETWORK: solo run: python test.py diff --git a/src/client/network.py b/src/client/network.py index 1d28c82..c50e93a 100644 --- a/src/client/network.py +++ b/src/client/network.py @@ -11,6 +11,7 @@ class Network: 'mainnet': 'https://mainnet-public.mirrornode.hedera.com', 'testnet': 'https://testnet.mirrornode.hedera.com', 'previewnet': 'https://previewnet.mirrornode.hedera.com', + 'solo': 'localhost:8080' } DEFAULT_NODES = { @@ -40,6 +41,9 @@ class Network: ("2.previewnet.hedera.com:50211", AccountId(0, 0, 5)), ("3.previewnet.hedera.com:50211", AccountId(0, 0, 6)), ], + 'solo': [ + ("localhost:50211", AccountId(0, 0, 3)) + ], } def __init__(self, network='testnet'): diff --git a/test.py b/test.py index 24e062f..95c3ec0 100644 --- a/test.py +++ b/test.py @@ -1,6 +1,5 @@ import os import sys -from dotenv import load_dotenv from src.client.network import Network from src.client.client import Client from src.account.account_id import AccountId @@ -11,8 +10,9 @@ from src.transaction.transfer_transaction import TransferTransaction from src.response_code import ResponseCode -# Load environment variables -load_dotenv() +# uncomment next two lines if running script manually to load .env file: +# from dotenv import load_dotenv +# load_dotenv() def load_operator_credentials(): """Load operator credentials from environment variables.""" @@ -127,7 +127,7 @@ def transfer_token(client, recipient_id, token_id): def main(): operator_id, operator_key = load_operator_credentials() - network = Network() + network = Network(os.getenv('NETWORK')) client = Client(network) client.set_operator(operator_id, operator_key)