Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: fix input_range params and export init_logger #1723

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

Thoralf-M
Copy link
Member

Description of change

Python: fix input_range params and export init_logger

Type of change

  • Bug fix (a non-breaking change which fixes an issue)

How the change has been tested

Running this

# pylint: disable=no-name-in-module
from iota_sdk import (init_logger)
import json
import os

from dotenv import load_dotenv

from iota_sdk import AddressAndAmount, Client, MnemonicSecretManager, CoinType, SecretManager

load_dotenv()


load_dotenv()
log_config = {
    'name': 'client.log',
    'levelFilter': 'debug',
    'targetExclusions': ["h2", "hyper", "rustls"]
}

log_config_str = json.dumps(log_config)

init_logger(log_config_str)

node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network')

# Create a Client instance
client = Client(nodes=[node_url])

if 'MNEMONIC' not in os.environ:
    raise Exception(".env MNEMONIC is undefined, see .env.example")

secret_manager = MnemonicSecretManager(
    os.environ['MNEMONIC'])

amount = 1000000
address_and_amount = AddressAndAmount(
    amount,
    'rms1qzgkhdwhe0z9ntgv4wcpys2zy4xv0fht87famu90g0wsp73qghz7vm3j8j0',
)


index = 200
addresses = SecretManager(secret_manager).generate_ed25519_addresses(
    coin_type=CoinType.IOTA,
    account_index=0,
    start=index,
    end=index + 1,
    internal=False,
    bech32_hrp='rms')

print(addresses)

inputs = client.find_inputs(addresses, amount)
print(inputs)

# Create and post a block with a transaction
block = client.build_and_post_block(secret_manager,
                                    account_index=0,
                                    coin_type=CoinType.IOTA,
                                    output=address_and_amount,
                                    inputs=inputs,
                                    input_range_start=index,
                                    input_range_end=index+1,
                                    )
print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{block[0]}')

@Thoralf-M Thoralf-M merged commit c72a00f into iotaledger:develop Dec 1, 2023
33 checks passed
@Thoralf-M Thoralf-M deleted the fix-python-binding branch December 1, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants