Skip to content

Commit

Permalink
changing env load setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nadineloepfe committed Nov 26, 2024
1 parent f18f447 commit 1f83fb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 4 additions & 0 deletions src/client/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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'):
Expand Down
8 changes: 4 additions & 4 deletions test.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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."""
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 1f83fb5

Please sign in to comment.